Compare commits

..

37 Commits

Author SHA1 Message Date
Emil Sjolander
22b0fdb3e6 Add experiment support to gentest
Summary:
This diff does two things
- Clean up some of the generated code making the files smaller.
- Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior.

Reviewed By: gkassabli

Differential Revision: D4226734

fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b
2016-11-23 11:22:36 -08:00
Emil Sjolander
a0d560a24b Fixup recent fix to flex basis and put it behind an experimental flag
Summary: D4207106 previously fixed an issue where the computed flex basis was cached in between layout calculations, potentially caching wrong values. After landing we noticed that some product were implicitly relying on this behavior so this diff instead puts that behind a feature flag.

Reviewed By: gkassabli

Differential Revision: D4222910

fbshipit-source-id: d693482441fcc4d37a288e2e3529057a04f60541
2016-11-23 05:37:32 -08:00
Dustin Shahidehpour
dc10fdd958 Fix bug where swapping views in hierarchy throws an assert.
Summary: I found that if you move a subview to a different index, it would cause a crash in subsequent layout passes because the `CSSNodeRef` representing it was being re-inserted into the list. I spent a lot of time figuring out the best way to "diff" the view hierarchy from before and after, and I found the easiest implementation is also the most reliable. We can continue to optimize, but this is a great start.

Reviewed By: emilsjolander

Differential Revision: D4218623

fbshipit-source-id: 06253089492ac37ae4b94b7c30140ce6ed680ed2
2016-11-22 08:37:38 -08:00
Lukas Woehrl
b90f6e21bd Added feature to use rounded values
Summary:
Added an experimental feature to allow to use only rounded values. See #184. It's not a perfect solution and definitely  can be further improved. I'm looking forward to your ideas.
Closes https://github.com/facebook/css-layout/pull/256

Reviewed By: splhack

Differential Revision: D4214168

Pulled By: emilsjolander

fbshipit-source-id: 6293352d479b7b4dad258eb3f9e0afaa11cf7236
2016-11-22 05:37:34 -08:00
Lukas Woehrl
d54f09e32b Use ASSERT_FLOAT_EQ instead of ASSERT_EQ
Summary:
Changes the unit test comparsion to use ```ASSERT_FLOAT_EQ``` instead of ```ASSERT_EQ``` as they check float values.
Closes https://github.com/facebook/css-layout/pull/257

Reviewed By: splhack

Differential Revision: D4213809

Pulled By: emilsjolander

fbshipit-source-id: a79d310840814f26a122e1a0f6db47383b17d7e2
2016-11-22 02:52:30 -08:00
Dustin Shahidehpour
49a21e657b Fix bug where we insert nodes at wrong index in view hierarchy.
Summary:
We currently have a bug in `UIView+CSSLayout.m` that you can repro in a scenario like this:

```
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
  [container css_setUsesFlexbox:YES];
  [container css_setFlexDirection:CSSFlexDirectionRow];

  UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
  [subview1 css_setUsesFlexbox:YES];
  [subview1 css_setIncludeInLayout:NO];
  [container addSubview:subview1];

  UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
  [subview2 css_setUsesFlexbox:YES];
  [subview2 css_setIncludeInLayout:NO];
  [container addSubview:subview2];

  UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
  [subview3 css_setUsesFlexbox:YES];
  [subview3 css_setIncludeInLayout:YES];
  [container addSubview:subview3];

  [container css_applyLayout];
```

`subview3` (which is the only view whose is going to be included in layout calculation) is inserted at child index 2, instead of 0. This eventually can cause crash in CSSLayout.c because it will attempt access a child in the list which is null.

Reviewed By: emilsjolander

Differential Revision: D4215659

fbshipit-source-id: a615f50e51f85b15d3bdb437e55958865898b183
2016-11-21 18:07:36 -08:00
Emil Sjolander
2d58a36619 Move measure code for known dimensions out of main layout function
Summary: Try to move more code out of the main measure function

Reviewed By: gkassabli

Differential Revision: D4213339

fbshipit-source-id: 5ca35ca307594f3419fd0dee81321d3c2e06710f
2016-11-21 11:07:45 -08:00
Emil Sjolander
f56e8a5163 Move measure code for empty containers out of main layout function
Summary: Try to move more code out of the main measure function

Reviewed By: gkassabli

Differential Revision: D4213313

fbshipit-source-id: 2061a809202f7f948bff1b3ee8dc4c230692a223
2016-11-21 11:07:45 -08:00
Emil Sjolander
e78cf02a30 Move custom measure code out of main layout function
Summary: Try to move more code out of the main measure function

Reviewed By: gkassabli

Differential Revision: D4213302

fbshipit-source-id: df4bc43848325e99ad338a2fa6d5c9404315b0e6
2016-11-21 11:07:45 -08:00
Emil Sjolander
55fc795686 Add aspectRatio style property
Summary: Implement aspect ratio as part of Yoga. Aspect ratio allows users of the library to specify the size of the undefined dimension in terms of an aspect ratio. See test cases for examples.

Reviewed By: gkassabli

Differential Revision: D4211458

fbshipit-source-id: f8d0d318369c7b529ee29e61a52b17d0cf3b396d
2016-11-21 10:22:32 -08:00
Emil Sjolander
b16c22a8f3 Only skip updating computed flex basis within the same generation
Summary:
computed flex basis was incorrectly being reused in some circumstances between calls to caluclateLayout

also run format script.

Reviewed By: dshahidehpour

Differential Revision: D4207106

fbshipit-source-id: fc1063ca79ecf75f6101aadded53bca96cb0585d
2016-11-20 05:07:33 -08:00
Lukas Wöhrl
56ec33a463 Fix CS0675 warning in c#
Summary:
Fix CS0675 warning in c#.
Closes https://github.com/facebook/css-layout/pull/255

Reviewed By: emilsjolander

Differential Revision: D4204765

Pulled By: splhack

fbshipit-source-id: bcf71796e1bf585a94b3549905cb6d6bc78a34b8
2016-11-18 09:37:33 -08:00
Lukas Wöhrl
367c3a28be use fmaxf to prevent casting from and to double
Summary:
Use ```fmaxf``` to prevent double casting.
Closes https://github.com/facebook/css-layout/pull/251

Reviewed By: emilsjolander

Differential Revision: D4199342

Pulled By: splhack

fbshipit-source-id: c04bc68a3c9c97b92e910e885457cf2fe00da28b
2016-11-17 20:52:54 -08:00
Lukas Wöhrl
653150a7c4 Change more method arguments to const
Summary:
Change more method arguments to ```const```
Closes https://github.com/facebook/css-layout/pull/252

Reviewed By: emilsjolander

Differential Revision: D4199335

Pulled By: splhack

fbshipit-source-id: f54fccaea8051a49c6cdf0fcaf1a68c025ba26da
2016-11-17 20:52:54 -08:00
Lukas Wöhrl
542fc50409 do not redefine isnan if already defined via math.h
Summary:
```isnan``` is already defined in ```math.h``` (at least when using VS13) so there is no need to redefine it. it also is a nan for float and not for double opposed to ```_isnan```
Closes https://github.com/facebook/css-layout/pull/253

Reviewed By: emilsjolander

Differential Revision: D4199331

Pulled By: splhack

fbshipit-source-id: 139fb0efd68dd5df79bbaef863a8e8b9246c795d
2016-11-17 20:52:54 -08:00
Lukas Wöhrl
4f192481ee use size_t instead of unsigned long
Summary:
Use ```size_t```instead of ```unsinged long``` as this is the "offical" return type of ```strlen```. Is VS13 ```size_t``` is defined as ```unsigned long long``` which leads to a compiler warning.
Closes https://github.com/facebook/css-layout/pull/254

Reviewed By: emilsjolander

Differential Revision: D4199327

Pulled By: splhack

fbshipit-source-id: 5e1a91f282bf776e4d9f5806e6467dfe36c7a633
2016-11-17 20:52:54 -08:00
Kazuki Sakamoto
0bb2955c5c CSSNodeCopyStyle API for Java and C#
Summary: Add CopyStyle API for Java and C#

Reviewed By: emilsjolander

Differential Revision: D4189954

fbshipit-source-id: 10759fdb27bf67350d3151614f7815aa09bf7e04
2016-11-17 09:22:37 -08:00
Kazuki Sakamoto
191ac98b89 Introduce CSSNodeCopyStyle
Summary:
- Add a convenience function to copy all style from one node to another.
- CSSNodeIsDirty will return true after this function if any style was changed in the destination node.

Reviewed By: emilsjolander

Differential Revision: D4188514

fbshipit-source-id: af8d7fb5e8688c64aea05ce7ad23fff9233fb441
2016-11-17 09:22:37 -08:00
Kazuki Sakamoto
32c175ac55 Workaround fix for Visual Studio
Summary:
- Problem: Build error in Visual Studio since an array cannot have zero size.
  -  e6702e1168 (commitcomment-19839659)
-  Solution: Add 1 until we'll have actual CSSExperimentalFeature value.

Reviewed By: emilsjolander

Differential Revision: D4191268

fbshipit-source-id: 53fdcc388292e76c2b97ad071f0d7c27d0613ecf
2016-11-17 09:07:28 -08:00
Dustin Shahidehpour
4b61cdccea Add flag to not include view in layout.
Summary:
When dealing with manual sizing in UIView's (or UIKit in general) we see a common pattern like so:

Below we have an example implementation of a view with two Labels that want to be stacked horizontally. If we don't pass a second string, we hide the second label and give up the available space to the first label. See below:

```
interface TitleSubtitleView : UIView

- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;

end

implementation {
  UILabel *_titleLabel;
  UILabel *_subtitleLabel;
}

....

- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
  _titleLabel.text = title;
  if (subtitle.length > 0) {
    _subtitleLabel.hidden = NO;
    _subtitleLabel.text = subtitle;
  } else {
    _subtitleLabel.hidden = YES;
  }
}

- (CGSize)sizeThatFits:(CGSize)size {
  const CGSize titleSize = [_titleLabel sizeThatFits:size];
  CGSize subtitleSize = CGSizeZero;
  if (!_subtitleLabel.isHidden) {
    subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
  }
}

- (void)layoutSubviews {
  [super layoutSubviews];

  const CGSize titleSize = [_titleLabel sizeThatFits:size];
  _titleLabel.frame = CGRectMake(0, 0, titleSize.width, titleSize.height);
  if (!_subtitleLabel.isHidden) {
    subtitleSize = [_subtitleSize sizeThatFits:CGSizeMake(size.width - titleSize.width, size.height - titleSize.height)];
    _subtitleLabel.frame = CGRectMake(CGRectGetMaxX(_titleLabel.frame), 0, subtitleSize.width, subtitleSize.height);
  }

}
```

The problem is with the CSSLayout framework, as long as your view is in hierarchy, it's going to be allocated space during layout calculation. The only way to fix the view above would be to completely remove it from view hierarchy if it isn't being used. The problem is that adding/removing views from hierarchy is much less performant than hiding.

As a result, we need a way to tell the CSSLayoutKit library that even though a view is in hierarchy, we don't want to include it in layout. With this diff, we could change the class to look like this:

```
interface TitleSubtitleView : UIView

- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle;

end

implementation {
  UILabel *_titleLabel;
  UILabel *_subtitleLabel;
}

....

- (void)configureWithTitle:(NSString *)title subtitle:(NSString *)subtitle {
  _titleLabel.text = title;
  _subtitleLabel.text = subtitle;

  const BOOL subtitleHasText = subtitle.length > 0;
  _subtitleLabel.hidden = !subtitleHasText;
  [_subtitleLabel css_includeInLayout:!subtitleHasText];
}

- (CGSize)sizeThatFits:(CGSize)size {
  const intrinsicSize = [self css_intrinsicSize];
  return CGSizeMake(MIN(size.width, intrinsicSize.width), MIN(size.height, intrinsicSize.height)));
}

- (void)layoutSubviews {
  [super layoutSubviews];

  [self css_applyLayout];
}
```

Reviewed By: emilsjolander

Differential Revision: D4189897

fbshipit-source-id: 403d11d84d47691e3ce0b5ac18a180b0e4c104c4
2016-11-17 08:37:34 -08:00
Kazuki Sakamoto
b9c4c403a9 Fix memory func test
Summary: Reset gNodeInstanceCount before memory func test.

Reviewed By: emilsjolander

Differential Revision: D4193712

fbshipit-source-id: a4aba84d054d98a7baf438e213a90bd7ef34e979
2016-11-17 07:52:34 -08:00
Dustin Shahidehpour
56aa279fef BREAKING: remove css_sizeThatFits:, replace with new API.
Summary: When I try to use this in practice, I have come to realize that css_sizeThatFits will 99% return to you the constrainedSize that you pass it, thus making it useless. Instead, we replace it with a new API that will tell you the optimal size of the resolved layout. From this we can choose to use that size, or scale it down.

Reviewed By: emilsjolander

Differential Revision: D4191873

fbshipit-source-id: d36a2850448d9d82f97e5ef4c7397778c2a14094
2016-11-17 07:37:32 -08:00
Kazuki Sakamoto
7e4bb732ff Introduce CSSNode.Create API
Summary:
Add a convenience construction method for CSSNode.

    CSSNode node = CSSNode.Create(
        positionType: CSSPositionType.Absolute,
        wrap: CSSWrap.Wrap,
        position: new Spacing(top:6, right:4),
        margin: new Spacing(bottom:5, left:3));

Reviewed By: emilsjolander

Differential Revision: D4193380

fbshipit-source-id: 30b917f64e92997355a76e3b11799883b86fb9de
2016-11-17 07:07:32 -08:00
Emil Sjolander
32ba5ae647 Make gtest a submodule in open source
Summary: Remove infra for dynamically downloading gtest as this fails like 50% of the time on travis. I'll manually push gtest as a submodule instead.

Reviewed By: gkassabli

Differential Revision: D4183033

fbshipit-source-id: 09a121b8ede7a5974a29b6692edc63bff79aece7
2016-11-17 04:52:31 -08:00
Emil Sjolander
2fa6f5087d Disable UIKit memory tests on travis
Summary: For some reason these tests don't pass when running in travis. They are still running internally so we should catch any regressions. We can remove this if we figure out what is causing travis to fail here but until now I would rather get travis to pass.

Reviewed By: dshahidehpour

Differential Revision: D4189251

fbshipit-source-id: a27d3390f6b6fdcac6a3312d02581bb64969fd4b
2016-11-17 04:37:34 -08:00
Emil Sjolander
c2aac9f46e Add googletest submodule 2016-11-16 16:36:36 +01:00
Kazuki Sakamoto
ef81d4b0c7 Introduce CSSLayoutSetMemoryFuncs
Summary:
- Add CSSLayoutSetMemoryFuncs function which allows application to replace malloc, calloc, realloc and free with application's functions, like zalloc and zfree of zlib.
- Fixed memory leaks in tests.
- Close #247

For example, to use dlmalloc with USE_DL_PREFIX

    CSSLayoutSetMemoryFuncs(&dlmalloc, &dlcalloc, &dlrealloc, &dlfree);

Reviewed By: emilsjolander

Differential Revision: D4178386

fbshipit-source-id: a79dbdaf82a512f42cc43f99dbc49faba296903b
2016-11-15 20:22:51 -08:00
Kazuki Sakamoto
667858990c Fix build
Summary: Fix C# build

Reviewed By: emilsjolander

Differential Revision: D4183287

fbshipit-source-id: 7dda449a940589de1d37f4024964a6512ab123e3
2016-11-15 17:37:34 -08:00
Kazuki Sakamoto
d80bac4234 Use LTR and RTL instead obsolete enums
Summary: Use LTR and RTL instead obsolete LeftToRight and RightToLeft enums

Reviewed By: emilsjolander

Differential Revision: D4175897

fbshipit-source-id: d22af46d3292f9ad1754f571e95cb64b11722f7b
2016-11-15 09:22:45 -08:00
Emil Sjolander
d1c555fede Autogenerate enum defenitions for all languages
Summary: Keeping enums in sync between all the different bindings is tedious and error prone. Getting one of the values in the incorrect order could lead to many hours of debugging as they are passed as ints to C. This diff adds a simple python script to generate these enums for all languages. This also makes it much easier to add support for more languages in the future

Reviewed By: gkassabli

Differential Revision: D4174263

fbshipit-source-id: 478961a8f683e196704d3c6ea1505a05c85fcb10
2016-11-15 08:52:59 -08:00
Emil Sjolander
ac4d0ab2a1 Count allocations relative to start of test
Summary: If some test previous to this test fails to de-allocate a node we don't want this test to fail.

Reviewed By: dshahidehpour

Differential Revision: D4182179

fbshipit-source-id: 229dd5736d6d7b9c1b22b181e022c788584b9c17
2016-11-15 07:22:34 -08:00
Emil Sjolander
603321e1ab Install and use java 8 on travis
Summary: Java tests need to run with java 8, ensure travis runs java 8

Reviewed By: gkassabli

Differential Revision: D4182384

fbshipit-source-id: 61ba77d3e0f008f50912d088d3e504cb96e46bdc
2016-11-15 06:40:51 -08:00
Dustin Shahidehpour
129437f49e Change CLK prefix on static functions to CSS.
Summary: Talked with emilsjolander offline, and we want to keep the prefixes standardized in this lib. Changing CLK prefixes to CSS.

Reviewed By: emilsjolander

Differential Revision: D4175634

fbshipit-source-id: 7152268b9312df3fdb8eaee7ce3f6baabc5de937
2016-11-14 13:22:52 -08:00
Fred Liu
204aba80b9 Revert D4157971: [csslayout] BREAKING - Fix sizing of container with child overflowing parent
Summary: This reverts commit 3cfae15ac8b65b70f01789444099ee684e1b099a

Differential Revision: D4157971

fbshipit-source-id: be055cf018fd39b3cee9af0bc777831fcf757190
2016-11-14 12:22:58 -08:00
Emil Sjolander
e6702e1168 Implement standard interface for toggling experimental features
Summary: We want to start experimenting with changes to the library in a more controlled and easier to measure manner. This diff adds the basics of an experiment layer to csslayout.

Reviewed By: gkassabli

Differential Revision: D4174260

fbshipit-source-id: ad3667183810c02833fba9a1276f89286e848fcd
2016-11-14 03:37:45 -08:00
Emil Sjolander
b99172d28b rename CSSWrapType to shorter CSSWrap matching java and csharp
Summary: Java and csharp already use CSSWrap and not CSSWrapType. Let's consolidate and stick with the shorter of the two.

Reviewed By: gkassabli

Differential Revision: D4174257

fbshipit-source-id: ba0bfab996ba158b07863d8c72cf2a41262c9592
2016-11-14 03:37:45 -08:00
Emil Sjolander
7a3df9999b BREAKING - Fix sizing of container with child overflowing parent
Summary:
Fixes issue brought up in https://github.com/facebook/react-native/issues/10603

The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this.

Reviewed By: gkassabli

Differential Revision: D4157971

fbshipit-source-id: 3cfae15ac8b65b70f01789444099ee684e1b099a
2016-11-14 02:22:44 -08:00
112 changed files with 11723 additions and 8304 deletions

1
.gitignore vendored
View File

@@ -4,7 +4,6 @@
/buck-out/ /buck-out/
/.buckconfig.local /.buckconfig.local
/.buckd /.buckd
/lib/gtest/googletest-*/
/gentest/test.html /gentest/test.html
# Visual studio code # Visual studio code

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "lib/gtest/googletest"]
path = lib/gtest/googletest
url = https://github.com/google/googletest.git

View File

@@ -4,8 +4,7 @@
/buck-out/ /buck-out/
/.buckconfig.local /.buckconfig.local
/.buckd /.buckd
/lib/gtest/googletest-*/
/gentest/test.html /gentest/test.html
# Visual studio code # Visual studio code
.vscode .vscode

View File

@@ -14,14 +14,17 @@ before_install:
- brew update - brew update
- brew tap facebook/fb - brew tap facebook/fb
- brew install buck - brew install buck
- brew cask install java
- brew outdated xctool || brew upgrade xctool - brew outdated xctool || brew upgrade xctool
- brew install mono - brew install mono
- export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
- export PATH=$JAVA_HOME/bin:$PATH
script: script:
- buck test //:CSSLayout - buck test //:CSSLayout
- buck test //java:java - buck test //java:java
- buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 - buck test //CSSLayoutKit:CSSLayoutKit --config cxx.default_platform=iphonesimulator-x86_64 --config cxx.cflags=-DTRAVIS_CI
- sh csharp/tests/Facebook.CSSLayout/test_macos.sh - sh csharp/tests/Facebook.CSSLayout/test_macos.sh
- buck run //benchmark:benchmark - buck run //benchmark:benchmark
- git checkout HEAD^ - git checkout HEAD^
- buck run //benchmark:benchmark - buck run //benchmark:benchmark

View File

@@ -6,8 +6,6 @@ JUNIT_TARGET = '//lib/junit:junit'
PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations' PROGRUARD_ANNOTATIONS_TARGET = '//java/com/facebook/proguard/annotations:annotations'
SOLOADER_TARGET = '//lib/soloader:soloader' SOLOADER_TARGET = '//lib/soloader:soloader'
GTEST_TARGET = '//lib/gtest:gtest' GTEST_TARGET = '//lib/gtest:gtest'
GTEST_DL_URL = 'https://github.com/google/googletest/archive/release-1.7.0.zip'
JNI_TARGET = '//lib/jni:jni' JNI_TARGET = '//lib/jni:jni'
FBJNI_TARGET = '//lib/fb:fbjni' FBJNI_TARGET = '//lib/fb:fbjni'

108
CSSLayout/CSSEnums.h Normal file
View File

@@ -0,0 +1,108 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
typedef enum CSSOverflow {
CSSOverflowVisible,
CSSOverflowHidden,
CSSOverflowScroll,
CSSOverflowCount,
} CSSOverflow;
typedef enum CSSJustify {
CSSJustifyFlexStart,
CSSJustifyCenter,
CSSJustifyFlexEnd,
CSSJustifySpaceBetween,
CSSJustifySpaceAround,
CSSJustifyCount,
} CSSJustify;
typedef enum CSSFlexDirection {
CSSFlexDirectionColumn,
CSSFlexDirectionColumnReverse,
CSSFlexDirectionRow,
CSSFlexDirectionRowReverse,
CSSFlexDirectionCount,
} CSSFlexDirection;
typedef enum CSSAlign {
CSSAlignAuto,
CSSAlignFlexStart,
CSSAlignCenter,
CSSAlignFlexEnd,
CSSAlignStretch,
CSSAlignCount,
} CSSAlign;
typedef enum CSSEdge {
CSSEdgeLeft,
CSSEdgeTop,
CSSEdgeRight,
CSSEdgeBottom,
CSSEdgeStart,
CSSEdgeEnd,
CSSEdgeHorizontal,
CSSEdgeVertical,
CSSEdgeAll,
CSSEdgeCount,
} CSSEdge;
typedef enum CSSWrap {
CSSWrapNoWrap,
CSSWrapWrap,
CSSWrapCount,
} CSSWrap;
typedef enum CSSDirection {
CSSDirectionInherit,
CSSDirectionLTR,
CSSDirectionRTL,
CSSDirectionCount,
} CSSDirection;
typedef enum CSSExperimentalFeature {
CSSExperimentalFeatureRounding,
CSSExperimentalFeatureWebFlexBasis,
CSSExperimentalFeatureCount,
} CSSExperimentalFeature;
typedef enum CSSLogLevel {
CSSLogLevelError,
CSSLogLevelWarn,
CSSLogLevelInfo,
CSSLogLevelDebug,
CSSLogLevelVerbose,
CSSLogLevelCount,
} CSSLogLevel;
typedef enum CSSDimension {
CSSDimensionWidth,
CSSDimensionHeight,
CSSDimensionCount,
} CSSDimension;
typedef enum CSSMeasureMode {
CSSMeasureModeUndefined,
CSSMeasureModeExactly,
CSSMeasureModeAtMost,
CSSMeasureModeCount,
} CSSMeasureMode;
typedef enum CSSPositionType {
CSSPositionTypeRelative,
CSSPositionTypeAbsolute,
CSSPositionTypeCount,
} CSSPositionType;
typedef enum CSSPrintOptions {
CSSPrintOptionsLayout = 1,
CSSPrintOptionsStyle = 2,
CSSPrintOptionsChildren = 4,
CSSPrintOptionsCount,
} CSSPrintOptions;

View File

@@ -14,7 +14,9 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <float.h> #include <float.h>
#ifndef isnan
#define isnan _isnan #define isnan _isnan
#endif
#ifndef __cplusplus #ifndef __cplusplus
#define inline __inline #define inline __inline
@@ -47,6 +49,7 @@ typedef struct CSSLayout {
float dimensions[2]; float dimensions[2];
CSSDirection direction; CSSDirection direction;
uint32_t computedFlexBasisGeneration;
float computedFlexBasis; float computedFlexBasis;
// Instead of recomputing the entire layout every single time, we // Instead of recomputing the entire layout every single time, we
@@ -69,7 +72,7 @@ typedef struct CSSStyle {
CSSAlign alignItems; CSSAlign alignItems;
CSSAlign alignSelf; CSSAlign alignSelf;
CSSPositionType positionType; CSSPositionType positionType;
CSSWrapType flexWrap; CSSWrap flexWrap;
CSSOverflow overflow; CSSOverflow overflow;
float flex; float flex;
float flexGrow; float flexGrow;
@@ -82,6 +85,9 @@ typedef struct CSSStyle {
float dimensions[2]; float dimensions[2];
float minDimensions[2]; float minDimensions[2];
float maxDimensions[2]; float maxDimensions[2];
// Yoga specific properties, not compatible with flexbox specification
float aspectRatio;
} CSSStyle; } CSSStyle;
typedef struct CSSNode { typedef struct CSSNode {
@@ -102,6 +108,11 @@ typedef struct CSSNode {
static void _CSSNodeMarkDirty(const CSSNodeRef node); static void _CSSNodeMarkDirty(const CSSNodeRef node);
CSSMalloc gCSSMalloc = &malloc;
CSSCalloc gCSSCalloc = &calloc;
CSSRealloc gCSSRealloc = &realloc;
CSSFree gCSSFree = &free;
#ifdef ANDROID #ifdef ANDROID
#include <android/log.h> #include <android/log.h>
static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list args) { static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list args) {
@@ -122,6 +133,8 @@ static int _csslayoutAndroidLog(CSSLogLevel level, const char *format, va_list a
case CSSLogLevelVerbose: case CSSLogLevelVerbose:
androidLevel = ANDROID_LOG_VERBOSE; androidLevel = ANDROID_LOG_VERBOSE;
break; break;
case CSSLogLevelCount:
break;
} }
const int result = __android_log_vprint(androidLevel, "css-layout", format, args); const int result = __android_log_vprint(androidLevel, "css-layout", format, args);
return result; return result;
@@ -173,10 +186,10 @@ static inline float computedEdgeValue(const float edges[CSSEdgeCount],
return defaultValue; return defaultValue;
} }
static int32_t gNodeInstanceCount = 0; int32_t gNodeInstanceCount = 0;
CSSNodeRef CSSNodeNew(void) { CSSNodeRef CSSNodeNew(void) {
const CSSNodeRef node = calloc(1, sizeof(CSSNode)); const CSSNodeRef node = gCSSCalloc(1, sizeof(CSSNode));
CSS_ASSERT(node, "Could not allocate memory for node"); CSS_ASSERT(node, "Could not allocate memory for node");
gNodeInstanceCount++; gNodeInstanceCount++;
@@ -197,7 +210,7 @@ void CSSNodeFree(const CSSNodeRef node) {
} }
CSSNodeListFree(node->children); CSSNodeListFree(node->children);
free(node); gCSSFree(node);
gNodeInstanceCount--; gNodeInstanceCount--;
} }
@@ -259,6 +272,8 @@ void CSSNodeInit(const CSSNodeRef node) {
node->style.border[edge] = CSSUndefined; node->style.border[edge] = CSSUndefined;
} }
node->style.aspectRatio = CSSUndefined;
node->layout.dimensions[CSSDimensionWidth] = CSSUndefined; node->layout.dimensions[CSSDimensionWidth] = CSSUndefined;
node->layout.dimensions[CSSDimensionHeight] = CSSUndefined; node->layout.dimensions[CSSDimensionHeight] = CSSUndefined;
@@ -334,7 +349,14 @@ bool CSSNodeIsDirty(const CSSNodeRef node) {
return node->isDirty; return node->isDirty;
} }
inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) { void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode) {
if (memcmp(&dstNode->style, &srcNode->style, sizeof(CSSStyle)) != 0) {
memcpy(&dstNode->style, &srcNode->style, sizeof(CSSStyle));
_CSSNodeMarkDirty(dstNode);
}
}
inline float CSSNodeStyleGetFlexGrow(const CSSNodeRef node) {
if (!CSSValueIsUndefined(node->style.flexGrow)) { if (!CSSValueIsUndefined(node->style.flexGrow)) {
return node->style.flexGrow; return node->style.flexGrow;
} }
@@ -344,7 +366,7 @@ inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) {
return 0; return 0;
} }
inline float CSSNodeStyleGetFlexShrink(CSSNodeRef node) { inline float CSSNodeStyleGetFlexShrink(const CSSNodeRef node) {
if (!CSSValueIsUndefined(node->style.flexShrink)) { if (!CSSValueIsUndefined(node->style.flexShrink)) {
return node->style.flexShrink; return node->style.flexShrink;
} }
@@ -354,7 +376,7 @@ inline float CSSNodeStyleGetFlexShrink(CSSNodeRef node) {
return 0; return 0;
} }
inline float CSSNodeStyleGetFlexBasis(CSSNodeRef node) { inline float CSSNodeStyleGetFlexBasis(const CSSNodeRef node) {
if (!CSSValueIsUndefined(node->style.flexBasis)) { if (!CSSValueIsUndefined(node->style.flexBasis)) {
return node->style.flexBasis; return node->style.flexBasis;
} }
@@ -423,7 +445,7 @@ CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignContent, alignContent, alignContent)
CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignItems, alignItems, alignItems); CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignItems, alignItems, alignItems);
CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignSelf, alignSelf, alignSelf); CSS_NODE_STYLE_PROPERTY_IMPL(CSSAlign, AlignSelf, alignSelf, alignSelf);
CSS_NODE_STYLE_PROPERTY_IMPL(CSSPositionType, PositionType, positionType, positionType); CSS_NODE_STYLE_PROPERTY_IMPL(CSSPositionType, PositionType, positionType, positionType);
CSS_NODE_STYLE_PROPERTY_IMPL(CSSWrapType, FlexWrap, flexWrap, flexWrap); CSS_NODE_STYLE_PROPERTY_IMPL(CSSWrap, FlexWrap, flexWrap, flexWrap);
CSS_NODE_STYLE_PROPERTY_IMPL(CSSOverflow, Overflow, overflow, overflow); CSS_NODE_STYLE_PROPERTY_IMPL(CSSOverflow, Overflow, overflow, overflow);
CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow); CSS_NODE_STYLE_PROPERTY_SETTER_IMPL(float, FlexGrow, flexGrow, flexGrow);
@@ -442,6 +464,9 @@ CSS_NODE_STYLE_PROPERTY_IMPL(float, MinHeight, minHeight, minDimensions[CSSDimen
CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxWidth, maxWidth, maxDimensions[CSSDimensionWidth]); CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxWidth, maxWidth, maxDimensions[CSSDimensionWidth]);
CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxHeight, maxHeight, maxDimensions[CSSDimensionHeight]); CSS_NODE_STYLE_PROPERTY_IMPL(float, MaxHeight, maxHeight, maxDimensions[CSSDimensionHeight]);
// Yoga specific properties, not compatible with flexbox specification
CSS_NODE_STYLE_PROPERTY_IMPL(float, AspectRatio, aspectRatio, aspectRatio);
CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[CSSEdgeLeft]); CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Left, position[CSSEdgeLeft]);
CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[CSSEdgeTop]); CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Top, position[CSSEdgeTop]);
CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[CSSEdgeRight]); CSS_NODE_LAYOUT_PROPERTY_IMPL(float, Right, position[CSSEdgeRight]);
@@ -951,7 +976,9 @@ static void computeChildFlexBasis(const CSSNodeRef node,
if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) && if (!CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(child)) &&
!CSSValueIsUndefined(isMainAxisRow ? width : height)) { !CSSValueIsUndefined(isMainAxisRow ? width : height)) {
if (CSSValueIsUndefined(child->layout.computedFlexBasis)) { if (CSSValueIsUndefined(child->layout.computedFlexBasis) ||
(CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis) &&
child->layout.computedFlexBasisGeneration != gCurrentGenerationCount)) {
child->layout.computedFlexBasis = child->layout.computedFlexBasis =
fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis)); fmaxf(CSSNodeStyleGetFlexBasis(child), getPaddingAndBorderAxis(child, mainAxis));
} }
@@ -1014,6 +1041,20 @@ static void computeChildFlexBasis(const CSSNodeRef node,
childHeightMeasureMode = CSSMeasureModeExactly; childHeightMeasureMode = CSSMeasureModeExactly;
} }
if (!CSSValueIsUndefined(child->style.aspectRatio)) {
if (!isMainAxisRow && childWidthMeasureMode == CSSMeasureModeExactly) {
child->layout.computedFlexBasis =
fmaxf(childWidth * child->style.aspectRatio,
getPaddingAndBorderAxis(child, CSSFlexDirectionColumn));
return;
} else if (isMainAxisRow && childHeightMeasureMode == CSSMeasureModeExactly) {
child->layout.computedFlexBasis =
fmaxf(childHeight * child->style.aspectRatio,
getPaddingAndBorderAxis(child, CSSFlexDirectionRow));
return;
}
}
constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionWidth], constrainMaxSizeForMode(child->style.maxDimensions[CSSDimensionWidth],
&childWidthMeasureMode, &childWidthMeasureMode,
&childWidth); &childWidth);
@@ -1036,6 +1077,8 @@ static void computeChildFlexBasis(const CSSNodeRef node,
: child->layout.measuredDimensions[CSSDimensionHeight], : child->layout.measuredDimensions[CSSDimensionHeight],
getPaddingAndBorderAxis(child, mainAxis)); getPaddingAndBorderAxis(child, mainAxis));
} }
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
} }
static void absoluteLayoutChild(const CSSNodeRef node, static void absoluteLayoutChild(const CSSNodeRef node,
@@ -1088,6 +1131,20 @@ static void absoluteLayoutChild(const CSSNodeRef node,
} }
} }
// Exactly one dimension needs to be defined for us to be able to do aspect ratio
// calculation. One dimension being the anchor and the other being flexible.
if (CSSValueIsUndefined(childWidth) ^ CSSValueIsUndefined(childHeight)) {
if (!CSSValueIsUndefined(child->style.aspectRatio)) {
if (CSSValueIsUndefined(childWidth)) {
childWidth = fmaxf(childHeight * child->style.aspectRatio,
getPaddingAndBorderAxis(child, CSSFlexDirectionColumn));
} else if (CSSValueIsUndefined(childHeight)) {
childHeight = fmaxf(childWidth * child->style.aspectRatio,
getPaddingAndBorderAxis(child, CSSFlexDirectionRow));
}
}
}
// If we're still missing one or the other dimension, measure the content. // If we're still missing one or the other dimension, measure the content.
if (CSSValueIsUndefined(childWidth) || CSSValueIsUndefined(childHeight)) { if (CSSValueIsUndefined(childWidth) || CSSValueIsUndefined(childHeight)) {
childWidthMeasureMode = childWidthMeasureMode =
@@ -1142,6 +1199,114 @@ static void absoluteLayoutChild(const CSSNodeRef node,
} }
} }
static void setMeasuredDimensionsForNodeWithMeasureFunc(const CSSNodeRef node,
const float availableWidth,
const float availableHeight,
const CSSMeasureMode widthMeasureMode,
const CSSMeasureMode heightMeasureMode) {
CSS_ASSERT(node->measure, "Expected node to have custom measure function");
const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow);
const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn);
const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow);
const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn);
const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow;
const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn;
if (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly) {
// Don't bother sizing the text if both dimensions are already defined.
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node, CSSFlexDirectionColumn, availableHeight - marginAxisColumn);
} else if (innerWidth <= 0 || innerHeight <= 0) {
// Don't bother sizing the text if there's no horizontal or vertical
// space.
node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node, CSSFlexDirectionColumn, 0);
} else {
// Measure the text under the current constraints.
const CSSSize measuredSize =
node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode);
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node,
CSSFlexDirectionRow,
(widthMeasureMode == CSSMeasureModeUndefined ||
widthMeasureMode == CSSMeasureModeAtMost)
? measuredSize.width + paddingAndBorderAxisRow
: availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node,
CSSFlexDirectionColumn,
(heightMeasureMode == CSSMeasureModeUndefined ||
heightMeasureMode == CSSMeasureModeAtMost)
? measuredSize.height + paddingAndBorderAxisColumn
: availableHeight - marginAxisColumn);
}
}
// For nodes with no children, use the available values if they were provided,
// or the minimum size as indicated by the padding and border sizes.
static void setMeasuredDimensionsForEmptyContainer(const CSSNodeRef node,
const float availableWidth,
const float availableHeight,
const CSSMeasureMode widthMeasureMode,
const CSSMeasureMode heightMeasureMode) {
const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow);
const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn);
const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow);
const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn);
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node,
CSSFlexDirectionRow,
(widthMeasureMode == CSSMeasureModeUndefined ||
widthMeasureMode == CSSMeasureModeAtMost)
? paddingAndBorderAxisRow
: availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node,
CSSFlexDirectionColumn,
(heightMeasureMode == CSSMeasureModeUndefined ||
heightMeasureMode == CSSMeasureModeAtMost)
? paddingAndBorderAxisColumn
: availableHeight - marginAxisColumn);
}
static bool setMeasuredDimensionsIfEmptyOrFixedSize(const CSSNodeRef node,
const float availableWidth,
const float availableHeight,
const CSSMeasureMode widthMeasureMode,
const CSSMeasureMode heightMeasureMode) {
if ((widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0) ||
(heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) ||
(widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly)) {
const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn);
const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow);
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node,
CSSFlexDirectionRow,
CSSValueIsUndefined(availableWidth) || availableWidth < 0
? 0
: availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node,
CSSFlexDirectionColumn,
CSSValueIsUndefined(availableHeight) || availableHeight < 0
? 0
: availableHeight - marginAxisColumn);
return true;
}
return false;
}
// //
// This is the main routine that implements a subset of the flexbox layout // This is the main routine that implements a subset of the flexbox layout
// algorithm // algorithm
@@ -1270,124 +1435,29 @@ static void layoutNodeImpl(const CSSNodeRef node,
"availableHeight is indefinite so heightMeasureMode must be " "availableHeight is indefinite so heightMeasureMode must be "
"CSSMeasureModeUndefined"); "CSSMeasureModeUndefined");
const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow);
const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn);
const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow);
const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn);
// Set the resolved resolution in the node's layout. // Set the resolved resolution in the node's layout.
const CSSDirection direction = resolveDirection(node, parentDirection); const CSSDirection direction = resolveDirection(node, parentDirection);
node->layout.direction = direction; node->layout.direction = direction;
// For content (text) nodes, determine the dimensions based on the text
// contents.
if (node->measure) { if (node->measure) {
const float innerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; setMeasuredDimensionsForNodeWithMeasureFunc(
const float innerHeight = availableHeight - marginAxisColumn - paddingAndBorderAxisColumn; node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode);
if (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly) {
// Don't bother sizing the text if both dimensions are already defined.
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node, CSSFlexDirectionColumn, availableHeight - marginAxisColumn);
} else if (innerWidth <= 0 || innerHeight <= 0) {
// Don't bother sizing the text if there's no horizontal or vertical
// space.
node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node, CSSFlexDirectionColumn, 0);
} else {
// Measure the text under the current constraints.
const CSSSize measuredSize =
node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode);
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node,
CSSFlexDirectionRow,
(widthMeasureMode == CSSMeasureModeUndefined ||
widthMeasureMode == CSSMeasureModeAtMost)
? measuredSize.width + paddingAndBorderAxisRow
: availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node,
CSSFlexDirectionColumn,
(heightMeasureMode == CSSMeasureModeUndefined ||
heightMeasureMode == CSSMeasureModeAtMost)
? measuredSize.height + paddingAndBorderAxisColumn
: availableHeight - marginAxisColumn);
}
return; return;
} }
// For nodes with no children, use the available values if they were provided,
// or
// the minimum size as indicated by the padding and border sizes.
const uint32_t childCount = CSSNodeListCount(node->children); const uint32_t childCount = CSSNodeListCount(node->children);
if (childCount == 0) { if (childCount == 0) {
node->layout.measuredDimensions[CSSDimensionWidth] = setMeasuredDimensionsForEmptyContainer(
boundAxis(node, node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode);
CSSFlexDirectionRow,
(widthMeasureMode == CSSMeasureModeUndefined ||
widthMeasureMode == CSSMeasureModeAtMost)
? paddingAndBorderAxisRow
: availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node,
CSSFlexDirectionColumn,
(heightMeasureMode == CSSMeasureModeUndefined ||
heightMeasureMode == CSSMeasureModeAtMost)
? paddingAndBorderAxisColumn
: availableHeight - marginAxisColumn);
return; return;
} }
// If we're not being asked to perform a full layout, we can handle a number // If we're not being asked to perform a full layout we can skip the algorithm if we already know
// of common // the size
// cases here without incurring the cost of the remaining function. if (!performLayout &&
if (!performLayout) { setMeasuredDimensionsIfEmptyOrFixedSize(
// If we're being asked to size the content with an at most constraint but node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode)) {
// there is no available return;
// width,
// the measurement will always be zero.
if (widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0 &&
heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) {
node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node, CSSFlexDirectionColumn, 0);
return;
}
if (widthMeasureMode == CSSMeasureModeAtMost && availableWidth <= 0) {
node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, CSSFlexDirectionRow, 0);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node,
CSSFlexDirectionColumn,
CSSValueIsUndefined(availableHeight) ? 0
: (availableHeight - marginAxisColumn));
return;
}
if (heightMeasureMode == CSSMeasureModeAtMost && availableHeight <= 0) {
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node,
CSSFlexDirectionRow,
CSSValueIsUndefined(availableWidth) ? 0 : (availableWidth - marginAxisRow));
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node, CSSFlexDirectionColumn, 0);
return;
}
// If we're being asked to use an exact width/height, there's no need to
// measure the children.
if (widthMeasureMode == CSSMeasureModeExactly && heightMeasureMode == CSSMeasureModeExactly) {
node->layout.measuredDimensions[CSSDimensionWidth] =
boundAxis(node, CSSFlexDirectionRow, availableWidth - marginAxisRow);
node->layout.measuredDimensions[CSSDimensionHeight] =
boundAxis(node, CSSFlexDirectionColumn, availableHeight - marginAxisColumn);
return;
}
} }
// STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM
@@ -1395,7 +1465,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction); const CSSFlexDirection crossAxis = getCrossFlexDirection(mainAxis, direction);
const bool isMainAxisRow = isRowDirection(mainAxis); const bool isMainAxisRow = isRowDirection(mainAxis);
const CSSJustify justifyContent = node->style.justifyContent; const CSSJustify justifyContent = node->style.justifyContent;
const bool isNodeFlexWrap = node->style.flexWrap == CSSWrapTypeWrap; const bool isNodeFlexWrap = node->style.flexWrap == CSSWrapWrap;
CSSNodeRef firstAbsoluteChild = NULL; CSSNodeRef firstAbsoluteChild = NULL;
CSSNodeRef currentAbsoluteChild = NULL; CSSNodeRef currentAbsoluteChild = NULL;
@@ -1409,6 +1479,11 @@ static void layoutNodeImpl(const CSSNodeRef node,
const CSSMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode; const CSSMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode;
const CSSMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode; const CSSMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode;
const float paddingAndBorderAxisRow = getPaddingAndBorderAxis(node, CSSFlexDirectionRow);
const float paddingAndBorderAxisColumn = getPaddingAndBorderAxis(node, CSSFlexDirectionColumn);
const float marginAxisRow = getMarginAxis(node, CSSFlexDirectionRow);
const float marginAxisColumn = getMarginAxis(node, CSSFlexDirectionColumn);
// STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS // STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow; const float availableInnerWidth = availableWidth - marginAxisRow - paddingAndBorderAxisRow;
const float availableInnerHeight = const float availableInnerHeight =
@@ -1461,6 +1536,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
child->nextChild = NULL; child->nextChild = NULL;
} else { } else {
if (child == singleFlexChild) { if (child == singleFlexChild) {
child->layout.computedFlexBasisGeneration = gCurrentGenerationCount;
child->layout.computedFlexBasis = 0; child->layout.computedFlexBasis = 0;
} else { } else {
computeChildFlexBasis(node, computeChildFlexBasis(node,
@@ -1753,6 +1829,19 @@ static void layoutNodeImpl(const CSSNodeRef node,
} }
} }
if (!CSSValueIsUndefined(currentRelativeChild->style.aspectRatio)) {
if (isMainAxisRow && childHeightMeasureMode != CSSMeasureModeExactly) {
childHeight =
fmaxf(childWidth * currentRelativeChild->style.aspectRatio,
getPaddingAndBorderAxis(currentRelativeChild, CSSFlexDirectionColumn));
childHeightMeasureMode = CSSMeasureModeExactly;
} else if (!isMainAxisRow && childWidthMeasureMode != CSSMeasureModeExactly) {
childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio,
getPaddingAndBorderAxis(currentRelativeChild, CSSFlexDirectionRow));
childWidthMeasureMode = CSSMeasureModeExactly;
}
}
constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[CSSDimensionWidth], constrainMaxSizeForMode(currentRelativeChild->style.maxDimensions[CSSDimensionWidth],
&childWidthMeasureMode, &childWidthMeasureMode,
&childWidth); &childWidth);
@@ -1796,9 +1885,9 @@ static void layoutNodeImpl(const CSSNodeRef node,
if (measureModeMainDim == CSSMeasureModeAtMost && remainingFreeSpace > 0) { if (measureModeMainDim == CSSMeasureModeAtMost && remainingFreeSpace > 0) {
if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) && if (!CSSValueIsUndefined(node->style.minDimensions[dim[mainAxis]]) &&
node->style.minDimensions[dim[mainAxis]] >= 0) { node->style.minDimensions[dim[mainAxis]] >= 0) {
remainingFreeSpace = fmax(0, remainingFreeSpace = fmaxf(0,
node->style.minDimensions[dim[mainAxis]] - node->style.minDimensions[dim[mainAxis]] -
(availableInnerMainDim - remainingFreeSpace)); (availableInnerMainDim - remainingFreeSpace));
} else { } else {
remainingFreeSpace = 0; remainingFreeSpace = 0;
} }
@@ -1824,6 +1913,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
leadingMainDim = betweenMainDim / 2; leadingMainDim = betweenMainDim / 2;
break; break;
case CSSJustifyFlexStart: case CSSJustifyFlexStart:
case CSSJustifyCount:
break; break;
} }
@@ -2015,6 +2105,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
break; break;
case CSSAlignAuto: case CSSAlignAuto:
case CSSAlignFlexStart: case CSSAlignFlexStart:
case CSSAlignCount:
break; break;
} }
@@ -2074,6 +2165,7 @@ static void layoutNodeImpl(const CSSNodeRef node,
break; break;
} }
case CSSAlignAuto: case CSSAlignAuto:
case CSSAlignCount:
break; break;
} }
} }
@@ -2156,7 +2248,7 @@ bool gPrintSkips = false;
static const char *spacer = " "; static const char *spacer = " ";
static const char *getSpacer(const unsigned long level) { static const char *getSpacer(const unsigned long level) {
const unsigned long spacerLen = strlen(spacer); const size_t spacerLen = strlen(spacer);
if (level > spacerLen) { if (level > spacerLen) {
return &spacer[0]; return &spacer[0];
} else { } else {
@@ -2443,6 +2535,25 @@ bool layoutNodeInternal(const CSSNodeRef node,
return (needToVisitNode || cachedResults == NULL); return (needToVisitNode || cachedResults == NULL);
} }
static void roundToPixelGrid(const CSSNodeRef node) {
const float fractialLeft =
node->layout.position[CSSEdgeLeft] - floorf(node->layout.position[CSSEdgeLeft]);
const float fractialTop =
node->layout.position[CSSEdgeTop] - floorf(node->layout.position[CSSEdgeTop]);
node->layout.dimensions[CSSDimensionWidth] =
roundf(fractialLeft + node->layout.dimensions[CSSDimensionWidth]) - roundf(fractialLeft);
node->layout.dimensions[CSSDimensionHeight] =
roundf(fractialTop + node->layout.dimensions[CSSDimensionHeight]) - roundf(fractialTop);
node->layout.position[CSSEdgeLeft] = roundf(node->layout.position[CSSEdgeLeft]);
node->layout.position[CSSEdgeTop] = roundf(node->layout.position[CSSEdgeTop]);
const uint32_t childCount = CSSNodeListCount(node->children);
for (uint32_t i = 0; i < childCount; i++) {
roundToPixelGrid(CSSNodeGetChild(node, i));
}
}
void CSSNodeCalculateLayout(const CSSNodeRef node, void CSSNodeCalculateLayout(const CSSNodeRef node,
const float availableWidth, const float availableWidth,
const float availableHeight, const float availableHeight,
@@ -2492,6 +2603,10 @@ void CSSNodeCalculateLayout(const CSSNodeRef node,
"l")) { "l")) {
setPosition(node, node->layout.direction); setPosition(node, node->layout.direction);
if (CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeatureRounding)) {
roundToPixelGrid(node);
}
if (gPrintTree) { if (gPrintTree) {
CSSNodePrint(node, CSSPrintOptionsLayout | CSSPrintOptionsChildren | CSSPrintOptionsStyle); CSSNodePrint(node, CSSPrintOptionsLayout | CSSPrintOptionsChildren | CSSPrintOptionsStyle);
} }
@@ -2508,3 +2623,35 @@ void CSSLog(CSSLogLevel level, const char *format, ...) {
gLogger(level, format, args); gLogger(level, format, args);
va_end(args); va_end(args);
} }
static bool experimentalFeatures[CSSExperimentalFeatureCount + 1];
void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature, bool enabled) {
experimentalFeatures[feature] = enabled;
}
inline bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature) {
return experimentalFeatures[feature];
}
void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
CSSCalloc cssCalloc,
CSSRealloc cssRealloc,
CSSFree cssFree) {
CSS_ASSERT(gNodeInstanceCount == 0, "Cannot set memory functions: all node must be freed first");
CSS_ASSERT((cssMalloc == NULL && cssCalloc == NULL && cssRealloc == NULL && cssFree == NULL) ||
(cssMalloc != NULL && cssCalloc != NULL && cssRealloc != NULL && cssFree != NULL),
"Cannot set memory functions: functions must be all NULL or Non-NULL");
if (cssMalloc == NULL || cssCalloc == NULL || cssRealloc == NULL || cssFree == NULL) {
gCSSMalloc = &malloc;
gCSSCalloc = &calloc;
gCSSRealloc = &realloc;
gCSSFree = &free;
} else {
gCSSMalloc = cssMalloc;
gCSSCalloc = cssCalloc;
gCSSRealloc = cssRealloc;
gCSSFree = cssFree;
}
}

View File

@@ -28,101 +28,16 @@ static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define CSSUndefined NAN #define CSSUndefined NAN
#include "CSSEnums.h"
#include "CSSMacros.h" #include "CSSMacros.h"
CSS_EXTERN_C_BEGIN CSS_EXTERN_C_BEGIN
typedef enum CSSDirection {
CSSDirectionInherit,
CSSDirectionLTR,
CSSDirectionRTL,
} CSSDirection;
typedef enum CSSFlexDirection {
CSSFlexDirectionColumn,
CSSFlexDirectionColumnReverse,
CSSFlexDirectionRow,
CSSFlexDirectionRowReverse,
} CSSFlexDirection;
typedef enum CSSJustify {
CSSJustifyFlexStart,
CSSJustifyCenter,
CSSJustifyFlexEnd,
CSSJustifySpaceBetween,
CSSJustifySpaceAround,
} CSSJustify;
typedef enum CSSOverflow {
CSSOverflowVisible,
CSSOverflowHidden,
CSSOverflowScroll,
} CSSOverflow;
// Note: auto is only a valid value for alignSelf. It is NOT a valid value for
// alignItems.
typedef enum CSSAlign {
CSSAlignAuto,
CSSAlignFlexStart,
CSSAlignCenter,
CSSAlignFlexEnd,
CSSAlignStretch,
} CSSAlign;
typedef enum CSSPositionType {
CSSPositionTypeRelative,
CSSPositionTypeAbsolute,
} CSSPositionType;
typedef enum CSSWrapType {
CSSWrapTypeNoWrap,
CSSWrapTypeWrap,
} CSSWrapType;
typedef enum CSSMeasureMode {
CSSMeasureModeUndefined,
CSSMeasureModeExactly,
CSSMeasureModeAtMost,
CSSMeasureModeCount,
} CSSMeasureMode;
typedef enum CSSDimension {
CSSDimensionWidth,
CSSDimensionHeight,
} CSSDimension;
typedef enum CSSEdge {
CSSEdgeLeft,
CSSEdgeTop,
CSSEdgeRight,
CSSEdgeBottom,
CSSEdgeStart,
CSSEdgeEnd,
CSSEdgeHorizontal,
CSSEdgeVertical,
CSSEdgeAll,
CSSEdgeCount,
} CSSEdge;
typedef enum CSSPrintOptions {
CSSPrintOptionsLayout = 1,
CSSPrintOptionsStyle = 2,
CSSPrintOptionsChildren = 4,
} CSSPrintOptions;
typedef struct CSSSize { typedef struct CSSSize {
float width; float width;
float height; float height;
} CSSSize; } CSSSize;
typedef enum CSSLogLevel {
CSSLogLevelError,
CSSLogLevelWarn,
CSSLogLevelInfo,
CSSLogLevelDebug,
CSSLogLevelVerbose,
} CSSLogLevel;
typedef struct CSSNode *CSSNodeRef; typedef struct CSSNode *CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
float width, float width,
@@ -132,6 +47,11 @@ typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
typedef void (*CSSPrintFunc)(CSSNodeRef node); typedef void (*CSSPrintFunc)(CSSNodeRef node);
typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args); typedef int (*CSSLogger)(CSSLogLevel level, const char *format, va_list args);
typedef void *(*CSSMalloc)(size_t size);
typedef void *(*CSSCalloc)(size_t count, size_t size);
typedef void *(*CSSRealloc)(void *ptr, size_t size);
typedef void (*CSSFree)(void *ptr);
// CSSNode // CSSNode
WIN_EXPORT CSSNodeRef CSSNodeNew(void); WIN_EXPORT CSSNodeRef CSSNodeNew(void);
WIN_EXPORT void CSSNodeInit(const CSSNodeRef node); WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
@@ -178,6 +98,8 @@ WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const CSSMeasureMode widthMode,
const float marginRow, const float marginRow,
const float marginColumn); const float marginColumn);
WIN_EXPORT void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode);
#define CSS_NODE_PROPERTY(type, name, paramName) \ #define CSS_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \ WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node); WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
@@ -207,7 +129,7 @@ CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignContent, alignContent);
CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignItems, alignItems); CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignItems, alignItems);
CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignSelf, alignSelf); CSS_NODE_STYLE_PROPERTY(CSSAlign, AlignSelf, alignSelf);
CSS_NODE_STYLE_PROPERTY(CSSPositionType, PositionType, positionType); CSS_NODE_STYLE_PROPERTY(CSSPositionType, PositionType, positionType);
CSS_NODE_STYLE_PROPERTY(CSSWrapType, FlexWrap, flexWrap); CSS_NODE_STYLE_PROPERTY(CSSWrap, FlexWrap, flexWrap);
CSS_NODE_STYLE_PROPERTY(CSSOverflow, Overflow, overflow); CSS_NODE_STYLE_PROPERTY(CSSOverflow, Overflow, overflow);
WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex); WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex);
@@ -227,6 +149,18 @@ CSS_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
CSS_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth); CSS_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
CSS_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight); CSS_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node.
// - On a node with a set width/height aspect ratio control the size of the unset dimension
// - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis if
// unset
// - On a node with a measure function aspect ratio works as though the measure function measures
// the flex basis
// - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis if
// unset
// - Aspect ratio takes min/max dimensions into account
CSS_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
CSS_NODE_LAYOUT_PROPERTY(float, Left); CSS_NODE_LAYOUT_PROPERTY(float, Left);
CSS_NODE_LAYOUT_PROPERTY(float, Top); CSS_NODE_LAYOUT_PROPERTY(float, Top);
CSS_NODE_LAYOUT_PROPERTY(float, Right); CSS_NODE_LAYOUT_PROPERTY(float, Right);
@@ -238,4 +172,13 @@ CSS_NODE_LAYOUT_PROPERTY(CSSDirection, Direction);
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger); WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...); WIN_EXPORT void CSSLog(CSSLogLevel level, const char *message, ...);
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature feature,
bool enabled);
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(CSSExperimentalFeature feature);
WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
CSSCalloc cssCalloc,
CSSRealloc cssRealloc,
CSSFree cssFree);
CSS_EXTERN_C_END CSS_EXTERN_C_END

View File

@@ -9,6 +9,10 @@
#include "CSSNodeList.h" #include "CSSNodeList.h"
extern CSSMalloc gCSSMalloc;
extern CSSRealloc gCSSRealloc;
extern CSSFree gCSSFree;
struct CSSNodeList { struct CSSNodeList {
uint32_t capacity; uint32_t capacity;
uint32_t count; uint32_t count;
@@ -16,12 +20,12 @@ struct CSSNodeList {
}; };
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) { CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
const CSSNodeListRef list = malloc(sizeof(struct CSSNodeList)); const CSSNodeListRef list = gCSSMalloc(sizeof(struct CSSNodeList));
CSS_ASSERT(list != NULL, "Could not allocate memory for list"); CSS_ASSERT(list != NULL, "Could not allocate memory for list");
list->capacity = initialCapacity; list->capacity = initialCapacity;
list->count = 0; list->count = 0;
list->items = malloc(sizeof(CSSNodeRef) * list->capacity); list->items = gCSSMalloc(sizeof(CSSNodeRef) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not allocate memory for items"); CSS_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list; return list;
@@ -29,8 +33,8 @@ CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
void CSSNodeListFree(const CSSNodeListRef list) { void CSSNodeListFree(const CSSNodeListRef list) {
if (list) { if (list) {
free(list->items); gCSSFree(list->items);
free(list); gCSSFree(list);
} }
} }
@@ -56,7 +60,7 @@ void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint3
if (list->count == list->capacity) { if (list->count == list->capacity) {
list->capacity *= 2; list->capacity *= 2;
list->items = realloc(list->items, sizeof(CSSNodeRef) * list->capacity); list->items = gCSSRealloc(list->items, sizeof(CSSNodeRef) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not extend allocation for items"); CSS_ASSERT(list->items != NULL, "Could not extend allocation for items");
} }

View File

@@ -0,0 +1,271 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <XCTest/XCTest.h>
#import "UIView+CSSLayout.h"
@interface CSSLayoutKitTests : XCTestCase
@end
@implementation CSSLayoutKitTests
#ifndef TRAVIS_CI
- (void)testNodesAreDeallocedWithSingleView
{
XCTAssertEqual(0, CSSNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view css_setFlexBasis:1];
XCTAssertEqual(1, CSSNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, CSSNodeGetInstanceCount());
}
- (void)testNodesAreDeallocedCascade
{
XCTAssertEqual(0, CSSNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view css_setFlexBasis:1];
for (int i=0; i<10; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
[subview css_setFlexBasis:1];
[view addSubview:subview];
}
XCTAssertEqual(11, CSSNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, CSSNodeGetInstanceCount());
}
#endif
- (void)testUsesFlexbox
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertFalse([view css_usesFlexbox]);
[view css_setUsesFlexbox:YES];
XCTAssertTrue([view css_usesFlexbox]);
[view css_setUsesFlexbox:NO];
XCTAssertFalse([view css_usesFlexbox]);
}
- (void)testSizeThatFitsAsserts
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){
XCTAssertThrows([view css_intrinsicSize]);
});
}
- (void)testSizeThatFitsSmoke
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
[container css_setAlignItems:CSSAlignFlexStart];
UILabel *longTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
longTextLabel.text = @"This is a very very very very very very very very long piece of text.";
longTextLabel.lineBreakMode = NSLineBreakByTruncatingTail;
longTextLabel.numberOfLines = 1;
[longTextLabel css_setUsesFlexbox:YES];
[longTextLabel css_setFlexShrink:1];
[container addSubview:longTextLabel];
UIView *textBadgeView = [[UIView alloc] initWithFrame:CGRectZero];
[textBadgeView css_setUsesFlexbox:YES];
[textBadgeView css_setMargin:3.0 forEdge:CSSEdgeLeft];
[textBadgeView css_setWidth:10];
[textBadgeView css_setHeight:10];
[container addSubview:textBadgeView];
const CGSize containerSize = [container css_intrinsicSize];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(514,21), containerSize), @"Size is actually %@", NSStringFromCGSize(containerSize));
}
- (void)testFrameAndOriginPlacement
{
const CGSize containerSize = CGSizeMake(320, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
for (int i = 0; i < 3; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
[subview css_setUsesFlexbox:YES];
[subview css_setFlexGrow:1];
[container addSubview:subview];
}
[container css_applyLayout];
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
CGFloat totalWidth = 0;
for (UIView *view in container.subviews) {
totalWidth += view.bounds.size.width;
}
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
}
- (void)testThatLayoutIsCorrectWhenWeSwapViewOrder
{
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 css_setUsesFlexbox:YES];
[subview1 css_setFlexGrow:1];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 css_setUsesFlexbox:YES];
[subview2 css_setFlexGrow:1];
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
[subview3 css_setUsesFlexbox:YES];
[subview3 css_setFlexGrow:1];
[container addSubview:subview3];
[container css_applyLayout];
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(0, 0, 100, 50)));
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)), @"It's actually %@", NSStringFromCGRect(subview2.frame));
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(200, 0, 100, 50)));
[container exchangeSubviewAtIndex:2 withSubviewAtIndex:0];
[subview2 css_setIncludeInLayout:NO];
[container css_applyLayout];
XCTAssertTrue(CGRectEqualToRect(subview3.frame, CGRectMake(0, 0, 150, 50)));
XCTAssertTrue(CGRectEqualToRect(subview1.frame, CGRectMake(150, 0, 150, 50)));
// this frame shouldn't have been modified since last time.
XCTAssertTrue(CGRectEqualToRect(subview2.frame, CGRectMake(100, 0, 100, 50)));
}
- (void)testThatWeRespectIncludeInLayoutFlag
{
const CGSize containerSize = CGSizeMake(300, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 css_setUsesFlexbox:YES];
[subview1 css_setFlexGrow:1];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 css_setUsesFlexbox:YES];
[subview2 css_setFlexGrow:1];
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
[subview3 css_setUsesFlexbox:YES];
[subview3 css_setFlexGrow:1];
[container addSubview:subview3];
[container css_applyLayout];
for (UIView *view in container.subviews) {
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
}
[subview3 css_setIncludeInLayout:NO];
[container css_applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
// We don't set the frame to zero, so, it should be set to what it was previously at.
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview3.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview3.bounds.size));
}
- (void)testThatNumberOfChildrenIsCorrectWhenWeIgnoreSubviews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectZero];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 css_setUsesFlexbox:YES];
[subview1 css_setIncludeInLayout:NO];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 css_setUsesFlexbox:YES];
[subview2 css_setIncludeInLayout:NO];
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
[subview3 css_setUsesFlexbox:YES];
[subview3 css_setIncludeInLayout:YES];
[container addSubview:subview3];
[container css_applyLayout];
XCTAssertEqual(1, [container css_numberOfChildren]);
[subview2 css_setIncludeInLayout:YES];
[container css_applyLayout];
XCTAssertEqual(2, [container css_numberOfChildren]);
}
- (void)testThatViewNotIncludedInFirstLayoutPassAreIncludedInSecond
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 css_setUsesFlexbox:YES];
[subview1 css_setFlexGrow:1];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 css_setUsesFlexbox:YES];
[subview2 css_setFlexGrow:1];
[container addSubview:subview2];
UIView *subview3 = [[UIView alloc] initWithFrame:CGRectZero];
[subview3 css_setUsesFlexbox:YES];
[subview3 css_setFlexGrow:1];
[subview3 css_setIncludeInLayout:NO];
[container addSubview:subview3];
[container css_applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 50), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
XCTAssertTrue(CGSizeEqualToSize(CGSizeZero, subview3.bounds.size), @"Actual size %@", NSStringFromCGSize(subview3.bounds.size));
[subview3 css_setIncludeInLayout:YES];
[container css_applyLayout];
for (UIView *view in container.subviews) {
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 50), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(view.bounds.size));
}
}
@end

View File

@@ -1,110 +0,0 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <XCTest/XCTest.h>
#import "UIView+CSSLayout.h"
@interface CSSLayoutTests : XCTestCase
@end
@implementation CSSLayoutTests
- (void)testNodesAreDeallocedWithSingleView
{
XCTAssertEqual(0, CSSNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view css_setFlexBasis:1];
XCTAssertEqual(1, CSSNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, CSSNodeGetInstanceCount());
}
- (void)testNodesAreDeallocedCascade
{
XCTAssertEqual(0, CSSNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view css_setFlexBasis:1];
for (int i=0; i<10; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
[subview css_setFlexBasis:1];
[view addSubview:subview];
}
XCTAssertEqual(11, CSSNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, CSSNodeGetInstanceCount());
}
- (void)testUsesFlexbox
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertFalse([view css_usesFlexbox]);
[view css_setUsesFlexbox:YES];
XCTAssertTrue([view css_usesFlexbox]);
[view css_setUsesFlexbox:NO];
XCTAssertFalse([view css_usesFlexbox]);
}
- (void)testSizeThatFitsAsserts
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertThrows([view css_sizeThatFits:CGSizeZero]);
dispatch_sync(dispatch_queue_create("com.facebook.CSSLayout.testing", DISPATCH_QUEUE_SERIAL), ^(void){
XCTAssertThrows([view css_sizeThatFits:CGSizeZero]);
});
}
- (void)testSizeThatFitsSmoke
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view css_setUsesFlexbox:YES];
const CGSize constrainedSize = CGSizeMake(50, 50);
const CGSize actualSize = [view css_sizeThatFits:constrainedSize];
XCTAssertTrue(CGSizeEqualToSize(constrainedSize, actualSize), @"Actual Size: %@", NSStringFromCGSize(actualSize));
}
- (void)testFrameAndOriginPlacement
{
const CGSize containerSize = CGSizeMake(320, 50);
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containerSize.width, containerSize.height)];
[container css_setUsesFlexbox:YES];
[container css_setFlexDirection:CSSFlexDirectionRow];
for (int i = 0; i < 3; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
[subview css_setUsesFlexbox:YES];
[subview css_setFlexGrow:1];
[container addSubview:subview];
}
[container css_applyLayout];
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:1].frame));
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:1].frame, [container.subviews objectAtIndex:2].frame));
XCTAssertFalse(CGRectIntersectsRect([container.subviews objectAtIndex:0].frame, [container.subviews objectAtIndex:2].frame));
CGFloat totalWidth = 0;
for (UIView *view in container.subviews) {
totalWidth += view.bounds.size.width;
}
XCTAssertEqual(containerSize.width, totalWidth, @"The container's width is %.6f, the subviews take up %.6f", containerSize.width, totalWidth);
}
@end

View File

@@ -12,6 +12,11 @@
@interface UIView (CSSLayout) @interface UIView (CSSLayout)
/**
The property that decides if we should include this view when calculating layout. Defaults to YES.
*/
@property (nonatomic, readwrite, assign, setter=css_setIncludeInLayout:) BOOL css_includeInLayout;
/** /**
The property that decides during layout/sizing whether or not css_* properties should be applied. Defaults to NO. The property that decides during layout/sizing whether or not css_* properties should be applied. Defaults to NO.
*/ */
@@ -24,7 +29,7 @@
- (void)css_setAlignItems:(CSSAlign)alignItems; - (void)css_setAlignItems:(CSSAlign)alignItems;
- (void)css_setAlignSelf:(CSSAlign)alignSelf; - (void)css_setAlignSelf:(CSSAlign)alignSelf;
- (void)css_setPositionType:(CSSPositionType)positionType; - (void)css_setPositionType:(CSSPositionType)positionType;
- (void)css_setFlexWrap:(CSSWrapType)flexWrap; - (void)css_setFlexWrap:(CSSWrap)flexWrap;
- (void)css_setFlexGrow:(CGFloat)flexGrow; - (void)css_setFlexGrow:(CGFloat)flexGrow;
- (void)css_setFlexShrink:(CGFloat)flexShrink; - (void)css_setFlexShrink:(CGFloat)flexShrink;
@@ -41,6 +46,9 @@
- (void)css_setMaxWidth:(CGFloat)maxWidth; - (void)css_setMaxWidth:(CGFloat)maxWidth;
- (void)css_setMaxHeight:(CGFloat)maxHeight; - (void)css_setMaxHeight:(CGFloat)maxHeight;
// Yoga specific properties, not compatible with flexbox specification
- (void)css_setAspectRatio:(CGFloat)aspectRatio;
/** /**
Get the resolved direction of this node. This won't be CSSDirectionInherit Get the resolved direction of this node. This won't be CSSDirectionInherit
*/ */
@@ -52,8 +60,13 @@
- (void)css_applyLayout; - (void)css_applyLayout;
/** /**
Compute the size of a layout with a constrained size. Returns the size of the view if no constraints were given. This could equivalent to calling [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)];
*/ */
- (CGSize)css_sizeThatFits:(CGSize)constrainedSize; - (CGSize)css_intrinsicSize;
/**
Returns the number of children that are using Flexbox.
*/
- (NSUInteger)css_numberOfChildren;
@end @end

View File

@@ -16,6 +16,12 @@
@end @end
@implementation CSSNodeBridge @implementation CSSNodeBridge
+ (void)initialize
{
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true);
}
- (instancetype)init - (instancetype)init
{ {
if ([super init]) { if ([super init]) {
@@ -39,8 +45,28 @@
return [usesFlexbox boolValue]; return [usesFlexbox boolValue];
} }
- (BOOL)css_includeInLayout
{
NSNumber *includeInLayout = objc_getAssociatedObject(self, @selector(css_includeInLayout));
return (includeInLayout != nil) ? [includeInLayout boolValue] : YES;
}
- (NSUInteger)css_numberOfChildren
{
return CSSNodeChildCount([self cssNode]);
}
#pragma mark - Setters #pragma mark - Setters
- (void)css_setIncludeInLayout:(BOOL)includeInLayout
{
objc_setAssociatedObject(
self,
@selector(css_includeInLayout),
@(includeInLayout),
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (void)css_setUsesFlexbox:(BOOL)enabled - (void)css_setUsesFlexbox:(BOOL)enabled
{ {
objc_setAssociatedObject( objc_setAssociatedObject(
@@ -85,7 +111,7 @@
CSSNodeStyleSetPositionType([self cssNode], positionType); CSSNodeStyleSetPositionType([self cssNode], positionType);
} }
- (void)css_setFlexWrap:(CSSWrapType)flexWrap - (void)css_setFlexWrap:(CSSWrap)flexWrap
{ {
CSSNodeStyleSetFlexWrap([self cssNode], flexWrap); CSSNodeStyleSetFlexWrap([self cssNode], flexWrap);
} }
@@ -150,6 +176,11 @@
CSSNodeStyleSetMaxHeight([self cssNode], maxHeight); CSSNodeStyleSetMaxHeight([self cssNode], maxHeight);
} }
- (void)css_setAspectRatio:(CGFloat)aspectRatio
{
CSSNodeStyleSetAspectRatio([self cssNode], aspectRatio);
}
#pragma mark - Layout and Sizing #pragma mark - Layout and Sizing
- (CSSDirection)css_resolvedDirection - (CSSDirection)css_resolvedDirection
@@ -157,30 +188,19 @@
return CSSNodeLayoutGetDirection([self cssNode]); return CSSNodeLayoutGetDirection([self cssNode]);
} }
- (CGSize)css_sizeThatFits:(CGSize)constrainedSize
{
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view.");
CLKAttachNodesFromViewHierachy(self);
const CSSNodeRef node = [self cssNode];
CSSNodeCalculateLayout(
node,
constrainedSize.width,
constrainedSize.height,
CSSNodeStyleGetDirection(node));
return (CGSize) {
.width = CSSNodeLayoutGetWidth(node),
.height = CSSNodeLayoutGetHeight(node),
};
}
- (void)css_applyLayout - (void)css_applyLayout
{ {
[self css_sizeThatFits:self.bounds.size]; [self calculateLayoutWithSize:self.bounds.size];
CLKApplyLayoutToViewHierarchy(self); CSSApplyLayoutToViewHierarchy(self);
}
- (CGSize)css_intrinsicSize
{
const CGSize constrainedSize = {
.width = CSSUndefined,
.height = CSSUndefined,
};
return [self calculateLayoutWithSize:constrainedSize];
} }
#pragma mark - Private #pragma mark - Private
@@ -197,7 +217,27 @@
return node.cnode; return node.cnode;
} }
static CSSSize CLKMeasureView( - (CGSize)calculateLayoutWithSize:(CGSize)size
{
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
NSAssert([self css_usesFlexbox], @"CSS Layout is not enabled for this view.");
CSSAttachNodesFromViewHierachy(self);
const CSSNodeRef node = [self cssNode];
CSSNodeCalculateLayout(
node,
size.width,
size.height,
CSSNodeStyleGetDirection(node));
return (CGSize) {
.width = CSSNodeLayoutGetWidth(node),
.height = CSSNodeLayoutGetHeight(node),
};
}
static CSSSize CSSMeasureView(
CSSNodeRef node, CSSNodeRef node,
float width, float width,
CSSMeasureMode widthMode, CSSMeasureMode widthMode,
@@ -214,12 +254,12 @@ static CSSSize CLKMeasureView(
}]; }];
return (CSSSize) { return (CSSSize) {
.width = CLKSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode), .width = CSSSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
.height = CLKSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode), .height = CSSSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
}; };
} }
static CGFloat CLKSanitizeMeasurement( static CGFloat CSSSanitizeMeasurement(
CGFloat constrainedSize, CGFloat constrainedSize,
CGFloat measuredSize, CGFloat measuredSize,
CSSMeasureMode measureMode) CSSMeasureMode measureMode)
@@ -236,39 +276,60 @@ static CGFloat CLKSanitizeMeasurement(
return result; return result;
} }
static void CLKAttachNodesFromViewHierachy(UIView *view) { static void CSSAttachNodesFromViewHierachy(UIView *view) {
CSSNodeRef node = [view cssNode]; CSSNodeRef node = [view cssNode];
const BOOL usesFlexbox = [view css_usesFlexbox];
const BOOL isLeaf = !usesFlexbox || view.subviews.count == 0;
// Only leaf nodes should have a measure function // Only leaf nodes should have a measure function
if (isLeaf) { if (![view css_usesFlexbox] || view.subviews.count == 0) {
CSSNodeSetMeasureFunc(node, CLKMeasureView); CSSNodeSetMeasureFunc(node, CSSMeasureView);
CSSRemoveAllChildren(node);
// Clear any children
while (CSSNodeChildCount(node) > 0) {
CSSNodeRemoveChild(node, CSSNodeGetChild(node, 0));
}
} else { } else {
CSSNodeSetMeasureFunc(node, NULL); CSSNodeSetMeasureFunc(node, NULL);
// Add any children which were added since the last call to css_applyLayout // Create a list of all the subviews that we are going to use for layout.
for (NSUInteger i = 0; i < view.subviews.count; i++) { NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
CSSNodeRef childNode = [view.subviews[i] cssNode]; for (UIView *subview in view.subviews) {
if (CSSNodeChildCount(node) < i + 1 || CSSNodeGetChild(node, i) != childNode) { if ([subview css_includeInLayout]) {
CSSNodeInsertChild(node, childNode, i); [subviewsToInclude addObject:subview];
} }
CLKAttachNodesFromViewHierachy(view.subviews[i]);
} }
// Remove any children which were removed since the last call to css_applyLayout BOOL shouldReconstructChildList = NO;
while (view.subviews.count < CSSNodeChildCount(node)) { if (CSSNodeChildCount(node) != subviewsToInclude.count) {
CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1)); shouldReconstructChildList = YES;
} else {
for (int i = 0; i < subviewsToInclude.count; i++) {
if (CSSNodeGetChild(node, i) != [subviewsToInclude[i] cssNode]) {
shouldReconstructChildList = YES;
break;
}
}
}
if (shouldReconstructChildList) {
CSSRemoveAllChildren(node);
for (int i = 0 ; i < subviewsToInclude.count; i++) {
UIView *const subview = subviewsToInclude[i];
CSSNodeInsertChild(node, [subview cssNode], i);
CSSAttachNodesFromViewHierachy(subview);
}
} }
} }
} }
static CGFloat CLKRoundPixelValue(CGFloat value) static void CSSRemoveAllChildren(const CSSNodeRef node)
{
if (node == NULL) {
return;
}
while (CSSNodeChildCount(node) > 0) {
CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1));
}
}
static CGFloat CSSRoundPixelValue(CGFloat value)
{ {
static CGFloat scale; static CGFloat scale;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
@@ -279,10 +340,13 @@ static CGFloat CLKRoundPixelValue(CGFloat value)
return round(value * scale) / scale; return round(value * scale) / scale;
} }
static void CLKApplyLayoutToViewHierarchy(UIView *view) { static void CSSApplyLayoutToViewHierarchy(UIView *view) {
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread."); NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
CSSNodeRef node = [view cssNode]; if (![view css_includeInLayout]) {
return;
}
CSSNodeRef node = [view cssNode];
const CGPoint topLeft = { const CGPoint topLeft = {
CSSNodeLayoutGetLeft(node), CSSNodeLayoutGetLeft(node),
CSSNodeLayoutGetTop(node), CSSNodeLayoutGetTop(node),
@@ -295,19 +359,19 @@ static void CLKApplyLayoutToViewHierarchy(UIView *view) {
view.frame = (CGRect) { view.frame = (CGRect) {
.origin = { .origin = {
.x = CLKRoundPixelValue(topLeft.x), .x = CSSRoundPixelValue(topLeft.x),
.y = CLKRoundPixelValue(topLeft.y), .y = CSSRoundPixelValue(topLeft.y),
}, },
.size = { .size = {
.width = CLKRoundPixelValue(bottomRight.x) - CLKRoundPixelValue(topLeft.x), .width = CSSRoundPixelValue(bottomRight.x) - CSSRoundPixelValue(topLeft.x),
.height = CLKRoundPixelValue(bottomRight.y) - CLKRoundPixelValue(topLeft.y), .height = CSSRoundPixelValue(bottomRight.y) - CSSRoundPixelValue(topLeft.y),
}, },
}; };
const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0; const BOOL isLeaf = ![view css_usesFlexbox] || view.subviews.count == 0;
if (!isLeaf) { if (!isLeaf) {
for (NSUInteger i = 0; i < view.subviews.count; i++) { for (NSUInteger i = 0; i < view.subviews.count; i++) {
CLKApplyLayoutToViewHierarchy(view.subviews[i]); CSSApplyLayoutToViewHierarchy(view.subviews[i]);
} }
} }
} }

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *
@@ -15,6 +15,6 @@ namespace Facebook.CSSLayout
FlexStart, FlexStart,
Center, Center,
FlexEnd, FlexEnd,
Stretch Stretch,
} }
} }

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *
@@ -12,7 +12,11 @@ namespace Facebook.CSSLayout
public enum CSSDirection public enum CSSDirection
{ {
Inherit, Inherit,
LeftToRight, LTR,
RightToLeft RTL,
[System.Obsolete("Use LTR instead")]
LeftToRight = LTR,
[System.Obsolete("Use RTL instead")]
RightToLeft = RTL,
} }
} }

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *
@@ -12,6 +12,6 @@ namespace Facebook.CSSLayout
public enum CSSDimension public enum CSSDimension
{ {
Width, Width,
Height Height,
} }
} }

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *
@@ -20,6 +20,5 @@ namespace Facebook.CSSLayout
Horizontal, Horizontal,
Vertical, Vertical,
All, All,
Count,
} }
} }

View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.CSSLayout
{
public enum CSSExperimentalFeature
{
Rounding,
WebFlexBasis,
}
}

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *
@@ -14,6 +14,5 @@ namespace Facebook.CSSLayout
Undefined, Undefined,
Exactly, Exactly,
AtMost, AtMost,
Count,
} }
} }

View File

@@ -0,0 +1,234 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using System;
namespace Facebook.CSSLayout
{
public partial class CSSNode
{
public static CSSNode Create(
CSSDirection? styleDirection = null,
CSSFlexDirection? flexDirection = null,
CSSJustify? justifyContent = null,
CSSAlign? alignContent = null,
CSSAlign? alignItems = null,
CSSAlign? alignSelf = null,
CSSPositionType? positionType = null,
CSSWrap? wrap = null,
CSSOverflow? overflow = null,
float? flex = null,
float? flexGrow = null,
float? flexShrink = null,
float? flexBasis = null,
Spacing position = null,
Spacing margin = null,
Spacing padding = null,
Spacing border = null,
float? styleWidth = null,
float? styleHeight = null,
float? styleMaxWidth = null,
float? styleMaxHeight = null,
float? styleMinWidth = null,
float? styleMinHeight = null)
{
CSSNode node = new CSSNode();
if (styleDirection.HasValue)
{
node.StyleDirection = styleDirection.Value;
}
if (flexDirection.HasValue)
{
node.FlexDirection = flexDirection.Value;
}
if (justifyContent.HasValue)
{
node.JustifyContent = justifyContent.Value;
}
if (alignContent.HasValue)
{
node.AlignContent = alignContent.Value;
}
if (alignItems.HasValue)
{
node.AlignItems = alignItems.Value;
}
if (alignSelf.HasValue)
{
node.AlignSelf = alignSelf.Value;
}
if (positionType.HasValue)
{
node.PositionType = positionType.Value;
}
if (wrap.HasValue)
{
node.Wrap = wrap.Value;
}
if (overflow.HasValue)
{
node.Overflow = overflow.Value;
}
if (flex.HasValue)
{
node.Flex = flex.Value;
}
if (flexGrow.HasValue)
{
node.FlexGrow = flexGrow.Value;
}
if (flexShrink.HasValue)
{
node.FlexShrink = flexShrink.Value;
}
if (flexBasis.HasValue)
{
node.FlexBasis = flexBasis.Value;
}
if (position != null)
{
if (position.Top.HasValue)
{
node.SetPosition(CSSEdge.Top, position.Top.Value);
}
if (position.Bottom.HasValue)
{
node.SetPosition(CSSEdge.Bottom, position.Bottom.Value);
}
if (position.Left.HasValue)
{
node.SetPosition(CSSEdge.Left, position.Left.Value);
}
if (position.Right.HasValue)
{
node.SetPosition(CSSEdge.Right, position.Right.Value);
}
}
if (margin != null)
{
if (margin.Top.HasValue)
{
node.SetMargin(CSSEdge.Top, margin.Top.Value);
}
if (margin.Bottom.HasValue)
{
node.SetMargin(CSSEdge.Bottom, margin.Bottom.Value);
}
if (margin.Left.HasValue)
{
node.SetMargin(CSSEdge.Left, margin.Left.Value);
}
if (margin.Right.HasValue)
{
node.SetMargin(CSSEdge.Right, margin.Right.Value);
}
}
if (padding != null)
{
if (padding.Top.HasValue)
{
node.SetPadding(CSSEdge.Top, padding.Top.Value);
}
if (padding.Bottom.HasValue)
{
node.SetPadding(CSSEdge.Bottom, padding.Bottom.Value);
}
if (padding.Left.HasValue)
{
node.SetPadding(CSSEdge.Left, padding.Left.Value);
}
if (padding.Right.HasValue)
{
node.SetPadding(CSSEdge.Right, padding.Right.Value);
}
}
if (border != null)
{
if (border.Top.HasValue)
{
node.SetBorder(CSSEdge.Top, border.Top.Value);
}
if (border.Bottom.HasValue)
{
node.SetBorder(CSSEdge.Bottom, border.Bottom.Value);
}
if (border.Left.HasValue)
{
node.SetBorder(CSSEdge.Left, border.Left.Value);
}
if (border.Right.HasValue)
{
node.SetBorder(CSSEdge.Right, border.Right.Value);
}
}
if (styleWidth.HasValue)
{
node.StyleWidth = styleWidth.Value;
}
if (styleHeight.HasValue)
{
node.StyleHeight = styleHeight.Value;
}
if (styleMinWidth.HasValue)
{
node.StyleMinWidth = styleMinWidth.Value;
}
if (styleMinHeight.HasValue)
{
node.StyleMinHeight = styleMinHeight.Value;
}
if (styleMaxWidth.HasValue)
{
node.StyleMaxWidth = styleMaxWidth.Value;
}
if (styleMaxHeight.HasValue)
{
node.StyleMaxHeight = styleMaxHeight.Value;
}
return node;
}
}
}

View File

@@ -15,7 +15,7 @@ using System.Text;
namespace Facebook.CSSLayout namespace Facebook.CSSLayout
{ {
public class CSSNode : IEnumerable<CSSNode> public partial class CSSNode : IEnumerable<CSSNode>
{ {
private IntPtr _cssNode; private IntPtr _cssNode;
private WeakReference _parent; private WeakReference _parent;
@@ -90,6 +90,11 @@ namespace Facebook.CSSLayout
} }
} }
public void CopyStyle(CSSNode srcNode)
{
Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode);
}
public CSSDirection StyleDirection public CSSDirection StyleDirection
{ {
get get
@@ -359,6 +364,19 @@ namespace Facebook.CSSLayout
} }
} }
public float StyleAspectRatio
{
get
{
return Native.CSSNodeStyleGetAspectRatio(_cssNode);
}
set
{
Native.CSSNodeStyleSetAspectRatio(_cssNode, value);
}
}
public float LayoutX public float LayoutX
{ {
get get
@@ -550,5 +568,17 @@ namespace Facebook.CSSLayout
{ {
return Native.CSSNodeGetInstanceCount(); return Native.CSSNodeGetInstanceCount();
} }
public static void SetExperimentalFeatureEnabled(
CSSExperimentalFeature feature,
bool enabled)
{
Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled);
}
public static bool IsExperimentalFeatureEnabled(CSSExperimentalFeature feature)
{
return Native.CSSLayoutIsExperimentalFeatureEnabled(feature);
}
} }
} }

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *
@@ -13,5 +13,6 @@ namespace Facebook.CSSLayout
{ {
Visible, Visible,
Hidden, Hidden,
Scroll,
} }
} }

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *
@@ -12,6 +12,6 @@ namespace Facebook.CSSLayout
public enum CSSPositionType public enum CSSPositionType
{ {
Relative, Relative,
Absolute Absolute,
} }
} }

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@@ -1,4 +1,4 @@
/** /**
* Copyright (c) 2014-present, Facebook, Inc. * Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@@ -18,7 +18,7 @@ namespace Facebook.CSSLayout
public static long Make(int width, int height) public static long Make(int width, int height)
{ {
return (long)(((ulong) width) << 32 | ((ulong) height)); return (long)(((ulong) width) << 32 | ((uint) height));
} }
public static int GetWidth(long measureOutput) public static int GetWidth(long measureOutput)

View File

@@ -39,6 +39,15 @@ namespace Facebook.CSSLayout
[DllImport(DllName)] [DllImport(DllName)]
public static extern int CSSNodeGetInstanceCount(); public static extern int CSSNodeGetInstanceCount();
[DllImport(DllName)]
public static extern void CSSLayoutSetExperimentalFeatureEnabled(
CSSExperimentalFeature feature,
bool enabled);
[DllImport(DllName)]
public static extern bool CSSLayoutIsExperimentalFeatureEnabled(
CSSExperimentalFeature feature);
[DllImport(DllName)] [DllImport(DllName)]
public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index); public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index);
@@ -71,6 +80,9 @@ namespace Facebook.CSSLayout
[return: MarshalAs(UnmanagedType.I1)] [return: MarshalAs(UnmanagedType.I1)]
public static extern bool CSSValueIsUndefined(float value); public static extern bool CSSValueIsUndefined(float value);
[DllImport(DllName)]
public static extern void CSSNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
#region CSS_NODE_PROPERTY #region CSS_NODE_PROPERTY
[DllImport(DllName)] [DllImport(DllName)]
@@ -210,6 +222,12 @@ namespace Facebook.CSSLayout
[DllImport(DllName)] [DllImport(DllName)]
public static extern float CSSNodeStyleGetMaxHeight(IntPtr node); public static extern float CSSNodeStyleGetMaxHeight(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetAspectRatio(IntPtr node, float aspectRatio);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetAspectRatio(IntPtr node);
#endregion #endregion
#region CSS_NODE_STYLE_EDGE_PROPERTY #region CSS_NODE_STYLE_EDGE_PROPERTY

View File

@@ -0,0 +1,31 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
namespace Facebook.CSSLayout
{
public class Spacing
{
public float? Top;
public float? Bottom;
public float? Left;
public float? Right;
public Spacing(
float? top = null,
float? bottom = null,
float? left = null,
float? right = null)
{
Top = top;
Bottom = bottom;
Left = left;
Right = right;
}
}
}

View File

@@ -7,37 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></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>
<div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
<div id="absolute_layout_within_border" style="height:100px; width:100px; border-width: 10px; margin: 10px; padding: 10px;">
<div style="position: absolute; width: 50px; height: 50px; left: 0px; top: 0px;"></div>
<div style="position: absolute; width: 50px; height: 50px; right: 0px; bottom: 0px;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -51,166 +21,166 @@ namespace Facebook.CSSLayout
public void Test_absolute_layout_width_height_start_top() public void Test_absolute_layout_width_height_start_top()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.PositionType = CSSPositionType.Absolute; root_child0.PositionType = CSSPositionType.Absolute;
root_child0.SetPosition(CSSEdge.Start, 10); root_child0.SetPosition(CSSEdge.Start, 10f);
root_child0.SetPosition(CSSEdge.Top, 10); root_child0.SetPosition(CSSEdge.Top, 10f);
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(80, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_absolute_layout_width_height_end_bottom() public void Test_absolute_layout_width_height_end_bottom()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.PositionType = CSSPositionType.Absolute; root_child0.PositionType = CSSPositionType.Absolute;
root_child0.SetPosition(CSSEdge.End, 10); root_child0.SetPosition(CSSEdge.End, 10f);
root_child0.SetPosition(CSSEdge.Bottom, 10); root_child0.SetPosition(CSSEdge.Bottom, 10f);
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(80, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(80, root_child0.LayoutY); Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(80, root_child0.LayoutY); Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_absolute_layout_start_top_end_bottom() public void Test_absolute_layout_start_top_end_bottom()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.PositionType = CSSPositionType.Absolute; root_child0.PositionType = CSSPositionType.Absolute;
root_child0.SetPosition(CSSEdge.Start, 10); root_child0.SetPosition(CSSEdge.Start, 10f);
root_child0.SetPosition(CSSEdge.Top, 10); root_child0.SetPosition(CSSEdge.Top, 10f);
root_child0.SetPosition(CSSEdge.End, 10); root_child0.SetPosition(CSSEdge.End, 10f);
root_child0.SetPosition(CSSEdge.Bottom, 10); root_child0.SetPosition(CSSEdge.Bottom, 10f);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_absolute_layout_width_height_start_top_end_bottom() public void Test_absolute_layout_width_height_start_top_end_bottom()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.PositionType = CSSPositionType.Absolute; root_child0.PositionType = CSSPositionType.Absolute;
root_child0.SetPosition(CSSEdge.Start, 10); root_child0.SetPosition(CSSEdge.Start, 10f);
root_child0.SetPosition(CSSEdge.Top, 10); root_child0.SetPosition(CSSEdge.Top, 10f);
root_child0.SetPosition(CSSEdge.End, 10); root_child0.SetPosition(CSSEdge.End, 10f);
root_child0.SetPosition(CSSEdge.Bottom, 10); root_child0.SetPosition(CSSEdge.Bottom, 10f);
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(80, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -219,125 +189,125 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.Overflow = CSSOverflow.Hidden; root.Overflow = CSSOverflow.Hidden;
root.StyleWidth = 50; root.StyleWidth = 50f;
root.StyleHeight = 50; root.StyleHeight = 50f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.PositionType = CSSPositionType.Absolute; root_child0.PositionType = CSSPositionType.Absolute;
root_child0.SetPosition(CSSEdge.Start, 0); root_child0.SetPosition(CSSEdge.Start, 0f);
root_child0.SetPosition(CSSEdge.Top, 0); root_child0.SetPosition(CSSEdge.Top, 0f);
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child0_child0 = new CSSNode(); CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.StyleWidth = 100; root_child0_child0.StyleWidth = 100f;
root_child0_child0.StyleHeight = 100; root_child0_child0.StyleHeight = 100f;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(50, root.LayoutWidth); Assert.AreEqual(50f, root.LayoutWidth);
Assert.AreEqual(50, root.LayoutHeight); Assert.AreEqual(50f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100, root_child0_child0.LayoutHeight); Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(50, root.LayoutWidth); Assert.AreEqual(50f, root.LayoutWidth);
Assert.AreEqual(50, root.LayoutHeight); Assert.AreEqual(50f, root.LayoutHeight);
Assert.AreEqual(-50, root_child0.LayoutX); Assert.AreEqual(-50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100, root_child0_child0.LayoutHeight); Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_absolute_layout_within_border() public void Test_absolute_layout_within_border()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetMargin(CSSEdge.Left, 10); root.SetMargin(CSSEdge.Left, 10f);
root.SetMargin(CSSEdge.Top, 10); root.SetMargin(CSSEdge.Top, 10f);
root.SetMargin(CSSEdge.Right, 10); root.SetMargin(CSSEdge.Right, 10f);
root.SetMargin(CSSEdge.Bottom, 10); root.SetMargin(CSSEdge.Bottom, 10f);
root.SetPadding(CSSEdge.Left, 10); root.SetPadding(CSSEdge.Left, 10f);
root.SetPadding(CSSEdge.Top, 10); root.SetPadding(CSSEdge.Top, 10f);
root.SetPadding(CSSEdge.Right, 10); root.SetPadding(CSSEdge.Right, 10f);
root.SetPadding(CSSEdge.Bottom, 10); root.SetPadding(CSSEdge.Bottom, 10f);
root.SetBorder(CSSEdge.Left, 10); root.SetBorder(CSSEdge.Left, 10f);
root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Top, 10f);
root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Right, 10f);
root.SetBorder(CSSEdge.Bottom, 10); root.SetBorder(CSSEdge.Bottom, 10f);
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.PositionType = CSSPositionType.Absolute; root_child0.PositionType = CSSPositionType.Absolute;
root_child0.SetPosition(CSSEdge.Left, 0); root_child0.SetPosition(CSSEdge.Left, 0f);
root_child0.SetPosition(CSSEdge.Top, 0); root_child0.SetPosition(CSSEdge.Top, 0f);
root_child0.StyleWidth = 50; root_child0.StyleWidth = 50f;
root_child0.StyleHeight = 50; root_child0.StyleHeight = 50f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.PositionType = CSSPositionType.Absolute; root_child1.PositionType = CSSPositionType.Absolute;
root_child1.SetPosition(CSSEdge.Right, 0); root_child1.SetPosition(CSSEdge.Right, 0f);
root_child1.SetPosition(CSSEdge.Bottom, 0); root_child1.SetPosition(CSSEdge.Bottom, 0f);
root_child1.StyleWidth = 50; root_child1.StyleWidth = 50f;
root_child1.StyleHeight = 50; root_child1.StyleHeight = 50f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(10, root.LayoutX); Assert.AreEqual(10f, root.LayoutX);
Assert.AreEqual(10, root.LayoutY); Assert.AreEqual(10f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(40, root_child1.LayoutX); Assert.AreEqual(40f, root_child1.LayoutX);
Assert.AreEqual(40, root_child1.LayoutY); Assert.AreEqual(40f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(10, root.LayoutX); Assert.AreEqual(10f, root.LayoutX);
Assert.AreEqual(10, root.LayoutY); Assert.AreEqual(10f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(40, root_child1.LayoutX); Assert.AreEqual(40f, root_child1.LayoutX);
Assert.AreEqual(40, root_child1.LayoutY); Assert.AreEqual(40f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
} }
} }

View File

@@ -7,42 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_content_flex_start" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-start;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -57,98 +22,98 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 50; root_child0.StyleWidth = 50f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 50; root_child1.StyleWidth = 50f;
root_child1.StyleHeight = 10; root_child1.StyleHeight = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 50; root_child2.StyleWidth = 50f;
root_child2.StyleHeight = 10; root_child2.StyleHeight = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 50; root_child3.StyleWidth = 50f;
root_child3.StyleHeight = 10; root_child3.StyleHeight = 10f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
CSSNode root_child4 = new CSSNode(); CSSNode root_child4 = new CSSNode();
root_child4.StyleWidth = 50; root_child4.StyleWidth = 50f;
root_child4.StyleHeight = 10; root_child4.StyleHeight = 10f;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10, root_child3.LayoutHeight); Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(0, root_child4.LayoutX); Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(40, root_child4.LayoutY); Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10, root_child4.LayoutHeight); Assert.AreEqual(10f, root_child4.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(50, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(50, root_child2.LayoutX); Assert.AreEqual(50f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(50, root_child3.LayoutX); Assert.AreEqual(50f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10, root_child3.LayoutHeight); Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(50, root_child4.LayoutX); Assert.AreEqual(50f, root_child4.LayoutX);
Assert.AreEqual(40, root_child4.LayoutY); Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10, root_child4.LayoutHeight); Assert.AreEqual(10f, root_child4.LayoutHeight);
} }
[Test] [Test]
@@ -157,98 +122,98 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignContent = CSSAlign.FlexEnd; root.AlignContent = CSSAlign.FlexEnd;
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 50; root_child0.StyleWidth = 50f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 50; root_child1.StyleWidth = 50f;
root_child1.StyleHeight = 10; root_child1.StyleHeight = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 50; root_child2.StyleWidth = 50f;
root_child2.StyleHeight = 10; root_child2.StyleHeight = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 50; root_child3.StyleWidth = 50f;
root_child3.StyleHeight = 10; root_child3.StyleHeight = 10f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
CSSNode root_child4 = new CSSNode(); CSSNode root_child4 = new CSSNode();
root_child4.StyleWidth = 50; root_child4.StyleWidth = 50f;
root_child4.StyleHeight = 10; root_child4.StyleHeight = 10f;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10, root_child3.LayoutHeight); Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(0, root_child4.LayoutX); Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(40, root_child4.LayoutY); Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10, root_child4.LayoutHeight); Assert.AreEqual(10f, root_child4.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(50, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(50, root_child2.LayoutX); Assert.AreEqual(50f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(50, root_child3.LayoutX); Assert.AreEqual(50f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10, root_child3.LayoutHeight); Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(50, root_child4.LayoutX); Assert.AreEqual(50f, root_child4.LayoutX);
Assert.AreEqual(40, root_child4.LayoutY); Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10, root_child4.LayoutHeight); Assert.AreEqual(10f, root_child4.LayoutHeight);
} }
[Test] [Test]
@@ -257,98 +222,98 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignContent = CSSAlign.Center; root.AlignContent = CSSAlign.Center;
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 50; root_child0.StyleWidth = 50f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 50; root_child1.StyleWidth = 50f;
root_child1.StyleHeight = 10; root_child1.StyleHeight = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 50; root_child2.StyleWidth = 50f;
root_child2.StyleHeight = 10; root_child2.StyleHeight = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 50; root_child3.StyleWidth = 50f;
root_child3.StyleHeight = 10; root_child3.StyleHeight = 10f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
CSSNode root_child4 = new CSSNode(); CSSNode root_child4 = new CSSNode();
root_child4.StyleWidth = 50; root_child4.StyleWidth = 50f;
root_child4.StyleHeight = 10; root_child4.StyleHeight = 10f;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10, root_child3.LayoutHeight); Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(0, root_child4.LayoutX); Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(40, root_child4.LayoutY); Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10, root_child4.LayoutHeight); Assert.AreEqual(10f, root_child4.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(50, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(50, root_child2.LayoutX); Assert.AreEqual(50f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
Assert.AreEqual(50, root_child3.LayoutX); Assert.AreEqual(50f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(10, root_child3.LayoutHeight); Assert.AreEqual(10f, root_child3.LayoutHeight);
Assert.AreEqual(50, root_child4.LayoutX); Assert.AreEqual(50f, root_child4.LayoutX);
Assert.AreEqual(40, root_child4.LayoutY); Assert.AreEqual(40f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(10, root_child4.LayoutHeight); Assert.AreEqual(10f, root_child4.LayoutHeight);
} }
[Test] [Test]
@@ -357,93 +322,93 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignContent = CSSAlign.Stretch; root.AlignContent = CSSAlign.Stretch;
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 50; root_child0.StyleWidth = 50f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 50; root_child1.StyleWidth = 50f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 50; root_child2.StyleWidth = 50f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 50; root_child3.StyleWidth = 50f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
CSSNode root_child4 = new CSSNode(); CSSNode root_child4 = new CSSNode();
root_child4.StyleWidth = 50; root_child4.StyleWidth = 50f;
root.Insert(4, root_child4); root.Insert(4, root_child4);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(0, root_child0.LayoutHeight); Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(0, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(0, root_child2.LayoutHeight); Assert.AreEqual(0f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(0, root_child3.LayoutY); Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(0, root_child3.LayoutHeight); Assert.AreEqual(0f, root_child3.LayoutHeight);
Assert.AreEqual(0, root_child4.LayoutX); Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(0, root_child4.LayoutY); Assert.AreEqual(0f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(0, root_child4.LayoutHeight); Assert.AreEqual(0f, root_child4.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(0, root_child0.LayoutHeight); Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(50, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(0, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutHeight);
Assert.AreEqual(50, root_child2.LayoutX); Assert.AreEqual(50f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(0, root_child2.LayoutHeight); Assert.AreEqual(0f, root_child2.LayoutHeight);
Assert.AreEqual(50, root_child3.LayoutX); Assert.AreEqual(50f, root_child3.LayoutX);
Assert.AreEqual(0, root_child3.LayoutY); Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(50, root_child3.LayoutWidth); Assert.AreEqual(50f, root_child3.LayoutWidth);
Assert.AreEqual(0, root_child3.LayoutHeight); Assert.AreEqual(0f, root_child3.LayoutHeight);
Assert.AreEqual(50, root_child4.LayoutX); Assert.AreEqual(50f, root_child4.LayoutX);
Assert.AreEqual(0, root_child4.LayoutY); Assert.AreEqual(0f, root_child4.LayoutY);
Assert.AreEqual(50, root_child4.LayoutWidth); Assert.AreEqual(50f, root_child4.LayoutWidth);
Assert.AreEqual(0, root_child4.LayoutHeight); Assert.AreEqual(0f, root_child4.LayoutHeight);
} }
} }

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_items_stretch" style="width: 100px; height: 100px;">
<div style="height: 10px;"></div>
</div>
<div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -40,37 +21,37 @@ namespace Facebook.CSSLayout
public void Test_align_items_stretch() public void Test_align_items_stretch()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -78,38 +59,38 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignItems = CSSAlign.Center; root.AlignItems = CSSAlign.Center;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(45, root_child0.LayoutX); Assert.AreEqual(45f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(45, root_child0.LayoutX); Assert.AreEqual(45f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -117,38 +98,38 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignItems = CSSAlign.FlexStart; root.AlignItems = CSSAlign.FlexStart;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -156,38 +137,38 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignItems = CSSAlign.FlexEnd; root.AlignItems = CSSAlign.FlexEnd;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
} }

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_self_center" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: center;"></div>
</div>
<div id="align_self_flex_end" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
<div id="align_self_flex_start" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-start;"></div>
</div>
<div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -40,117 +21,117 @@ namespace Facebook.CSSLayout
public void Test_align_self_center() public void Test_align_self_center()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.AlignSelf = CSSAlign.Center; root_child0.AlignSelf = CSSAlign.Center;
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(45, root_child0.LayoutX); Assert.AreEqual(45f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(45, root_child0.LayoutX); Assert.AreEqual(45f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_align_self_flex_end() public void Test_align_self_flex_end()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.AlignSelf = CSSAlign.FlexEnd; root_child0.AlignSelf = CSSAlign.FlexEnd;
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_align_self_flex_start() public void Test_align_self_flex_start()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.AlignSelf = CSSAlign.FlexStart; root_child0.AlignSelf = CSSAlign.FlexStart;
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -158,39 +139,39 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignItems = CSSAlign.FlexStart; root.AlignItems = CSSAlign.FlexStart;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.AlignSelf = CSSAlign.FlexEnd; root_child0.AlignSelf = CSSAlign.FlexEnd;
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
} }

View File

@@ -7,29 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="border_no_size" style="border-width: 10px;">
</div>
<div id="border_container_match_child" style="border-width: 10px;">
<div style="width: 10px; height: 10px;"></div>
</div>
<div id="border_flex_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="width: 10px; flex-grow:1"></div>
</div>
<div id="border_stretch_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="height: 10px;"></div>
</div>
<div id="border_center_child" style="width: 100px; height: 100px; border-start-width: 10px; border-top-width: 10; border-end-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -43,148 +21,148 @@ namespace Facebook.CSSLayout
public void Test_border_no_size() public void Test_border_no_size()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetBorder(CSSEdge.Left, 10); root.SetBorder(CSSEdge.Left, 10f);
root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Top, 10f);
root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Right, 10f);
root.SetBorder(CSSEdge.Bottom, 10); root.SetBorder(CSSEdge.Bottom, 10f);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutWidth);
Assert.AreEqual(20, root.LayoutHeight); Assert.AreEqual(20f, root.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutWidth);
Assert.AreEqual(20, root.LayoutHeight); Assert.AreEqual(20f, root.LayoutHeight);
} }
[Test] [Test]
public void Test_border_container_match_child() public void Test_border_container_match_child()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetBorder(CSSEdge.Left, 10); root.SetBorder(CSSEdge.Left, 10f);
root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Top, 10f);
root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Right, 10f);
root.SetBorder(CSSEdge.Bottom, 10); root.SetBorder(CSSEdge.Bottom, 10f);
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30f, root.LayoutWidth);
Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(30f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30f, root.LayoutWidth);
Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(30f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_border_flex_child() public void Test_border_flex_child()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetBorder(CSSEdge.Left, 10); root.SetBorder(CSSEdge.Left, 10f);
root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Top, 10f);
root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Right, 10f);
root.SetBorder(CSSEdge.Bottom, 10); root.SetBorder(CSSEdge.Bottom, 10f);
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(80, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_border_stretch_child() public void Test_border_stretch_child()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetBorder(CSSEdge.Left, 10); root.SetBorder(CSSEdge.Left, 10f);
root.SetBorder(CSSEdge.Top, 10); root.SetBorder(CSSEdge.Top, 10f);
root.SetBorder(CSSEdge.Right, 10); root.SetBorder(CSSEdge.Right, 10f);
root.SetBorder(CSSEdge.Bottom, 10); root.SetBorder(CSSEdge.Bottom, 10f);
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -193,41 +171,41 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.JustifyContent = CSSJustify.Center; root.JustifyContent = CSSJustify.Center;
root.AlignItems = CSSAlign.Center; root.AlignItems = CSSAlign.Center;
root.SetBorder(CSSEdge.Start, 10); root.SetBorder(CSSEdge.Start, 10f);
root.SetBorder(CSSEdge.End, 20); root.SetBorder(CSSEdge.End, 20f);
root.SetBorder(CSSEdge.Bottom, 20); root.SetBorder(CSSEdge.Bottom, 20f);
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(40, root_child0.LayoutX); Assert.AreEqual(40f, root_child0.LayoutX);
Assert.AreEqual(35, root_child0.LayoutY); Assert.AreEqual(35f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(35, root_child0.LayoutY); Assert.AreEqual(35f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
} }

View File

@@ -7,46 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_direction_column_no_height" style="width: 100px">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_no_width" style="height: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column" style="height: 100px; width: 100px;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row" style="height: 100px; width: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column_reverse" style="height: 100px; width: 100px; flex-direction: column-reverse;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_reverse" style="height: 100px; width: 100px; flex-direction: row-reverse;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -60,64 +21,64 @@ namespace Facebook.CSSLayout
public void Test_flex_direction_column_no_height() public void Test_flex_direction_column_no_height()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleHeight = 10; root_child1.StyleHeight = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleHeight = 10; root_child2.StyleHeight = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(30f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(30f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
} }
[Test] [Test]
@@ -125,129 +86,129 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 10; root_child1.StyleWidth = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 10; root_child2.StyleWidth = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(10, root_child1.LayoutX); Assert.AreEqual(10f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(10, root_child1.LayoutWidth); Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(20, root_child2.LayoutX); Assert.AreEqual(20f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(100, root_child2.LayoutHeight); Assert.AreEqual(100f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20, root_child0.LayoutX); Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(10, root_child1.LayoutX); Assert.AreEqual(10f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(10, root_child1.LayoutWidth); Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(100, root_child2.LayoutHeight); Assert.AreEqual(100f, root_child2.LayoutHeight);
} }
[Test] [Test]
public void Test_flex_direction_column() public void Test_flex_direction_column()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleHeight = 10; root_child1.StyleHeight = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleHeight = 10; root_child2.StyleHeight = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(20, root_child2.LayoutY); Assert.AreEqual(20f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
} }
[Test] [Test]
@@ -255,65 +216,65 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 10; root_child1.StyleWidth = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 10; root_child2.StyleWidth = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(10, root_child1.LayoutX); Assert.AreEqual(10f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(10, root_child1.LayoutWidth); Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(20, root_child2.LayoutX); Assert.AreEqual(20f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(100, root_child2.LayoutHeight); Assert.AreEqual(100f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(80, root_child1.LayoutX); Assert.AreEqual(80f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(10, root_child1.LayoutWidth); Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(70, root_child2.LayoutX); Assert.AreEqual(70f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(100, root_child2.LayoutHeight); Assert.AreEqual(100f, root_child2.LayoutHeight);
} }
[Test] [Test]
@@ -321,65 +282,65 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.ColumnReverse; root.FlexDirection = CSSFlexDirection.ColumnReverse;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleHeight = 10; root_child1.StyleHeight = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleHeight = 10; root_child2.StyleHeight = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(90, root_child0.LayoutY); Assert.AreEqual(90f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(80, root_child1.LayoutY); Assert.AreEqual(80f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(70, root_child2.LayoutY); Assert.AreEqual(70f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(90, root_child0.LayoutY); Assert.AreEqual(90f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(80, root_child1.LayoutY); Assert.AreEqual(80f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(10, root_child1.LayoutHeight); Assert.AreEqual(10f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(70, root_child2.LayoutY); Assert.AreEqual(70f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(10, root_child2.LayoutHeight); Assert.AreEqual(10f, root_child2.LayoutHeight);
} }
[Test] [Test]
@@ -387,65 +348,65 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.RowReverse; root.FlexDirection = CSSFlexDirection.RowReverse;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 10; root_child1.StyleWidth = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 10; root_child2.StyleWidth = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(80, root_child1.LayoutX); Assert.AreEqual(80f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(10, root_child1.LayoutWidth); Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(70, root_child2.LayoutX); Assert.AreEqual(70f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(100, root_child2.LayoutHeight); Assert.AreEqual(100f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(10, root_child1.LayoutX); Assert.AreEqual(10f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(10, root_child1.LayoutWidth); Assert.AreEqual(10f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(20, root_child2.LayoutX); Assert.AreEqual(20f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(10, root_child2.LayoutWidth); Assert.AreEqual(10f, root_child2.LayoutWidth);
Assert.AreEqual(100, root_child2.LayoutHeight); Assert.AreEqual(100f, root_child2.LayoutHeight);
} }
} }

View File

@@ -7,48 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_basis_flex_grow_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_shrink_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_basis_flex_shrink_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_shrink_to_zero" style="height: 75px;">
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
<div style="width: 50px; height: 50px; flex-shrink:1;"></div>
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
</div>
<div id="flex_basis_overrides_main_size" style="height: 100px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="flex_grow_shrink_at_most" style="height: 100px; width: 100px;">
<div>
<div style="flex-grow:1; flex-shrink:1;"></div>
</div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -62,52 +21,52 @@ namespace Facebook.CSSLayout
public void Test_flex_basis_flex_grow_column() public void Test_flex_basis_flex_grow_column()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50; root_child0.FlexBasis = 50f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1; root_child1.FlexGrow = 1f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(75, root_child0.LayoutHeight); Assert.AreEqual(75f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(75, root_child1.LayoutY); Assert.AreEqual(75f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25, root_child1.LayoutHeight); Assert.AreEqual(25f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(75, root_child0.LayoutHeight); Assert.AreEqual(75f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(75, root_child1.LayoutY); Assert.AreEqual(75f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25, root_child1.LayoutHeight); Assert.AreEqual(25f, root_child1.LayoutHeight);
} }
[Test] [Test]
@@ -115,104 +74,104 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50; root_child0.FlexBasis = 50f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1; root_child1.FlexGrow = 1f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(75, root_child0.LayoutWidth); Assert.AreEqual(75f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(75, root_child1.LayoutX); Assert.AreEqual(75f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(25, root_child1.LayoutWidth); Assert.AreEqual(25f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(25, root_child0.LayoutX); Assert.AreEqual(25f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(75, root_child0.LayoutWidth); Assert.AreEqual(75f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(25, root_child1.LayoutWidth); Assert.AreEqual(25f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
} }
[Test] [Test]
public void Test_flex_basis_flex_shrink_column() public void Test_flex_basis_flex_shrink_column()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexShrink = 1; root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100; root_child0.FlexBasis = 100f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexBasis = 50; root_child1.FlexBasis = 50f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
} }
[Test] [Test]
@@ -220,240 +179,240 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexShrink = 1; root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100; root_child0.FlexBasis = 100f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexBasis = 50; root_child1.FlexBasis = 50f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(50, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
} }
[Test] [Test]
public void Test_flex_shrink_to_zero() public void Test_flex_shrink_to_zero()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleHeight = 75; root.StyleHeight = 75f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 50; root_child0.StyleWidth = 50f;
root_child0.StyleHeight = 50; root_child0.StyleHeight = 50f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexShrink = 1; root_child1.FlexShrink = 1f;
root_child1.StyleWidth = 50; root_child1.StyleWidth = 50f;
root_child1.StyleHeight = 50; root_child1.StyleHeight = 50f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 50; root_child2.StyleWidth = 50f;
root_child2.StyleHeight = 50; root_child2.StyleHeight = 50f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(50, root.LayoutWidth); Assert.AreEqual(50f, root.LayoutWidth);
Assert.AreEqual(75, root.LayoutHeight); Assert.AreEqual(75f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(0, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(50, root_child2.LayoutY); Assert.AreEqual(50f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(50, root_child2.LayoutHeight); Assert.AreEqual(50f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(50, root.LayoutWidth); Assert.AreEqual(50f, root.LayoutWidth);
Assert.AreEqual(75, root.LayoutHeight); Assert.AreEqual(75f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(0, root_child1.LayoutHeight); Assert.AreEqual(0f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(50, root_child2.LayoutY); Assert.AreEqual(50f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(50, root_child2.LayoutHeight); Assert.AreEqual(50f, root_child2.LayoutHeight);
} }
[Test] [Test]
public void Test_flex_basis_overrides_main_size() public void Test_flex_basis_overrides_main_size()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50; root_child0.FlexBasis = 50f;
root_child0.StyleHeight = 20; root_child0.StyleHeight = 20f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1; root_child1.FlexGrow = 1f;
root_child1.StyleHeight = 10; root_child1.StyleHeight = 10f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1; root_child2.FlexGrow = 1f;
root_child2.StyleHeight = 10; root_child2.StyleHeight = 10f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(60, root_child0.LayoutHeight); Assert.AreEqual(60f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(60, root_child1.LayoutY); Assert.AreEqual(60f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(80, root_child2.LayoutY); Assert.AreEqual(80f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(20, root_child2.LayoutHeight); Assert.AreEqual(20f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(60, root_child0.LayoutHeight); Assert.AreEqual(60f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(60, root_child1.LayoutY); Assert.AreEqual(60f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(80, root_child2.LayoutY); Assert.AreEqual(80f, root_child2.LayoutY);
Assert.AreEqual(100, root_child2.LayoutWidth); Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(20, root_child2.LayoutHeight); Assert.AreEqual(20f, root_child2.LayoutHeight);
} }
[Test] [Test]
public void Test_flex_grow_shrink_at_most() public void Test_flex_grow_shrink_at_most()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child0_child0 = new CSSNode(); CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.FlexGrow = 1; root_child0_child0.FlexGrow = 1f;
root_child0_child0.FlexShrink = 1; root_child0_child0.FlexShrink = 1f;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(0, root_child0.LayoutHeight); Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(0, root_child0_child0.LayoutHeight); Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(0, root_child0.LayoutHeight); Assert.AreEqual(0f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(0, root_child0_child0.LayoutHeight); Assert.AreEqual(0f, root_child0_child0.LayoutHeight);
} }
} }

View File

@@ -7,38 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="wrap_column" style="height: 100px; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row" style="width: 100px; flex-direction: row; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_flex_end" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: flex-end;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_center" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: center;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -53,82 +22,82 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 30; root_child0.StyleWidth = 30f;
root_child0.StyleHeight = 30; root_child0.StyleHeight = 30f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 30; root_child1.StyleWidth = 30f;
root_child1.StyleHeight = 30; root_child1.StyleHeight = 30f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 30; root_child2.StyleWidth = 30f;
root_child2.StyleHeight = 30; root_child2.StyleHeight = 30f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 30; root_child3.StyleWidth = 30f;
root_child3.StyleHeight = 30; root_child3.StyleHeight = 30f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(60, root.LayoutWidth); Assert.AreEqual(60f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(30, root_child0.LayoutHeight); Assert.AreEqual(30f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(30, root_child1.LayoutY); Assert.AreEqual(30f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(30, root_child1.LayoutHeight); Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(60, root_child2.LayoutY); Assert.AreEqual(60f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(30, root_child3.LayoutX); Assert.AreEqual(30f, root_child3.LayoutX);
Assert.AreEqual(0, root_child3.LayoutY); Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(60, root.LayoutWidth); Assert.AreEqual(60f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(30, root_child0.LayoutX); Assert.AreEqual(30f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(30, root_child0.LayoutHeight); Assert.AreEqual(30f, root_child0.LayoutHeight);
Assert.AreEqual(30, root_child1.LayoutX); Assert.AreEqual(30f, root_child1.LayoutX);
Assert.AreEqual(30, root_child1.LayoutY); Assert.AreEqual(30f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(30, root_child1.LayoutHeight); Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(30, root_child2.LayoutX); Assert.AreEqual(30f, root_child2.LayoutX);
Assert.AreEqual(60, root_child2.LayoutY); Assert.AreEqual(60f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(0, root_child3.LayoutY); Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
} }
[Test] [Test]
@@ -137,82 +106,82 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleWidth = 100; root.StyleWidth = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 30; root_child0.StyleWidth = 30f;
root_child0.StyleHeight = 30; root_child0.StyleHeight = 30f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 30; root_child1.StyleWidth = 30f;
root_child1.StyleHeight = 30; root_child1.StyleHeight = 30f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 30; root_child2.StyleWidth = 30f;
root_child2.StyleHeight = 30; root_child2.StyleHeight = 30f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 30; root_child3.StyleWidth = 30f;
root_child3.StyleHeight = 30; root_child3.StyleHeight = 30f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(60, root.LayoutHeight); Assert.AreEqual(60f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(30, root_child0.LayoutHeight); Assert.AreEqual(30f, root_child0.LayoutHeight);
Assert.AreEqual(30, root_child1.LayoutX); Assert.AreEqual(30f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(30, root_child1.LayoutHeight); Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(60, root_child2.LayoutX); Assert.AreEqual(60f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(60, root.LayoutHeight); Assert.AreEqual(60f, root.LayoutHeight);
Assert.AreEqual(70, root_child0.LayoutX); Assert.AreEqual(70f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(30, root_child0.LayoutHeight); Assert.AreEqual(30f, root_child0.LayoutHeight);
Assert.AreEqual(40, root_child1.LayoutX); Assert.AreEqual(40f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(30, root_child1.LayoutHeight); Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(10, root_child2.LayoutX); Assert.AreEqual(10f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(70, root_child3.LayoutX); Assert.AreEqual(70f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
} }
[Test] [Test]
@@ -222,82 +191,82 @@ namespace Facebook.CSSLayout
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.AlignItems = CSSAlign.FlexEnd; root.AlignItems = CSSAlign.FlexEnd;
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleWidth = 100; root.StyleWidth = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 30; root_child0.StyleWidth = 30f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 30; root_child1.StyleWidth = 30f;
root_child1.StyleHeight = 20; root_child1.StyleHeight = 20f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 30; root_child2.StyleWidth = 30f;
root_child2.StyleHeight = 30; root_child2.StyleHeight = 30f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 30; root_child3.StyleWidth = 30f;
root_child3.StyleHeight = 30; root_child3.StyleHeight = 30f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(60, root.LayoutHeight); Assert.AreEqual(60f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(20, root_child0.LayoutY); Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(30, root_child1.LayoutX); Assert.AreEqual(30f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
Assert.AreEqual(60, root_child2.LayoutX); Assert.AreEqual(60f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(60, root.LayoutHeight); Assert.AreEqual(60f, root.LayoutHeight);
Assert.AreEqual(70, root_child0.LayoutX); Assert.AreEqual(70f, root_child0.LayoutX);
Assert.AreEqual(20, root_child0.LayoutY); Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(40, root_child1.LayoutX); Assert.AreEqual(40f, root_child1.LayoutX);
Assert.AreEqual(10, root_child1.LayoutY); Assert.AreEqual(10f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
Assert.AreEqual(10, root_child2.LayoutX); Assert.AreEqual(10f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(70, root_child3.LayoutX); Assert.AreEqual(70f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
} }
[Test] [Test]
@@ -307,82 +276,82 @@ namespace Facebook.CSSLayout
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.AlignItems = CSSAlign.Center; root.AlignItems = CSSAlign.Center;
root.Wrap = CSSWrap.Wrap; root.Wrap = CSSWrap.Wrap;
root.StyleWidth = 100; root.StyleWidth = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 30; root_child0.StyleWidth = 30f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 30; root_child1.StyleWidth = 30f;
root_child1.StyleHeight = 20; root_child1.StyleHeight = 20f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 30; root_child2.StyleWidth = 30f;
root_child2.StyleHeight = 30; root_child2.StyleHeight = 30f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode(); CSSNode root_child3 = new CSSNode();
root_child3.StyleWidth = 30; root_child3.StyleWidth = 30f;
root_child3.StyleHeight = 30; root_child3.StyleHeight = 30f;
root.Insert(3, root_child3); root.Insert(3, root_child3);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(60, root.LayoutHeight); Assert.AreEqual(60f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(30, root_child1.LayoutX); Assert.AreEqual(30f, root_child1.LayoutX);
Assert.AreEqual(5, root_child1.LayoutY); Assert.AreEqual(5f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
Assert.AreEqual(60, root_child2.LayoutX); Assert.AreEqual(60f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(0, root_child3.LayoutX); Assert.AreEqual(0f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(60, root.LayoutHeight); Assert.AreEqual(60f, root.LayoutHeight);
Assert.AreEqual(70, root_child0.LayoutX); Assert.AreEqual(70f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(30, root_child0.LayoutWidth); Assert.AreEqual(30f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
Assert.AreEqual(40, root_child1.LayoutX); Assert.AreEqual(40f, root_child1.LayoutX);
Assert.AreEqual(5, root_child1.LayoutY); Assert.AreEqual(5f, root_child1.LayoutY);
Assert.AreEqual(30, root_child1.LayoutWidth); Assert.AreEqual(30f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
Assert.AreEqual(10, root_child2.LayoutX); Assert.AreEqual(10f, root_child2.LayoutX);
Assert.AreEqual(0, root_child2.LayoutY); Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(30, root_child2.LayoutWidth); Assert.AreEqual(30f, root_child2.LayoutWidth);
Assert.AreEqual(30, root_child2.LayoutHeight); Assert.AreEqual(30f, root_child2.LayoutHeight);
Assert.AreEqual(70, root_child3.LayoutX); Assert.AreEqual(70f, root_child3.LayoutX);
Assert.AreEqual(30, root_child3.LayoutY); Assert.AreEqual(30f, root_child3.LayoutY);
Assert.AreEqual(30, root_child3.LayoutWidth); Assert.AreEqual(30f, root_child3.LayoutWidth);
Assert.AreEqual(30, root_child3.LayoutHeight); Assert.AreEqual(30f, root_child3.LayoutHeight);
} }
} }

View File

@@ -7,52 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="margin_start" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 10px; margin-start: 10px;"></div>
</div>
<div id="margin_top" style="width: 100px; height: 100px;">
<div style="height: 10px; margin-top: 10px;"></div>
</div>
<div id="margin_end" style="width: 100px; height: 100px; flex-direction: row; justify-content: flex-end;">
<div style="width: 10px; margin-end: 10px;"></div>
</div>
<div id="margin_bottom" style="width: 100px; height: 100px; justify-content: flex-end;">
<div style="height: 10px; margin-bottom: 10px;"></div>
</div>
<div id="margin_and_flex_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_flex_column" style="width: 100px; height: 100px;">
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_stretch_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_stretch_column" style="width: 100px; height: 100px;">
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_with_sibling_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-end; 10px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="margin_with_sibling_column" style="width: 100px; height: 100px;">
<div style="margin-bottom; 10px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -67,76 +22,76 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.SetMargin(CSSEdge.Start, 10); root_child0.SetMargin(CSSEdge.Start, 10f);
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(80, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_margin_top() public void Test_margin_top()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.SetMargin(CSSEdge.Top, 10); root_child0.SetMargin(CSSEdge.Top, 10f);
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -145,38 +100,38 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.JustifyContent = CSSJustify.FlexEnd; root.JustifyContent = CSSJustify.FlexEnd;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.SetMargin(CSSEdge.End, 10); root_child0.SetMargin(CSSEdge.End, 10f);
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(80, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -184,38 +139,38 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.JustifyContent = CSSJustify.FlexEnd; root.JustifyContent = CSSJustify.FlexEnd;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.SetMargin(CSSEdge.Bottom, 10); root_child0.SetMargin(CSSEdge.Bottom, 10f);
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(80, root_child0.LayoutY); Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(80, root_child0.LayoutY); Assert.AreEqual(80f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -223,76 +178,76 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.SetMargin(CSSEdge.Start, 10); root_child0.SetMargin(CSSEdge.Start, 10f);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(90, root_child0.LayoutWidth); Assert.AreEqual(90f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(90, root_child0.LayoutWidth); Assert.AreEqual(90f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_margin_and_flex_column() public void Test_margin_and_flex_column()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.SetMargin(CSSEdge.Top, 10); root_child0.SetMargin(CSSEdge.Top, 10f);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(90, root_child0.LayoutHeight); Assert.AreEqual(90f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(90, root_child0.LayoutHeight); Assert.AreEqual(90f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -300,76 +255,76 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.SetMargin(CSSEdge.Top, 10); root_child0.SetMargin(CSSEdge.Top, 10f);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(90, root_child0.LayoutHeight); Assert.AreEqual(90f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(90, root_child0.LayoutHeight); Assert.AreEqual(90f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_margin_and_stretch_column() public void Test_margin_and_stretch_column()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.SetMargin(CSSEdge.Start, 10); root_child0.SetMargin(CSSEdge.Start, 10f);
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(90, root_child0.LayoutWidth); Assert.AreEqual(90f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(90, root_child0.LayoutWidth); Assert.AreEqual(90f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -377,102 +332,102 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1; root_child1.FlexGrow = 1f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(50, root_child1.LayoutX); Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
} }
[Test] [Test]
public void Test_margin_with_sibling_column() public void Test_margin_with_sibling_column()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1; root_child1.FlexGrow = 1f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50, root_child1.LayoutY); Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
} }
} }

View File

@@ -7,54 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="max_width" style="width: 100px; height: 100px;">
<div style="height: 10px; max-width: 50px;"></div>
</div>
<div id="max_height" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 10px; max-height: 50px;"></div>
</div>
<div id="min_height" style="width: 100px; height: 100px;">
<div style="flex-grow: 1; min-height: 60px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="min_width" style="width: 100px; height: 100px; flex-direction: row">
<div style="flex-grow: 1; min-width: 60px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="justify_content_min_max" style="max-height: 200px; min-height: 100px; width: 100px; justify-content: center;">
<div style="width: 60px; height: 60px;"></div>
</div>
<div id="align_items_min_max" style="max-width: 200px; min-width: 100px; height: 100px; align-items: center;">
<div style="width: 60px; height: 60px;"></div>
</div>
<div id="justify_content_overflow_min_max" style="min-height: 100px; max-height: 110px; justify-content: center;">
<div style="width: 50px; height: 50px;"></div>
<div style="width: 50px; height: 50px;"></div>
<div style="width: 50px; height: 50px;"></div>
</div>
<div id="flex_grow_within_max_width" style="width: 200px; height: 100px;">
<div style="flex-direction: row; max-width: 100px;">
<div style="height: 20px; flex-grow: 1;"></div>
</div>
</div>
<div id="flex_grow_within_constrained_max_width" style="width: 200px; height: 100px;">
<div style="flex-direction: row; max-width: 300px;">
<div style="height: 20px; flex-grow: 1;"></div>
</div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -68,38 +21,38 @@ namespace Facebook.CSSLayout
public void Test_max_width() public void Test_max_width()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleMaxWidth = 50; root_child0.StyleMaxWidth = 50f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -107,90 +60,90 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleMaxHeight = 50; root_child0.StyleMaxHeight = 50f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90, root_child0.LayoutX); Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_min_height() public void Test_min_height()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.StyleMinHeight = 60; root_child0.StyleMinHeight = 60f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1; root_child1.FlexGrow = 1f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(80, root_child1.LayoutY); Assert.AreEqual(80f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(80, root_child1.LayoutY); Assert.AreEqual(80f, root_child1.LayoutY);
Assert.AreEqual(100, root_child1.LayoutWidth); Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(20, root_child1.LayoutHeight); Assert.AreEqual(20f, root_child1.LayoutHeight);
} }
[Test] [Test]
@@ -198,52 +151,52 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row; root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.StyleMinWidth = 60; root_child0.StyleMinWidth = 60f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1; root_child1.FlexGrow = 1f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(80, root_child1.LayoutX); Assert.AreEqual(80f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(20, root_child1.LayoutWidth); Assert.AreEqual(20f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20, root_child0.LayoutX); Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(100, root_child0.LayoutHeight); Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0, root_child1.LayoutY); Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(20, root_child1.LayoutWidth); Assert.AreEqual(20f, root_child1.LayoutWidth);
Assert.AreEqual(100, root_child1.LayoutHeight); Assert.AreEqual(100f, root_child1.LayoutHeight);
} }
[Test] [Test]
@@ -251,39 +204,39 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.JustifyContent = CSSJustify.Center; root.JustifyContent = CSSJustify.Center;
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleMinHeight = 100; root.StyleMinHeight = 100f;
root.StyleMaxHeight = 200; root.StyleMaxHeight = 200f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 60; root_child0.StyleWidth = 60f;
root_child0.StyleHeight = 60; root_child0.StyleHeight = 60f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(20, root_child0.LayoutY); Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(60, root_child0.LayoutWidth); Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60, root_child0.LayoutHeight); Assert.AreEqual(60f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(40, root_child0.LayoutX); Assert.AreEqual(40f, root_child0.LayoutX);
Assert.AreEqual(20, root_child0.LayoutY); Assert.AreEqual(20f, root_child0.LayoutY);
Assert.AreEqual(60, root_child0.LayoutWidth); Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60, root_child0.LayoutHeight); Assert.AreEqual(60f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -291,39 +244,39 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.AlignItems = CSSAlign.Center; root.AlignItems = CSSAlign.Center;
root.StyleMinWidth = 100; root.StyleMinWidth = 100f;
root.StyleMaxWidth = 200; root.StyleMaxWidth = 200f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 60; root_child0.StyleWidth = 60f;
root_child0.StyleHeight = 60; root_child0.StyleHeight = 60f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20, root_child0.LayoutX); Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60, root_child0.LayoutWidth); Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60, root_child0.LayoutHeight); Assert.AreEqual(60f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(20, root_child0.LayoutX); Assert.AreEqual(20f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(60, root_child0.LayoutWidth); Assert.AreEqual(60f, root_child0.LayoutWidth);
Assert.AreEqual(60, root_child0.LayoutHeight); Assert.AreEqual(60f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -331,174 +284,174 @@ namespace Facebook.CSSLayout
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.JustifyContent = CSSJustify.Center; root.JustifyContent = CSSJustify.Center;
root.StyleMinHeight = 100; root.StyleMinHeight = 100f;
root.StyleMaxHeight = 110; root.StyleMaxHeight = 110f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 50; root_child0.StyleWidth = 50f;
root_child0.StyleHeight = 50; root_child0.StyleHeight = 50f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode(); CSSNode root_child1 = new CSSNode();
root_child1.StyleWidth = 50; root_child1.StyleWidth = 50f;
root_child1.StyleHeight = 50; root_child1.StyleHeight = 50f;
root.Insert(1, root_child1); root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode(); CSSNode root_child2 = new CSSNode();
root_child2.StyleWidth = 50; root_child2.StyleWidth = 50f;
root_child2.StyleHeight = 50; root_child2.StyleHeight = 50f;
root.Insert(2, root_child2); root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(50, root.LayoutWidth); Assert.AreEqual(50f, root.LayoutWidth);
Assert.AreEqual(110, root.LayoutHeight); Assert.AreEqual(110f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(-20, root_child0.LayoutY); Assert.AreEqual(-20f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(30, root_child1.LayoutY); Assert.AreEqual(30f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(80, root_child2.LayoutY); Assert.AreEqual(80f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(50, root_child2.LayoutHeight); Assert.AreEqual(50f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(50, root.LayoutWidth); Assert.AreEqual(50f, root.LayoutWidth);
Assert.AreEqual(110, root.LayoutHeight); Assert.AreEqual(110f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(-20, root_child0.LayoutY); Assert.AreEqual(-20f, root_child0.LayoutY);
Assert.AreEqual(50, root_child0.LayoutWidth); Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(50, root_child0.LayoutHeight); Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child1.LayoutX); Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(30, root_child1.LayoutY); Assert.AreEqual(30f, root_child1.LayoutY);
Assert.AreEqual(50, root_child1.LayoutWidth); Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(50, root_child1.LayoutHeight); Assert.AreEqual(50f, root_child1.LayoutHeight);
Assert.AreEqual(0, root_child2.LayoutX); Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(80, root_child2.LayoutY); Assert.AreEqual(80f, root_child2.LayoutY);
Assert.AreEqual(50, root_child2.LayoutWidth); Assert.AreEqual(50f, root_child2.LayoutWidth);
Assert.AreEqual(50, root_child2.LayoutHeight); Assert.AreEqual(50f, root_child2.LayoutHeight);
} }
[Test] [Test]
public void Test_flex_grow_within_max_width() public void Test_flex_grow_within_max_width()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 200; root.StyleWidth = 200f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexDirection = CSSFlexDirection.Row; root_child0.FlexDirection = CSSFlexDirection.Row;
root_child0.StyleMaxWidth = 100; root_child0.StyleMaxWidth = 100f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child0_child0 = new CSSNode(); CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.FlexGrow = 1; root_child0_child0.FlexGrow = 1f;
root_child0_child0.StyleHeight = 20; root_child0_child0.StyleHeight = 20f;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(20, root_child0.LayoutHeight); Assert.AreEqual(20f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(20, root_child0_child0.LayoutHeight); Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(100, root_child0.LayoutX); Assert.AreEqual(100f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100, root_child0.LayoutWidth); Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(20, root_child0.LayoutHeight); Assert.AreEqual(20f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(100, root_child0_child0.LayoutWidth); Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
Assert.AreEqual(20, root_child0_child0.LayoutHeight); Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_flex_grow_within_constrained_max_width() public void Test_flex_grow_within_constrained_max_width()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.StyleWidth = 200; root.StyleWidth = 200f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexDirection = CSSFlexDirection.Row; root_child0.FlexDirection = CSSFlexDirection.Row;
root_child0.StyleMaxWidth = 300; root_child0.StyleMaxWidth = 300f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
CSSNode root_child0_child0 = new CSSNode(); CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.FlexGrow = 1; root_child0_child0.FlexGrow = 1f;
root_child0_child0.StyleHeight = 20; root_child0_child0.StyleHeight = 20f;
root_child0.Insert(0, root_child0_child0); root_child0.Insert(0, root_child0_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200, root_child0.LayoutWidth); Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(20, root_child0.LayoutHeight); Assert.AreEqual(20f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(200, root_child0_child0.LayoutWidth); Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
Assert.AreEqual(20, root_child0_child0.LayoutHeight); Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200, root.LayoutWidth); Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0, root_child0.LayoutX); Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0, root_child0.LayoutY); Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(200, root_child0.LayoutWidth); Assert.AreEqual(200f, root_child0.LayoutWidth);
Assert.AreEqual(20, root_child0.LayoutHeight); Assert.AreEqual(20f, root_child0.LayoutHeight);
Assert.AreEqual(0, root_child0_child0.LayoutX); Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0, root_child0_child0.LayoutY); Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(200, root_child0_child0.LayoutWidth); Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
Assert.AreEqual(20, root_child0_child0.LayoutHeight); Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
} }
} }

View File

@@ -7,29 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="padding_no_size" style="padding: 10px;">
</div>
<div id="padding_container_match_child" style="padding: 10px;">
<div style="width: 10px; height: 10px;"></div>
</div>
<div id="padding_flex_child" style="width: 100px; height: 100px; padding: 10px;">
<div style="width: 10px; flex-grow:1"></div>
</div>
<div id="padding_stretch_child" style="width: 100px; height: 100px; padding: 10px;">
<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 style="height: 10px; width: 10px;"></div>
</div>
*
*/
using System; using System;
using NUnit.Framework; using NUnit.Framework;
@@ -43,148 +21,148 @@ namespace Facebook.CSSLayout
public void Test_padding_no_size() public void Test_padding_no_size()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetPadding(CSSEdge.Left, 10); root.SetPadding(CSSEdge.Left, 10f);
root.SetPadding(CSSEdge.Top, 10); root.SetPadding(CSSEdge.Top, 10f);
root.SetPadding(CSSEdge.Right, 10); root.SetPadding(CSSEdge.Right, 10f);
root.SetPadding(CSSEdge.Bottom, 10); root.SetPadding(CSSEdge.Bottom, 10f);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutWidth);
Assert.AreEqual(20, root.LayoutHeight); Assert.AreEqual(20f, root.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(20, root.LayoutWidth); Assert.AreEqual(20f, root.LayoutWidth);
Assert.AreEqual(20, root.LayoutHeight); Assert.AreEqual(20f, root.LayoutHeight);
} }
[Test] [Test]
public void Test_padding_container_match_child() public void Test_padding_container_match_child()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetPadding(CSSEdge.Left, 10); root.SetPadding(CSSEdge.Left, 10f);
root.SetPadding(CSSEdge.Top, 10); root.SetPadding(CSSEdge.Top, 10f);
root.SetPadding(CSSEdge.Right, 10); root.SetPadding(CSSEdge.Right, 10f);
root.SetPadding(CSSEdge.Bottom, 10); root.SetPadding(CSSEdge.Bottom, 10f);
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30f, root.LayoutWidth);
Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(30f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(30, root.LayoutWidth); Assert.AreEqual(30f, root.LayoutWidth);
Assert.AreEqual(30, root.LayoutHeight); Assert.AreEqual(30f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_padding_flex_child() public void Test_padding_flex_child()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetPadding(CSSEdge.Left, 10); root.SetPadding(CSSEdge.Left, 10f);
root.SetPadding(CSSEdge.Top, 10); root.SetPadding(CSSEdge.Top, 10f);
root.SetPadding(CSSEdge.Right, 10); root.SetPadding(CSSEdge.Right, 10f);
root.SetPadding(CSSEdge.Bottom, 10); root.SetPadding(CSSEdge.Bottom, 10f);
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1; root_child0.FlexGrow = 1f;
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(80, root_child0.LayoutX); Assert.AreEqual(80f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(80, root_child0.LayoutHeight); Assert.AreEqual(80f, root_child0.LayoutHeight);
} }
[Test] [Test]
public void Test_padding_stretch_child() public void Test_padding_stretch_child()
{ {
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.SetPadding(CSSEdge.Left, 10); root.SetPadding(CSSEdge.Left, 10f);
root.SetPadding(CSSEdge.Top, 10); root.SetPadding(CSSEdge.Top, 10f);
root.SetPadding(CSSEdge.Right, 10); root.SetPadding(CSSEdge.Right, 10f);
root.SetPadding(CSSEdge.Bottom, 10); root.SetPadding(CSSEdge.Bottom, 10f);
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(10, root_child0.LayoutX); Assert.AreEqual(10f, root_child0.LayoutX);
Assert.AreEqual(10, root_child0.LayoutY); Assert.AreEqual(10f, root_child0.LayoutY);
Assert.AreEqual(80, root_child0.LayoutWidth); Assert.AreEqual(80f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
[Test] [Test]
@@ -193,41 +171,41 @@ namespace Facebook.CSSLayout
CSSNode root = new CSSNode(); CSSNode root = new CSSNode();
root.JustifyContent = CSSJustify.Center; root.JustifyContent = CSSJustify.Center;
root.AlignItems = CSSAlign.Center; root.AlignItems = CSSAlign.Center;
root.SetPadding(CSSEdge.Start, 10); root.SetPadding(CSSEdge.Start, 10f);
root.SetPadding(CSSEdge.End, 20); root.SetPadding(CSSEdge.End, 20f);
root.SetPadding(CSSEdge.Bottom, 20); root.SetPadding(CSSEdge.Bottom, 20f);
root.StyleWidth = 100; root.StyleWidth = 100f;
root.StyleHeight = 100; root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode(); CSSNode root_child0 = new CSSNode();
root_child0.StyleWidth = 10; root_child0.StyleWidth = 10f;
root_child0.StyleHeight = 10; root_child0.StyleHeight = 10f;
root.Insert(0, root_child0); root.Insert(0, root_child0);
root.StyleDirection = CSSDirection.LeftToRight; root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(40, root_child0.LayoutX); Assert.AreEqual(40f, root_child0.LayoutX);
Assert.AreEqual(35, root_child0.LayoutY); Assert.AreEqual(35f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
root.StyleDirection = CSSDirection.RightToLeft; root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout(); root.CalculateLayout();
Assert.AreEqual(0, root.LayoutX); Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0, root.LayoutY); Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100, root.LayoutWidth); Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100, root.LayoutHeight); Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50, root_child0.LayoutX); Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(35, root_child0.LayoutY); Assert.AreEqual(35f, root_child0.LayoutY);
Assert.AreEqual(10, root_child0.LayoutWidth); Assert.AreEqual(10f, root_child0.LayoutWidth);
Assert.AreEqual(10, root_child0.LayoutHeight); Assert.AreEqual(10f, root_child0.LayoutHeight);
} }
} }

View File

@@ -0,0 +1,807 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html
using System;
using NUnit.Framework;
namespace Facebook.CSSLayout
{
[TestFixture]
public class CSSLayoutRoundingTest
{
[Test]
public void Test_rounding_flex_basis_flex_grow_row_width_of_100()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 100f;
root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(33f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(33f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(34f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(67f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(33f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(67f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(33f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(33f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(34f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(33f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_flex_basis_flex_grow_row_prime_number_width()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 113f;
root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1f;
root.Insert(2, root_child2);
CSSNode root_child3 = new CSSNode();
root_child3.FlexGrow = 1f;
root.Insert(3, root_child3);
CSSNode root_child4 = new CSSNode();
root_child4.FlexGrow = 1f;
root.Insert(4, root_child4);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(113f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(23f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(23f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(22f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(45f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(23f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
Assert.AreEqual(68f, root_child3.LayoutX);
Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(22f, root_child3.LayoutWidth);
Assert.AreEqual(100f, root_child3.LayoutHeight);
Assert.AreEqual(90f, root_child4.LayoutX);
Assert.AreEqual(0f, root_child4.LayoutY);
Assert.AreEqual(23f, root_child4.LayoutWidth);
Assert.AreEqual(100f, root_child4.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(113f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(90f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(23f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(68f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(22f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(45f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(23f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
Assert.AreEqual(23f, root_child3.LayoutX);
Assert.AreEqual(0f, root_child3.LayoutY);
Assert.AreEqual(22f, root_child3.LayoutWidth);
Assert.AreEqual(100f, root_child3.LayoutHeight);
Assert.AreEqual(0f, root_child4.LayoutX);
Assert.AreEqual(0f, root_child4.LayoutY);
Assert.AreEqual(23f, root_child4.LayoutWidth);
Assert.AreEqual(100f, root_child4.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_flex_basis_flex_shrink_row()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.FlexDirection = CSSFlexDirection.Row;
root.StyleWidth = 101f;
root.StyleHeight = 100f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexBasis = 25f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexBasis = 25f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(101f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(51f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(51f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(25f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(76f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(25f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(101f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(51f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(25f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(25f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(0f, root_child2.LayoutY);
Assert.AreEqual(25f, root_child2.LayoutWidth);
Assert.AreEqual(100f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_flex_basis_overrides_main_size()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.StyleWidth = 100f;
root.StyleHeight = 113f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.StyleHeight = 20f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1f;
root_child1.StyleHeight = 10f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1f;
root_child2.StyleHeight = 10f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_total_fractial()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.StyleWidth = 87.4f;
root.StyleHeight = 113.4f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 0.7f;
root_child0.FlexBasis = 50.3f;
root_child0.StyleHeight = 20.3f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1.6f;
root_child1.StyleHeight = 10f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1.1f;
root_child2.StyleHeight = 10.7f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(87f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(87f, root_child0.LayoutWidth);
Assert.AreEqual(59f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(59f, root_child1.LayoutY);
Assert.AreEqual(87f, root_child1.LayoutWidth);
Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(87f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(87f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(87f, root_child0.LayoutWidth);
Assert.AreEqual(59f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(59f, root_child1.LayoutY);
Assert.AreEqual(87f, root_child1.LayoutWidth);
Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(87f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_total_fractial_nested()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.StyleWidth = 87.4f;
root.StyleHeight = 113.4f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 0.7f;
root_child0.FlexBasis = 50.3f;
root_child0.StyleHeight = 20.3f;
root.Insert(0, root_child0);
CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.FlexGrow = 1f;
root_child0_child0.FlexBasis = 0.3f;
root_child0_child0.SetPosition(CSSEdge.Bottom, 13.3f);
root_child0_child0.StyleHeight = 9.9f;
root_child0.Insert(0, root_child0_child0);
CSSNode root_child0_child1 = new CSSNode();
root_child0_child1.FlexGrow = 4f;
root_child0_child1.FlexBasis = 0.3f;
root_child0_child1.SetPosition(CSSEdge.Top, 13.3f);
root_child0_child1.StyleHeight = 1.1f;
root_child0.Insert(1, root_child0_child1);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1.6f;
root_child1.StyleHeight = 10f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1.1f;
root_child2.StyleHeight = 10.7f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(87f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(87f, root_child0.LayoutWidth);
Assert.AreEqual(59f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(-13f, root_child0_child0.LayoutY);
Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
Assert.AreEqual(12f, root_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child1.LayoutX);
Assert.AreEqual(25f, root_child0_child1.LayoutY);
Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
Assert.AreEqual(47f, root_child0_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(59f, root_child1.LayoutY);
Assert.AreEqual(87f, root_child1.LayoutWidth);
Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(87f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(87f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(87f, root_child0.LayoutWidth);
Assert.AreEqual(59f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(-13f, root_child0_child0.LayoutY);
Assert.AreEqual(87f, root_child0_child0.LayoutWidth);
Assert.AreEqual(12f, root_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child1.LayoutX);
Assert.AreEqual(25f, root_child0_child1.LayoutY);
Assert.AreEqual(87f, root_child0_child1.LayoutWidth);
Assert.AreEqual(47f, root_child0_child1.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(59f, root_child1.LayoutY);
Assert.AreEqual(87f, root_child1.LayoutWidth);
Assert.AreEqual(30f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(87f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_fractial_input_1()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.StyleWidth = 100f;
root.StyleHeight = 113.4f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.StyleHeight = 20f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1f;
root_child1.StyleHeight = 10f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1f;
root_child2.StyleHeight = 10f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_fractial_input_2()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.StyleWidth = 100f;
root.StyleHeight = 113.6f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.StyleHeight = 20f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1f;
root_child1.StyleHeight = 10f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1f;
root_child2.StyleHeight = 10f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(114f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(65f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(65f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(24f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(25f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(114f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(65f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(65f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(24f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(25f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_fractial_input_3()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.SetPosition(CSSEdge.Top, 0.3f);
root.StyleWidth = 100f;
root.StyleHeight = 113.4f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.StyleHeight = 20f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1f;
root_child1.StyleHeight = 10f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1f;
root_child2.StyleHeight = 10f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(114f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(114f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
[Test]
public void Test_rounding_fractial_input_4()
{
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, true);
CSSNode root = new CSSNode();
root.SetPosition(CSSEdge.Top, 0.7f);
root.StyleWidth = 100f;
root.StyleHeight = 113.4f;
CSSNode root_child0 = new CSSNode();
root_child0.FlexGrow = 1f;
root_child0.FlexBasis = 50f;
root_child0.StyleHeight = 20f;
root.Insert(0, root_child0);
CSSNode root_child1 = new CSSNode();
root_child1.FlexGrow = 1f;
root_child1.StyleHeight = 10f;
root.Insert(1, root_child1);
CSSNode root_child2 = new CSSNode();
root_child2.FlexGrow = 1f;
root_child2.StyleHeight = 10f;
root.Insert(2, root_child2);
root.StyleDirection = CSSDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(1f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
root.StyleDirection = CSSDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(1f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(113f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(64f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(64f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(25f, root_child1.LayoutHeight);
Assert.AreEqual(0f, root_child2.LayoutX);
Assert.AreEqual(89f, root_child2.LayoutY);
Assert.AreEqual(100f, root_child2.LayoutWidth);
Assert.AreEqual(24f, root_child2.LayoutHeight);
CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.Rounding, false);
}
}
}

View File

@@ -0,0 +1,143 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
using NUnit.Framework;
using System;
/**
* Tests for {@link CSSNode}.
*/
namespace Facebook.CSSLayout
{
[TestFixture]
public class CSSNodeCreateTest
{
[Test]
public void TestSimple()
{
CSSNode nodeDefault = new CSSNode();
CSSNode nodeCreated = CSSNode.Create(flexDirection: CSSFlexDirection.Row);
Assert.AreEqual(CSSFlexDirection.Row, nodeCreated.FlexDirection);
Assert.IsFalse(nodeDefault.IsDirty);
nodeDefault.CopyStyle(nodeCreated);
Assert.IsTrue(nodeDefault.IsDirty);
}
[Test]
public void TestSame()
{
CSSNode nodeDefault = new CSSNode();
CSSNode nodeCreated = CSSNode.Create();
Assert.IsFalse(nodeDefault.IsDirty);
nodeDefault.CopyStyle(nodeCreated);
Assert.IsFalse(nodeDefault.IsDirty);
}
[Test]
public void TestMultiple()
{
CSSNode node = CSSNode.Create(
positionType: CSSPositionType.Absolute,
wrap: CSSWrap.Wrap,
position: new Spacing(top:6, right:4),
margin: new Spacing(bottom:5, left:3));
Assert.AreEqual(CSSFlexDirection.Column, node.FlexDirection);
Assert.AreEqual(CSSPositionType.Absolute, node.PositionType);
Assert.AreEqual(CSSWrap.Wrap, node.Wrap);
Assert.AreEqual(6, node.GetPosition(CSSEdge.Top));
Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Bottom)));
Assert.AreEqual(4, node.GetPosition(CSSEdge.Right));
Assert.IsTrue(CSSConstants.IsUndefined(node.GetPosition(CSSEdge.Left)));
Assert.AreEqual(0, node.GetMargin(CSSEdge.Top));
Assert.AreEqual(5, node.GetMargin(CSSEdge.Bottom));
Assert.AreEqual(3, node.GetMargin(CSSEdge.Left));
Assert.AreEqual(0, node.GetMargin(CSSEdge.Right));
}
[Test]
public void TestFull()
{
CSSNode node = CSSNode.Create(
styleDirection: CSSDirection.RTL,
flexDirection: CSSFlexDirection.RowReverse,
justifyContent: CSSJustify.SpaceAround,
alignContent: CSSAlign.Center,
alignItems: CSSAlign.FlexEnd,
alignSelf: CSSAlign.Stretch,
positionType: CSSPositionType.Absolute,
wrap: CSSWrap.Wrap,
overflow: CSSOverflow.Scroll,
flex: 1,
flexGrow: 2,
flexShrink: 3,
flexBasis: 4,
position: new Spacing(top: 5, bottom: 6, left: 7, right: 8),
margin: new Spacing(top: 9, bottom: 10, left: 11, right: 12),
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
border: new Spacing(top: 17, bottom: 18, left: 19, right: 20),
styleWidth: 21,
styleHeight: 22,
styleMinWidth: 23,
styleMinHeight: 24,
styleMaxWidth: 25,
styleMaxHeight: 26);
Assert.AreEqual(CSSDirection.RTL, node.StyleDirection);
Assert.AreEqual(CSSFlexDirection.RowReverse, node.FlexDirection);
Assert.AreEqual(CSSJustify.SpaceAround, node.JustifyContent);
Assert.AreEqual(CSSAlign.Center, node.AlignContent);
Assert.AreEqual(CSSAlign.FlexEnd, node.AlignItems);
Assert.AreEqual(CSSAlign.Stretch, node.AlignSelf);
Assert.AreEqual(CSSPositionType.Absolute, node.PositionType);
Assert.AreEqual(CSSWrap.Wrap, node.Wrap);
Assert.AreEqual(CSSOverflow.Scroll, node.Overflow);
Assert.AreEqual(2, node.FlexGrow);
Assert.AreEqual(3, node.FlexShrink);
Assert.AreEqual(4, node.FlexBasis);
node.FlexGrow = CSSConstants.Undefined;
Assert.AreEqual(1, node.FlexGrow);
Assert.AreEqual(5, node.GetPosition(CSSEdge.Top));
Assert.AreEqual(6, node.GetPosition(CSSEdge.Bottom));
Assert.AreEqual(7, node.GetPosition(CSSEdge.Left));
Assert.AreEqual(8, node.GetPosition(CSSEdge.Right));
Assert.AreEqual(9, node.GetMargin(CSSEdge.Top));
Assert.AreEqual(10, node.GetMargin(CSSEdge.Bottom));
Assert.AreEqual(11, node.GetMargin(CSSEdge.Left));
Assert.AreEqual(12, node.GetMargin(CSSEdge.Right));
Assert.AreEqual(13, node.GetPadding(CSSEdge.Top));
Assert.AreEqual(14, node.GetPadding(CSSEdge.Bottom));
Assert.AreEqual(15, node.GetPadding(CSSEdge.Left));
Assert.AreEqual(16, node.GetPadding(CSSEdge.Right));
Assert.AreEqual(17, node.GetBorder(CSSEdge.Top));
Assert.AreEqual(18, node.GetBorder(CSSEdge.Bottom));
Assert.AreEqual(19, node.GetBorder(CSSEdge.Left));
Assert.AreEqual(20, node.GetBorder(CSSEdge.Right));
Assert.AreEqual(21, node.StyleWidth);
Assert.AreEqual(22, node.StyleHeight);
Assert.AreEqual(23, node.StyleMinWidth);
Assert.AreEqual(24, node.StyleMinHeight);
Assert.AreEqual(25, node.StyleMaxWidth);
Assert.AreEqual(26, node.StyleMaxHeight);
}
}
}

View File

@@ -215,13 +215,26 @@ namespace Facebook.CSSLayout
Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n"); Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n");
} }
[Test]
public void TestCopyStyle()
{
CSSNode node0 = new CSSNode();
Assert.IsTrue(CSSConstants.IsUndefined(node0.StyleMaxHeight));
CSSNode node1 = new CSSNode();
node1.StyleMaxHeight = 100;
node0.CopyStyle(node1);
Assert.AreEqual(100, node0.StyleMaxHeight);
}
#if !UNITY_EDITOR
private void ForceGC() private void ForceGC()
{ {
GC.Collect(GC.MaxGeneration); GC.Collect(GC.MaxGeneration);
GC.WaitForPendingFinalizers(); GC.WaitForPendingFinalizers();
} }
#if !UNITY_EDITOR
[Test] [Test]
public void TestDestructor() public void TestDestructor()
{ {

186
enums.py Normal file
View File

@@ -0,0 +1,186 @@
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import os
ENUMS = {
'CSSDirection': [
'Inherit',
'LTR',
'RTL',
],
'CSSFlexDirection': [
'Column',
'ColumnReverse',
'Row',
'RowReverse',
],
'CSSJustify': [
'FlexStart',
'Center',
'FlexEnd',
'SpaceBetween',
'SpaceAround',
],
'CSSOverflow': [
'Visible',
'Hidden',
'Scroll',
],
'CSSAlign': [
'Auto',
'FlexStart',
'Center',
'FlexEnd',
'Stretch',
],
'CSSPositionType': [
'Relative',
'Absolute',
],
'CSSWrap': [
'NoWrap',
'Wrap',
],
'CSSMeasureMode': [
'Undefined',
'Exactly',
'AtMost',
],
'CSSDimension': [
'Width',
'Height',
],
'CSSEdge': [
'Left',
'Top',
'Right',
'Bottom',
'Start',
'End',
'Horizontal',
'Vertical',
'All',
],
'CSSLogLevel': [
'Error',
'Warn',
'Info',
'Debug',
'Verbose',
],
'CSSExperimentalFeature': [
'Rounding',
# Mimic web flex-basis behavior.
'WebFlexBasis',
],
'CSSPrintOptions': [
('Layout', 1),
('Style', 2),
('Children', 4),
],
}
LICENSE = """/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
"""
def to_java_upper(symbol):
symbol = str(symbol)
out = ''
for i in range(0, len(symbol)):
c = symbol[i]
if str.istitle(c) and i is not 0 and not str.istitle(symbol[i - 1]):
out += '_'
out += c.upper()
return out
root = os.path.dirname(__file__)
# write out C header
with open(root + '/CSSLayout/CSSEnums.h', 'w') as f:
f.write(LICENSE)
remaining = len(ENUMS)
for name, values in ENUMS.items():
f.write('typedef enum %s {\n' % name)
for value in values:
if isinstance(value, tuple):
f.write(' %s%s = %d,\n' % (name, value[0], value[1]))
else:
f.write(' %s%s,\n' % (name, value))
f.write(' %sCount,\n' % name)
f.write('} %s;\n' % name)
if remaining > 1:
f.write('\n')
remaining = remaining - 1
# write out java files
for name, values in ENUMS.items():
with open(root + '/java/com/facebook/csslayout/%s.java' % name, 'w') as f:
f.write(LICENSE)
f.write('package com.facebook.csslayout;\n\n')
f.write('public enum %s {\n' % name)
if len(values) > 0:
for value in values:
if isinstance(value, tuple):
f.write(' %s(%d)' % (to_java_upper(value[0]), value[1]))
else:
f.write(' %s(%d)' % (to_java_upper(value), values.index(value)))
if values.index(value) is len(values) - 1:
f.write(';\n')
else:
f.write(',\n')
else:
f.write('__EMPTY(-1);')
f.write('\n')
f.write(' private int mIntValue;\n')
f.write('\n')
f.write(' %s(int intValue) {\n' % name)
f.write(' mIntValue = intValue;\n')
f.write(' }\n')
f.write('\n')
f.write(' public int intValue() {\n')
f.write(' return mIntValue;\n')
f.write(' }\n')
f.write('\n')
f.write(' public static %s fromInt(int value) {\n' % name)
f.write(' switch (value) {\n')
for value in values:
if isinstance(value, tuple):
f.write(' case %d: return %s;\n' % (value[1], to_java_upper(value[0])))
else:
f.write(' case %d: return %s;\n' % (values.index(value), to_java_upper(value)))
f.write(' default: throw new IllegalArgumentException("Unkown enum value: " + value);\n')
f.write(' }\n')
f.write(' }\n')
f.write('}\n')
# write out csharp files
for name, values in ENUMS.items():
with open(root + '/csharp/Facebook.CSSLayout/%s.cs' % name, 'w') as f:
f.write(LICENSE)
f.write('namespace Facebook.CSSLayout\n{\n')
f.write(' public enum %s\n {\n' % name)
for value in values:
if isinstance(value, tuple):
f.write(' %s = %d,\n' % (value[0], value[1]))
else:
f.write(' %s,\n' % value)
f.write(' }\n')
f.write('}\n')

View File

@@ -0,0 +1,64 @@
<div id="rounding_flex_basis_flex_grow_row_width_of_100" experiments="Rounding" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="rounding_flex_basis_flex_grow_row_prime_number_width" experiments="Rounding" style="width: 113px; height: 100px; flex-direction: row;">
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="rounding_flex_basis_flex_shrink_row" experiments="Rounding" style="width: 101px; height: 100px; flex-direction: row;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 25px;"></div>
<div style="flex-basis: 25px;"></div>
</div>
<div id="rounding_flex_basis_overrides_main_size" experiments="Rounding" style="height: 113px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="rounding_total_fractial" experiments="Rounding" style="height: 113.4px; width: 87.4px;">
<div style="height: 20.3px; flex-grow:0.7; flex-basis:50.3px;"></div>
<div style="height: 10px; flex-grow:1.6;"></div>
<div style="height: 10.7px; flex-grow:1.1;"></div>
</div>
<div id="rounding_total_fractial_nested" experiments="Rounding" style="height: 113.4px; width: 87.4px;">
<div style="height: 20.3px; flex-grow:0.7; flex-basis:50.3px;">
<div style="bottom: 13.3px; height: 9.9px; flex-grow:1; flex-basis:0.3px;"></div>
<div style="top: 13.3px; height: 1.1px; flex-grow:4; flex-basis:0.3px;"></div>
</div>
<div style="height: 10px; flex-grow:1.6;"></div>
<div style="height: 10.7px; flex-grow:1.1;"></div>
</div>
<div id="rounding_fractial_input_1" experiments="Rounding" style="height: 113.4px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="rounding_fractial_input_2" experiments="Rounding" style="height: 113.6px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="rounding_fractial_input_3" experiments="Rounding" style="top: 0.3px; height: 113.4px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="rounding_fractial_input_4" experiments="Rounding" style="top: 0.7px; height: 113.4px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>

View File

@@ -7,6 +7,10 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
function toFloatString(n) {
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
}
var CPPEmitter = function() { var CPPEmitter = function() {
Emitter.call(this, 'cpp', ' '); Emitter.call(this, 'cpp', ' ');
}; };
@@ -22,20 +26,35 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
]); ]);
}}, }},
emitTestPrologue:{value:function(name) { emitTestPrologue:{value:function(name, experiments) {
this.push('TEST(CSSLayoutTest, ' + name + ') {'); this.push('TEST(CSSLayoutTest, ' + name + ') {');
this.pushIndent(); this.pushIndent();
if (experiments.length > 0) {
for (var i in experiments) {
this.push('CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature' + experiments[i] +', true);');
}
this.push('');
}
}}, }},
emitTestTreePrologue:{value:function(nodeName) { emitTestTreePrologue:{value:function(nodeName) {
this.push('const CSSNodeRef ' + nodeName + ' = CSSNodeNew();'); this.push('const CSSNodeRef ' + nodeName + ' = CSSNodeNew();');
}}, }},
emitTestEpilogue:{value:function() { emitTestEpilogue:{value:function(experiments) {
this.push([ this.push([
'', '',
'CSSNodeFreeRecursive(root);', 'CSSNodeFreeRecursive(root);',
]); ]);
if (experiments.length > 0) {
this.push('');
for (var i in experiments) {
this.push('CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeature' + experiments[i] +', false);');
}
}
this.popIndent(); this.popIndent();
this.push([ this.push([
'}', '}',
@@ -47,7 +66,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
AssertEQ:{value:function(v0, v1) { AssertEQ:{value:function(v0, v1) {
this.push('ASSERT_EQ(' + v0 + ', ' + v1 + ');'); this.push('ASSERT_FLOAT_EQ(' + toFloatString(v0) + ', ' + v1 + ');');
}}, }},
CSSAlignAuto:{value:'CSSAlignAuto'}, CSSAlignAuto:{value:'CSSAlignAuto'},
@@ -84,8 +103,8 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
CSSPositionTypeAbsolute:{value:'CSSPositionTypeAbsolute'}, CSSPositionTypeAbsolute:{value:'CSSPositionTypeAbsolute'},
CSSPositionTypeRelative:{value:'CSSPositionTypeRelative'}, CSSPositionTypeRelative:{value:'CSSPositionTypeRelative'},
CSSWrapTypeNoWrap:{value:'CSSWrapTypeNoWrap'}, CSSWrapNoWrap:{value:'CSSWrapNoWrap'},
CSSWrapTypeWrap:{value:'CSSWrapTypeWrap'}, CSSWrapWrap:{value:'CSSWrapWrap'},
CSSUndefined:{value:'CSSUndefined'}, CSSUndefined:{value:'CSSUndefined'},
@@ -126,7 +145,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + value + ');'); this.push('CSSNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetDirection:{value:function(nodeName, value) { CSSNodeStyleSetDirection:{value:function(nodeName, value) {
@@ -134,7 +153,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexBasis(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) {
@@ -142,11 +161,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexGrow(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexShrink(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) {
@@ -154,7 +173,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetHeight:{value:function(nodeName, value) { CSSNodeStyleSetHeight:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetHeight(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) {
@@ -162,23 +181,23 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + value + ');'); this.push('CSSNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMaxHeight(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMaxWidth(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { CSSNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMinHeight(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { CSSNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMinWidth(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetOverflow:{value:function(nodeName, value) { CSSNodeStyleSetOverflow:{value:function(nodeName, value) {
@@ -186,11 +205,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + value + ');'); this.push('CSSNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + value + ');'); this.push('CSSNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}}, }},
CSSNodeStyleSetPositionType:{value:function(nodeName, value) { CSSNodeStyleSetPositionType:{value:function(nodeName, value) {
@@ -198,6 +217,6 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetWidth:{value:function(nodeName, value) { CSSNodeStyleSetWidth:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetWidth(' + nodeName + ', ' + value + ');'); this.push('CSSNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');');
}}, }},
}); });

View File

@@ -31,18 +31,32 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
this.pushIndent(); this.pushIndent();
}}, }},
emitTestPrologue:{value:function(name) { emitTestPrologue:{value:function(name, experiments) {
this.push('[Test]'); this.push('[Test]');
this.push('public void Test_' + name + '()'); this.push('public void Test_' + name + '()');
this.push('{'); this.push('{');
this.pushIndent(); this.pushIndent();
if (experiments.length > 0) {
for (var i in experiments) {
this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', true);');
}
this.push('');
}
}}, }},
emitTestTreePrologue:{value:function(nodeName) { emitTestTreePrologue:{value:function(nodeName) {
this.push('CSSNode ' + nodeName + ' = new CSSNode();'); this.push('CSSNode ' + nodeName + ' = new CSSNode();');
}}, }},
emitTestEpilogue:{value:function() { emitTestEpilogue:{value:function(experiments) {
if (experiments.length > 0) {
this.push('');
for (var i in experiments) {
this.push('CSSNode.SetExperimentalFeatureEnabled(CSSExperimentalFeature.' + experiments[i] +', false);');
}
}
this.popIndent(); this.popIndent();
this.push([ this.push([
'}', '}',
@@ -61,7 +75,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
AssertEQ:{value:function(v0, v1) { AssertEQ:{value:function(v0, v1) {
this.push('Assert.AreEqual(' + v0 + ', ' + v1 + ');'); this.push('Assert.AreEqual(' + v0 + 'f, ' + v1 + ');');
}}, }},
CSSAlignAuto:{value:'CSSAlign.Auto'}, CSSAlignAuto:{value:'CSSAlign.Auto'},
@@ -71,8 +85,8 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
CSSAlignStretch:{value:'CSSAlign.Stretch'}, CSSAlignStretch:{value:'CSSAlign.Stretch'},
CSSDirectionInherit:{value:'CSSDirection.Inherit'}, CSSDirectionInherit:{value:'CSSDirection.Inherit'},
CSSDirectionLTR:{value:'CSSDirection.LeftToRight'}, CSSDirectionLTR:{value:'CSSDirection.LTR'},
CSSDirectionRTL:{value:'CSSDirection.RightToLeft'}, CSSDirectionRTL:{value:'CSSDirection.RTL'},
CSSEdgeBottom:{value:'CSSEdge.Bottom'}, CSSEdgeBottom:{value:'CSSEdge.Bottom'},
CSSEdgeEnd:{value:'CSSEdge.End'}, CSSEdgeEnd:{value:'CSSEdge.End'},
@@ -100,8 +114,8 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
CSSUndefined:{value:'CSSConstants.Undefined'}, CSSUndefined:{value:'CSSConstants.Undefined'},
CSSWrapTypeNoWrap:{value:'CSSWrap.NoWrap'}, CSSWrapNoWrap:{value:'CSSWrap.NoWrap'},
CSSWrapTypeWrap:{value:'CSSWrap.Wrap'}, CSSWrapWrap:{value:'CSSWrap.Wrap'},
CSSNodeCalculateLayout:{value:function(node, dir) { CSSNodeCalculateLayout:{value:function(node, dir) {
this.push(node + '.StyleDirection = ' + dir + ';'); this.push(node + '.StyleDirection = ' + dir + ';');
@@ -141,7 +155,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetBorder(' + edge + ', ' + value + ');'); this.push(nodeName + '.SetBorder(' + edge + ', ' + value + 'f);');
}}, }},
CSSNodeStyleSetDirection:{value:function(nodeName, value) { CSSNodeStyleSetDirection:{value:function(nodeName, value) {
@@ -149,7 +163,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.FlexBasis = ' + value + ';'); this.push(nodeName + '.FlexBasis = ' + value + 'f;');
}}, }},
CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) {
@@ -157,11 +171,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.FlexGrow = ' + value + ';'); this.push(nodeName + '.FlexGrow = ' + value + 'f;');
}}, }},
CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.FlexShrink = ' + value + ';'); this.push(nodeName + '.FlexShrink = ' + value + 'f;');
}}, }},
CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) {
@@ -169,7 +183,7 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetHeight:{value:function(nodeName, value) { CSSNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.StyleHeight = ' + value + ';'); this.push(nodeName + '.StyleHeight = ' + value + 'f;');
}}, }},
CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) {
@@ -177,23 +191,23 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetMargin(' + edge + ', ' + value + ');'); this.push(nodeName + '.SetMargin(' + edge + ', ' + value + 'f);');
}}, }},
CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMaxHeight = ' + value + ';'); this.push(nodeName + '.StyleMaxHeight = ' + value + 'f;');
}}, }},
CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMaxWidth = ' + value + ';'); this.push(nodeName + '.StyleMaxWidth = ' + value + 'f;');
}}, }},
CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { CSSNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMinHeight = ' + value + ';'); this.push(nodeName + '.StyleMinHeight = ' + value + 'f;');
}}, }},
CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { CSSNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.StyleMinWidth = ' + value + ';'); this.push(nodeName + '.StyleMinWidth = ' + value + 'f;');
}}, }},
CSSNodeStyleSetOverflow:{value:function(nodeName, value) { CSSNodeStyleSetOverflow:{value:function(nodeName, value) {
@@ -201,11 +215,11 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) { CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPadding(' + edge + ', ' + value + ');'); this.push(nodeName + '.SetPadding(' + edge + ', ' + value + 'f);');
}}, }},
CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.SetPosition(' + edge + ', ' + value + ');'); this.push(nodeName + '.SetPosition(' + edge + ', ' + value + 'f);');
}}, }},
CSSNodeStyleSetPositionType:{value:function(nodeName, value) { CSSNodeStyleSetPositionType:{value:function(nodeName, value) {
@@ -213,6 +227,6 @@ CSEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetWidth:{value:function(nodeName, value) { CSSNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.StyleWidth = ' + value + ';'); this.push(nodeName + '.StyleWidth = ' + value + 'f;');
}}, }},
}); });

View File

@@ -11,6 +11,18 @@ var JavaEmitter = function() {
Emitter.call(this, 'java', ' '); Emitter.call(this, 'java', ' ');
}; };
function toJavaUpper(symbol) {
var out = '';
for (var i = 0; i < symbol.length; i++) {
var c = symbol[i];
if (c == c.toUpperCase() && i != 0 && symbol[i - 1] != symbol[i - 1].toUpperCase()) {
out += '_';
}
out += c.toUpperCase();
}
return out;
}
JavaEmitter.prototype = Object.create(Emitter.prototype, { JavaEmitter.prototype = Object.create(Emitter.prototype, {
constructor:{value:JavaEmitter}, constructor:{value:JavaEmitter},
@@ -27,17 +39,31 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
this.pushIndent(); this.pushIndent();
}}, }},
emitTestPrologue:{value:function(name) { emitTestPrologue:{value:function(name, experiments) {
this.push('@Test'); this.push('@Test');
this.push('public void test_' + name + '() {'); this.push('public void test_' + name + '() {');
this.pushIndent(); this.pushIndent();
if (experiments.length > 0) {
for (var i in experiments) {
this.push('CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.' + toJavaUpper(experiments[i]) +', true);');
}
this.push('');
}
}}, }},
emitTestTreePrologue:{value:function(nodeName) { emitTestTreePrologue:{value:function(nodeName) {
this.push('final CSSNode ' + nodeName + ' = new CSSNode();'); this.push('final CSSNode ' + nodeName + ' = new CSSNode();');
}}, }},
emitTestEpilogue:{value:function() { emitTestEpilogue:{value:function(experiments) {
if (experiments.length > 0) {
this.push('');
for (var i in experiments) {
this.push('CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.' + toJavaUpper(experiments[i]) +', false);');
}
}
this.popIndent(); this.popIndent();
this.push([ this.push([
'}', '}',
@@ -54,7 +80,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
AssertEQ:{value:function(v0, v1) { AssertEQ:{value:function(v0, v1) {
this.push('assertEquals(' + v0 + ', ' + v1 + ', 0.0f);'); this.push('assertEquals(' + v0 + 'f, ' + v1 + ', 0.0f);');
}}, }},
CSSAlignAuto:{value:'CSSAlign.AUTO'}, CSSAlignAuto:{value:'CSSAlign.AUTO'},
@@ -93,8 +119,8 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
CSSUndefined:{value:'CSSConstants.UNDEFINED'}, CSSUndefined:{value:'CSSConstants.UNDEFINED'},
CSSWrapTypeNoWrap:{value:'CSSWrap.NO_WRAP'}, CSSWrapNoWrap:{value:'CSSWrap.NO_WRAP'},
CSSWrapTypeWrap:{value:'CSSWrap.WRAP'}, CSSWrapWrap:{value:'CSSWrap.WRAP'},
CSSNodeCalculateLayout:{value:function(node, dir) { CSSNodeCalculateLayout:{value:function(node, dir) {
this.push(node + '.setDirection(' + dir + ');'); this.push(node + '.setDirection(' + dir + ');');
@@ -134,7 +160,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) { CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setBorder(' + edge + ', ' + value + ');'); this.push(nodeName + '.setBorder(' + edge + ', ' + value + 'f);');
}}, }},
CSSNodeStyleSetDirection:{value:function(nodeName, value) { CSSNodeStyleSetDirection:{value:function(nodeName, value) {
@@ -142,7 +168,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) { CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexBasis(' + value + ');'); this.push(nodeName + '.setFlexBasis(' + value + 'f);');
}}, }},
CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) { CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) {
@@ -150,11 +176,11 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) { CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexGrow(' + value + ');'); this.push(nodeName + '.setFlexGrow(' + value + 'f);');
}}, }},
CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) { CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.setFlexShrink(' + value + ');'); this.push(nodeName + '.setFlexShrink(' + value + 'f);');
}}, }},
CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) { CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) {
@@ -162,7 +188,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetHeight:{value:function(nodeName, value) { CSSNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setStyleHeight(' + value + ');'); this.push(nodeName + '.setStyleHeight(' + value + 'f);');
}}, }},
CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) { CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) {
@@ -170,23 +196,23 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) { CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setMargin(' + edge + ', ' + value + ');'); this.push(nodeName + '.setMargin(' + edge + ', ' + value + 'f);');
}}, }},
CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) { CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setStyleMaxHeight(' + value + ');'); this.push(nodeName + '.setStyleMaxHeight(' + value + 'f);');
}}, }},
CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) { CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setStyleMaxWidth(' + value + ');'); this.push(nodeName + '.setStyleMaxWidth(' + value + 'f);');
}}, }},
CSSNodeStyleSetMinHeight:{value:function(nodeName, value) { CSSNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.setStyleMinHeight(' + value + ');'); this.push(nodeName + '.setStyleMinHeight(' + value + 'f);');
}}, }},
CSSNodeStyleSetMinWidth:{value:function(nodeName, value) { CSSNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setStyleMinWidth(' + value + ');'); this.push(nodeName + '.setStyleMinWidth(' + value + 'f);');
}}, }},
CSSNodeStyleSetOverflow:{value:function(nodeName, value) { CSSNodeStyleSetOverflow:{value:function(nodeName, value) {
@@ -198,7 +224,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) { CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.setPosition(' + edge + ', ' + value + ');'); this.push(nodeName + '.setPosition(' + edge + ', ' + value + 'f);');
}}, }},
CSSNodeStyleSetPositionType:{value:function(nodeName, value) { CSSNodeStyleSetPositionType:{value:function(nodeName, value) {
@@ -206,6 +232,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
}}, }},
CSSNodeStyleSetWidth:{value:function(nodeName, value) { CSSNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.setStyleWidth(' + value + ');'); this.push(nodeName + '.setStyleWidth(' + value + 'f);');
}}, }},
}); });

View File

@@ -46,36 +46,7 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) {
' * of patent rights can be found in the PATENTS file in the same directory.', ' * of patent rights can be found in the PATENTS file in the same directory.',
' */', ' */',
'', '',
'/**', ' // @Generated by gentest/gentest.rb from gentest/fixtures/' + document.title + '.html',
' * @Generated by gentest/gentest.sh with the following input',
' *',
]);
var indentation = 0;
e.push(genericContainer.innerHTML.split('\n').map(function(line) {
return line.trim();
}).filter(function(line) {
return line.length > 0 && line !== '<div id="default"></div>';
}).map(function(line) {
var result;
if (line.indexOf('</div') == 0) {
result = ' '.repeat(indentation - 1) + line;
} else {
result = ' '.repeat(indentation) + line;
}
indentation += (line.match(/<div/g) || []).length;
indentation -= (line.match(/<\/div/g) || []).length;
return result;
}).reduce(function(curr, prev) {
if (prev.indexOf('<div') == 0) {
prev = '\n' + prev;
}
return curr + '\n' + prev;
}));
e.push([
' *',
' */',
'', '',
]); ]);
e.emitPrologue(); e.emitPrologue();
@@ -86,7 +57,7 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) {
for (var i = 0; i < genericLayoutTree.length; i++) { for (var i = 0; i < genericLayoutTree.length; i++) {
e.emitTestPrologue(genericLayoutTree[i].name); e.emitTestPrologue(genericLayoutTree[i].name, genericLayoutTree[i].experiments);
if (genericLayoutTree[i].name == 'wrap_column') { if (genericLayoutTree[i].name == 'wrap_column') {
// Modify width and left values due to both safari and chrome not abiding by the // Modify width and left values due to both safari and chrome not abiding by the
@@ -127,7 +98,7 @@ function printTest(e, LTRContainer, RTLContainer, genericContainer) {
assertTestTree(e, RTLLayoutTree[i], 'root', null); assertTestTree(e, RTLLayoutTree[i], 'root', null);
e.emitTestEpilogue(); e.emitTestEpilogue(genericLayoutTree[i].experiments);
} }
e.emitEpilogue(); e.emitEpilogue();
@@ -354,8 +325,8 @@ function overflowValue(e, value) {
function wrapValue(e, value) { function wrapValue(e, value) {
switch (value) { switch (value) {
case 'wrap': return e.CSSWrapTypeWrap; case 'wrap': return e.CSSWrapWrap;
case 'nowrap': return e.CSSWrapTypeNoWrap; case 'nowrap': return e.CSSWrapNoWrap;
} }
} }
@@ -443,6 +414,9 @@ function calculateTree(root) {
style: getCSSLayoutStyle(child), style: getCSSLayoutStyle(child),
declaredStyle: child.style, declaredStyle: child.style,
rawStyle: child.getAttribute('style'), rawStyle: child.getAttribute('style'),
experiments: child.getAttribute('experiments')
? child.getAttribute('experiments').split(' ')
: [],
}); });
} }

View File

@@ -1,10 +1,17 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
require 'watir-webdriver' require 'watir-webdriver'
require 'fileutils' require 'fileutils'
caps = Selenium::WebDriver::Remote::Capabilities.chrome( caps = Selenium::WebDriver::Remote::Capabilities.chrome(
"loggingPrefs"=>{"browser"=>"ALL", "performance"=>"ALL"}) "loggingPrefs"=>{
"browser"=>"ALL",
"performance"=>"ALL"
}
)
browser = Watir::Browser.new(:chrome, :desired_capabilities => caps) browser = Watir::Browser.new(:chrome, :desired_capabilities => caps)
Dir.chdir(File.dirname($0)) Dir.chdir(File.dirname($0))
Dir['fixtures/*.html'].each do |file| Dir['fixtures/*.html'].each do |file|
fixture = File.read(file) fixture = File.read(file)
name = File.basename(file, '.*') name = File.basename(file, '.*')
@@ -22,7 +29,7 @@ Dir['fixtures/*.html'].each do |file|
template = File.open('test-template.html').read template = File.open('test-template.html').read
f = File.open('test.html', 'w') f = File.open('test.html', 'w')
f.write sprintf(template, ltr_fixture, rtl_fixture, fixture) f.write sprintf(template, name, ltr_fixture, rtl_fixture, fixture)
f.close f.close
FileUtils.copy('test.html', "#{name}.html") if $DEBUG FileUtils.copy('test.html', "#{name}.html") if $DEBUG

View File

@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>test page</title> <title>%s</title>
<script src="gentest.js"></script> <script src="gentest.js"></script>
<script src="gentest-cpp.js"></script> <script src="gentest-cpp.js"></script>
<script src="gentest-java.js"></script> <script src="gentest-java.js"></script>

View File

@@ -10,9 +10,30 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSAlign { public enum CSSAlign {
AUTO, AUTO(0),
FLEX_START, FLEX_START(1),
CENTER, CENTER(2),
FLEX_END, FLEX_END(3),
STRETCH, STRETCH(4);
private int mIntValue;
CSSAlign(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSAlign fromInt(int value) {
switch (value) {
case 0: return AUTO;
case 1: return FLEX_START;
case 2: return CENTER;
case 3: return FLEX_END;
case 4: return STRETCH;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSDimension {
WIDTH(0),
HEIGHT(1);
private int mIntValue;
CSSDimension(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSDimension fromInt(int value) {
switch (value) {
case 0: return WIDTH;
case 1: return HEIGHT;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}

View File

@@ -10,7 +10,26 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSDirection { public enum CSSDirection {
INHERIT, INHERIT(0),
LTR, LTR(1),
RTL, RTL(2);
private int mIntValue;
CSSDirection(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSDirection fromInt(int value) {
switch (value) {
case 0: return INHERIT;
case 1: return LTR;
case 2: return RTL;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -0,0 +1,47 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSEdge {
LEFT(0),
TOP(1),
RIGHT(2),
BOTTOM(3),
START(4),
END(5),
HORIZONTAL(6),
VERTICAL(7),
ALL(8);
private int mIntValue;
CSSEdge(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSEdge fromInt(int value) {
switch (value) {
case 0: return LEFT;
case 1: return TOP;
case 2: return RIGHT;
case 3: return BOTTOM;
case 4: return START;
case 5: return END;
case 6: return HORIZONTAL;
case 7: return VERTICAL;
case 8: return ALL;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}

View File

@@ -0,0 +1,33 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSExperimentalFeature {
ROUNDING(0),
WEB_FLEX_BASIS(1);
private int mIntValue;
CSSExperimentalFeature(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSExperimentalFeature fromInt(int value) {
switch (value) {
case 0: return ROUNDING;
case 1: return WEB_FLEX_BASIS;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}

View File

@@ -10,8 +10,28 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSFlexDirection { public enum CSSFlexDirection {
COLUMN, COLUMN(0),
COLUMN_REVERSE, COLUMN_REVERSE(1),
ROW, ROW(2),
ROW_REVERSE ROW_REVERSE(3);
private int mIntValue;
CSSFlexDirection(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSFlexDirection fromInt(int value) {
switch (value) {
case 0: return COLUMN;
case 1: return COLUMN_REVERSE;
case 2: return ROW;
case 3: return ROW_REVERSE;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -10,9 +10,30 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSJustify { public enum CSSJustify {
FLEX_START, FLEX_START(0),
CENTER, CENTER(1),
FLEX_END, FLEX_END(2),
SPACE_BETWEEN, SPACE_BETWEEN(3),
SPACE_AROUND, SPACE_AROUND(4);
private int mIntValue;
CSSJustify(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSJustify fromInt(int value) {
switch (value) {
case 0: return FLEX_START;
case 1: return CENTER;
case 2: return FLEX_END;
case 3: return SPACE_BETWEEN;
case 4: return SPACE_AROUND;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSLogLevel {
ERROR(0),
WARN(1),
INFO(2),
DEBUG(3),
VERBOSE(4);
private int mIntValue;
CSSLogLevel(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSLogLevel fromInt(int value) {
switch (value) {
case 0: return ERROR;
case 1: return WARN;
case 2: return INFO;
case 3: return DEBUG;
case 4: return VERBOSE;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}

View File

@@ -13,15 +13,9 @@ import com.facebook.proguard.annotations.DoNotStrip;
/** /**
* Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger); * Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger);
* LOG_LEVEL_ERROR indicated a fatal error. * See CSSLogLevel for the different log levels.
*/ */
public interface CSSLogger { public interface CSSLogger {
public final int LOG_LEVEL_ERROR = 0;
public final int LOG_LEVEL_WARN = 1;
public final int LOG_LEVEL_INFO = 2;
public final int LOG_LEVEL_DEBUG = 3;
public final int LOG_LEVEL_VERBOSE = 4;
@DoNotStrip @DoNotStrip
void log(int level, String message); void log(CSSLogLevel level, String message);
} }

View File

@@ -10,7 +10,26 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSMeasureMode { public enum CSSMeasureMode {
UNDEFINED, UNDEFINED(0),
EXACTLY, EXACTLY(1),
AT_MOST, AT_MOST(2);
private int mIntValue;
CSSMeasureMode(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSMeasureMode fromInt(int value) {
switch (value) {
case 0: return UNDEFINED;
case 1: return EXACTLY;
case 2: return AT_MOST;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -40,6 +40,20 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
jni_CSSLayoutSetLogger(logger); jni_CSSLayoutSetLogger(logger);
} }
private static native void jni_CSSLayoutSetExperimentalFeatureEnabled(
int feature,
boolean enabled);
public static void setExperimentalFeatureEnabled(
CSSExperimentalFeature feature,
boolean enabled) {
jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled);
}
private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature);
public static boolean isExperimentalFeatureEnabled(CSSExperimentalFeature feature) {
return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue());
}
private CSSNode mParent; private CSSNode mParent;
private List<CSSNode> mChildren; private List<CSSNode> mChildren;
private MeasureFunction mMeasureFunction; private MeasureFunction mMeasureFunction;
@@ -176,6 +190,12 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
jni_CSSNodeMarkLayoutSeen(mNativePointer); jni_CSSNodeMarkLayoutSeen(mNativePointer);
} }
private native void jni_CSSNodeCopyStyle(long dstNativePointer, long srcNativePointer);
@Override
public void copyStyle(CSSNode srcNode) {
jni_CSSNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
}
private native int jni_CSSNodeStyleGetDirection(long nativePointer); private native int jni_CSSNodeStyleGetDirection(long nativePointer);
@Override @Override
public CSSDirection getStyleDirection() { public CSSDirection getStyleDirection() {
@@ -185,7 +205,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction); private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction);
@Override @Override
public void setDirection(CSSDirection direction) { public void setDirection(CSSDirection direction) {
jni_CSSNodeStyleSetDirection(mNativePointer, direction.ordinal()); jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue());
} }
private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer); private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer);
@@ -197,7 +217,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection); private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
@Override @Override
public void setFlexDirection(CSSFlexDirection flexDirection) { public void setFlexDirection(CSSFlexDirection flexDirection) {
jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.ordinal()); jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
} }
private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer); private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer);
@@ -209,7 +229,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent); private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
@Override @Override
public void setJustifyContent(CSSJustify justifyContent) { public void setJustifyContent(CSSJustify justifyContent) {
jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.ordinal()); jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
} }
private native int jni_CSSNodeStyleGetAlignItems(long nativePointer); private native int jni_CSSNodeStyleGetAlignItems(long nativePointer);
@@ -221,7 +241,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems); private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems);
@Override @Override
public void setAlignItems(CSSAlign alignItems) { public void setAlignItems(CSSAlign alignItems) {
jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.ordinal()); jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
} }
private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer); private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer);
@@ -233,7 +253,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf); private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
@Override @Override
public void setAlignSelf(CSSAlign alignSelf) { public void setAlignSelf(CSSAlign alignSelf) {
jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.ordinal()); jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
} }
private native int jni_CSSNodeStyleGetAlignContent(long nativePointer); private native int jni_CSSNodeStyleGetAlignContent(long nativePointer);
@@ -245,7 +265,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent); private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent);
@Override @Override
public void setAlignContent(CSSAlign alignContent) { public void setAlignContent(CSSAlign alignContent) {
jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.ordinal()); jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
} }
private native int jni_CSSNodeStyleGetPositionType(long nativePointer); private native int jni_CSSNodeStyleGetPositionType(long nativePointer);
@@ -257,13 +277,13 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType); private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType);
@Override @Override
public void setPositionType(CSSPositionType positionType) { public void setPositionType(CSSPositionType positionType) {
jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.ordinal()); jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue());
} }
private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType); private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType);
@Override @Override
public void setWrap(CSSWrap flexWrap) { public void setWrap(CSSWrap flexWrap) {
jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.ordinal()); jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
} }
private native int jni_CSSNodeStyleGetOverflow(long nativePointer); private native int jni_CSSNodeStyleGetOverflow(long nativePointer);
@@ -275,7 +295,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow); private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow);
@Override @Override
public void setOverflow(CSSOverflow overflow) { public void setOverflow(CSSOverflow overflow) {
jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.ordinal()); jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue());
} }
private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex); private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex);
@@ -456,6 +476,16 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight); jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight);
} }
private native float jni_CSSNodeStyleGetAspectRatio(long nativePointer);
public float getStyleAspectRatio() {
return jni_CSSNodeStyleGetAspectRatio(mNativePointer);
}
private native void jni_CSSNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
public void setStyleAspectRatio(float aspectRatio) {
jni_CSSNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
}
@Override @Override
public float getLayoutX() { public float getLayoutX() {
return mLeft; return mLeft;

View File

@@ -37,6 +37,7 @@ public interface CSSNodeAPI<CSSNodeType extends CSSNodeAPI> {
void dirty(); void dirty();
void markLayoutSeen(); void markLayoutSeen();
boolean valuesEqual(float f1, float f2); boolean valuesEqual(float f1, float f2);
void copyStyle(CSSNodeType srcNode);
CSSDirection getStyleDirection(); CSSDirection getStyleDirection();
void setDirection(CSSDirection direction); void setDirection(CSSDirection direction);
CSSFlexDirection getFlexDirection(); CSSFlexDirection getFlexDirection();

View File

@@ -222,6 +222,11 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI<CSSNodeDEPRECATED> {
return FloatUtil.floatsEqual(f1, f2); return FloatUtil.floatsEqual(f1, f2);
} }
@Override
public void copyStyle(CSSNodeDEPRECATED srcNode) {
throw new UnsupportedOperationException("copyStyle is not implemented");
}
/** /**
* Get this node's direction, as defined in the style. * Get this node's direction, as defined in the style.
*/ */

View File

@@ -10,7 +10,26 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSOverflow { public enum CSSOverflow {
VISIBLE, VISIBLE(0),
HIDDEN, HIDDEN(1),
SCROLL, SCROLL(2);
private int mIntValue;
CSSOverflow(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSOverflow fromInt(int value) {
switch (value) {
case 0: return VISIBLE;
case 1: return HIDDEN;
case 2: return SCROLL;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -10,6 +10,24 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSPositionType { public enum CSSPositionType {
RELATIVE, RELATIVE(0),
ABSOLUTE, ABSOLUTE(1);
private int mIntValue;
CSSPositionType(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSPositionType fromInt(int value) {
switch (value) {
case 0: return RELATIVE;
case 1: return ABSOLUTE;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -0,0 +1,35 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSPrintOptions {
LAYOUT(1),
STYLE(2),
CHILDREN(4);
private int mIntValue;
CSSPrintOptions(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSPrintOptions fromInt(int value) {
switch (value) {
case 1: return LAYOUT;
case 2: return STYLE;
case 4: return CHILDREN;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}

View File

@@ -54,7 +54,7 @@ public class CSSStyle {
alignItems = CSSAlign.STRETCH; alignItems = CSSAlign.STRETCH;
alignSelf = CSSAlign.AUTO; alignSelf = CSSAlign.AUTO;
positionType = CSSPositionType.RELATIVE; positionType = CSSPositionType.RELATIVE;
flexWrap = CSSWrap.NOWRAP; flexWrap = CSSWrap.NO_WRAP;
overflow = CSSOverflow.VISIBLE; overflow = CSSOverflow.VISIBLE;
flexGrow = 0; flexGrow = 0;
flexShrink = 0; flexShrink = 0;

View File

@@ -10,6 +10,24 @@
package com.facebook.csslayout; package com.facebook.csslayout;
public enum CSSWrap { public enum CSSWrap {
NOWRAP, NO_WRAP(0),
WRAP, WRAP(1);
private int mIntValue;
CSSWrap(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSWrap fromInt(int value) {
switch (value) {
case 0: return NO_WRAP;
case 1: return WRAP;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
} }

View File

@@ -68,14 +68,24 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node,
return CSSSize{measuredWidth, measuredHeight}; return CSSSize{measuredWidth, measuredHeight};
} }
struct JCSSLogLevel : public JavaClass<JCSSLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/CSSLogLevel;";
};
static global_ref<jobject> *jLogger; static global_ref<jobject> *jLogger;
static int _jniLog(CSSLogLevel level, const char *format, va_list args) { static int _jniLog(CSSLogLevel level, const char *format, va_list args) {
char buffer[256]; char buffer[256];
int result = vsnprintf(buffer, sizeof(buffer), format, args); int result = vsnprintf(buffer, sizeof(buffer), format, args);
static auto logFunc = static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
findClassLocal("com/facebook/csslayout/CSSLogger")->getMethod<void(jint, jstring)>("log"); ->getMethod<void(local_ref<JCSSLogLevel>, jstring)>("log");
logFunc(jLogger->get(), static_cast<jint>(level), Environment::current()->NewStringUTF(buffer));
static auto logLevelFromInt =
JCSSLogLevel::javaClassStatic()->getStaticMethod<JCSSLogLevel::javaobject(jint)>("fromInt");
logFunc(jLogger->get(),
logLevelFromInt(JCSSLogLevel::javaClassStatic(), static_cast<jint>(level)),
Environment::current()->NewStringUTF(buffer));
return result; return result;
} }
@@ -105,6 +115,16 @@ void jni_CSSLog(alias_ref<jclass> clazz, jint level, jstring message) {
Environment::current()->ReleaseStringUTFChars(message, nMessage); Environment::current()->ReleaseStringUTFChars(message, nMessage);
} }
void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref<jclass> clazz,
jint feature,
jboolean enabled) {
CSSLayoutSetExperimentalFeatureEnabled(static_cast<CSSExperimentalFeature>(feature), enabled);
}
jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
return CSSLayoutIsExperimentalFeatureEnabled(static_cast<CSSExperimentalFeature>(feature));
}
jint jni_CSSNodeGetInstanceCount(alias_ref<jclass> clazz) { jint jni_CSSNodeGetInstanceCount(alias_ref<jclass> clazz) {
return CSSNodeGetInstanceCount(); return CSSNodeGetInstanceCount();
} }
@@ -172,6 +192,10 @@ void jni_CSSNodeMarkLayoutSeen(alias_ref<jobject>, jlong nativePointer) {
CSSNodeSetHasNewLayout(_jlong2CSSNodeRef(nativePointer), false); CSSNodeSetHasNewLayout(_jlong2CSSNodeRef(nativePointer), false);
} }
void jni_CSSNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNativePointer) {
CSSNodeCopyStyle(_jlong2CSSNodeRef(dstNativePointer), _jlong2CSSNodeRef(srcNativePointer));
}
#define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \ #define CSS_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \ javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer)); \ return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer)); \
@@ -203,7 +227,7 @@ CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignItems);
CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignSelf); CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignSelf);
CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignContent); CSS_NODE_JNI_STYLE_PROP(jint, CSSAlign, AlignContent);
CSS_NODE_JNI_STYLE_PROP(jint, CSSPositionType, PositionType); CSS_NODE_JNI_STYLE_PROP(jint, CSSPositionType, PositionType);
CSS_NODE_JNI_STYLE_PROP(jint, CSSWrapType, FlexWrap); CSS_NODE_JNI_STYLE_PROP(jint, CSSWrap, FlexWrap);
CSS_NODE_JNI_STYLE_PROP(jint, CSSOverflow, Overflow); CSS_NODE_JNI_STYLE_PROP(jint, CSSOverflow, Overflow);
void jni_CSSNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) { void jni_CSSNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
@@ -225,6 +249,9 @@ CSS_NODE_JNI_STYLE_PROP(jfloat, float, Height);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight); CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight); CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight);
// Yoga specific properties, not compatible with flexbox specification
CSS_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
#define CSSMakeNativeMethod(name) makeNativeMethod(#name, name) #define CSSMakeNativeMethod(name) makeNativeMethod(#name, name)
jint JNI_OnLoad(JavaVM *vm, void *) { jint JNI_OnLoad(JavaVM *vm, void *) {
@@ -242,6 +269,7 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
CSSMakeNativeMethod(jni_CSSNodeIsDirty), CSSMakeNativeMethod(jni_CSSNodeIsDirty),
CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen), CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen),
CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc), CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc),
CSSMakeNativeMethod(jni_CSSNodeCopyStyle),
CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection), CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection), CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection),
@@ -287,10 +315,14 @@ jint JNI_OnLoad(JavaVM *vm, void *) {
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth), CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight), CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight), CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAspectRatio),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAspectRatio),
CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount), CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount),
CSSMakeNativeMethod(jni_CSSLayoutSetLogger), CSSMakeNativeMethod(jni_CSSLayoutSetLogger),
CSSMakeNativeMethod(jni_CSSLog), CSSMakeNativeMethod(jni_CSSLog),
CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled),
CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled),
}); });
}); });
} }

View File

@@ -7,37 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></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>
<div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
<div id="absolute_layout_within_border" style="height:100px; width:100px; border-width: 10px; margin: 10px; padding: 10px;">
<div style="position: absolute; width: 50px; height: 50px; left: 0px; top: 0px;"></div>
<div style="position: absolute; width: 50px; height: 50px; right: 0px; bottom: 0px;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -49,163 +19,163 @@ public class CSSLayoutAbsolutePositionTest {
@Test @Test
public void test_absolute_layout_width_height_start_top() { public void test_absolute_layout_width_height_start_top() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPositionType(CSSPositionType.ABSOLUTE);
root_child0.setPosition(Spacing.START, 10); root_child0.setPosition(Spacing.START, 10f);
root_child0.setPosition(Spacing.TOP, 10); root_child0.setPosition(Spacing.TOP, 10f);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80, root_child0.getLayoutX(), 0.0f); assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_absolute_layout_width_height_end_bottom() { public void test_absolute_layout_width_height_end_bottom() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPositionType(CSSPositionType.ABSOLUTE);
root_child0.setPosition(Spacing.END, 10); root_child0.setPosition(Spacing.END, 10f);
root_child0.setPosition(Spacing.BOTTOM, 10); root_child0.setPosition(Spacing.BOTTOM, 10f);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80, root_child0.getLayoutX(), 0.0f); assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(80, root_child0.getLayoutY(), 0.0f); assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(80, root_child0.getLayoutY(), 0.0f); assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_absolute_layout_start_top_end_bottom() { public void test_absolute_layout_start_top_end_bottom() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPositionType(CSSPositionType.ABSOLUTE);
root_child0.setPosition(Spacing.START, 10); root_child0.setPosition(Spacing.START, 10f);
root_child0.setPosition(Spacing.TOP, 10); root_child0.setPosition(Spacing.TOP, 10f);
root_child0.setPosition(Spacing.END, 10); root_child0.setPosition(Spacing.END, 10f);
root_child0.setPosition(Spacing.BOTTOM, 10); root_child0.setPosition(Spacing.BOTTOM, 10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_absolute_layout_width_height_start_top_end_bottom() { public void test_absolute_layout_width_height_start_top_end_bottom() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPositionType(CSSPositionType.ABSOLUTE);
root_child0.setPosition(Spacing.START, 10); root_child0.setPosition(Spacing.START, 10f);
root_child0.setPosition(Spacing.TOP, 10); root_child0.setPosition(Spacing.TOP, 10f);
root_child0.setPosition(Spacing.END, 10); root_child0.setPosition(Spacing.END, 10f);
root_child0.setPosition(Spacing.BOTTOM, 10); root_child0.setPosition(Spacing.BOTTOM, 10f);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80, root_child0.getLayoutX(), 0.0f); assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -213,124 +183,124 @@ public class CSSLayoutAbsolutePositionTest {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setOverflow(CSSOverflow.HIDDEN); root.setOverflow(CSSOverflow.HIDDEN);
root.setStyleWidth(50); root.setStyleWidth(50f);
root.setStyleHeight(50); root.setStyleHeight(50f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPositionType(CSSPositionType.ABSOLUTE);
root_child0.setPosition(Spacing.START, 0); root_child0.setPosition(Spacing.START, 0f);
root_child0.setPosition(Spacing.TOP, 0); root_child0.setPosition(Spacing.TOP, 0f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child0_child0 = new CSSNode(); final CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.setStyleWidth(100); root_child0_child0.setStyleWidth(100f);
root_child0_child0.setStyleHeight(100); root_child0_child0.setStyleHeight(100f);
root_child0.addChildAt(root_child0_child0, 0); root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50, root.getLayoutWidth(), 0.0f); assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50, root.getLayoutHeight(), 0.0f); assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50, root.getLayoutWidth(), 0.0f); assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50, root.getLayoutHeight(), 0.0f); assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(-50, root_child0.getLayoutX(), 0.0f); assertEquals(-50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_absolute_layout_within_border() { public void test_absolute_layout_within_border() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setMargin(Spacing.LEFT, 10); root.setMargin(Spacing.LEFT, 10f);
root.setMargin(Spacing.TOP, 10); root.setMargin(Spacing.TOP, 10f);
root.setMargin(Spacing.RIGHT, 10); root.setMargin(Spacing.RIGHT, 10f);
root.setMargin(Spacing.BOTTOM, 10); root.setMargin(Spacing.BOTTOM, 10f);
root.setPadding(Spacing.LEFT, 10); root.setPadding(Spacing.LEFT, 10);
root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.TOP, 10);
root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.RIGHT, 10);
root.setPadding(Spacing.BOTTOM, 10); root.setPadding(Spacing.BOTTOM, 10);
root.setBorder(Spacing.LEFT, 10); root.setBorder(Spacing.LEFT, 10f);
root.setBorder(Spacing.TOP, 10); root.setBorder(Spacing.TOP, 10f);
root.setBorder(Spacing.RIGHT, 10); root.setBorder(Spacing.RIGHT, 10f);
root.setBorder(Spacing.BOTTOM, 10); root.setBorder(Spacing.BOTTOM, 10f);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setPositionType(CSSPositionType.ABSOLUTE); root_child0.setPositionType(CSSPositionType.ABSOLUTE);
root_child0.setPosition(Spacing.LEFT, 0); root_child0.setPosition(Spacing.LEFT, 0f);
root_child0.setPosition(Spacing.TOP, 0); root_child0.setPosition(Spacing.TOP, 0f);
root_child0.setStyleWidth(50); root_child0.setStyleWidth(50f);
root_child0.setStyleHeight(50); root_child0.setStyleHeight(50f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setPositionType(CSSPositionType.ABSOLUTE); root_child1.setPositionType(CSSPositionType.ABSOLUTE);
root_child1.setPosition(Spacing.RIGHT, 0); root_child1.setPosition(Spacing.RIGHT, 0f);
root_child1.setPosition(Spacing.BOTTOM, 0); root_child1.setPosition(Spacing.BOTTOM, 0f);
root_child1.setStyleWidth(50); root_child1.setStyleWidth(50f);
root_child1.setStyleHeight(50); root_child1.setStyleHeight(50f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(10, root.getLayoutX(), 0.0f); assertEquals(10f, root.getLayoutX(), 0.0f);
assertEquals(10, root.getLayoutY(), 0.0f); assertEquals(10f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40, root_child1.getLayoutX(), 0.0f); assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(40, root_child1.getLayoutY(), 0.0f); assertEquals(40f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(10, root.getLayoutX(), 0.0f); assertEquals(10f, root.getLayoutX(), 0.0f);
assertEquals(10, root.getLayoutY(), 0.0f); assertEquals(10f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40, root_child1.getLayoutX(), 0.0f); assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(40, root_child1.getLayoutY(), 0.0f); assertEquals(40f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,42 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_content_flex_start" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-start;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -55,98 +20,98 @@ public class CSSLayoutAlignContentTest {
public void test_align_content_flex_start() { public void test_align_content_flex_start() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(50); root_child0.setStyleWidth(50f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(50); root_child1.setStyleWidth(50f);
root_child1.setStyleHeight(10); root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(50); root_child2.setStyleWidth(50f);
root_child2.setStyleHeight(10); root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(50); root_child3.setStyleWidth(50f);
root_child3.setStyleHeight(10); root_child3.setStyleHeight(10f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
final CSSNode root_child4 = new CSSNode(); final CSSNode root_child4 = new CSSNode();
root_child4.setStyleWidth(50); root_child4.setStyleWidth(50f);
root_child4.setStyleHeight(10); root_child4.setStyleHeight(10f);
root.addChildAt(root_child4, 4); root.addChildAt(root_child4, 4);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10, root_child3.getLayoutHeight(), 0.0f); assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0, root_child4.getLayoutX(), 0.0f); assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(40, root_child4.getLayoutY(), 0.0f); assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10, root_child4.getLayoutHeight(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50, root_child1.getLayoutX(), 0.0f); assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(50, root_child2.getLayoutX(), 0.0f); assertEquals(50f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(50, root_child3.getLayoutX(), 0.0f); assertEquals(50f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10, root_child3.getLayoutHeight(), 0.0f); assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(50, root_child4.getLayoutX(), 0.0f); assertEquals(50f, root_child4.getLayoutX(), 0.0f);
assertEquals(40, root_child4.getLayoutY(), 0.0f); assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10, root_child4.getLayoutHeight(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -154,98 +119,98 @@ public class CSSLayoutAlignContentTest {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignContent(CSSAlign.FLEX_END); root.setAlignContent(CSSAlign.FLEX_END);
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(50); root_child0.setStyleWidth(50f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(50); root_child1.setStyleWidth(50f);
root_child1.setStyleHeight(10); root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(50); root_child2.setStyleWidth(50f);
root_child2.setStyleHeight(10); root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(50); root_child3.setStyleWidth(50f);
root_child3.setStyleHeight(10); root_child3.setStyleHeight(10f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
final CSSNode root_child4 = new CSSNode(); final CSSNode root_child4 = new CSSNode();
root_child4.setStyleWidth(50); root_child4.setStyleWidth(50f);
root_child4.setStyleHeight(10); root_child4.setStyleHeight(10f);
root.addChildAt(root_child4, 4); root.addChildAt(root_child4, 4);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10, root_child3.getLayoutHeight(), 0.0f); assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0, root_child4.getLayoutX(), 0.0f); assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(40, root_child4.getLayoutY(), 0.0f); assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10, root_child4.getLayoutHeight(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50, root_child1.getLayoutX(), 0.0f); assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(50, root_child2.getLayoutX(), 0.0f); assertEquals(50f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(50, root_child3.getLayoutX(), 0.0f); assertEquals(50f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10, root_child3.getLayoutHeight(), 0.0f); assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(50, root_child4.getLayoutX(), 0.0f); assertEquals(50f, root_child4.getLayoutX(), 0.0f);
assertEquals(40, root_child4.getLayoutY(), 0.0f); assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10, root_child4.getLayoutHeight(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -253,98 +218,98 @@ public class CSSLayoutAlignContentTest {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignContent(CSSAlign.CENTER); root.setAlignContent(CSSAlign.CENTER);
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(50); root_child0.setStyleWidth(50f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(50); root_child1.setStyleWidth(50f);
root_child1.setStyleHeight(10); root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(50); root_child2.setStyleWidth(50f);
root_child2.setStyleHeight(10); root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(50); root_child3.setStyleWidth(50f);
root_child3.setStyleHeight(10); root_child3.setStyleHeight(10f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
final CSSNode root_child4 = new CSSNode(); final CSSNode root_child4 = new CSSNode();
root_child4.setStyleWidth(50); root_child4.setStyleWidth(50f);
root_child4.setStyleHeight(10); root_child4.setStyleHeight(10f);
root.addChildAt(root_child4, 4); root.addChildAt(root_child4, 4);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10, root_child3.getLayoutHeight(), 0.0f); assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0, root_child4.getLayoutX(), 0.0f); assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(40, root_child4.getLayoutY(), 0.0f); assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10, root_child4.getLayoutHeight(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50, root_child1.getLayoutX(), 0.0f); assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(50, root_child2.getLayoutX(), 0.0f); assertEquals(50f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(50, root_child3.getLayoutX(), 0.0f); assertEquals(50f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(10, root_child3.getLayoutHeight(), 0.0f); assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(50, root_child4.getLayoutX(), 0.0f); assertEquals(50f, root_child4.getLayoutX(), 0.0f);
assertEquals(40, root_child4.getLayoutY(), 0.0f); assertEquals(40f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(10, root_child4.getLayoutHeight(), 0.0f); assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -352,93 +317,93 @@ public class CSSLayoutAlignContentTest {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignContent(CSSAlign.STRETCH); root.setAlignContent(CSSAlign.STRETCH);
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(50); root_child0.setStyleWidth(50f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(50); root_child1.setStyleWidth(50f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(50); root_child2.setStyleWidth(50f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(50); root_child3.setStyleWidth(50f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
final CSSNode root_child4 = new CSSNode(); final CSSNode root_child4 = new CSSNode();
root_child4.setStyleWidth(50); root_child4.setStyleWidth(50f);
root.addChildAt(root_child4, 4); root.addChildAt(root_child4, 4);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0, root_child0.getLayoutHeight(), 0.0f); assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0, root_child1.getLayoutHeight(), 0.0f); assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(0, root_child2.getLayoutHeight(), 0.0f); assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(0, root_child3.getLayoutY(), 0.0f); assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(0, root_child3.getLayoutHeight(), 0.0f); assertEquals(0f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0, root_child4.getLayoutX(), 0.0f); assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(0, root_child4.getLayoutY(), 0.0f); assertEquals(0f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(0, root_child4.getLayoutHeight(), 0.0f); assertEquals(0f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0, root_child0.getLayoutHeight(), 0.0f); assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50, root_child1.getLayoutX(), 0.0f); assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0, root_child1.getLayoutHeight(), 0.0f); assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(50, root_child2.getLayoutX(), 0.0f); assertEquals(50f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(0, root_child2.getLayoutHeight(), 0.0f); assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(50, root_child3.getLayoutX(), 0.0f); assertEquals(50f, root_child3.getLayoutX(), 0.0f);
assertEquals(0, root_child3.getLayoutY(), 0.0f); assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(50, root_child3.getLayoutWidth(), 0.0f); assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(0, root_child3.getLayoutHeight(), 0.0f); assertEquals(0f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(50, root_child4.getLayoutX(), 0.0f); assertEquals(50f, root_child4.getLayoutX(), 0.0f);
assertEquals(0, root_child4.getLayoutY(), 0.0f); assertEquals(0f, root_child4.getLayoutY(), 0.0f);
assertEquals(50, root_child4.getLayoutWidth(), 0.0f); assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(0, root_child4.getLayoutHeight(), 0.0f); assertEquals(0f, root_child4.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_items_stretch" style="width: 100px; height: 100px;">
<div style="height: 10px;"></div>
</div>
<div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -38,151 +19,151 @@ public class CSSLayoutAlignItemsTest {
@Test @Test
public void test_align_items_stretch() { public void test_align_items_stretch() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_align_items_center() { public void test_align_items_center() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignItems(CSSAlign.CENTER); root.setAlignItems(CSSAlign.CENTER);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(45, root_child0.getLayoutX(), 0.0f); assertEquals(45f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(45, root_child0.getLayoutX(), 0.0f); assertEquals(45f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_align_items_flex_start() { public void test_align_items_flex_start() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignItems(CSSAlign.FLEX_START); root.setAlignItems(CSSAlign.FLEX_START);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_align_items_flex_end() { public void test_align_items_flex_end() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignItems(CSSAlign.FLEX_END); root.setAlignItems(CSSAlign.FLEX_END);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_self_center" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: center;"></div>
</div>
<div id="align_self_flex_end" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
<div id="align_self_flex_start" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-start;"></div>
</div>
<div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -38,154 +19,154 @@ public class CSSLayoutAlignSelfTest {
@Test @Test
public void test_align_self_center() { public void test_align_self_center() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setAlignSelf(CSSAlign.CENTER); root_child0.setAlignSelf(CSSAlign.CENTER);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(45, root_child0.getLayoutX(), 0.0f); assertEquals(45f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(45, root_child0.getLayoutX(), 0.0f); assertEquals(45f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_align_self_flex_end() { public void test_align_self_flex_end() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setAlignSelf(CSSAlign.FLEX_END); root_child0.setAlignSelf(CSSAlign.FLEX_END);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_align_self_flex_start() { public void test_align_self_flex_start() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setAlignSelf(CSSAlign.FLEX_START); root_child0.setAlignSelf(CSSAlign.FLEX_START);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_align_self_flex_end_override_flex_start() { public void test_align_self_flex_end_override_flex_start() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignItems(CSSAlign.FLEX_START); root.setAlignItems(CSSAlign.FLEX_START);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setAlignSelf(CSSAlign.FLEX_END); root_child0.setAlignSelf(CSSAlign.FLEX_END);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,29 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="border_no_size" style="border-width: 10px;">
</div>
<div id="border_container_match_child" style="border-width: 10px;">
<div style="width: 10px; height: 10px;"></div>
</div>
<div id="border_flex_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="width: 10px; flex-grow:1"></div>
</div>
<div id="border_stretch_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="height: 10px;"></div>
</div>
<div id="border_center_child" style="width: 100px; height: 100px; border-start-width: 10px; border-top-width: 10; border-end-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -41,145 +19,145 @@ public class CSSLayoutBorderTest {
@Test @Test
public void test_border_no_size() { public void test_border_no_size() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setBorder(Spacing.LEFT, 10); root.setBorder(Spacing.LEFT, 10f);
root.setBorder(Spacing.TOP, 10); root.setBorder(Spacing.TOP, 10f);
root.setBorder(Spacing.RIGHT, 10); root.setBorder(Spacing.RIGHT, 10f);
root.setBorder(Spacing.BOTTOM, 10); root.setBorder(Spacing.BOTTOM, 10f);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(20, root.getLayoutWidth(), 0.0f); assertEquals(20f, root.getLayoutWidth(), 0.0f);
assertEquals(20, root.getLayoutHeight(), 0.0f); assertEquals(20f, root.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(20, root.getLayoutWidth(), 0.0f); assertEquals(20f, root.getLayoutWidth(), 0.0f);
assertEquals(20, root.getLayoutHeight(), 0.0f); assertEquals(20f, root.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_border_container_match_child() { public void test_border_container_match_child() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setBorder(Spacing.LEFT, 10); root.setBorder(Spacing.LEFT, 10f);
root.setBorder(Spacing.TOP, 10); root.setBorder(Spacing.TOP, 10f);
root.setBorder(Spacing.RIGHT, 10); root.setBorder(Spacing.RIGHT, 10f);
root.setBorder(Spacing.BOTTOM, 10); root.setBorder(Spacing.BOTTOM, 10f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(30, root.getLayoutWidth(), 0.0f); assertEquals(30f, root.getLayoutWidth(), 0.0f);
assertEquals(30, root.getLayoutHeight(), 0.0f); assertEquals(30f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(30, root.getLayoutWidth(), 0.0f); assertEquals(30f, root.getLayoutWidth(), 0.0f);
assertEquals(30, root.getLayoutHeight(), 0.0f); assertEquals(30f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_border_flex_child() { public void test_border_flex_child() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setBorder(Spacing.LEFT, 10); root.setBorder(Spacing.LEFT, 10f);
root.setBorder(Spacing.TOP, 10); root.setBorder(Spacing.TOP, 10f);
root.setBorder(Spacing.RIGHT, 10); root.setBorder(Spacing.RIGHT, 10f);
root.setBorder(Spacing.BOTTOM, 10); root.setBorder(Spacing.BOTTOM, 10f);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80, root_child0.getLayoutX(), 0.0f); assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_border_stretch_child() { public void test_border_stretch_child() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setBorder(Spacing.LEFT, 10); root.setBorder(Spacing.LEFT, 10f);
root.setBorder(Spacing.TOP, 10); root.setBorder(Spacing.TOP, 10f);
root.setBorder(Spacing.RIGHT, 10); root.setBorder(Spacing.RIGHT, 10f);
root.setBorder(Spacing.BOTTOM, 10); root.setBorder(Spacing.BOTTOM, 10f);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -187,41 +165,41 @@ public class CSSLayoutBorderTest {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setJustifyContent(CSSJustify.CENTER); root.setJustifyContent(CSSJustify.CENTER);
root.setAlignItems(CSSAlign.CENTER); root.setAlignItems(CSSAlign.CENTER);
root.setBorder(Spacing.START, 10); root.setBorder(Spacing.START, 10f);
root.setBorder(Spacing.END, 20); root.setBorder(Spacing.END, 20f);
root.setBorder(Spacing.BOTTOM, 20); root.setBorder(Spacing.BOTTOM, 20f);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(40, root_child0.getLayoutX(), 0.0f); assertEquals(40f, root_child0.getLayoutX(), 0.0f);
assertEquals(35, root_child0.getLayoutY(), 0.0f); assertEquals(35f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(35, root_child0.getLayoutY(), 0.0f); assertEquals(35f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,46 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_direction_column_no_height" style="width: 100px">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_no_width" style="height: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column" style="height: 100px; width: 100px;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row" style="height: 100px; width: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column_reverse" style="height: 100px; width: 100px; flex-direction: column-reverse;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_reverse" style="height: 100px; width: 100px; flex-direction: row-reverse;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -58,387 +19,387 @@ public class CSSLayoutFlexDirectionTest {
@Test @Test
public void test_flex_direction_column_no_height() { public void test_flex_direction_column_no_height() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleHeight(10); root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleHeight(10); root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(30, root.getLayoutHeight(), 0.0f); assertEquals(30f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(30, root.getLayoutHeight(), 0.0f); assertEquals(30f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_direction_row_no_width() { public void test_flex_direction_row_no_width() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(10); root_child1.setStyleWidth(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(10); root_child2.setStyleWidth(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(30, root.getLayoutWidth(), 0.0f); assertEquals(30f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10, root_child1.getLayoutX(), 0.0f); assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10, root_child1.getLayoutWidth(), 0.0f); assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(20, root_child2.getLayoutX(), 0.0f); assertEquals(20f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100, root_child2.getLayoutHeight(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(30, root.getLayoutWidth(), 0.0f); assertEquals(30f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20, root_child0.getLayoutX(), 0.0f); assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10, root_child1.getLayoutX(), 0.0f); assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10, root_child1.getLayoutWidth(), 0.0f); assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100, root_child2.getLayoutHeight(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_direction_column() { public void test_flex_direction_column() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleHeight(10); root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleHeight(10); root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(20, root_child2.getLayoutY(), 0.0f); assertEquals(20f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_direction_row() { public void test_flex_direction_row() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(10); root_child1.setStyleWidth(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(10); root_child2.setStyleWidth(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10, root_child1.getLayoutX(), 0.0f); assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10, root_child1.getLayoutWidth(), 0.0f); assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(20, root_child2.getLayoutX(), 0.0f); assertEquals(20f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100, root_child2.getLayoutHeight(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(80, root_child1.getLayoutX(), 0.0f); assertEquals(80f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10, root_child1.getLayoutWidth(), 0.0f); assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(70, root_child2.getLayoutX(), 0.0f); assertEquals(70f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100, root_child2.getLayoutHeight(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_direction_column_reverse() { public void test_flex_direction_column_reverse() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.COLUMN_REVERSE); root.setFlexDirection(CSSFlexDirection.COLUMN_REVERSE);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleHeight(10); root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleHeight(10); root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(90, root_child0.getLayoutY(), 0.0f); assertEquals(90f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(80, root_child1.getLayoutY(), 0.0f); assertEquals(80f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(70, root_child2.getLayoutY(), 0.0f); assertEquals(70f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(90, root_child0.getLayoutY(), 0.0f); assertEquals(90f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(80, root_child1.getLayoutY(), 0.0f); assertEquals(80f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(10, root_child1.getLayoutHeight(), 0.0f); assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(70, root_child2.getLayoutY(), 0.0f); assertEquals(70f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(10, root_child2.getLayoutHeight(), 0.0f); assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_direction_row_reverse() { public void test_flex_direction_row_reverse() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW_REVERSE); root.setFlexDirection(CSSFlexDirection.ROW_REVERSE);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(10); root_child1.setStyleWidth(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(10); root_child2.setStyleWidth(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(80, root_child1.getLayoutX(), 0.0f); assertEquals(80f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10, root_child1.getLayoutWidth(), 0.0f); assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(70, root_child2.getLayoutX(), 0.0f); assertEquals(70f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100, root_child2.getLayoutHeight(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(10, root_child1.getLayoutX(), 0.0f); assertEquals(10f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(10, root_child1.getLayoutWidth(), 0.0f); assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(20, root_child2.getLayoutX(), 0.0f); assertEquals(20f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(10, root_child2.getLayoutWidth(), 0.0f); assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100, root_child2.getLayoutHeight(), 0.0f); assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,48 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_basis_flex_grow_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_shrink_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_basis_flex_shrink_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_shrink_to_zero" style="height: 75px;">
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
<div style="width: 50px; height: 50px; flex-shrink:1;"></div>
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
</div>
<div id="flex_basis_overrides_main_size" style="height: 100px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="flex_grow_shrink_at_most" style="height: 100px; width: 100px;">
<div>
<div style="flex-grow:1; flex-shrink:1;"></div>
</div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -60,392 +19,392 @@ public class CSSLayoutFlexTest {
@Test @Test
public void test_flex_basis_flex_grow_column() { public void test_flex_basis_flex_grow_column() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50); root_child0.setFlexBasis(50f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(75, root_child0.getLayoutHeight(), 0.0f); assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(75, root_child1.getLayoutY(), 0.0f); assertEquals(75f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25, root_child1.getLayoutHeight(), 0.0f); assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(75, root_child0.getLayoutHeight(), 0.0f); assertEquals(75f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(75, root_child1.getLayoutY(), 0.0f); assertEquals(75f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25, root_child1.getLayoutHeight(), 0.0f); assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_basis_flex_grow_row() { public void test_flex_basis_flex_grow_row() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50); root_child0.setFlexBasis(50f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(75, root_child0.getLayoutWidth(), 0.0f); assertEquals(75f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(75, root_child1.getLayoutX(), 0.0f); assertEquals(75f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(25, root_child1.getLayoutWidth(), 0.0f); assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(25, root_child0.getLayoutX(), 0.0f); assertEquals(25f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(75, root_child0.getLayoutWidth(), 0.0f); assertEquals(75f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(25, root_child1.getLayoutWidth(), 0.0f); assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_basis_flex_shrink_column() { public void test_flex_basis_flex_shrink_column() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexShrink(1); root_child0.setFlexShrink(1f);
root_child0.setFlexBasis(100); root_child0.setFlexBasis(100f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexBasis(50); root_child1.setFlexBasis(50f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50, root_child1.getLayoutY(), 0.0f); assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50, root_child1.getLayoutY(), 0.0f); assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_basis_flex_shrink_row() { public void test_flex_basis_flex_shrink_row() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexShrink(1); root_child0.setFlexShrink(1f);
root_child0.setFlexBasis(100); root_child0.setFlexBasis(100f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexBasis(50); root_child1.setFlexBasis(50f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50, root_child1.getLayoutX(), 0.0f); assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_shrink_to_zero() { public void test_flex_shrink_to_zero() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleHeight(75); root.setStyleHeight(75f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(50); root_child0.setStyleWidth(50f);
root_child0.setStyleHeight(50); root_child0.setStyleHeight(50f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexShrink(1); root_child1.setFlexShrink(1f);
root_child1.setStyleWidth(50); root_child1.setStyleWidth(50f);
root_child1.setStyleHeight(50); root_child1.setStyleHeight(50f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(50); root_child2.setStyleWidth(50f);
root_child2.setStyleHeight(50); root_child2.setStyleHeight(50f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50, root.getLayoutWidth(), 0.0f); assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(75, root.getLayoutHeight(), 0.0f); assertEquals(75f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50, root_child1.getLayoutY(), 0.0f); assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0, root_child1.getLayoutHeight(), 0.0f); assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(50, root_child2.getLayoutY(), 0.0f); assertEquals(50f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50, root_child2.getLayoutHeight(), 0.0f); assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50, root.getLayoutWidth(), 0.0f); assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(75, root.getLayoutHeight(), 0.0f); assertEquals(75f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50, root_child1.getLayoutY(), 0.0f); assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0, root_child1.getLayoutHeight(), 0.0f); assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(50, root_child2.getLayoutY(), 0.0f); assertEquals(50f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50, root_child2.getLayoutHeight(), 0.0f); assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_basis_overrides_main_size() { public void test_flex_basis_overrides_main_size() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50); root_child0.setFlexBasis(50f);
root_child0.setStyleHeight(20); root_child0.setStyleHeight(20f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1f);
root_child1.setStyleHeight(10); root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1); root_child2.setFlexGrow(1f);
root_child2.setStyleHeight(10); root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60, root_child0.getLayoutHeight(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(60, root_child1.getLayoutY(), 0.0f); assertEquals(60f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(80, root_child2.getLayoutY(), 0.0f); assertEquals(80f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(20, root_child2.getLayoutHeight(), 0.0f); assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60, root_child0.getLayoutHeight(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(60, root_child1.getLayoutY(), 0.0f); assertEquals(60f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(80, root_child2.getLayoutY(), 0.0f); assertEquals(80f, root_child2.getLayoutY(), 0.0f);
assertEquals(100, root_child2.getLayoutWidth(), 0.0f); assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(20, root_child2.getLayoutHeight(), 0.0f); assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_grow_shrink_at_most() { public void test_flex_grow_shrink_at_most() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child0_child0 = new CSSNode(); final CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1); root_child0_child0.setFlexShrink(1f);
root_child0.addChildAt(root_child0_child0, 0); root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0, root_child0.getLayoutHeight(), 0.0f); assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0, root_child0.getLayoutHeight(), 0.0f); assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,38 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="wrap_column" style="height: 100px; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row" style="width: 100px; flex-direction: row; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_flex_end" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: flex-end;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_center" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: center;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -51,82 +20,82 @@ public class CSSLayoutFlexWrapTest {
public void test_wrap_column() { public void test_wrap_column() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(30); root_child0.setStyleWidth(30f);
root_child0.setStyleHeight(30); root_child0.setStyleHeight(30f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(30); root_child1.setStyleWidth(30f);
root_child1.setStyleHeight(30); root_child1.setStyleHeight(30f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(30); root_child2.setStyleWidth(30f);
root_child2.setStyleHeight(30); root_child2.setStyleHeight(30f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(30); root_child3.setStyleWidth(30f);
root_child3.setStyleHeight(30); root_child3.setStyleHeight(30f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(60, root.getLayoutWidth(), 0.0f); assertEquals(60f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(30, root_child0.getLayoutHeight(), 0.0f); assertEquals(30f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(30, root_child1.getLayoutY(), 0.0f); assertEquals(30f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30, root_child1.getLayoutHeight(), 0.0f); assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(60, root_child2.getLayoutY(), 0.0f); assertEquals(60f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(30, root_child3.getLayoutX(), 0.0f); assertEquals(30f, root_child3.getLayoutX(), 0.0f);
assertEquals(0, root_child3.getLayoutY(), 0.0f); assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(60, root.getLayoutWidth(), 0.0f); assertEquals(60f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(30, root_child0.getLayoutX(), 0.0f); assertEquals(30f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(30, root_child0.getLayoutHeight(), 0.0f); assertEquals(30f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30, root_child1.getLayoutX(), 0.0f); assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(30, root_child1.getLayoutY(), 0.0f); assertEquals(30f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30, root_child1.getLayoutHeight(), 0.0f); assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(30, root_child2.getLayoutX(), 0.0f); assertEquals(30f, root_child2.getLayoutX(), 0.0f);
assertEquals(60, root_child2.getLayoutY(), 0.0f); assertEquals(60f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(0, root_child3.getLayoutY(), 0.0f); assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -134,82 +103,82 @@ public class CSSLayoutFlexWrapTest {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleWidth(100); root.setStyleWidth(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(30); root_child0.setStyleWidth(30f);
root_child0.setStyleHeight(30); root_child0.setStyleHeight(30f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(30); root_child1.setStyleWidth(30f);
root_child1.setStyleHeight(30); root_child1.setStyleHeight(30f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(30); root_child2.setStyleWidth(30f);
root_child2.setStyleHeight(30); root_child2.setStyleHeight(30f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(30); root_child3.setStyleWidth(30f);
root_child3.setStyleHeight(30); root_child3.setStyleHeight(30f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(60, root.getLayoutHeight(), 0.0f); assertEquals(60f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(30, root_child0.getLayoutHeight(), 0.0f); assertEquals(30f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30, root_child1.getLayoutX(), 0.0f); assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30, root_child1.getLayoutHeight(), 0.0f); assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(60, root_child2.getLayoutX(), 0.0f); assertEquals(60f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(60, root.getLayoutHeight(), 0.0f); assertEquals(60f, root.getLayoutHeight(), 0.0f);
assertEquals(70, root_child0.getLayoutX(), 0.0f); assertEquals(70f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(30, root_child0.getLayoutHeight(), 0.0f); assertEquals(30f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40, root_child1.getLayoutX(), 0.0f); assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30, root_child1.getLayoutHeight(), 0.0f); assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(10, root_child2.getLayoutX(), 0.0f); assertEquals(10f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(70, root_child3.getLayoutX(), 0.0f); assertEquals(70f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -218,82 +187,82 @@ public class CSSLayoutFlexWrapTest {
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setAlignItems(CSSAlign.FLEX_END); root.setAlignItems(CSSAlign.FLEX_END);
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleWidth(100); root.setStyleWidth(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(30); root_child0.setStyleWidth(30f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(30); root_child1.setStyleWidth(30f);
root_child1.setStyleHeight(20); root_child1.setStyleHeight(20f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(30); root_child2.setStyleWidth(30f);
root_child2.setStyleHeight(30); root_child2.setStyleHeight(30f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(30); root_child3.setStyleWidth(30f);
root_child3.setStyleHeight(30); root_child3.setStyleHeight(30f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(60, root.getLayoutHeight(), 0.0f); assertEquals(60f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(20, root_child0.getLayoutY(), 0.0f); assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30, root_child1.getLayoutX(), 0.0f); assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(60, root_child2.getLayoutX(), 0.0f); assertEquals(60f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(60, root.getLayoutHeight(), 0.0f); assertEquals(60f, root.getLayoutHeight(), 0.0f);
assertEquals(70, root_child0.getLayoutX(), 0.0f); assertEquals(70f, root_child0.getLayoutX(), 0.0f);
assertEquals(20, root_child0.getLayoutY(), 0.0f); assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40, root_child1.getLayoutX(), 0.0f); assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(10, root_child1.getLayoutY(), 0.0f); assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(10, root_child2.getLayoutX(), 0.0f); assertEquals(10f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(70, root_child3.getLayoutX(), 0.0f); assertEquals(70f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -302,82 +271,82 @@ public class CSSLayoutFlexWrapTest {
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setAlignItems(CSSAlign.CENTER); root.setAlignItems(CSSAlign.CENTER);
root.setWrap(CSSWrap.WRAP); root.setWrap(CSSWrap.WRAP);
root.setStyleWidth(100); root.setStyleWidth(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(30); root_child0.setStyleWidth(30f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(30); root_child1.setStyleWidth(30f);
root_child1.setStyleHeight(20); root_child1.setStyleHeight(20f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(30); root_child2.setStyleWidth(30f);
root_child2.setStyleHeight(30); root_child2.setStyleHeight(30f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode(); final CSSNode root_child3 = new CSSNode();
root_child3.setStyleWidth(30); root_child3.setStyleWidth(30f);
root_child3.setStyleHeight(30); root_child3.setStyleHeight(30f);
root.addChildAt(root_child3, 3); root.addChildAt(root_child3, 3);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(60, root.getLayoutHeight(), 0.0f); assertEquals(60f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30, root_child1.getLayoutX(), 0.0f); assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(5, root_child1.getLayoutY(), 0.0f); assertEquals(5f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(60, root_child2.getLayoutX(), 0.0f); assertEquals(60f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(0, root_child3.getLayoutX(), 0.0f); assertEquals(0f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(60, root.getLayoutHeight(), 0.0f); assertEquals(60f, root.getLayoutHeight(), 0.0f);
assertEquals(70, root_child0.getLayoutX(), 0.0f); assertEquals(70f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(30, root_child0.getLayoutWidth(), 0.0f); assertEquals(30f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40, root_child1.getLayoutX(), 0.0f); assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(5, root_child1.getLayoutY(), 0.0f); assertEquals(5f, root_child1.getLayoutY(), 0.0f);
assertEquals(30, root_child1.getLayoutWidth(), 0.0f); assertEquals(30f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(10, root_child2.getLayoutX(), 0.0f); assertEquals(10f, root_child2.getLayoutX(), 0.0f);
assertEquals(0, root_child2.getLayoutY(), 0.0f); assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30, root_child2.getLayoutWidth(), 0.0f); assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(30, root_child2.getLayoutHeight(), 0.0f); assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(70, root_child3.getLayoutX(), 0.0f); assertEquals(70f, root_child3.getLayoutX(), 0.0f);
assertEquals(30, root_child3.getLayoutY(), 0.0f); assertEquals(30f, root_child3.getLayoutY(), 0.0f);
assertEquals(30, root_child3.getLayoutWidth(), 0.0f); assertEquals(30f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(30, root_child3.getLayoutHeight(), 0.0f); assertEquals(30f, root_child3.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,52 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="margin_start" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 10px; margin-start: 10px;"></div>
</div>
<div id="margin_top" style="width: 100px; height: 100px;">
<div style="height: 10px; margin-top: 10px;"></div>
</div>
<div id="margin_end" style="width: 100px; height: 100px; flex-direction: row; justify-content: flex-end;">
<div style="width: 10px; margin-end: 10px;"></div>
</div>
<div id="margin_bottom" style="width: 100px; height: 100px; justify-content: flex-end;">
<div style="height: 10px; margin-bottom: 10px;"></div>
</div>
<div id="margin_and_flex_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_flex_column" style="width: 100px; height: 100px;">
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_stretch_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_stretch_column" style="width: 100px; height: 100px;">
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_with_sibling_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-end; 10px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="margin_with_sibling_column" style="width: 100px; height: 100px;">
<div style="margin-bottom; 10px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -65,75 +20,75 @@ public class CSSLayoutMarginTest {
public void test_margin_start() { public void test_margin_start() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setMargin(Spacing.START, 10); root_child0.setMargin(Spacing.START, 10f);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80, root_child0.getLayoutX(), 0.0f); assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_top() { public void test_margin_top() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setMargin(Spacing.TOP, 10); root_child0.setMargin(Spacing.TOP, 10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -141,327 +96,327 @@ public class CSSLayoutMarginTest {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setJustifyContent(CSSJustify.FLEX_END); root.setJustifyContent(CSSJustify.FLEX_END);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setMargin(Spacing.END, 10); root_child0.setMargin(Spacing.END, 10f);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80, root_child0.getLayoutX(), 0.0f); assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_bottom() { public void test_margin_bottom() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setJustifyContent(CSSJustify.FLEX_END); root.setJustifyContent(CSSJustify.FLEX_END);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setMargin(Spacing.BOTTOM, 10); root_child0.setMargin(Spacing.BOTTOM, 10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(80, root_child0.getLayoutY(), 0.0f); assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(80, root_child0.getLayoutY(), 0.0f); assertEquals(80f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_and_flex_row() { public void test_margin_and_flex_row() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setMargin(Spacing.START, 10); root_child0.setMargin(Spacing.START, 10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(90, root_child0.getLayoutWidth(), 0.0f); assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(90, root_child0.getLayoutWidth(), 0.0f); assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_and_flex_column() { public void test_margin_and_flex_column() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setMargin(Spacing.TOP, 10); root_child0.setMargin(Spacing.TOP, 10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(90, root_child0.getLayoutHeight(), 0.0f); assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(90, root_child0.getLayoutHeight(), 0.0f); assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_and_stretch_row() { public void test_margin_and_stretch_row() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setMargin(Spacing.TOP, 10); root_child0.setMargin(Spacing.TOP, 10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(90, root_child0.getLayoutHeight(), 0.0f); assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(90, root_child0.getLayoutHeight(), 0.0f); assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_and_stretch_column() { public void test_margin_and_stretch_column() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setMargin(Spacing.START, 10); root_child0.setMargin(Spacing.START, 10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(90, root_child0.getLayoutWidth(), 0.0f); assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(90, root_child0.getLayoutWidth(), 0.0f); assertEquals(90f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_with_sibling_row() { public void test_margin_with_sibling_row() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50, root_child1.getLayoutX(), 0.0f); assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_margin_with_sibling_column() { public void test_margin_with_sibling_column() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50, root_child1.getLayoutY(), 0.0f); assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50, root_child1.getLayoutY(), 0.0f); assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,54 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="max_width" style="width: 100px; height: 100px;">
<div style="height: 10px; max-width: 50px;"></div>
</div>
<div id="max_height" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 10px; max-height: 50px;"></div>
</div>
<div id="min_height" style="width: 100px; height: 100px;">
<div style="flex-grow: 1; min-height: 60px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="min_width" style="width: 100px; height: 100px; flex-direction: row">
<div style="flex-grow: 1; min-width: 60px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="justify_content_min_max" style="max-height: 200px; min-height: 100px; width: 100px; justify-content: center;">
<div style="width: 60px; height: 60px;"></div>
</div>
<div id="align_items_min_max" style="max-width: 200px; min-width: 100px; height: 100px; align-items: center;">
<div style="width: 60px; height: 60px;"></div>
</div>
<div id="justify_content_overflow_min_max" style="min-height: 100px; max-height: 110px; justify-content: center;">
<div style="width: 50px; height: 50px;"></div>
<div style="width: 50px; height: 50px;"></div>
<div style="width: 50px; height: 50px;"></div>
</div>
<div id="flex_grow_within_max_width" style="width: 200px; height: 100px;">
<div style="flex-direction: row; max-width: 100px;">
<div style="height: 20px; flex-grow: 1;"></div>
</div>
</div>
<div id="flex_grow_within_constrained_max_width" style="width: 200px; height: 100px;">
<div style="flex-direction: row; max-width: 300px;">
<div style="height: 20px; flex-grow: 1;"></div>
</div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -66,429 +19,429 @@ public class CSSLayoutMinMaxDimensionTest {
@Test @Test
public void test_max_width() { public void test_max_width() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleMaxWidth(50); root_child0.setStyleMaxWidth(50f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_max_height() { public void test_max_height() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleMaxHeight(50); root_child0.setStyleMaxHeight(50f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90, root_child0.getLayoutX(), 0.0f); assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_min_height() { public void test_min_height() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setStyleMinHeight(60); root_child0.setStyleMinHeight(60f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(80, root_child1.getLayoutY(), 0.0f); assertEquals(80f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(80, root_child1.getLayoutY(), 0.0f); assertEquals(80f, root_child1.getLayoutY(), 0.0f);
assertEquals(100, root_child1.getLayoutWidth(), 0.0f); assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(20, root_child1.getLayoutHeight(), 0.0f); assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_min_width() { public void test_min_width() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW); root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setStyleMinWidth(60); root_child0.setStyleMinWidth(60f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1); root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(80, root_child1.getLayoutX(), 0.0f); assertEquals(80f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(20, root_child1.getLayoutWidth(), 0.0f); assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20, root_child0.getLayoutX(), 0.0f); assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100, root_child0.getLayoutHeight(), 0.0f); assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0, root_child1.getLayoutY(), 0.0f); assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(20, root_child1.getLayoutWidth(), 0.0f); assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100, root_child1.getLayoutHeight(), 0.0f); assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_justify_content_min_max() { public void test_justify_content_min_max() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setJustifyContent(CSSJustify.CENTER); root.setJustifyContent(CSSJustify.CENTER);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleMinHeight(100); root.setStyleMinHeight(100f);
root.setStyleMaxHeight(200); root.setStyleMaxHeight(200f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(60); root_child0.setStyleWidth(60f);
root_child0.setStyleHeight(60); root_child0.setStyleHeight(60f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(20, root_child0.getLayoutY(), 0.0f); assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(60, root_child0.getLayoutWidth(), 0.0f); assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60, root_child0.getLayoutHeight(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(40, root_child0.getLayoutX(), 0.0f); assertEquals(40f, root_child0.getLayoutX(), 0.0f);
assertEquals(20, root_child0.getLayoutY(), 0.0f); assertEquals(20f, root_child0.getLayoutY(), 0.0f);
assertEquals(60, root_child0.getLayoutWidth(), 0.0f); assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60, root_child0.getLayoutHeight(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_align_items_min_max() { public void test_align_items_min_max() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setAlignItems(CSSAlign.CENTER); root.setAlignItems(CSSAlign.CENTER);
root.setStyleMinWidth(100); root.setStyleMinWidth(100f);
root.setStyleMaxWidth(200); root.setStyleMaxWidth(200f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(60); root_child0.setStyleWidth(60f);
root_child0.setStyleHeight(60); root_child0.setStyleHeight(60f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20, root_child0.getLayoutX(), 0.0f); assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(60, root_child0.getLayoutWidth(), 0.0f); assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60, root_child0.getLayoutHeight(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(20, root_child0.getLayoutX(), 0.0f); assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(60, root_child0.getLayoutWidth(), 0.0f); assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(60, root_child0.getLayoutHeight(), 0.0f); assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_justify_content_overflow_min_max() { public void test_justify_content_overflow_min_max() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setJustifyContent(CSSJustify.CENTER); root.setJustifyContent(CSSJustify.CENTER);
root.setStyleMinHeight(100); root.setStyleMinHeight(100f);
root.setStyleMaxHeight(110); root.setStyleMaxHeight(110f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(50); root_child0.setStyleWidth(50f);
root_child0.setStyleHeight(50); root_child0.setStyleHeight(50f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode(); final CSSNode root_child1 = new CSSNode();
root_child1.setStyleWidth(50); root_child1.setStyleWidth(50f);
root_child1.setStyleHeight(50); root_child1.setStyleHeight(50f);
root.addChildAt(root_child1, 1); root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode(); final CSSNode root_child2 = new CSSNode();
root_child2.setStyleWidth(50); root_child2.setStyleWidth(50f);
root_child2.setStyleHeight(50); root_child2.setStyleHeight(50f);
root.addChildAt(root_child2, 2); root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50, root.getLayoutWidth(), 0.0f); assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(110, root.getLayoutHeight(), 0.0f); assertEquals(110f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(-20, root_child0.getLayoutY(), 0.0f); assertEquals(-20f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(30, root_child1.getLayoutY(), 0.0f); assertEquals(30f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(80, root_child2.getLayoutY(), 0.0f); assertEquals(80f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50, root_child2.getLayoutHeight(), 0.0f); assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50, root.getLayoutWidth(), 0.0f); assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(110, root.getLayoutHeight(), 0.0f); assertEquals(110f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(-20, root_child0.getLayoutY(), 0.0f); assertEquals(-20f, root_child0.getLayoutY(), 0.0f);
assertEquals(50, root_child0.getLayoutWidth(), 0.0f); assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50, root_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child1.getLayoutX(), 0.0f); assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(30, root_child1.getLayoutY(), 0.0f); assertEquals(30f, root_child1.getLayoutY(), 0.0f);
assertEquals(50, root_child1.getLayoutWidth(), 0.0f); assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50, root_child1.getLayoutHeight(), 0.0f); assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0, root_child2.getLayoutX(), 0.0f); assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(80, root_child2.getLayoutY(), 0.0f); assertEquals(80f, root_child2.getLayoutY(), 0.0f);
assertEquals(50, root_child2.getLayoutWidth(), 0.0f); assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50, root_child2.getLayoutHeight(), 0.0f); assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_grow_within_max_width() { public void test_flex_grow_within_max_width() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(200); root.setStyleWidth(200f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexDirection(CSSFlexDirection.ROW); root_child0.setFlexDirection(CSSFlexDirection.ROW);
root_child0.setStyleMaxWidth(100); root_child0.setStyleMaxWidth(100f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child0_child0 = new CSSNode(); final CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexGrow(1f);
root_child0_child0.setStyleHeight(20); root_child0_child0.setStyleHeight(20f);
root_child0.addChildAt(root_child0_child0, 0); root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200, root.getLayoutWidth(), 0.0f); assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200, root.getLayoutWidth(), 0.0f); assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(100, root_child0.getLayoutX(), 0.0f); assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
public void test_flex_grow_within_constrained_max_width() { public void test_flex_grow_within_constrained_max_width() {
final CSSNode root = new CSSNode(); final CSSNode root = new CSSNode();
root.setStyleWidth(200); root.setStyleWidth(200f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexDirection(CSSFlexDirection.ROW); root_child0.setFlexDirection(CSSFlexDirection.ROW);
root_child0.setStyleMaxWidth(300); root_child0.setStyleMaxWidth(300f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
final CSSNode root_child0_child0 = new CSSNode(); final CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.setFlexGrow(1); root_child0_child0.setFlexGrow(1f);
root_child0_child0.setStyleHeight(20); root_child0_child0.setStyleHeight(20f);
root_child0.addChildAt(root_child0_child0, 0); root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200, root.getLayoutWidth(), 0.0f); assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200, root_child0.getLayoutWidth(), 0.0f); assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200, root.getLayoutWidth(), 0.0f); assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(200, root_child0.getLayoutWidth(), 0.0f); assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f); assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200, root_child0_child0.getLayoutWidth(), 0.0f); assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f); assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -7,29 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="padding_no_size" style="padding: 10px;">
</div>
<div id="padding_container_match_child" style="padding: 10px;">
<div style="width: 10px; height: 10px;"></div>
</div>
<div id="padding_flex_child" style="width: 100px; height: 100px; padding: 10px;">
<div style="width: 10px; flex-grow:1"></div>
</div>
<div id="padding_stretch_child" style="width: 100px; height: 100px; padding: 10px;">
<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 style="height: 10px; width: 10px;"></div>
</div>
*
*/
package com.facebook.csslayout; package com.facebook.csslayout;
@@ -48,18 +26,18 @@ public class CSSLayoutPaddingTest {
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(20, root.getLayoutWidth(), 0.0f); assertEquals(20f, root.getLayoutWidth(), 0.0f);
assertEquals(20, root.getLayoutHeight(), 0.0f); assertEquals(20f, root.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(20, root.getLayoutWidth(), 0.0f); assertEquals(20f, root.getLayoutWidth(), 0.0f);
assertEquals(20, root.getLayoutHeight(), 0.0f); assertEquals(20f, root.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -71,34 +49,34 @@ public class CSSLayoutPaddingTest {
root.setPadding(Spacing.BOTTOM, 10); root.setPadding(Spacing.BOTTOM, 10);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(30, root.getLayoutWidth(), 0.0f); assertEquals(30f, root.getLayoutWidth(), 0.0f);
assertEquals(30, root.getLayoutHeight(), 0.0f); assertEquals(30f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(30, root.getLayoutWidth(), 0.0f); assertEquals(30f, root.getLayoutWidth(), 0.0f);
assertEquals(30, root.getLayoutHeight(), 0.0f); assertEquals(30f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -108,38 +86,38 @@ public class CSSLayoutPaddingTest {
root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.TOP, 10);
root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.RIGHT, 10);
root.setPadding(Spacing.BOTTOM, 10); root.setPadding(Spacing.BOTTOM, 10);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1); root_child0.setFlexGrow(1f);
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80, root_child0.getLayoutX(), 0.0f); assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(80, root_child0.getLayoutHeight(), 0.0f); assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -149,37 +127,37 @@ public class CSSLayoutPaddingTest {
root.setPadding(Spacing.TOP, 10); root.setPadding(Spacing.TOP, 10);
root.setPadding(Spacing.RIGHT, 10); root.setPadding(Spacing.RIGHT, 10);
root.setPadding(Spacing.BOTTOM, 10); root.setPadding(Spacing.BOTTOM, 10);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10, root_child0.getLayoutX(), 0.0f); assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10, root_child0.getLayoutY(), 0.0f); assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(80, root_child0.getLayoutWidth(), 0.0f); assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
@Test @Test
@@ -190,38 +168,38 @@ public class CSSLayoutPaddingTest {
root.setPadding(Spacing.START, 10); root.setPadding(Spacing.START, 10);
root.setPadding(Spacing.END, 20); root.setPadding(Spacing.END, 20);
root.setPadding(Spacing.BOTTOM, 20); root.setPadding(Spacing.BOTTOM, 20);
root.setStyleWidth(100); root.setStyleWidth(100f);
root.setStyleHeight(100); root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode(); final CSSNode root_child0 = new CSSNode();
root_child0.setStyleWidth(10); root_child0.setStyleWidth(10f);
root_child0.setStyleHeight(10); root_child0.setStyleHeight(10f);
root.addChildAt(root_child0, 0); root.addChildAt(root_child0, 0);
root.setDirection(CSSDirection.LTR); root.setDirection(CSSDirection.LTR);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(40, root_child0.getLayoutX(), 0.0f); assertEquals(40f, root_child0.getLayoutX(), 0.0f);
assertEquals(35, root_child0.getLayoutY(), 0.0f); assertEquals(35f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL); root.setDirection(CSSDirection.RTL);
root.calculateLayout(null); root.calculateLayout(null);
assertEquals(0, root.getLayoutX(), 0.0f); assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0, root.getLayoutY(), 0.0f); assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100, root.getLayoutWidth(), 0.0f); assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100, root.getLayoutHeight(), 0.0f); assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50, root_child0.getLayoutX(), 0.0f); assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(35, root_child0.getLayoutY(), 0.0f); assertEquals(35f, root_child0.getLayoutY(), 0.0f);
assertEquals(10, root_child0.getLayoutWidth(), 0.0f); assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10, root_child0.getLayoutHeight(), 0.0f); assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
} }
} }

View File

@@ -0,0 +1,795 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html
package com.facebook.csslayout;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class CSSLayoutRoundingTest {
@Test
public void test_rounding_flex_basis_flex_grow_row_width_of_100() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(100f);
root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
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(33f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(33f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(34f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(67f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(33f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
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(67f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(33f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(33f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(34f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(33f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_flex_basis_flex_grow_row_prime_number_width() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(113f);
root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1f);
root.addChildAt(root_child2, 2);
final CSSNode root_child3 = new CSSNode();
root_child3.setFlexGrow(1f);
root.addChildAt(root_child3, 3);
final CSSNode root_child4 = new CSSNode();
root_child4.setFlexGrow(1f);
root.addChildAt(root_child4, 4);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(113f, 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(23f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(23f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(22f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(45f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(23f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(68f, root_child3.getLayoutX(), 0.0f);
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(22f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child4.getLayoutX(), 0.0f);
assertEquals(0f, root_child4.getLayoutY(), 0.0f);
assertEquals(23f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(113f, 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(23f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(68f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(22f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(45f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(23f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(23f, root_child3.getLayoutX(), 0.0f);
assertEquals(0f, root_child3.getLayoutY(), 0.0f);
assertEquals(22f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(0f, root_child4.getLayoutY(), 0.0f);
assertEquals(23f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_flex_basis_flex_shrink_row() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(101f);
root.setStyleHeight(100f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexShrink(1f);
root_child0.setFlexBasis(100f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexBasis(25f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexBasis(25f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(101f, 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(51f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(51f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(76f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(101f, 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(51f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(25f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(25f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_flex_basis_overrides_main_size() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setStyleWidth(100f);
root.setStyleHeight(113f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setStyleHeight(20f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1f);
root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1f);
root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_total_fractial() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setStyleWidth(87.4f);
root.setStyleHeight(113.4f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(0.7f);
root_child0.setFlexBasis(50.3f);
root_child0.setStyleHeight(20.3f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1.6f);
root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1.1f);
root_child2.setStyleHeight(10.7f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(87f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(87f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(59f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(59f, root_child1.getLayoutY(), 0.0f);
assertEquals(87f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(87f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(87f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(87f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(59f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(59f, root_child1.getLayoutY(), 0.0f);
assertEquals(87f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(87f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_total_fractial_nested() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setStyleWidth(87.4f);
root.setStyleHeight(113.4f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(0.7f);
root_child0.setFlexBasis(50.3f);
root_child0.setStyleHeight(20.3f);
root.addChildAt(root_child0, 0);
final CSSNode root_child0_child0 = new CSSNode();
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexBasis(0.3f);
root_child0_child0.setPosition(Spacing.BOTTOM, 13.3f);
root_child0_child0.setStyleHeight(9.9f);
root_child0.addChildAt(root_child0_child0, 0);
final CSSNode root_child0_child1 = new CSSNode();
root_child0_child1.setFlexGrow(4f);
root_child0_child1.setFlexBasis(0.3f);
root_child0_child1.setPosition(Spacing.TOP, 13.3f);
root_child0_child1.setStyleHeight(1.1f);
root_child0.addChildAt(root_child0_child1, 1);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1.6f);
root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1.1f);
root_child2.setStyleHeight(10.7f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(87f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(87f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(59f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(-13f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(87f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(12f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(25f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(87f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(47f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(59f, root_child1.getLayoutY(), 0.0f);
assertEquals(87f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(87f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(87f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(87f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(59f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(-13f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(87f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(12f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(25f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(87f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(47f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(59f, root_child1.getLayoutY(), 0.0f);
assertEquals(87f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(30f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(87f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_1() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setStyleWidth(100f);
root.setStyleHeight(113.4f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setStyleHeight(20f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1f);
root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1f);
root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_2() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setStyleWidth(100f);
root.setStyleHeight(113.6f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setStyleHeight(20f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1f);
root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1f);
root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(114f, 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(65f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(65f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(114f, 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(65f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(65f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_3() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setPosition(Spacing.TOP, 0.3f);
root.setStyleWidth(100f);
root.setStyleHeight(113.4f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setStyleHeight(20f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1f);
root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1f);
root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(114f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(114f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
@Test
public void test_rounding_fractial_input_4() {
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, true);
final CSSNode root = new CSSNode();
root.setPosition(Spacing.TOP, 0.7f);
root.setStyleWidth(100f);
root.setStyleHeight(113.4f);
final CSSNode root_child0 = new CSSNode();
root_child0.setFlexGrow(1f);
root_child0.setFlexBasis(50f);
root_child0.setStyleHeight(20f);
root.addChildAt(root_child0, 0);
final CSSNode root_child1 = new CSSNode();
root_child1.setFlexGrow(1f);
root_child1.setStyleHeight(10f);
root.addChildAt(root_child1, 1);
final CSSNode root_child2 = new CSSNode();
root_child2.setFlexGrow(1f);
root_child2.setStyleHeight(10f);
root.addChildAt(root_child2, 2);
root.setDirection(CSSDirection.LTR);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(1f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(CSSDirection.RTL);
root.calculateLayout(null);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(1f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(113f, 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(64f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(64f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(89f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(24f, root_child2.getLayoutHeight(), 0.0f);
CSSNode.setExperimentalFeatureEnabled(CSSExperimentalFeature.ROUNDING, false);
}
}

View File

@@ -12,6 +12,7 @@ package com.facebook.csslayout;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class CSSNodeTest { public class CSSNodeTest {
@@ -40,35 +41,47 @@ public class CSSNodeTest {
assertEquals(100, (int) node.getLayoutHeight()); assertEquals(100, (int) node.getLayoutHeight());
} }
private int mLogLevel; private CSSLogLevel mLogLevel;
private String mLogMessage; private String mLogMessage;
@Test @Test
public void testLogger() { public void testLogger() {
CSSNode.setLogger(new CSSLogger() { CSSNode.setLogger(new CSSLogger() {
public void log(int level, String message) { public void log(CSSLogLevel level, String message) {
mLogLevel = level; mLogLevel = level;
mLogMessage = message; mLogMessage = message;
} }
}); });
CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_DEBUG, "Hello"); CSSNode.jni_CSSLog(CSSLogLevel.DEBUG.intValue(), "Hello");
assertEquals(CSSLogger.LOG_LEVEL_DEBUG, mLogLevel); assertEquals(CSSLogLevel.DEBUG, mLogLevel);
assertEquals("Hello", mLogMessage); assertEquals("Hello", mLogMessage);
} }
@Test @Test
public void testUpdateLogger() { public void testUpdateLogger() {
CSSNode.setLogger(new CSSLogger() { CSSNode.setLogger(new CSSLogger() {
public void log(int level, String message) {} public void log(CSSLogLevel level, String message) {}
}); });
CSSNode.setLogger(new CSSLogger() { CSSNode.setLogger(new CSSLogger() {
public void log(int level, String message) { public void log(CSSLogLevel level, String message) {
mLogLevel = level; mLogLevel = level;
mLogMessage = message; mLogMessage = message;
} }
}); });
CSSNode.jni_CSSLog(CSSLogger.LOG_LEVEL_VERBOSE, "Flexbox"); CSSNode.jni_CSSLog(CSSLogLevel.VERBOSE.intValue(), "Flexbox");
assertEquals(CSSLogger.LOG_LEVEL_VERBOSE, mLogLevel); assertEquals(CSSLogLevel.VERBOSE, mLogLevel);
assertEquals("Flexbox", mLogMessage); assertEquals("Flexbox", mLogMessage);
} }
@Test
public void testCopyStyle() {
final CSSNode node0 = new CSSNode();
assertTrue(CSSConstants.isUndefined(node0.getStyleMaxHeight()));
final CSSNode node1 = new CSSNode();
node1.setStyleMaxHeight(100);
node0.copyStyle(node1);
assertEquals(100, (int) node0.getStyleMaxHeight());
}
} }

View File

@@ -7,22 +7,6 @@
include_defs('//CSSLAYOUT_DEFS') include_defs('//CSSLAYOUT_DEFS')
with allow_unsafe_import():
import os
import urllib2
import zipfile
# Download gtest dep if it does not exists in path
current_dir = os.path.dirname(os.path.realpath(__file__))
gtest_folder = 'googletest-release-1.7.0'
if GTEST_DL_URL != None and not os.path.isdir(current_dir + gtest_folder):
gtest = urllib2.urlopen('https://github.com/google/googletest/archive/release-1.7.0.zip').read()
with open("gtest.zip", 'w') as f:
f.write(gtest)
with zipfile.ZipFile('gtest.zip',"r") as zip:
zip.extractall(os.path.dirname(os.path.realpath(__file__)))
os.remove('gtest.zip')
COMPILER_FLAGS = [ COMPILER_FLAGS = [
'-std=c++11', '-std=c++11',
'-Wno-missing-prototypes', '-Wno-missing-prototypes',
@@ -30,11 +14,11 @@ COMPILER_FLAGS = [
cxx_library( cxx_library(
name = 'gtest', name = 'gtest',
srcs = glob([gtest_folder + '/src/*.cc']), srcs = glob(['googletest/googletest/src/*.cc']),
exported_headers = subdir_glob([ exported_headers = subdir_glob([
(gtest_folder + '/include', '**/*.h'), ('googletest/googletest/include', '**/*.h'),
(gtest_folder, 'src/*.h'), ('googletest/googletest', 'src/*.h'),
(gtest_folder, 'src/*.cc'), ('googletest/googletest', 'src/*.cc'),
]), ]),
header_namespace = '', header_namespace = '',
compiler_flags = COMPILER_FLAGS, compiler_flags = COMPILER_FLAGS,

1
lib/gtest/googletest Submodule

Submodule lib/gtest/googletest added at a2b8a8e076

View File

@@ -7,37 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></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>
<div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
<div id="absolute_layout_within_border" style="height:100px; width:100px; border-width: 10px; margin: 10px; padding: 10px;">
<div style="position: absolute; width: 50px; height: 50px; left: 0px; top: 0px;"></div>
<div style="position: absolute; width: 50px; height: 50px; right: 0px; bottom: 0px;"></div>
</div>
*
*/
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -56,27 +26,27 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -95,27 +65,27 @@ TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -134,27 +104,27 @@ TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -175,27 +145,27 @@ TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -219,37 +189,37 @@ TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overfl
CSSNodeInsertChild(root_child0, root_child0_child0, 0); CSSNodeInsertChild(root_child0, root_child0_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(-50, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(-50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -288,37 +258,37 @@ TEST(CSSLayoutTest, absolute_layout_within_border) {
CSSNodeInsertChild(root, root_child1, 1); CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -7,49 +7,14 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_content_flex_start" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-start;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
</div>
*
*/
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
TEST(CSSLayoutTest, align_content_flex_start) { TEST(CSSLayoutTest, align_content_flex_start) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -79,67 +44,67 @@ TEST(CSSLayoutTest, align_content_flex_start) {
CSSNodeInsertChild(root, root_child4, 4); CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -147,7 +112,7 @@ TEST(CSSLayoutTest, align_content_flex_start) {
TEST(CSSLayoutTest, align_content_flex_end) { TEST(CSSLayoutTest, align_content_flex_end) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, CSSAlignFlexEnd); CSSNodeStyleSetAlignContent(root, CSSAlignFlexEnd);
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -177,67 +142,67 @@ TEST(CSSLayoutTest, align_content_flex_end) {
CSSNodeInsertChild(root, root_child4, 4); CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -245,7 +210,7 @@ TEST(CSSLayoutTest, align_content_flex_end) {
TEST(CSSLayoutTest, align_content_center) { TEST(CSSLayoutTest, align_content_center) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, CSSAlignCenter); CSSNodeStyleSetAlignContent(root, CSSAlignCenter);
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -275,67 +240,67 @@ TEST(CSSLayoutTest, align_content_center) {
CSSNodeInsertChild(root, root_child4, 4); CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(30, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(40, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -343,7 +308,7 @@ TEST(CSSLayoutTest, align_content_center) {
TEST(CSSLayoutTest, align_content_stretch) { TEST(CSSLayoutTest, align_content_stretch) {
const CSSNodeRef root = CSSNodeNew(); const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, CSSAlignStretch); CSSNodeStyleSetAlignContent(root, CSSAlignStretch);
CSSNodeStyleSetFlexWrap(root, CSSWrapTypeWrap); CSSNodeStyleSetFlexWrap(root, CSSWrapWrap);
CSSNodeStyleSetWidth(root, 100); CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100); CSSNodeStyleSetHeight(root, 100);
@@ -368,67 +333,67 @@ TEST(CSSLayoutTest, align_content_stretch) {
CSSNodeInsertChild(root, root_child4, 4); CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child3)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child3)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child3));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child4)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child4)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_items_stretch" style="width: 100px; height: 100px;">
<div style="height: 10px;"></div>
</div>
<div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -41,27 +22,27 @@ TEST(CSSLayoutTest, align_items_stretch) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -78,27 +59,27 @@ TEST(CSSLayoutTest, align_items_center) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -115,27 +96,27 @@ TEST(CSSLayoutTest, align_items_flex_start) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -152,27 +133,27 @@ TEST(CSSLayoutTest, align_items_flex_end) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_self_center" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: center;"></div>
</div>
<div id="align_self_flex_end" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
<div id="align_self_flex_start" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-start;"></div>
</div>
<div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
*
*/
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -43,27 +24,27 @@ TEST(CSSLayoutTest, align_self_center) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(45, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -80,27 +61,27 @@ TEST(CSSLayoutTest, align_self_flex_end) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -117,27 +98,27 @@ TEST(CSSLayoutTest, align_self_flex_start) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -155,27 +136,27 @@ TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -0,0 +1,407 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>
static CSSSize _measure(CSSNodeRef node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode) {
return CSSSize {
.width = widthMode == CSSMeasureModeExactly ? width : 50,
.height = heightMode == CSSMeasureModeExactly ? height : 50,
};
}
TEST(CSSLayoutTest, aspect_ratio_cross_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_main_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_both_dimensions_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_align_stretch) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_flex_grow) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_flex_shrink) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 150);
CSSNodeStyleSetFlexShrink(root_child0, 1);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_basis) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexBasis(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_absolute_layout_width_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0);
CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0);
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_absolute_layout_height_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, CSSPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, CSSEdgeLeft, 0);
CSSNodeStyleSetPosition(root_child0, CSSEdgeTop, 0);
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_max_cross_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetMaxWidth(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_max_main_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetMaxHeight(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_min_cross_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 30);
CSSNodeStyleSetMinWidth(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_min_main_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetMinHeight(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_double_cross) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 2);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_half_cross) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 100);
CSSNodeStyleSetAspectRatio(root_child0, 0.5);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_double_main) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 2);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_half_main) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 100);
CSSNodeStyleSetAspectRatio(root_child0, 0.5);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_measure_func) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, CSSAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}

View File

@@ -7,29 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="border_no_size" style="border-width: 10px;">
</div>
<div id="border_container_match_child" style="border-width: 10px;">
<div style="width: 10px; height: 10px;"></div>
</div>
<div id="border_flex_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="width: 10px; flex-grow:1"></div>
</div>
<div id="border_stretch_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="height: 10px;"></div>
</div>
<div id="border_center_child" style="width: 100px; height: 100px; border-start-width: 10px; border-top-width: 10; border-end-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -42,17 +20,17 @@ TEST(CSSLayoutTest, border_no_size) {
CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10); CSSNodeStyleSetBorder(root, CSSEdgeBottom, 10);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(20, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -70,27 +48,27 @@ TEST(CSSLayoutTest, border_container_match_child) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -110,27 +88,27 @@ TEST(CSSLayoutTest, border_flex_child) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -149,27 +127,27 @@ TEST(CSSLayoutTest, border_stretch_child) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -190,27 +168,27 @@ TEST(CSSLayoutTest, border_center_child) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(40, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(35, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -23,10 +23,10 @@ TEST(CSSLayoutTest, assert_default_values) {
ASSERT_EQ(CSSAlignStretch, CSSNodeStyleGetAlignItems(root)); ASSERT_EQ(CSSAlignStretch, CSSNodeStyleGetAlignItems(root));
ASSERT_EQ(CSSAlignAuto, CSSNodeStyleGetAlignSelf(root)); ASSERT_EQ(CSSAlignAuto, CSSNodeStyleGetAlignSelf(root));
ASSERT_EQ(CSSPositionTypeRelative, CSSNodeStyleGetPositionType(root)); ASSERT_EQ(CSSPositionTypeRelative, CSSNodeStyleGetPositionType(root));
ASSERT_EQ(CSSWrapTypeNoWrap, CSSNodeStyleGetFlexWrap(root)); ASSERT_EQ(CSSWrapNoWrap, CSSNodeStyleGetFlexWrap(root));
ASSERT_EQ(CSSOverflowVisible, CSSNodeStyleGetOverflow(root)); ASSERT_EQ(CSSOverflowVisible, CSSNodeStyleGetOverflow(root));
ASSERT_EQ(0, CSSNodeStyleGetFlexGrow(root)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexGrow(root));
ASSERT_EQ(0, CSSNodeStyleGetFlexShrink(root)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexShrink(root));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeLeft))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeLeft)));
@@ -36,24 +36,24 @@ TEST(CSSLayoutTest, assert_default_values) {
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeEnd))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, CSSEdgeEnd)));
ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeLeft)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeLeft));
ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeTop)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeTop));
ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeRight)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeRight));
ASSERT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeBottom)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, CSSEdgeBottom));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeEnd))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, CSSEdgeEnd)));
ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeLeft)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeLeft));
ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeTop)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeTop));
ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeRight)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeRight));
ASSERT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeBottom)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, CSSEdgeBottom));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeEnd))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, CSSEdgeEnd)));
ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeLeft)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeLeft));
ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeTop)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeTop));
ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeRight)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeRight));
ASSERT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeBottom)); ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, CSSEdgeBottom));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeStart))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeEnd))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, CSSEdgeEnd)));
@@ -64,10 +64,10 @@ TEST(CSSLayoutTest, assert_default_values) {
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxWidth(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxWidth(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(root)));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(0, CSSNodeLayoutGetRight(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetRight(root));
ASSERT_EQ(0, CSSNodeLayoutGetBottom(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetBottom(root));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetWidth(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetWidth(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetHeight(root))); ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetHeight(root)));
ASSERT_EQ(CSSDirectionInherit, CSSNodeLayoutGetDirection(root)); ASSERT_EQ(CSSDirectionInherit, CSSNodeLayoutGetDirection(root));

View File

@@ -83,11 +83,14 @@ TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) {
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
CSSNodeRemoveChild(root, CSSNodeNew()); const CSSNodeRef child1 = CSSNodeNew();
CSSNodeRemoveChild(root, child1);
EXPECT_FALSE(CSSNodeIsDirty(root)); EXPECT_FALSE(CSSNodeIsDirty(root));
CSSNodeFree(child1);
CSSNodeRemoveChild(root, child0); CSSNodeRemoveChild(root, child0);
EXPECT_TRUE(CSSNodeIsDirty(root)); EXPECT_TRUE(CSSNodeIsDirty(root));
CSSNodeFree(child0);
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -24,12 +24,12 @@ TEST(CSSLayoutTest, start_overrides) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -48,12 +48,12 @@ TEST(CSSLayoutTest, end_overrides) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -71,8 +71,8 @@ TEST(CSSLayoutTest, horizontal_overridden) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -90,8 +90,8 @@ TEST(CSSLayoutTest, vertical_overridden) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -109,10 +109,10 @@ TEST(CSSLayoutTest, horizontal_overrides_all) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetBottom(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -130,10 +130,10 @@ TEST(CSSLayoutTest, vertical_overrides_all) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(20, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -154,10 +154,10 @@ TEST(CSSLayoutTest, all_overridden) {
CSSNodeInsertChild(root, root_child0, 0); CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetRight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetBottom(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -7,46 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_direction_column_no_height" style="width: 100px">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_no_width" style="height: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column" style="height: 100px; width: 100px;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row" style="height: 100px; width: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column_reverse" style="height: 100px; width: 100px; flex-direction: column-reverse;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_reverse" style="height: 100px; width: 100px; flex-direction: row-reverse;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
*
*/
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -68,47 +29,47 @@ TEST(CSSLayoutTest, flex_direction_column_no_height) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -131,47 +92,47 @@ TEST(CSSLayoutTest, flex_direction_row_no_width) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -194,47 +155,47 @@ TEST(CSSLayoutTest, flex_direction_column) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -258,47 +219,47 @@ TEST(CSSLayoutTest, flex_direction_row) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(70, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -322,47 +283,47 @@ TEST(CSSLayoutTest, flex_direction_column_reverse) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(90, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(70, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -386,47 +347,47 @@ TEST(CSSLayoutTest, flex_direction_row_reverse) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(90, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(80, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(70, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(10, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(10, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

View File

@@ -7,48 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
/** // @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_basis_flex_grow_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_shrink_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_basis_flex_shrink_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_shrink_to_zero" style="height: 75px;">
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
<div style="width: 50px; height: 50px; flex-shrink:1;"></div>
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
</div>
<div id="flex_basis_overrides_main_size" style="height: 100px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="flex_grow_shrink_at_most" style="height: 100px; width: 100px;">
<div>
<div style="flex-grow:1; flex-shrink:1;"></div>
</div>
</div>
*
*/
#include <CSSLayout/CSSLayout.h> #include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
@@ -68,37 +27,37 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_column) {
CSSNodeInsertChild(root, root_child1, 1); CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(75, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(75, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(75, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -119,37 +78,37 @@ TEST(CSSLayoutTest, flex_basis_flex_grow_row) {
CSSNodeInsertChild(root, root_child1, 1); CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(75, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(75, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(25, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(75, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -169,37 +128,37 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_column) {
CSSNodeInsertChild(root, root_child1, 1); CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -220,37 +179,37 @@ TEST(CSSLayoutTest, flex_basis_flex_shrink_row) {
CSSNodeInsertChild(root, root_child1, 1); CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(50, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -276,47 +235,47 @@ TEST(CSSLayoutTest, flex_shrink_to_zero) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(75, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(75, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -343,47 +302,47 @@ TEST(CSSLayoutTest, flex_basis_overrides_main_size) {
CSSNodeInsertChild(root, root_child2, 2); CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(60, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(60, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(60, CSSNodeLayoutGetTop(root_child1)); ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child1)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(80, CSSNodeLayoutGetTop(root_child2)); ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child2)); ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }
@@ -402,37 +361,37 @@ TEST(CSSLayoutTest, flex_grow_shrink_at_most) {
CSSNodeInsertChild(root_child0, root_child0_child0, 0); CSSNodeInsertChild(root_child0, root_child0_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL); CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0)); ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0)); ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0));
CSSNodeFreeRecursive(root); CSSNodeFreeRecursive(root);
} }

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