Rename C api

Summary: This renames the core C api to use the new Yoga branding.

Differential Revision: D4259190

fbshipit-source-id: 26c8b356ca464d4304f5f9dc4192bff10cea2dc9
This commit is contained in:
Emil Sjolander
2016-12-03 04:40:18 -08:00
committed by Facebook Github Bot
parent f7cc614d67
commit dda24b1e23
49 changed files with 6459 additions and 6441 deletions

View File

@@ -1,183 +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.
*/
#pragma once
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *) __nan)
#endif
#define YGUndefined NAN
#include "CSSEnums.h"
#include "CSSMacros.h"
CSS_EXTERN_C_BEGIN
typedef struct CSSSize {
float width;
float height;
} CSSSize;
typedef struct CSSNode *CSSNodeRef;
typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
typedef void (*CSSPrintFunc)(CSSNodeRef node);
typedef int (*CSSLogger)(YGLogLevel 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
WIN_EXPORT CSSNodeRef CSSNodeNew(void);
WIN_EXPORT void CSSNodeInit(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFree(const CSSNodeRef node);
WIN_EXPORT void CSSNodeFreeRecursive(const CSSNodeRef node);
WIN_EXPORT void CSSNodeReset(const CSSNodeRef node);
WIN_EXPORT int32_t CSSNodeGetInstanceCount(void);
WIN_EXPORT void CSSNodeInsertChild(const CSSNodeRef node,
const CSSNodeRef child,
const uint32_t index);
WIN_EXPORT void CSSNodeRemoveChild(const CSSNodeRef node, const CSSNodeRef child);
WIN_EXPORT CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index);
WIN_EXPORT uint32_t CSSNodeChildCount(const CSSNodeRef node);
WIN_EXPORT void CSSNodeCalculateLayout(const CSSNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function
// set.
// CSSLayout knows when to mark all other nodes as dirty but because nodes with
// measure functions
// depends on information not known to CSSLayout they must perform this dirty
// marking manually.
WIN_EXPORT void CSSNodeMarkDirty(const CSSNodeRef node);
WIN_EXPORT bool CSSNodeIsDirty(const CSSNodeRef node);
WIN_EXPORT void CSSNodePrint(const CSSNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool CSSValueIsUndefined(const float value);
WIN_EXPORT bool CSSNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn);
WIN_EXPORT void CSSNodeCopyStyle(const CSSNodeRef dstNode, const CSSNodeRef srcNode);
#define CSS_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeSet##name(const CSSNodeRef node, type paramName); \
WIN_EXPORT type CSSNodeGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, const type paramName); \
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node);
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void CSSNodeStyleSet##name(const CSSNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type CSSNodeStyleGet##name(const CSSNodeRef node, const YGEdge edge);
#define CSS_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type CSSNodeLayoutGet##name(const CSSNodeRef node);
CSS_NODE_PROPERTY(void *, Context, context);
CSS_NODE_PROPERTY(CSSMeasureFunc, MeasureFunc, measureFunc);
CSS_NODE_PROPERTY(CSSPrintFunc, PrintFunc, printFunc);
CSS_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout);
CSS_NODE_STYLE_PROPERTY(YGDirection, Direction, direction);
CSS_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection);
CSS_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems);
CSS_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf);
CSS_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
CSS_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
CSS_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void CSSNodeStyleSetFlex(const CSSNodeRef node, const float flex);
CSS_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
CSS_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
CSS_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
CSS_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
CSS_NODE_STYLE_PROPERTY(float, Width, width);
CSS_NODE_STYLE_PROPERTY(float, Height, height);
CSS_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
CSS_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
CSS_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
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, Top);
CSS_NODE_LAYOUT_PROPERTY(float, Right);
CSS_NODE_LAYOUT_PROPERTY(float, Bottom);
CSS_NODE_LAYOUT_PROPERTY(float, Width);
CSS_NODE_LAYOUT_PROPERTY(float, Height);
CSS_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
WIN_EXPORT void CSSLayoutSetLogger(CSSLogger logger);
WIN_EXPORT void CSSLog(YGLogLevel level, const char *message, ...);
WIN_EXPORT void CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled);
WIN_EXPORT bool CSSLayoutIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
WIN_EXPORT void CSSLayoutSetMemoryFuncs(CSSMalloc cssMalloc,
CSSCalloc cssCalloc,
CSSRealloc cssRealloc,
CSSFree cssFree);
CSS_EXTERN_C_END

View File

@@ -1,104 +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.
*/
#include "CSSNodeList.h"
extern CSSMalloc gCSSMalloc;
extern CSSRealloc gCSSRealloc;
extern CSSFree gCSSFree;
struct CSSNodeList {
uint32_t capacity;
uint32_t count;
CSSNodeRef *items;
};
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
const CSSNodeListRef list = gCSSMalloc(sizeof(struct CSSNodeList));
CSS_ASSERT(list != NULL, "Could not allocate memory for list");
list->capacity = initialCapacity;
list->count = 0;
list->items = gCSSMalloc(sizeof(CSSNodeRef) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list;
}
void CSSNodeListFree(const CSSNodeListRef list) {
if (list) {
gCSSFree(list->items);
gCSSFree(list);
}
}
uint32_t CSSNodeListCount(const CSSNodeListRef list) {
if (list) {
return list->count;
}
return 0;
}
void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node) {
if (!*listp) {
*listp = CSSNodeListNew(4);
}
CSSNodeListInsert(listp, node, (*listp)->count);
}
void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index) {
if (!*listp) {
*listp = CSSNodeListNew(4);
}
CSSNodeListRef list = *listp;
if (list->count == list->capacity) {
list->capacity *= 2;
list->items = gCSSRealloc(list->items, sizeof(CSSNodeRef) * list->capacity);
CSS_ASSERT(list->items != NULL, "Could not extend allocation for items");
}
for (uint32_t i = list->count; i > index; i--) {
list->items[i] = list->items[i - 1];
}
list->count++;
list->items[index] = node;
}
CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index) {
const CSSNodeRef removed = list->items[index];
list->items[index] = NULL;
for (uint32_t i = index; i < list->count - 1; i++) {
list->items[i] = list->items[i + 1];
list->items[i + 1] = NULL;
}
list->count--;
return removed;
}
CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node) {
for (uint32_t i = 0; i < list->count; i++) {
if (list->items[i] == node) {
return CSSNodeListRemove(list, i);
}
}
return NULL;
}
CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index) {
if (CSSNodeListCount(list) > 0) {
return list->items[index];
}
return NULL;
}

View File

@@ -1,33 +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.
*/
#pragma once
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "CSSLayout.h"
#include "CSSMacros.h"
CSS_EXTERN_C_BEGIN
typedef struct CSSNodeList *CSSNodeListRef;
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity);
void CSSNodeListFree(const CSSNodeListRef list);
uint32_t CSSNodeListCount(const CSSNodeListRef list);
void CSSNodeListAdd(CSSNodeListRef *listp, const CSSNodeRef node);
void CSSNodeListInsert(CSSNodeListRef *listp, const CSSNodeRef node, const uint32_t index);
CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index);
CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node);
CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index);
CSS_EXTERN_C_END

View File

@@ -10,11 +10,11 @@
#pragma once
#ifdef __cplusplus
#define CSS_EXTERN_C_BEGIN extern "C" {
#define CSS_EXTERN_C_END }
#define YG_EXTERN_C_BEGIN extern "C" {
#define YG_EXTERN_C_END }
#else
#define CSS_EXTERN_C_BEGIN
#define CSS_EXTERN_C_END
#define YG_EXTERN_C_BEGIN
#define YG_EXTERN_C_END
#endif
#ifdef _WINDLL
@@ -28,15 +28,15 @@
#endif
#if FB_ASSERTIONS_ENABLED
#define CSS_ABORT() abort()
#define YG_ABORT() abort()
#else
#define CSS_ABORT()
#define YG_ABORT()
#endif
#ifndef CSS_ASSERT
#define CSS_ASSERT(X, message) \
if (!(X)) { \
CSSLog(YGLogLevelError, "%s", message); \
CSS_ABORT(); \
#ifndef YG_ASSERT
#define YG_ASSERT(X, message) \
if (!(X)) { \
YGLog(YGLogLevelError, "%s", message); \
YG_ABORT(); \
}
#endif

104
CSSLayout/YGNodeList.c Normal file
View File

@@ -0,0 +1,104 @@
/**
* 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 "YGNodeList.h"
extern YGMalloc gYGMalloc;
extern YGRealloc gYGRealloc;
extern YGFree gYGFree;
struct YGNodeList {
uint32_t capacity;
uint32_t count;
YGNodeRef *items;
};
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity) {
const YGNodeListRef list = gYGMalloc(sizeof(struct YGNodeList));
YG_ASSERT(list != NULL, "Could not allocate memory for list");
list->capacity = initialCapacity;
list->count = 0;
list->items = gYGMalloc(sizeof(YGNodeRef) * list->capacity);
YG_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list;
}
void YGNodeListFree(const YGNodeListRef list) {
if (list) {
gYGFree(list->items);
gYGFree(list);
}
}
uint32_t YGNodeListCount(const YGNodeListRef list) {
if (list) {
return list->count;
}
return 0;
}
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListInsert(listp, node, (*listp)->count);
}
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index) {
if (!*listp) {
*listp = YGNodeListNew(4);
}
YGNodeListRef list = *listp;
if (list->count == list->capacity) {
list->capacity *= 2;
list->items = gYGRealloc(list->items, sizeof(YGNodeRef) * list->capacity);
YG_ASSERT(list->items != NULL, "Could not extend allocation for items");
}
for (uint32_t i = list->count; i > index; i--) {
list->items[i] = list->items[i - 1];
}
list->count++;
list->items[index] = node;
}
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index) {
const YGNodeRef removed = list->items[index];
list->items[index] = NULL;
for (uint32_t i = index; i < list->count - 1; i++) {
list->items[i] = list->items[i + 1];
list->items[i + 1] = NULL;
}
list->count--;
return removed;
}
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node) {
for (uint32_t i = 0; i < list->count; i++) {
if (list->items[i] == node) {
return YGNodeListRemove(list, i);
}
}
return NULL;
}
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index) {
if (YGNodeListCount(list) > 0) {
return list->items[index];
}
return NULL;
}

33
CSSLayout/YGNodeList.h Normal file
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.
*/
#pragma once
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "YGMacros.h"
#include "Yoga.h"
YG_EXTERN_C_BEGIN
typedef struct YGNodeList *YGNodeListRef;
YGNodeListRef YGNodeListNew(const uint32_t initialCapacity);
void YGNodeListFree(const YGNodeListRef list);
uint32_t YGNodeListCount(const YGNodeListRef list);
void YGNodeListAdd(YGNodeListRef *listp, const YGNodeRef node);
void YGNodeListInsert(YGNodeListRef *listp, const YGNodeRef node, const uint32_t index);
YGNodeRef YGNodeListRemove(const YGNodeListRef list, const uint32_t index);
YGNodeRef YGNodeListDelete(const YGNodeListRef list, const YGNodeRef node);
YGNodeRef YGNodeListGet(const YGNodeListRef list, const uint32_t index);
YG_EXTERN_C_END

File diff suppressed because it is too large Load Diff

181
CSSLayout/Yoga.h Normal file
View File

@@ -0,0 +1,181 @@
/**
* 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.
*/
#pragma once
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
// Not defined in MSVC++
#ifndef NAN
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
#define NAN (*(const float *) __nan)
#endif
#define YGUndefined NAN
#include "YGEnums.h"
#include "YGMacros.h"
YG_EXTERN_C_BEGIN
typedef struct YGSize {
float width;
float height;
} YGSize;
typedef struct YGNode *YGNodeRef;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode);
typedef void (*YGPrintFunc)(YGNodeRef node);
typedef int (*YGLogger)(YGLogLevel level, const char *format, va_list args);
typedef void *(*YGMalloc)(size_t size);
typedef void *(*YGCalloc)(size_t count, size_t size);
typedef void *(*YGRealloc)(void *ptr, size_t size);
typedef void (*YGFree)(void *ptr);
// YGNode
WIN_EXPORT YGNodeRef YGNodeNew(void);
WIN_EXPORT void YGNodeInit(const YGNodeRef node);
WIN_EXPORT void YGNodeFree(const YGNodeRef node);
WIN_EXPORT void YGNodeFreeRecursive(const YGNodeRef node);
WIN_EXPORT void YGNodeReset(const YGNodeRef node);
WIN_EXPORT int32_t YGNodeGetInstanceCount(void);
WIN_EXPORT void YGNodeInsertChild(const YGNodeRef node,
const YGNodeRef child,
const uint32_t index);
WIN_EXPORT void YGNodeRemoveChild(const YGNodeRef node, const YGNodeRef child);
WIN_EXPORT YGNodeRef YGNodeGetChild(const YGNodeRef node, const uint32_t index);
WIN_EXPORT uint32_t YGNodeChildCount(const YGNodeRef node);
WIN_EXPORT void YGNodeCalculateLayout(const YGNodeRef node,
const float availableWidth,
const float availableHeight,
const YGDirection parentDirection);
// Mark a node as dirty. Only valid for nodes with a custom measure function
// set.
// YG knows when to mark all other nodes as dirty but because nodes with
// measure functions
// depends on information not known to YG they must perform this dirty
// marking manually.
WIN_EXPORT void YGNodeMarkDirty(const YGNodeRef node);
WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node);
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool YGValueIsUndefined(const float value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
const YGMeasureMode heightMode,
const float height,
const YGMeasureMode lastWidthMode,
const float lastWidth,
const YGMeasureMode lastHeightMode,
const float lastHeight,
const float lastComputedWidth,
const float lastComputedHeight,
const float marginRow,
const float marginColumn);
WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode);
#define YG_NODE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeSet##name(const YGNodeRef node, type paramName); \
WIN_EXPORT type YGNodeGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
YG_NODE_PROPERTY(void *, Context, context);
YG_NODE_PROPERTY(YGMeasureFunc, MeasureFunc, measureFunc);
YG_NODE_PROPERTY(YGPrintFunc, PrintFunc, printFunc);
YG_NODE_PROPERTY(bool, HasNewLayout, hasNewLayout);
YG_NODE_STYLE_PROPERTY(YGDirection, Direction, direction);
YG_NODE_STYLE_PROPERTY(YGFlexDirection, FlexDirection, flexDirection);
YG_NODE_STYLE_PROPERTY(YGJustify, JustifyContent, justifyContent);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignContent, alignContent);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignItems, alignItems);
YG_NODE_STYLE_PROPERTY(YGAlign, AlignSelf, alignSelf);
YG_NODE_STYLE_PROPERTY(YGPositionType, PositionType, positionType);
YG_NODE_STYLE_PROPERTY(YGWrap, FlexWrap, flexWrap);
YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex);
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
YG_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
YG_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
YG_NODE_STYLE_PROPERTY(float, Width, width);
YG_NODE_STYLE_PROPERTY(float, Height, height);
YG_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
YG_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
YG_NODE_STYLE_PROPERTY(float, AspectRatio, aspectRatio);
YG_NODE_LAYOUT_PROPERTY(float, Left);
YG_NODE_LAYOUT_PROPERTY(float, Top);
YG_NODE_LAYOUT_PROPERTY(float, Right);
YG_NODE_LAYOUT_PROPERTY(float, Bottom);
YG_NODE_LAYOUT_PROPERTY(float, Width);
YG_NODE_LAYOUT_PROPERTY(float, Height);
YG_NODE_LAYOUT_PROPERTY(YGDirection, Direction);
WIN_EXPORT void YGSetLogger(YGLogger logger);
WIN_EXPORT void YGLog(YGLogLevel level, const char *message, ...);
WIN_EXPORT void YGSetExperimentalFeatureEnabled(YGExperimentalFeature feature, bool enabled);
WIN_EXPORT bool YGIsExperimentalFeatureEnabled(YGExperimentalFeature feature);
WIN_EXPORT void
YGSetMemoryFuncs(YGMalloc cssMalloc, YGCalloc cssCalloc, YGRealloc cssRealloc, YGFree cssFree);
YG_EXTERN_C_END

View File

@@ -20,19 +20,19 @@
- (void)testNodesAreDeallocedWithSingleView
{
XCTAssertEqual(0, CSSNodeGetInstanceCount());
XCTAssertEqual(0, YGNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view yg_setFlexBasis:1];
XCTAssertEqual(1, CSSNodeGetInstanceCount());
XCTAssertEqual(1, YGNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, CSSNodeGetInstanceCount());
XCTAssertEqual(0, YGNodeGetInstanceCount());
}
- (void)testNodesAreDeallocedCascade
{
XCTAssertEqual(0, CSSNodeGetInstanceCount());
XCTAssertEqual(0, YGNodeGetInstanceCount());
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
[view yg_setFlexBasis:1];
@@ -42,10 +42,10 @@
[subview yg_setFlexBasis:1];
[view addSubview:subview];
}
XCTAssertEqual(11, CSSNodeGetInstanceCount());
XCTAssertEqual(11, YGNodeGetInstanceCount());
view = nil;
XCTAssertEqual(0, CSSNodeGetInstanceCount());
XCTAssertEqual(0, YGNodeGetInstanceCount());
}
#endif

View File

@@ -8,9 +8,9 @@
*/
#import <UIKit/UIKit.h>
#import <CSSLayout/CSSLayout.h>
#import <CSSLayout/Yoga.h>
@interface UIView (CSSLayout)
@interface UIView (Yoga)
/**
The property that decides if we should include this view when calculating layout. Defaults to YES.

View File

@@ -11,21 +11,21 @@
#import <objc/runtime.h>
@interface CSSNodeBridge : NSObject
@property (nonatomic, assign, readonly) CSSNodeRef cnode;
@interface YGNodeBridge : NSObject
@property (nonatomic, assign, readonly) YGNodeRef cnode;
@end
@implementation CSSNodeBridge
@implementation YGNodeBridge
+ (void)initialize
{
CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
YogaSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
}
- (instancetype)init
{
if ([super init]) {
_cnode = CSSNodeNew();
_cnode = YGNodeNew();
}
return self;
@@ -33,11 +33,11 @@
- (void)dealloc
{
CSSNodeFree(_cnode);
YGNodeFree(_cnode);
}
@end
@implementation UIView (CSSLayout)
@implementation UIView (Yoga)
- (BOOL)yg_usesYoga
{
@@ -53,7 +53,7 @@
- (NSUInteger)yg_numberOfChildren
{
return CSSNodeChildCount([self cssNode]);
return YGNodeChildCount([self ygNode]);
}
#pragma mark - Setters
@@ -78,120 +78,120 @@
- (void)yg_setDirection:(YGDirection)direction
{
CSSNodeStyleSetDirection([self cssNode], direction);
YGNodeStyleSetDirection([self ygNode], direction);
}
- (void)yg_setFlexDirection:(YGFlexDirection)flexDirection
{
CSSNodeStyleSetFlexDirection([self cssNode], flexDirection);
YGNodeStyleSetFlexDirection([self ygNode], flexDirection);
}
- (void)yg_setJustifyContent:(YGJustify)justifyContent
{
CSSNodeStyleSetJustifyContent([self cssNode], justifyContent);
YGNodeStyleSetJustifyContent([self ygNode], justifyContent);
}
- (void)yg_setAlignContent:(YGAlign)alignContent
{
CSSNodeStyleSetAlignContent([self cssNode], alignContent);
YGNodeStyleSetAlignContent([self ygNode], alignContent);
}
- (void)yg_setAlignItems:(YGAlign)alignItems
{
CSSNodeStyleSetAlignItems([self cssNode], alignItems);
YGNodeStyleSetAlignItems([self ygNode], alignItems);
}
- (void)yg_setAlignSelf:(YGAlign)alignSelf
{
CSSNodeStyleSetAlignSelf([self cssNode], alignSelf);
YGNodeStyleSetAlignSelf([self ygNode], alignSelf);
}
- (void)yg_setPositionType:(YGPositionType)positionType
{
CSSNodeStyleSetPositionType([self cssNode], positionType);
YGNodeStyleSetPositionType([self ygNode], positionType);
}
- (void)yg_setFlexWrap:(YGWrap)flexWrap
{
CSSNodeStyleSetFlexWrap([self cssNode], flexWrap);
YGNodeStyleSetFlexWrap([self ygNode], flexWrap);
}
- (void)yg_setFlexGrow:(CGFloat)flexGrow
{
CSSNodeStyleSetFlexGrow([self cssNode], flexGrow);
YGNodeStyleSetFlexGrow([self ygNode], flexGrow);
}
- (void)yg_setFlexShrink:(CGFloat)flexShrink
{
CSSNodeStyleSetFlexShrink([self cssNode], flexShrink);
YGNodeStyleSetFlexShrink([self ygNode], flexShrink);
}
- (void)yg_setFlexBasis:(CGFloat)flexBasis
{
CSSNodeStyleSetFlexBasis([self cssNode], flexBasis);
YGNodeStyleSetFlexBasis([self ygNode], flexBasis);
}
- (void)yg_setPosition:(CGFloat)position forEdge:(YGEdge)edge
{
CSSNodeStyleSetPosition([self cssNode], edge, position);
YGNodeStyleSetPosition([self ygNode], edge, position);
}
- (void)yg_setMargin:(CGFloat)margin forEdge:(YGEdge)edge
{
CSSNodeStyleSetMargin([self cssNode], edge, margin);
YGNodeStyleSetMargin([self ygNode], edge, margin);
}
- (void)yg_setPadding:(CGFloat)padding forEdge:(YGEdge)edge
{
CSSNodeStyleSetPadding([self cssNode], edge, padding);
YGNodeStyleSetPadding([self ygNode], edge, padding);
}
- (void)yg_setWidth:(CGFloat)width
{
CSSNodeStyleSetWidth([self cssNode], width);
YGNodeStyleSetWidth([self ygNode], width);
}
- (void)yg_setHeight:(CGFloat)height
{
CSSNodeStyleSetHeight([self cssNode], height);
YGNodeStyleSetHeight([self ygNode], height);
}
- (void)yg_setMinWidth:(CGFloat)minWidth
{
CSSNodeStyleSetMinWidth([self cssNode], minWidth);
YGNodeStyleSetMinWidth([self ygNode], minWidth);
}
- (void)yg_setMinHeight:(CGFloat)minHeight
{
CSSNodeStyleSetMinHeight([self cssNode], minHeight);
YGNodeStyleSetMinHeight([self ygNode], minHeight);
}
- (void)yg_setMaxWidth:(CGFloat)maxWidth
{
CSSNodeStyleSetMaxWidth([self cssNode], maxWidth);
YGNodeStyleSetMaxWidth([self ygNode], maxWidth);
}
- (void)yg_setMaxHeight:(CGFloat)maxHeight
{
CSSNodeStyleSetMaxHeight([self cssNode], maxHeight);
YGNodeStyleSetMaxHeight([self ygNode], maxHeight);
}
- (void)yg_setAspectRatio:(CGFloat)aspectRatio
{
CSSNodeStyleSetAspectRatio([self cssNode], aspectRatio);
YGNodeStyleSetAspectRatio([self ygNode], aspectRatio);
}
#pragma mark - Layout and Sizing
- (YGDirection)yg_resolvedDirection
{
return CSSNodeLayoutGetDirection([self cssNode]);
return YGNodeLayoutGetDirection([self ygNode]);
}
- (void)yg_applyLayout
{
[self calculateLayoutWithSize:self.bounds.size];
CSSApplyLayoutToViewHierarchy(self);
YGApplyLayoutToViewHierarchy(self);
}
- (CGSize)yg_intrinsicSize
@@ -205,13 +205,13 @@
#pragma mark - Private
- (CSSNodeRef)cssNode
- (YGNodeRef)ygNode
{
CSSNodeBridge *node = objc_getAssociatedObject(self, @selector(cssNode));
YGNodeBridge *node = objc_getAssociatedObject(self, @selector(ygNode));
if (!node) {
node = [CSSNodeBridge new];
CSSNodeSetContext(node.cnode, (__bridge void *) self);
objc_setAssociatedObject(self, @selector(cssNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
node = [YGNodeBridge new];
YGNodeSetContext(node.cnode, (__bridge void *) self);
objc_setAssociatedObject(self, @selector(ygNode), node, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return node.cnode;
@@ -219,26 +219,26 @@
- (CGSize)calculateLayoutWithSize:(CGSize)size
{
NSAssert([NSThread isMainThread], @"CSS Layout calculation must be done on main.");
NSAssert([self yg_usesYoga], @"CSS Layout is not enabled for this view.");
NSAssert([NSThread isMainThread], @"YG Layout calculation must be done on main.");
NSAssert([self yg_usesYoga], @"YG Layout is not enabled for this view.");
CSSAttachNodesFromViewHierachy(self);
YGAttachNodesFromViewHierachy(self);
const CSSNodeRef node = [self cssNode];
CSSNodeCalculateLayout(
const YGNodeRef node = [self ygNode];
YGNodeCalculateLayout(
node,
size.width,
size.height,
CSSNodeStyleGetDirection(node));
YGNodeStyleGetDirection(node));
return (CGSize) {
.width = CSSNodeLayoutGetWidth(node),
.height = CSSNodeLayoutGetHeight(node),
.width = YGNodeLayoutGetWidth(node),
.height = YGNodeLayoutGetHeight(node),
};
}
static CSSSize CSSMeasureView(
CSSNodeRef node,
static YGSize YGMeasureView(
YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
@@ -247,19 +247,19 @@ static CSSSize CSSMeasureView(
const CGFloat constrainedWidth = (widthMode == YGMeasureModeUndefined) ? CGFLOAT_MAX : width;
const CGFloat constrainedHeight = (heightMode == YGMeasureModeUndefined) ? CGFLOAT_MAX: height;
UIView *view = (__bridge UIView*) CSSNodeGetContext(node);
UIView *view = (__bridge UIView*) YGNodeGetContext(node);
const CGSize sizeThatFits = [view sizeThatFits:(CGSize) {
.width = constrainedWidth,
.height = constrainedHeight,
}];
return (CSSSize) {
.width = CSSSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
.height = CSSSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
return (YGSize) {
.width = YGSanitizeMeasurement(constrainedWidth, sizeThatFits.width, widthMode),
.height = YGSanitizeMeasurement(constrainedHeight, sizeThatFits.height, heightMode),
};
}
static CGFloat CSSSanitizeMeasurement(
static CGFloat YGSanitizeMeasurement(
CGFloat constrainedSize,
CGFloat measuredSize,
YGMeasureMode measureMode)
@@ -276,15 +276,15 @@ static CGFloat CSSSanitizeMeasurement(
return result;
}
static void CSSAttachNodesFromViewHierachy(UIView *view) {
CSSNodeRef node = [view cssNode];
static void YGAttachNodesFromViewHierachy(UIView *view) {
YGNodeRef node = [view ygNode];
// Only leaf nodes should have a measure function
if (![view yg_usesYoga] || view.subviews.count == 0) {
CSSNodeSetMeasureFunc(node, CSSMeasureView);
CSSRemoveAllChildren(node);
YGNodeSetMeasureFunc(node, YGMeasureView);
YGRemoveAllChildren(node);
} else {
CSSNodeSetMeasureFunc(node, NULL);
YGNodeSetMeasureFunc(node, NULL);
// Create a list of all the subviews that we are going to use for layout.
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
@@ -295,11 +295,11 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) {
}
BOOL shouldReconstructChildList = NO;
if (CSSNodeChildCount(node) != subviewsToInclude.count) {
if (YGNodeChildCount(node) != subviewsToInclude.count) {
shouldReconstructChildList = YES;
} else {
for (int i = 0; i < subviewsToInclude.count; i++) {
if (CSSNodeGetChild(node, i) != [subviewsToInclude[i] cssNode]) {
if (YGNodeGetChild(node, i) != [subviewsToInclude[i] ygNode]) {
shouldReconstructChildList = YES;
break;
}
@@ -307,29 +307,29 @@ static void CSSAttachNodesFromViewHierachy(UIView *view) {
}
if (shouldReconstructChildList) {
CSSRemoveAllChildren(node);
YGRemoveAllChildren(node);
for (int i = 0 ; i < subviewsToInclude.count; i++) {
UIView *const subview = subviewsToInclude[i];
CSSNodeInsertChild(node, [subview cssNode], i);
CSSAttachNodesFromViewHierachy(subview);
YGNodeInsertChild(node, [subview ygNode], i);
YGAttachNodesFromViewHierachy(subview);
}
}
}
}
static void CSSRemoveAllChildren(const CSSNodeRef node)
static void YGRemoveAllChildren(const YGNodeRef node)
{
if (node == NULL) {
return;
}
while (CSSNodeChildCount(node) > 0) {
CSSNodeRemoveChild(node, CSSNodeGetChild(node, CSSNodeChildCount(node) - 1));
while (YGNodeChildCount(node) > 0) {
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeChildCount(node) - 1));
}
}
static CGFloat CSSRoundPixelValue(CGFloat value)
static CGFloat YGRoundPixelValue(CGFloat value)
{
static CGFloat scale;
static dispatch_once_t onceToken;
@@ -340,38 +340,38 @@ static CGFloat CSSRoundPixelValue(CGFloat value)
return round(value * scale) / scale;
}
static void CSSApplyLayoutToViewHierarchy(UIView *view) {
static void YGApplyLayoutToViewHierarchy(UIView *view) {
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
if (![view yg_includeInLayout]) {
return;
}
CSSNodeRef node = [view cssNode];
YGNodeRef node = [view ygNode];
const CGPoint topLeft = {
CSSNodeLayoutGetLeft(node),
CSSNodeLayoutGetTop(node),
YGNodeLayoutGetLeft(node),
YGNodeLayoutGetTop(node),
};
const CGPoint bottomRight = {
topLeft.x + CSSNodeLayoutGetWidth(node),
topLeft.y + CSSNodeLayoutGetHeight(node),
topLeft.x + YGNodeLayoutGetWidth(node),
topLeft.y + YGNodeLayoutGetHeight(node),
};
view.frame = (CGRect) {
.origin = {
.x = CSSRoundPixelValue(topLeft.x),
.y = CSSRoundPixelValue(topLeft.y),
.x = YGRoundPixelValue(topLeft.x),
.y = YGRoundPixelValue(topLeft.y),
},
.size = {
.width = CSSRoundPixelValue(bottomRight.x) - CSSRoundPixelValue(topLeft.x),
.height = CSSRoundPixelValue(bottomRight.y) - CSSRoundPixelValue(topLeft.y),
.width = YGRoundPixelValue(bottomRight.x) - YGRoundPixelValue(topLeft.x),
.height = YGRoundPixelValue(bottomRight.y) - YGRoundPixelValue(topLeft.y),
},
};
const BOOL isLeaf = ![view yg_usesYoga] || view.subviews.count == 0;
if (!isLeaf) {
for (NSUInteger i = 0; i < view.subviews.count; i++) {
CSSApplyLayoutToViewHierarchy(view.subviews[i]);
YGApplyLayoutToViewHierarchy(view.subviews[i]);
}
}
}

View File

@@ -9,14 +9,14 @@
#include "YGBenchmark.h"
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
static CSSSize _measure(CSSNodeRef node,
static YGSize _measure(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
return (CSSSize){
return (YGSize){
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : width,
};
@@ -25,94 +25,94 @@ static CSSSize _measure(CSSNodeRef node,
YGBENCHMARKS({
YGBENCHMARK("Stack with flex", {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
for (uint32_t i = 0; i < 10; i++) {
const CSSNodeRef child = CSSNodeNew();
CSSNodeSetMeasureFunc(child, _measure);
CSSNodeStyleSetFlex(child, 1);
CSSNodeInsertChild(root, child, 0);
const YGNodeRef child = YGNodeNew();
YGNodeSetMeasureFunc(child, _measure);
YGNodeStyleSetFlex(child, 1);
YGNodeInsertChild(root, child, 0);
}
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
CSSNodeFreeRecursive(root);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
YGBENCHMARK("Align stretch in undefined axis", {
const CSSNodeRef root = CSSNodeNew();
const YGNodeRef root = YGNodeNew();
for (uint32_t i = 0; i < 10; i++) {
const CSSNodeRef child = CSSNodeNew();
CSSNodeStyleSetHeight(child, 20);
CSSNodeSetMeasureFunc(child, _measure);
CSSNodeInsertChild(root, child, 0);
const YGNodeRef child = YGNodeNew();
YGNodeStyleSetHeight(child, 20);
YGNodeSetMeasureFunc(child, _measure);
YGNodeInsertChild(root, child, 0);
}
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
CSSNodeFreeRecursive(root);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
YGBENCHMARK("Nested flex", {
const CSSNodeRef root = CSSNodeNew();
const YGNodeRef root = YGNodeNew();
for (uint32_t i = 0; i < 10; i++) {
const CSSNodeRef child = CSSNodeNew();
CSSNodeStyleSetFlex(child, 1);
CSSNodeInsertChild(root, child, 0);
const YGNodeRef child = YGNodeNew();
YGNodeStyleSetFlex(child, 1);
YGNodeInsertChild(root, child, 0);
for (uint32_t ii = 0; ii < 10; ii++) {
const CSSNodeRef grandChild = CSSNodeNew();
CSSNodeSetMeasureFunc(grandChild, _measure);
CSSNodeStyleSetFlex(grandChild, 1);
CSSNodeInsertChild(child, grandChild, 0);
const YGNodeRef grandChild = YGNodeNew();
YGNodeSetMeasureFunc(grandChild, _measure);
YGNodeStyleSetFlex(grandChild, 1);
YGNodeInsertChild(child, grandChild, 0);
}
}
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
CSSNodeFreeRecursive(root);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
YGBENCHMARK("Huge nested layout", {
const CSSNodeRef root = CSSNodeNew();
const YGNodeRef root = YGNodeNew();
for (uint32_t i = 0; i < 10; i++) {
const CSSNodeRef child = CSSNodeNew();
CSSNodeStyleSetFlexGrow(child, 1);
CSSNodeStyleSetWidth(child, 10);
CSSNodeStyleSetHeight(child, 10);
CSSNodeInsertChild(root, child, 0);
const YGNodeRef child = YGNodeNew();
YGNodeStyleSetFlexGrow(child, 1);
YGNodeStyleSetWidth(child, 10);
YGNodeStyleSetHeight(child, 10);
YGNodeInsertChild(root, child, 0);
for (uint32_t ii = 0; ii < 10; ii++) {
const CSSNodeRef grandChild = CSSNodeNew();
CSSNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow);
CSSNodeStyleSetFlexGrow(grandChild, 1);
CSSNodeStyleSetWidth(grandChild, 10);
CSSNodeStyleSetHeight(grandChild, 10);
CSSNodeInsertChild(child, grandChild, 0);
const YGNodeRef grandChild = YGNodeNew();
YGNodeStyleSetFlexDirection(grandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandChild, 1);
YGNodeStyleSetWidth(grandChild, 10);
YGNodeStyleSetHeight(grandChild, 10);
YGNodeInsertChild(child, grandChild, 0);
for (uint32_t iii = 0; iii < 10; iii++) {
const CSSNodeRef grandGrandChild = CSSNodeNew();
CSSNodeStyleSetFlexGrow(grandGrandChild, 1);
CSSNodeStyleSetWidth(grandGrandChild, 10);
CSSNodeStyleSetHeight(grandGrandChild, 10);
CSSNodeInsertChild(grandChild, grandGrandChild, 0);
const YGNodeRef grandGrandChild = YGNodeNew();
YGNodeStyleSetFlexGrow(grandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandChild, 10);
YGNodeInsertChild(grandChild, grandGrandChild, 0);
for (uint32_t iii = 0; iii < 10; iii++) {
const CSSNodeRef grandGrandGrandChild = CSSNodeNew();
CSSNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
CSSNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
CSSNodeStyleSetWidth(grandGrandGrandChild, 10);
CSSNodeStyleSetHeight(grandGrandGrandChild, 10);
CSSNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0);
const YGNodeRef grandGrandGrandChild = YGNodeNew();
YGNodeStyleSetFlexDirection(grandGrandGrandChild, YGFlexDirectionRow);
YGNodeStyleSetFlexGrow(grandGrandGrandChild, 1);
YGNodeStyleSetWidth(grandGrandGrandChild, 10);
YGNodeStyleSetHeight(grandGrandGrandChild, 10);
YGNodeInsertChild(grandGrandChild, grandGrandGrandChild, 0);
}
}
}
}
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
CSSNodeFreeRecursive(root);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeFreeRecursive(root);
});
});

View File

@@ -25,261 +25,261 @@ namespace Facebook.Yoga
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func);
[DllImport(DllName)]
public static extern IntPtr CSSNodeNew();
public static extern IntPtr YGNodeNew();
[DllImport(DllName)]
public static extern void CSSNodeInit(IntPtr cssNode);
public static extern void YGNodeInit(IntPtr cssNode);
[DllImport(DllName)]
public static extern void CSSNodeFree(IntPtr cssNode);
public static extern void YGNodeFree(IntPtr cssNode);
[DllImport(DllName)]
public static extern void CSSNodeReset(IntPtr cssNode);
public static extern void YGNodeReset(IntPtr cssNode);
[DllImport(DllName)]
public static extern int CSSNodeGetInstanceCount();
public static extern int YGNodeGetInstanceCount();
[DllImport(DllName)]
public static extern void CSSLayoutSetExperimentalFeatureEnabled(
public static extern void YGSetExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
bool enabled);
[DllImport(DllName)]
public static extern bool CSSLayoutIsExperimentalFeatureEnabled(
public static extern bool YGIsExperimentalFeatureEnabled(
YogaExperimentalFeature feature);
[DllImport(DllName)]
public static extern void CSSNodeInsertChild(IntPtr node, IntPtr child, uint index);
public static extern void YGNodeInsertChild(IntPtr node, IntPtr child, uint index);
[DllImport(DllName)]
public static extern void CSSNodeRemoveChild(IntPtr node, IntPtr child);
public static extern void YGNodeRemoveChild(IntPtr node, IntPtr child);
[DllImport(DllName)]
public static extern IntPtr CSSNodeGetChild(IntPtr node, uint index);
public static extern IntPtr YGNodeGetChild(IntPtr node, uint index);
[DllImport(DllName)]
public static extern uint CSSNodeChildCount(IntPtr node);
public static extern uint YGNodeChildCount(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeCalculateLayout(IntPtr node,
public static extern void YGNodeCalculateLayout(IntPtr node,
float availableWidth,
float availableHeight,
YogaDirection parentDirection);
[DllImport(DllName)]
public static extern void CSSNodeMarkDirty(IntPtr node);
public static extern void YGNodeMarkDirty(IntPtr node);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool CSSNodeIsDirty(IntPtr node);
public static extern bool YGNodeIsDirty(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodePrint(IntPtr node, YogaPrintOptions options);
public static extern void YGNodePrint(IntPtr node, YogaPrintOptions options);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool CSSValueIsUndefined(float value);
public static extern bool YGValueIsUndefined(float value);
[DllImport(DllName)]
public static extern void CSSNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
public static extern void YGNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
#region CSS_NODE_PROPERTY
#region YG_NODE_PROPERTY
[DllImport(DllName)]
public static extern void CSSNodeSetContext(IntPtr node, IntPtr context);
public static extern void YGNodeSetContext(IntPtr node, IntPtr context);
[DllImport(DllName)]
public static extern IntPtr CSSNodeGetContext(IntPtr node);
public static extern IntPtr YGNodeGetContext(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeSetMeasureFunc(
public static extern void YGNodeSetMeasureFunc(
IntPtr node,
[MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.FunctionPtr)]
public static extern YogaMeasureFunc CSSNodeGetMeasureFunc(IntPtr node);
public static extern YogaMeasureFunc YGNodeGetMeasureFunc(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
public static extern void YGNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool CSSNodeGetHasNewLayout(IntPtr node);
public static extern bool YGNodeGetHasNewLayout(IntPtr node);
#endregion
#region CSS_NODE_STYLE_PROPERTY
#region YG_NODE_STYLE_PROPERTY
[DllImport(DllName)]
public static extern void CSSNodeStyleSetDirection(IntPtr node, YogaDirection direction);
public static extern void YGNodeStyleSetDirection(IntPtr node, YogaDirection direction);
[DllImport(DllName)]
public static extern YogaDirection CSSNodeStyleGetDirection(IntPtr node);
public static extern YogaDirection YGNodeStyleGetDirection(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection);
public static extern void YGNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection);
[DllImport(DllName)]
public static extern YogaFlexDirection CSSNodeStyleGetFlexDirection(IntPtr node);
public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent);
public static extern void YGNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent);
[DllImport(DllName)]
public static extern YogaJustify CSSNodeStyleGetJustifyContent(IntPtr node);
public static extern YogaJustify YGNodeStyleGetJustifyContent(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent);
public static extern void YGNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent);
[DllImport(DllName)]
public static extern YogaAlign CSSNodeStyleGetAlignContent(IntPtr node);
public static extern YogaAlign YGNodeStyleGetAlignContent(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems);
public static extern void YGNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems);
[DllImport(DllName)]
public static extern YogaAlign CSSNodeStyleGetAlignItems(IntPtr node);
public static extern YogaAlign YGNodeStyleGetAlignItems(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf);
public static extern void YGNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf);
[DllImport(DllName)]
public static extern YogaAlign CSSNodeStyleGetAlignSelf(IntPtr node);
public static extern YogaAlign YGNodeStyleGetAlignSelf(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType);
public static extern void YGNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType);
[DllImport(DllName)]
public static extern YogaPositionType CSSNodeStyleGetPositionType(IntPtr node);
public static extern YogaPositionType YGNodeStyleGetPositionType(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap);
public static extern void YGNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap);
[DllImport(DllName)]
public static extern YogaWrap CSSNodeStyleGetFlexWrap(IntPtr node);
public static extern YogaWrap YGNodeStyleGetFlexWrap(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap);
public static extern void YGNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap);
[DllImport(DllName)]
public static extern YogaOverflow CSSNodeStyleGetOverflow(IntPtr node);
public static extern YogaOverflow YGNodeStyleGetOverflow(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetFlex(IntPtr node, float flex);
public static extern void YGNodeStyleSetFlex(IntPtr node, float flex);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetFlexGrow(IntPtr node, float flexGrow);
public static extern void YGNodeStyleSetFlexGrow(IntPtr node, float flexGrow);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetFlexGrow(IntPtr node);
public static extern float YGNodeStyleGetFlexGrow(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetFlexShrink(IntPtr node, float flexShrink);
public static extern void YGNodeStyleSetFlexShrink(IntPtr node, float flexShrink);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetFlexShrink(IntPtr node);
public static extern float YGNodeStyleGetFlexShrink(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetFlexBasis(IntPtr node, float flexBasis);
public static extern void YGNodeStyleSetFlexBasis(IntPtr node, float flexBasis);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetFlexBasis(IntPtr node);
public static extern float YGNodeStyleGetFlexBasis(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetWidth(IntPtr node, float width);
public static extern void YGNodeStyleSetWidth(IntPtr node, float width);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetWidth(IntPtr node);
public static extern float YGNodeStyleGetWidth(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetHeight(IntPtr node, float height);
public static extern void YGNodeStyleSetHeight(IntPtr node, float height);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetHeight(IntPtr node);
public static extern float YGNodeStyleGetHeight(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetMinWidth(IntPtr node, float minWidth);
public static extern void YGNodeStyleSetMinWidth(IntPtr node, float minWidth);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetMinWidth(IntPtr node);
public static extern float YGNodeStyleGetMinWidth(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetMinHeight(IntPtr node, float minHeight);
public static extern void YGNodeStyleSetMinHeight(IntPtr node, float minHeight);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetMinHeight(IntPtr node);
public static extern float YGNodeStyleGetMinHeight(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetMaxWidth(IntPtr node, float maxWidth);
public static extern void YGNodeStyleSetMaxWidth(IntPtr node, float maxWidth);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetMaxWidth(IntPtr node);
public static extern float YGNodeStyleGetMaxWidth(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetMaxHeight(IntPtr node, float maxHeight);
public static extern void YGNodeStyleSetMaxHeight(IntPtr node, float maxHeight);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetMaxHeight(IntPtr node);
public static extern float YGNodeStyleGetMaxHeight(IntPtr node);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetAspectRatio(IntPtr node, float aspectRatio);
public static extern void YGNodeStyleSetAspectRatio(IntPtr node, float aspectRatio);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetAspectRatio(IntPtr node);
public static extern float YGNodeStyleGetAspectRatio(IntPtr node);
#endregion
#region CSS_NODE_STYLE_EDGE_PROPERTY
#region YG_NODE_STYLE_EDGE_PROPERTY
[DllImport(DllName)]
public static extern void CSSNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position);
public static extern void YGNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetPosition(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetPosition(IntPtr node, YogaEdge edge);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin);
public static extern void YGNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetMargin(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetMargin(IntPtr node, YogaEdge edge);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding);
public static extern void YGNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetPadding(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetPadding(IntPtr node, YogaEdge edge);
[DllImport(DllName)]
public static extern void CSSNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border);
public static extern void YGNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border);
[DllImport(DllName)]
public static extern float CSSNodeStyleGetBorder(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetBorder(IntPtr node, YogaEdge edge);
#endregion
#region CSS_NODE_LAYOUT_PROPERTY
#region YG_NODE_LAYOUT_PROPERTY
[DllImport(DllName)]
public static extern float CSSNodeLayoutGetLeft(IntPtr node);
public static extern float YGNodeLayoutGetLeft(IntPtr node);
[DllImport(DllName)]
public static extern float CSSNodeLayoutGetTop(IntPtr node);
public static extern float YGNodeLayoutGetTop(IntPtr node);
[DllImport(DllName)]
public static extern float CSSNodeLayoutGetRight(IntPtr node);
public static extern float YGNodeLayoutGetRight(IntPtr node);
[DllImport(DllName)]
public static extern float CSSNodeLayoutGetBottom(IntPtr node);
public static extern float YGNodeLayoutGetBottom(IntPtr node);
[DllImport(DllName)]
public static extern float CSSNodeLayoutGetWidth(IntPtr node);
public static extern float YGNodeLayoutGetWidth(IntPtr node);
[DllImport(DllName)]
public static extern float CSSNodeLayoutGetHeight(IntPtr node);
public static extern float YGNodeLayoutGetHeight(IntPtr node);
[DllImport(DllName)]
public static extern YogaDirection CSSNodeLayoutGetDirection(IntPtr node);
public static extern YogaDirection YGNodeLayoutGetDirection(IntPtr node);
#endregion
}

View File

@@ -17,19 +17,19 @@ namespace Facebook.Yoga
{
public partial class YogaNode : IEnumerable<YogaNode>
{
private IntPtr _cssNode;
private IntPtr _ygNode;
private WeakReference _parent;
private List<YogaNode> _children;
private MeasureFunction _measureFunction;
private YogaMeasureFunc _cssMeasureFunc;
private YogaMeasureFunc _ygMeasureFunc;
private object _data;
public YogaNode()
{
YogaLogger.Initialize();
_cssNode = Native.CSSNodeNew();
if (_cssNode == IntPtr.Zero)
_ygNode = Native.YGNodeNew();
if (_ygNode == IntPtr.Zero)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
@@ -37,7 +37,7 @@ namespace Facebook.Yoga
~YogaNode()
{
Native.CSSNodeFree(_cssNode);
Native.YGNodeFree(_ygNode);
}
public void Reset()
@@ -45,33 +45,33 @@ namespace Facebook.Yoga
_measureFunction = null;
_data = null;
Native.CSSNodeReset(_cssNode);
Native.YGNodeReset(_ygNode);
}
public bool IsDirty
{
get
{
return Native.CSSNodeIsDirty(_cssNode);
return Native.YGNodeIsDirty(_ygNode);
}
}
public virtual void MarkDirty()
{
Native.CSSNodeMarkDirty(_cssNode);
Native.YGNodeMarkDirty(_ygNode);
}
public bool HasNewLayout
{
get
{
return Native.CSSNodeGetHasNewLayout(_cssNode);
return Native.YGNodeGetHasNewLayout(_ygNode);
}
}
public void MarkHasNewLayout()
{
Native.CSSNodeSetHasNewLayout(_cssNode, true);
Native.YGNodeSetHasNewLayout(_ygNode, true);
}
public YogaNode Parent
@@ -92,19 +92,19 @@ namespace Facebook.Yoga
public void CopyStyle(YogaNode srcNode)
{
Native.CSSNodeCopyStyle(_cssNode, srcNode._cssNode);
Native.YGNodeCopyStyle(_ygNode, srcNode._ygNode);
}
public YogaDirection StyleDirection
{
get
{
return Native.CSSNodeStyleGetDirection(_cssNode);
return Native.YGNodeStyleGetDirection(_ygNode);
}
set
{
Native.CSSNodeStyleSetDirection(_cssNode, value);
Native.YGNodeStyleSetDirection(_ygNode, value);
}
}
@@ -112,12 +112,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetFlexDirection(_cssNode);
return Native.YGNodeStyleGetFlexDirection(_ygNode);
}
set
{
Native.CSSNodeStyleSetFlexDirection(_cssNode, value);
Native.YGNodeStyleSetFlexDirection(_ygNode, value);
}
}
@@ -125,12 +125,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetJustifyContent(_cssNode);
return Native.YGNodeStyleGetJustifyContent(_ygNode);
}
set
{
Native.CSSNodeStyleSetJustifyContent(_cssNode, value);
Native.YGNodeStyleSetJustifyContent(_ygNode, value);
}
}
@@ -138,12 +138,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetAlignItems(_cssNode);
return Native.YGNodeStyleGetAlignItems(_ygNode);
}
set
{
Native.CSSNodeStyleSetAlignItems(_cssNode, value);
Native.YGNodeStyleSetAlignItems(_ygNode, value);
}
}
@@ -151,12 +151,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetAlignSelf(_cssNode);
return Native.YGNodeStyleGetAlignSelf(_ygNode);
}
set
{
Native.CSSNodeStyleSetAlignSelf(_cssNode, value);
Native.YGNodeStyleSetAlignSelf(_ygNode, value);
}
}
@@ -164,12 +164,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetAlignContent(_cssNode);
return Native.YGNodeStyleGetAlignContent(_ygNode);
}
set
{
Native.CSSNodeStyleSetAlignContent(_cssNode, value);
Native.YGNodeStyleSetAlignContent(_ygNode, value);
}
}
@@ -177,12 +177,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetPositionType(_cssNode);
return Native.YGNodeStyleGetPositionType(_ygNode);
}
set
{
Native.CSSNodeStyleSetPositionType(_cssNode, value);
Native.YGNodeStyleSetPositionType(_ygNode, value);
}
}
@@ -190,12 +190,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetFlexWrap(_cssNode);
return Native.YGNodeStyleGetFlexWrap(_ygNode);
}
set
{
Native.CSSNodeStyleSetFlexWrap(_cssNode, value);
Native.YGNodeStyleSetFlexWrap(_ygNode, value);
}
}
@@ -203,7 +203,7 @@ namespace Facebook.Yoga
{
set
{
Native.CSSNodeStyleSetFlex(_cssNode, value);
Native.YGNodeStyleSetFlex(_ygNode, value);
}
}
@@ -211,12 +211,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetFlexGrow(_cssNode);
return Native.YGNodeStyleGetFlexGrow(_ygNode);
}
set
{
Native.CSSNodeStyleSetFlexGrow(_cssNode, value);
Native.YGNodeStyleSetFlexGrow(_ygNode, value);
}
}
@@ -224,12 +224,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetFlexShrink(_cssNode);
return Native.YGNodeStyleGetFlexShrink(_ygNode);
}
set
{
Native.CSSNodeStyleSetFlexShrink(_cssNode, value);
Native.YGNodeStyleSetFlexShrink(_ygNode, value);
}
}
@@ -237,65 +237,65 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetFlexBasis(_cssNode);
return Native.YGNodeStyleGetFlexBasis(_ygNode);
}
set
{
Native.CSSNodeStyleSetFlexBasis(_cssNode, value);
Native.YGNodeStyleSetFlexBasis(_ygNode, value);
}
}
public float GetMargin(YogaEdge edge)
{
return Native.CSSNodeStyleGetMargin(_cssNode, edge);
return Native.YGNodeStyleGetMargin(_ygNode, edge);
}
public void SetMargin(YogaEdge edge, float value)
{
Native.CSSNodeStyleSetMargin(_cssNode, edge, value);
Native.YGNodeStyleSetMargin(_ygNode, edge, value);
}
public float GetPadding(YogaEdge edge)
{
return Native.CSSNodeStyleGetPadding(_cssNode, edge);
return Native.YGNodeStyleGetPadding(_ygNode, edge);
}
public void SetPadding(YogaEdge edge, float padding)
{
Native.CSSNodeStyleSetPadding(_cssNode, edge, padding);
Native.YGNodeStyleSetPadding(_ygNode, edge, padding);
}
public float GetBorder(YogaEdge edge)
{
return Native.CSSNodeStyleGetBorder(_cssNode, edge);
return Native.YGNodeStyleGetBorder(_ygNode, edge);
}
public void SetBorder(YogaEdge edge, float border)
{
Native.CSSNodeStyleSetBorder(_cssNode, edge, border);
Native.YGNodeStyleSetBorder(_ygNode, edge, border);
}
public float GetPosition(YogaEdge edge)
{
return Native.CSSNodeStyleGetPosition(_cssNode, edge);
return Native.YGNodeStyleGetPosition(_ygNode, edge);
}
public void SetPosition(YogaEdge edge, float position)
{
Native.CSSNodeStyleSetPosition(_cssNode, edge, position);
Native.YGNodeStyleSetPosition(_ygNode, edge, position);
}
public float Width
{
get
{
return Native.CSSNodeStyleGetWidth(_cssNode);
return Native.YGNodeStyleGetWidth(_ygNode);
}
set
{
Native.CSSNodeStyleSetWidth(_cssNode, value);
Native.YGNodeStyleSetWidth(_ygNode, value);
}
}
@@ -303,12 +303,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetHeight(_cssNode);
return Native.YGNodeStyleGetHeight(_ygNode);
}
set
{
Native.CSSNodeStyleSetHeight(_cssNode, value);
Native.YGNodeStyleSetHeight(_ygNode, value);
}
}
@@ -316,12 +316,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetMaxWidth(_cssNode);
return Native.YGNodeStyleGetMaxWidth(_ygNode);
}
set
{
Native.CSSNodeStyleSetMaxWidth(_cssNode, value);
Native.YGNodeStyleSetMaxWidth(_ygNode, value);
}
}
@@ -329,12 +329,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetMaxHeight(_cssNode);
return Native.YGNodeStyleGetMaxHeight(_ygNode);
}
set
{
Native.CSSNodeStyleSetMaxHeight(_cssNode, value);
Native.YGNodeStyleSetMaxHeight(_ygNode, value);
}
}
@@ -342,12 +342,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetMinWidth(_cssNode);
return Native.YGNodeStyleGetMinWidth(_ygNode);
}
set
{
Native.CSSNodeStyleSetMinWidth(_cssNode, value);
Native.YGNodeStyleSetMinWidth(_ygNode, value);
}
}
@@ -355,12 +355,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetMinHeight(_cssNode);
return Native.YGNodeStyleGetMinHeight(_ygNode);
}
set
{
Native.CSSNodeStyleSetMinHeight(_cssNode, value);
Native.YGNodeStyleSetMinHeight(_ygNode, value);
}
}
@@ -368,12 +368,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetAspectRatio(_cssNode);
return Native.YGNodeStyleGetAspectRatio(_ygNode);
}
set
{
Native.CSSNodeStyleSetAspectRatio(_cssNode, value);
Native.YGNodeStyleSetAspectRatio(_ygNode, value);
}
}
@@ -381,7 +381,7 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeLayoutGetLeft(_cssNode);
return Native.YGNodeLayoutGetLeft(_ygNode);
}
}
@@ -389,7 +389,7 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeLayoutGetTop(_cssNode);
return Native.YGNodeLayoutGetTop(_ygNode);
}
}
@@ -397,7 +397,7 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeLayoutGetWidth(_cssNode);
return Native.YGNodeLayoutGetWidth(_ygNode);
}
}
@@ -405,7 +405,7 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeLayoutGetHeight(_cssNode);
return Native.YGNodeLayoutGetHeight(_ygNode);
}
}
@@ -413,7 +413,7 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeLayoutGetDirection(_cssNode);
return Native.YGNodeLayoutGetDirection(_ygNode);
}
}
@@ -421,12 +421,12 @@ namespace Facebook.Yoga
{
get
{
return Native.CSSNodeStyleGetOverflow(_cssNode);
return Native.YGNodeStyleGetOverflow(_ygNode);
}
set
{
Native.CSSNodeStyleSetOverflow(_cssNode, value);
Native.YGNodeStyleSetOverflow(_ygNode, value);
}
}
@@ -461,7 +461,7 @@ namespace Facebook.Yoga
public void MarkLayoutSeen()
{
Native.CSSNodeSetHasNewLayout(_cssNode, false);
Native.YGNodeSetHasNewLayout(_ygNode, false);
}
public bool ValuesEqual(float f1, float f2)
@@ -482,7 +482,7 @@ namespace Facebook.Yoga
}
_children.Insert(index, node);
node._parent = new WeakReference(this);
Native.CSSNodeInsertChild(_cssNode, node._cssNode, (uint)index);
Native.YGNodeInsertChild(_ygNode, node._ygNode, (uint)index);
}
public void RemoveAt(int index)
@@ -490,7 +490,7 @@ namespace Facebook.Yoga
var child = _children[index];
child._parent = null;
_children.RemoveAt(index);
Native.CSSNodeRemoveChild(_cssNode, child._cssNode);
Native.YGNodeRemoveChild(_ygNode, child._ygNode);
}
public void Clear()
@@ -512,17 +512,17 @@ namespace Facebook.Yoga
public void SetMeasureFunction(MeasureFunction measureFunction)
{
_measureFunction = measureFunction;
_cssMeasureFunc = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null;
Native.CSSNodeSetMeasureFunc(_cssNode, _cssMeasureFunc);
_ygMeasureFunc = measureFunction != null ? MeasureInternal : (YogaMeasureFunc)null;
Native.YGNodeSetMeasureFunc(_ygNode, _ygMeasureFunc);
}
public void CalculateLayout()
{
Native.CSSNodeCalculateLayout(
_cssNode,
Native.YGNodeCalculateLayout(
_ygNode,
YogaConstants.Undefined,
YogaConstants.Undefined,
Native.CSSNodeStyleGetDirection(_cssNode));
Native.YGNodeStyleGetDirection(_ygNode));
}
private YogaSize MeasureInternal(
@@ -547,7 +547,7 @@ namespace Facebook.Yoga
StringBuilder sb = new StringBuilder();
YogaLogger.Func orig = YogaLogger.Logger;
YogaLogger.Logger = (level, message) => {sb.Append(message);};
Native.CSSNodePrint(_cssNode, options);
Native.YGNodePrint(_ygNode, options);
YogaLogger.Logger = orig;
return sb.ToString();
}
@@ -566,19 +566,19 @@ namespace Facebook.Yoga
public static int GetInstanceCount()
{
return Native.CSSNodeGetInstanceCount();
return Native.YGNodeGetInstanceCount();
}
public static void SetExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
bool enabled)
{
Native.CSSLayoutSetExperimentalFeatureEnabled(feature, enabled);
Native.YGSetExperimentalFeatureEnabled(feature, enabled);
}
public static bool IsExperimentalFeatureEnabled(YogaExperimentalFeature feature)
{
return Native.CSSLayoutIsExperimentalFeatureEnabled(feature);
return Native.YGIsExperimentalFeatureEnabled(feature);
}
}
}

View File

@@ -23,5 +23,5 @@ static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) {
void YGInteropSetLogger(YGInteropLoggerFunc managedFunc) {
gManagedFunc = managedFunc;
CSSLayoutSetLogger(&unmanagedLogger);
YGSetLogger(&unmanagedLogger);
}

View File

@@ -9,12 +9,12 @@
#pragma once
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
CSS_EXTERN_C_BEGIN
YG_EXTERN_C_BEGIN
typedef void (*YGInteropLoggerFunc)(YGLogLevel level, const char *message);
WIN_EXPORT void YGInteropSetLogger(YGInteropLoggerFunc managedFunc);
CSS_EXTERN_C_END
YG_EXTERN_C_END

View File

@@ -87,7 +87,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@@ -102,7 +102,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@@ -119,7 +119,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@@ -138,7 +138,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;CSSLAYOUT_EXPORTS;CSS_ASSERT_FAIL_ENABLED;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;YOGA_EXPORTS;FB_ASSERTIONS_ENABLED=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
@@ -150,16 +150,16 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\CSSLayout\CSSLayout.h" />
<ClInclude Include="..\..\CSSLayout\CSSMacros.h" />
<ClInclude Include="..\..\CSSLayout\CSSNodeList.h" />
<ClInclude Include="..\..\CSSLayout\Yoga.h" />
<ClInclude Include="..\..\CSSLayout\YGMacros.h" />
<ClInclude Include="..\..\CSSLayout\YGNodeList.h" />
<ClInclude Include="YGInterop.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\CSSLayout\CSSLayout.c" />
<ClCompile Include="..\..\CSSLayout\CSSNodeList.c" />
<ClCompile Include="..\..\CSSLayout\Yoga.c" />
<ClCompile Include="..\..\CSSLayout\YGNodeList.c" />
<ClCompile Include="YGInterop.cpp" />
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>

View File

@@ -21,13 +21,13 @@
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\CSSLayout\CSSLayout.h">
<ClInclude Include="..\..\CSSLayout\Yoga.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\CSSLayout\CSSMacros.h">
<ClInclude Include="..\..\CSSLayout\YGMacros.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\CSSLayout\CSSNodeList.h">
<ClInclude Include="..\..\CSSLayout\YGNodeList.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="YGInterop.h">
@@ -41,10 +41,10 @@
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\CSSLayout\CSSLayout.c">
<ClCompile Include="..\..\CSSLayout\Yoga.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\CSSLayout\CSSNodeList.c">
<ClCompile Include="..\..\CSSLayout\YGNodeList.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="YGInterop.cpp">

View File

@@ -114,7 +114,7 @@ def to_java_upper(symbol):
root = os.path.dirname(__file__)
# write out C header
with open(root + '/CSSLayout/CSSEnums.h', 'w') as f:
with open(root + '/CSSLayout/YGEnums.h', 'w') as f:
f.write(LICENSE)
remaining = len(ENUMS)
for name, values in ENUMS.items():

View File

@@ -20,38 +20,38 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
emitPrologue:{value:function() {
this.push([
'#include <CSSLayout/CSSLayout.h>',
'#include <CSSLayout/Yoga.h>',
'#include <gtest/gtest.h>',
'',
]);
}},
emitTestPrologue:{value:function(name, experiments) {
this.push('TEST(CSSLayoutTest, ' + name + ') {');
this.push('TEST(YogaTest, ' + name + ') {');
this.pushIndent();
if (experiments.length > 0) {
for (var i in experiments) {
this.push('CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', true);');
this.push('YGSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', true);');
}
this.push('');
}
}},
emitTestTreePrologue:{value:function(nodeName) {
this.push('const CSSNodeRef ' + nodeName + ' = CSSNodeNew();');
this.push('const YGNodeRef ' + nodeName + ' = YGNodeNew();');
}},
emitTestEpilogue:{value:function(experiments) {
this.push([
'',
'CSSNodeFreeRecursive(root);',
'YGNodeFreeRecursive(root);',
]);
if (experiments.length > 0) {
this.push('');
for (var i in experiments) {
this.push('CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', false);');
this.push('YGSetExperimentalFeatureEnabled(YGExperimentalFeature' + experiments[i] +', false);');
}
}
@@ -109,114 +109,114 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGUndefined:{value:'YGUndefined'},
CSSNodeCalculateLayout:{value:function(node, dir) {
this.push('CSSNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');');
this.push('YGNodeCalculateLayout(' + node + ', YGUndefined, YGUndefined, ' + dir + ');');
}},
CSSNodeInsertChild:{value:function(parentName, nodeName, index) {
this.push('CSSNodeInsertChild(' + parentName + ', ' + nodeName + ', ' + index + ');');
this.push('YGNodeInsertChild(' + parentName + ', ' + nodeName + ', ' + index + ');');
}},
CSSNodeLayoutGetLeft:{value:function(nodeName) {
return 'CSSNodeLayoutGetLeft(' + nodeName + ')';
return 'YGNodeLayoutGetLeft(' + nodeName + ')';
}},
CSSNodeLayoutGetTop:{value:function(nodeName) {
return 'CSSNodeLayoutGetTop(' + nodeName + ')';
return 'YGNodeLayoutGetTop(' + nodeName + ')';
}},
CSSNodeLayoutGetWidth:{value:function(nodeName) {
return 'CSSNodeLayoutGetWidth(' + nodeName + ')';
return 'YGNodeLayoutGetWidth(' + nodeName + ')';
}},
CSSNodeLayoutGetHeight:{value:function(nodeName) {
return 'CSSNodeLayoutGetHeight(' + nodeName + ')';
return 'YGNodeLayoutGetHeight(' + nodeName + ')';
}},
CSSNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetAlignContent(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetAlignItems(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetAlignSelf(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetBorder(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetDirection:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetDirection(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetDirection(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetFlexBasis(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetFlexDirection(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetFlexGrow(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetFlexShrink(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetFlexWrap(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetHeight:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetHeight(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetJustifyContent(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMargin(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMaxHeight(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMaxWidth(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMinHeight(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetMinWidth(' + nodeName + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetOverflow(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetOverflow(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetPadding(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push('CSSNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetPosition(' + nodeName + ', ' + edge + ', ' + toFloatString(value) + ');');
}},
CSSNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetPositionType(' + nodeName + ', ' + value + ');');
this.push('YGNodeStyleSetPositionType(' + nodeName + ', ' + value + ');');
}},
CSSNodeStyleSetWidth:{value:function(nodeName, value) {
this.push('CSSNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');');
this.push('YGNodeStyleSetWidth(' + nodeName + ', ' + toFloatString(value) + ');');
}},
});

View File

@@ -27,26 +27,26 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
/**
* Get native instance count. Useful for testing only.
*/
static native int jni_CSSNodeGetInstanceCount();
static native void jni_CSSLog(int level, String message);
static native int jni_YGNodeGetInstanceCount();
static native void jni_YGLog(int level, String message);
private static native void jni_CSSLayoutSetLogger(Object logger);
private static native void jni_YGSetLogger(Object logger);
public static void setLogger(CSSLogger logger) {
jni_CSSLayoutSetLogger(logger);
jni_YGSetLogger(logger);
}
private static native void jni_CSSLayoutSetExperimentalFeatureEnabled(
private static native void jni_YGSetExperimentalFeatureEnabled(
int feature,
boolean enabled);
public static void setExperimentalFeatureEnabled(
YogaExperimentalFeature feature,
boolean enabled) {
jni_CSSLayoutSetExperimentalFeatureEnabled(feature.intValue(), enabled);
jni_YGSetExperimentalFeatureEnabled(feature.intValue(), enabled);
}
private static native boolean jni_CSSLayoutIsExperimentalFeatureEnabled(int feature);
private static native boolean jni_YGIsExperimentalFeatureEnabled(int feature);
public static boolean isExperimentalFeatureEnabled(YogaExperimentalFeature feature) {
return jni_CSSLayoutIsExperimentalFeatureEnabled(feature.intValue());
return jni_YGIsExperimentalFeatureEnabled(feature.intValue());
}
private CSSNode mParent;
@@ -71,25 +71,25 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
@DoNotStrip
private int mLayoutDirection = 0;
private native long jni_CSSNodeNew();
private native long jni_YGNodeNew();
public CSSNode() {
mNativePointer = jni_CSSNodeNew();
mNativePointer = jni_YGNodeNew();
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
}
}
private native void jni_CSSNodeFree(long nativePointer);
private native void jni_YGNodeFree(long nativePointer);
@Override
protected void finalize() throws Throwable {
try {
jni_CSSNodeFree(mNativePointer);
jni_YGNodeFree(mNativePointer);
} finally {
super.finalize();
}
}
private native void jni_CSSNodeReset(long nativePointer);
private native void jni_YGNodeReset(long nativePointer);
@Override
public void reset() {
mHasSetPadding = false;
@@ -106,7 +106,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
mMeasureFunction = null;
mData = null;
jni_CSSNodeReset(mNativePointer);
jni_YGNodeReset(mNativePointer);
}
@Override
@@ -119,7 +119,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
return mChildren.get(i);
}
private native void jni_CSSNodeInsertChild(long nativePointer, long childPointer, int index);
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
@Override
public void addChildAt(CSSNode child, int i) {
if (child.mParent != null) {
@@ -131,16 +131,16 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
}
mChildren.add(i, child);
child.mParent = this;
jni_CSSNodeInsertChild(mNativePointer, child.mNativePointer, i);
jni_YGNodeInsertChild(mNativePointer, child.mNativePointer, i);
}
private native void jni_CSSNodeRemoveChild(long nativePointer, long childPointer);
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
@Override
public CSSNode removeChildAt(int i) {
final CSSNode child = mChildren.remove(i);
child.mParent = null;
jni_CSSNodeRemoveChild(mNativePointer, child.mNativePointer);
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
return child;
}
@@ -155,330 +155,330 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
return mChildren == null ? -1 : mChildren.indexOf(child);
}
private native void jni_CSSNodeCalculateLayout(long nativePointer);
private native void jni_YGNodeCalculateLayout(long nativePointer);
@Override
public void calculateLayout() {
jni_CSSNodeCalculateLayout(mNativePointer);
jni_YGNodeCalculateLayout(mNativePointer);
}
private native boolean jni_CSSNodeHasNewLayout(long nativePointer);
private native boolean jni_YGNodeHasNewLayout(long nativePointer);
@Override
public boolean hasNewLayout() {
return jni_CSSNodeHasNewLayout(mNativePointer);
return jni_YGNodeHasNewLayout(mNativePointer);
}
private native void jni_CSSNodeMarkDirty(long nativePointer);
private native void jni_YGNodeMarkDirty(long nativePointer);
@Override
public void dirty() {
jni_CSSNodeMarkDirty(mNativePointer);
jni_YGNodeMarkDirty(mNativePointer);
}
private native boolean jni_CSSNodeIsDirty(long nativePointer);
private native boolean jni_YGNodeIsDirty(long nativePointer);
@Override
public boolean isDirty() {
return jni_CSSNodeIsDirty(mNativePointer);
return jni_YGNodeIsDirty(mNativePointer);
}
private native void jni_CSSNodeMarkLayoutSeen(long nativePointer);
private native void jni_YGNodeMarkLayoutSeen(long nativePointer);
@Override
public void markLayoutSeen() {
jni_CSSNodeMarkLayoutSeen(mNativePointer);
jni_YGNodeMarkLayoutSeen(mNativePointer);
}
private native void jni_CSSNodeCopyStyle(long dstNativePointer, long srcNativePointer);
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
@Override
public void copyStyle(CSSNode srcNode) {
jni_CSSNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
}
private native int jni_CSSNodeStyleGetDirection(long nativePointer);
private native int jni_YGNodeStyleGetDirection(long nativePointer);
@Override
public YogaDirection getStyleDirection() {
return YogaDirection.values()[jni_CSSNodeStyleGetDirection(mNativePointer)];
return YogaDirection.values()[jni_YGNodeStyleGetDirection(mNativePointer)];
}
private native void jni_CSSNodeStyleSetDirection(long nativePointer, int direction);
private native void jni_YGNodeStyleSetDirection(long nativePointer, int direction);
@Override
public void setDirection(YogaDirection direction) {
jni_CSSNodeStyleSetDirection(mNativePointer, direction.intValue());
jni_YGNodeStyleSetDirection(mNativePointer, direction.intValue());
}
private native int jni_CSSNodeStyleGetFlexDirection(long nativePointer);
private native int jni_YGNodeStyleGetFlexDirection(long nativePointer);
@Override
public YogaFlexDirection getFlexDirection() {
return YogaFlexDirection.values()[jni_CSSNodeStyleGetFlexDirection(mNativePointer)];
return YogaFlexDirection.values()[jni_YGNodeStyleGetFlexDirection(mNativePointer)];
}
private native void jni_CSSNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
private native void jni_YGNodeStyleSetFlexDirection(long nativePointer, int flexDirection);
@Override
public void setFlexDirection(YogaFlexDirection flexDirection) {
jni_CSSNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
jni_YGNodeStyleSetFlexDirection(mNativePointer, flexDirection.intValue());
}
private native int jni_CSSNodeStyleGetJustifyContent(long nativePointer);
private native int jni_YGNodeStyleGetJustifyContent(long nativePointer);
@Override
public YogaJustify getJustifyContent() {
return YogaJustify.values()[jni_CSSNodeStyleGetJustifyContent(mNativePointer)];
return YogaJustify.values()[jni_YGNodeStyleGetJustifyContent(mNativePointer)];
}
private native void jni_CSSNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
private native void jni_YGNodeStyleSetJustifyContent(long nativePointer, int justifyContent);
@Override
public void setJustifyContent(YogaJustify justifyContent) {
jni_CSSNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
jni_YGNodeStyleSetJustifyContent(mNativePointer, justifyContent.intValue());
}
private native int jni_CSSNodeStyleGetAlignItems(long nativePointer);
private native int jni_YGNodeStyleGetAlignItems(long nativePointer);
@Override
public YogaAlign getAlignItems() {
return YogaAlign.values()[jni_CSSNodeStyleGetAlignItems(mNativePointer)];
return YogaAlign.values()[jni_YGNodeStyleGetAlignItems(mNativePointer)];
}
private native void jni_CSSNodeStyleSetAlignItems(long nativePointer, int alignItems);
private native void jni_YGNodeStyleSetAlignItems(long nativePointer, int alignItems);
@Override
public void setAlignItems(YogaAlign alignItems) {
jni_CSSNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
jni_YGNodeStyleSetAlignItems(mNativePointer, alignItems.intValue());
}
private native int jni_CSSNodeStyleGetAlignSelf(long nativePointer);
private native int jni_YGNodeStyleGetAlignSelf(long nativePointer);
@Override
public YogaAlign getAlignSelf() {
return YogaAlign.values()[jni_CSSNodeStyleGetAlignSelf(mNativePointer)];
return YogaAlign.values()[jni_YGNodeStyleGetAlignSelf(mNativePointer)];
}
private native void jni_CSSNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
private native void jni_YGNodeStyleSetAlignSelf(long nativePointer, int alignSelf);
@Override
public void setAlignSelf(YogaAlign alignSelf) {
jni_CSSNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
jni_YGNodeStyleSetAlignSelf(mNativePointer, alignSelf.intValue());
}
private native int jni_CSSNodeStyleGetAlignContent(long nativePointer);
private native int jni_YGNodeStyleGetAlignContent(long nativePointer);
@Override
public YogaAlign getAlignContent() {
return YogaAlign.values()[jni_CSSNodeStyleGetAlignContent(mNativePointer)];
return YogaAlign.values()[jni_YGNodeStyleGetAlignContent(mNativePointer)];
}
private native void jni_CSSNodeStyleSetAlignContent(long nativePointer, int alignContent);
private native void jni_YGNodeStyleSetAlignContent(long nativePointer, int alignContent);
@Override
public void setAlignContent(YogaAlign alignContent) {
jni_CSSNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
jni_YGNodeStyleSetAlignContent(mNativePointer, alignContent.intValue());
}
private native int jni_CSSNodeStyleGetPositionType(long nativePointer);
private native int jni_YGNodeStyleGetPositionType(long nativePointer);
@Override
public YogaPositionType getPositionType() {
return YogaPositionType.values()[jni_CSSNodeStyleGetPositionType(mNativePointer)];
return YogaPositionType.values()[jni_YGNodeStyleGetPositionType(mNativePointer)];
}
private native void jni_CSSNodeStyleSetPositionType(long nativePointer, int positionType);
private native void jni_YGNodeStyleSetPositionType(long nativePointer, int positionType);
@Override
public void setPositionType(YogaPositionType positionType) {
jni_CSSNodeStyleSetPositionType(mNativePointer, positionType.intValue());
jni_YGNodeStyleSetPositionType(mNativePointer, positionType.intValue());
}
private native void jni_CSSNodeStyleSetFlexWrap(long nativePointer, int wrapType);
private native void jni_YGNodeStyleSetFlexWrap(long nativePointer, int wrapType);
@Override
public void setWrap(YogaWrap flexWrap) {
jni_CSSNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
jni_YGNodeStyleSetFlexWrap(mNativePointer, flexWrap.intValue());
}
private native int jni_CSSNodeStyleGetOverflow(long nativePointer);
private native int jni_YGNodeStyleGetOverflow(long nativePointer);
@Override
public YogaOverflow getOverflow() {
return YogaOverflow.values()[jni_CSSNodeStyleGetOverflow(mNativePointer)];
return YogaOverflow.values()[jni_YGNodeStyleGetOverflow(mNativePointer)];
}
private native void jni_CSSNodeStyleSetOverflow(long nativePointer, int overflow);
private native void jni_YGNodeStyleSetOverflow(long nativePointer, int overflow);
@Override
public void setOverflow(YogaOverflow overflow) {
jni_CSSNodeStyleSetOverflow(mNativePointer, overflow.intValue());
jni_YGNodeStyleSetOverflow(mNativePointer, overflow.intValue());
}
private native void jni_CSSNodeStyleSetFlex(long nativePointer, float flex);
private native void jni_YGNodeStyleSetFlex(long nativePointer, float flex);
@Override
public void setFlex(float flex) {
jni_CSSNodeStyleSetFlex(mNativePointer, flex);
jni_YGNodeStyleSetFlex(mNativePointer, flex);
}
private native float jni_CSSNodeStyleGetFlexGrow(long nativePointer);
private native float jni_YGNodeStyleGetFlexGrow(long nativePointer);
@Override
public float getFlexGrow() {
return jni_CSSNodeStyleGetFlexGrow(mNativePointer);
return jni_YGNodeStyleGetFlexGrow(mNativePointer);
}
private native void jni_CSSNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
private native void jni_YGNodeStyleSetFlexGrow(long nativePointer, float flexGrow);
@Override
public void setFlexGrow(float flexGrow) {
jni_CSSNodeStyleSetFlexGrow(mNativePointer, flexGrow);
jni_YGNodeStyleSetFlexGrow(mNativePointer, flexGrow);
}
private native float jni_CSSNodeStyleGetFlexShrink(long nativePointer);
private native float jni_YGNodeStyleGetFlexShrink(long nativePointer);
@Override
public float getFlexShrink() {
return jni_CSSNodeStyleGetFlexShrink(mNativePointer);
return jni_YGNodeStyleGetFlexShrink(mNativePointer);
}
private native void jni_CSSNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
private native void jni_YGNodeStyleSetFlexShrink(long nativePointer, float flexShrink);
@Override
public void setFlexShrink(float flexShrink) {
jni_CSSNodeStyleSetFlexShrink(mNativePointer, flexShrink);
jni_YGNodeStyleSetFlexShrink(mNativePointer, flexShrink);
}
private native float jni_CSSNodeStyleGetFlexBasis(long nativePointer);
private native float jni_YGNodeStyleGetFlexBasis(long nativePointer);
@Override
public float getFlexBasis() {
return jni_CSSNodeStyleGetFlexBasis(mNativePointer);
return jni_YGNodeStyleGetFlexBasis(mNativePointer);
}
private native void jni_CSSNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
private native void jni_YGNodeStyleSetFlexBasis(long nativePointer, float flexBasis);
@Override
public void setFlexBasis(float flexBasis) {
jni_CSSNodeStyleSetFlexBasis(mNativePointer, flexBasis);
jni_YGNodeStyleSetFlexBasis(mNativePointer, flexBasis);
}
private native float jni_CSSNodeStyleGetMargin(long nativePointer, int edge);
private native float jni_YGNodeStyleGetMargin(long nativePointer, int edge);
@Override
public float getMargin(YogaEdge edge) {
if (!mHasSetMargin) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetMargin(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetMargin(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetMargin(long nativePointer, int edge, float margin);
private native void jni_YGNodeStyleSetMargin(long nativePointer, int edge, float margin);
@Override
public void setMargin(YogaEdge edge, float margin) {
mHasSetMargin = true;
jni_CSSNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
jni_YGNodeStyleSetMargin(mNativePointer, edge.intValue(), margin);
}
private native float jni_CSSNodeStyleGetPadding(long nativePointer, int edge);
private native float jni_YGNodeStyleGetPadding(long nativePointer, int edge);
@Override
public float getPadding(YogaEdge edge) {
if (!mHasSetPadding) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetPadding(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetPadding(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetPadding(long nativePointer, int edge, float padding);
private native void jni_YGNodeStyleSetPadding(long nativePointer, int edge, float padding);
@Override
public void setPadding(YogaEdge edge, float padding) {
mHasSetPadding = true;
jni_CSSNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
jni_YGNodeStyleSetPadding(mNativePointer, edge.intValue(), padding);
}
private native float jni_CSSNodeStyleGetBorder(long nativePointer, int edge);
private native float jni_YGNodeStyleGetBorder(long nativePointer, int edge);
@Override
public float getBorder(YogaEdge edge) {
if (!mHasSetBorder) {
return edge.intValue() < YogaEdge.START.intValue() ? 0 : YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetBorder(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetBorder(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetBorder(long nativePointer, int edge, float border);
private native void jni_YGNodeStyleSetBorder(long nativePointer, int edge, float border);
@Override
public void setBorder(YogaEdge edge, float border) {
mHasSetBorder = true;
jni_CSSNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
jni_YGNodeStyleSetBorder(mNativePointer, edge.intValue(), border);
}
private native float jni_CSSNodeStyleGetPosition(long nativePointer, int edge);
private native float jni_YGNodeStyleGetPosition(long nativePointer, int edge);
@Override
public float getPosition(YogaEdge edge) {
if (!mHasSetPosition) {
return YogaConstants.UNDEFINED;
}
return jni_CSSNodeStyleGetPosition(mNativePointer, edge.intValue());
return jni_YGNodeStyleGetPosition(mNativePointer, edge.intValue());
}
private native void jni_CSSNodeStyleSetPosition(long nativePointer, int edge, float position);
private native void jni_YGNodeStyleSetPosition(long nativePointer, int edge, float position);
@Override
public void setPosition(YogaEdge edge, float position) {
mHasSetPosition = true;
jni_CSSNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
jni_YGNodeStyleSetPosition(mNativePointer, edge.intValue(), position);
}
private native float jni_CSSNodeStyleGetWidth(long nativePointer);
private native float jni_YGNodeStyleGetWidth(long nativePointer);
@Override
public float getWidth() {
return jni_CSSNodeStyleGetWidth(mNativePointer);
return jni_YGNodeStyleGetWidth(mNativePointer);
}
private native void jni_CSSNodeStyleSetWidth(long nativePointer, float width);
private native void jni_YGNodeStyleSetWidth(long nativePointer, float width);
@Override
public void setWidth(float width) {
jni_CSSNodeStyleSetWidth(mNativePointer, width);
jni_YGNodeStyleSetWidth(mNativePointer, width);
}
private native float jni_CSSNodeStyleGetHeight(long nativePointer);
private native float jni_YGNodeStyleGetHeight(long nativePointer);
@Override
public float getHeight() {
return jni_CSSNodeStyleGetHeight(mNativePointer);
return jni_YGNodeStyleGetHeight(mNativePointer);
}
private native void jni_CSSNodeStyleSetHeight(long nativePointer, float height);
private native void jni_YGNodeStyleSetHeight(long nativePointer, float height);
@Override
public void setHeight(float height) {
jni_CSSNodeStyleSetHeight(mNativePointer, height);
jni_YGNodeStyleSetHeight(mNativePointer, height);
}
private native float jni_CSSNodeStyleGetMinWidth(long nativePointer);
private native float jni_YGNodeStyleGetMinWidth(long nativePointer);
@Override
public float getMinWidth() {
return jni_CSSNodeStyleGetMinWidth(mNativePointer);
return jni_YGNodeStyleGetMinWidth(mNativePointer);
}
private native void jni_CSSNodeStyleSetMinWidth(long nativePointer, float minWidth);
private native void jni_YGNodeStyleSetMinWidth(long nativePointer, float minWidth);
@Override
public void setMinWidth(float minWidth) {
jni_CSSNodeStyleSetMinWidth(mNativePointer, minWidth);
jni_YGNodeStyleSetMinWidth(mNativePointer, minWidth);
}
private native float jni_CSSNodeStyleGetMinHeight(long nativePointer);
private native float jni_YGNodeStyleGetMinHeight(long nativePointer);
@Override
public float getMinHeight() {
return jni_CSSNodeStyleGetMinHeight(mNativePointer);
return jni_YGNodeStyleGetMinHeight(mNativePointer);
}
private native void jni_CSSNodeStyleSetMinHeight(long nativePointer, float minHeight);
private native void jni_YGNodeStyleSetMinHeight(long nativePointer, float minHeight);
@Override
public void setMinHeight(float minHeight) {
jni_CSSNodeStyleSetMinHeight(mNativePointer, minHeight);
jni_YGNodeStyleSetMinHeight(mNativePointer, minHeight);
}
private native float jni_CSSNodeStyleGetMaxWidth(long nativePointer);
private native float jni_YGNodeStyleGetMaxWidth(long nativePointer);
@Override
public float getMaxWidth() {
return jni_CSSNodeStyleGetMaxWidth(mNativePointer);
return jni_YGNodeStyleGetMaxWidth(mNativePointer);
}
private native void jni_CSSNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
private native void jni_YGNodeStyleSetMaxWidth(long nativePointer, float maxWidth);
@Override
public void setMaxWidth(float maxWidth) {
jni_CSSNodeStyleSetMaxWidth(mNativePointer, maxWidth);
jni_YGNodeStyleSetMaxWidth(mNativePointer, maxWidth);
}
private native float jni_CSSNodeStyleGetMaxHeight(long nativePointer);
private native float jni_YGNodeStyleGetMaxHeight(long nativePointer);
@Override
public float getMaxHeight() {
return jni_CSSNodeStyleGetMaxHeight(mNativePointer);
return jni_YGNodeStyleGetMaxHeight(mNativePointer);
}
private native void jni_CSSNodeStyleSetMaxHeight(long nativePointer, float maxheight);
private native void jni_YGNodeStyleSetMaxHeight(long nativePointer, float maxheight);
@Override
public void setMaxHeight(float maxheight) {
jni_CSSNodeStyleSetMaxHeight(mNativePointer, maxheight);
jni_YGNodeStyleSetMaxHeight(mNativePointer, maxheight);
}
private native float jni_CSSNodeStyleGetAspectRatio(long nativePointer);
private native float jni_YGNodeStyleGetAspectRatio(long nativePointer);
public float getAspectRatio() {
return jni_CSSNodeStyleGetAspectRatio(mNativePointer);
return jni_YGNodeStyleGetAspectRatio(mNativePointer);
}
private native void jni_CSSNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
private native void jni_YGNodeStyleSetAspectRatio(long nativePointer, float aspectRatio);
public void setAspectRatio(float aspectRatio) {
jni_CSSNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
jni_YGNodeStyleSetAspectRatio(mNativePointer, aspectRatio);
}
@Override
@@ -506,11 +506,11 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
return YogaDirection.values()[mLayoutDirection];
}
private native void jni_CSSNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
@Override
public void setMeasureFunction(MeasureFunction measureFunction) {
mMeasureFunction = measureFunction;
jni_CSSNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
}
// Implementation Note: Why this method needs to stay final

View File

@@ -1,340 +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.
*/
#include <CSSLayout/CSSLayout.h>
#include <fb/fbjni.h>
#include <iostream>
using namespace facebook::jni;
using namespace std;
static inline weak_ref<jobject> *jobjectContext(CSSNodeRef node) {
return reinterpret_cast<weak_ref<jobject> *>(CSSNodeGetContext(node));
}
static void _jniTransferLayoutDirection(CSSNodeRef node, alias_ref<jobject> javaNode) {
static auto layoutDirectionField = javaNode->getClass()->getField<jint>("mLayoutDirection");
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(CSSNodeLayoutGetDirection(node)));
}
static void _jniTransferLayoutOutputsRecursive(CSSNodeRef root) {
if (auto obj = jobjectContext(root)->lockLocal()) {
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
static auto topField = obj->getClass()->getField<jfloat>("mTop");
obj->setFieldValue(widthField, CSSNodeLayoutGetWidth(root));
obj->setFieldValue(heightField, CSSNodeLayoutGetHeight(root));
obj->setFieldValue(leftField, CSSNodeLayoutGetLeft(root));
obj->setFieldValue(topField, CSSNodeLayoutGetTop(root));
_jniTransferLayoutDirection(root, obj);
for (uint32_t i = 0; i < CSSNodeChildCount(root); i++) {
_jniTransferLayoutOutputsRecursive(CSSNodeGetChild(root, i));
}
} else {
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
}
}
static void _jniPrint(CSSNodeRef node) {
if (auto obj = jobjectContext(node)->lockLocal()) {
cout << obj->toString() << endl;
} else {
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
}
}
static CSSSize _jniMeasureFunc(CSSNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
if (auto obj = jobjectContext(node)->lockLocal()) {
static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode")
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
_jniTransferLayoutDirection(node, obj);
const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode);
static_assert(sizeof(measureResult) == 8,
"Expected measureResult to be 8 bytes, or two 32 bit ints");
const float measuredWidth = static_cast<float>(0xFFFFFFFF & (measureResult >> 32));
const float measuredHeight = static_cast<float>(0xFFFFFFFF & measureResult);
return CSSSize{measuredWidth, measuredHeight};
} else {
CSSLog(YGLogLevelError, "Java CSSNode was GCed during layout calculation\n");
return CSSSize{
widthMode == YGMeasureModeUndefined ? 0 : width,
heightMode == YGMeasureModeUndefined ? 0 : height,
};
}
}
struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;";
};
static global_ref<jobject> *jLogger;
static int _jniLog(YGLogLevel level, const char *format, va_list args) {
char buffer[256];
int result = vsnprintf(buffer, sizeof(buffer), format, args);
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
static auto logLevelFromInt =
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
logFunc(jLogger->get(),
logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
Environment::current()->NewStringUTF(buffer));
return result;
}
static inline CSSNodeRef _jlong2CSSNodeRef(jlong addr) {
return reinterpret_cast<CSSNodeRef>(static_cast<intptr_t>(addr));
}
void jni_CSSLayoutSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
if (jLogger) {
jLogger->releaseAlias();
delete jLogger;
}
if (logger) {
jLogger = new global_ref<jobject>(make_global(logger));
CSSLayoutSetLogger(_jniLog);
} else {
jLogger = NULL;
CSSLayoutSetLogger(NULL);
}
}
void jni_CSSLog(alias_ref<jclass> clazz, jint level, jstring message) {
const char *nMessage = Environment::current()->GetStringUTFChars(message, 0);
CSSLog(static_cast<YGLogLevel>(level), "%s", nMessage);
Environment::current()->ReleaseStringUTFChars(message, nMessage);
}
void jni_CSSLayoutSetExperimentalFeatureEnabled(alias_ref<jclass> clazz,
jint feature,
jboolean enabled) {
CSSLayoutSetExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature), enabled);
}
jboolean jni_CSSLayoutIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
return CSSLayoutIsExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature));
}
jint jni_CSSNodeGetInstanceCount(alias_ref<jclass> clazz) {
return CSSNodeGetInstanceCount();
}
jlong jni_CSSNodeNew(alias_ref<jobject> thiz) {
const CSSNodeRef node = CSSNodeNew();
CSSNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
CSSNodeSetPrintFunc(node, _jniPrint);
return reinterpret_cast<jlong>(node);
}
void jni_CSSNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer);
delete jobjectContext(node);
CSSNodeFree(node);
}
void jni_CSSNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
const CSSNodeRef node = _jlong2CSSNodeRef(nativePointer);
void *context = CSSNodeGetContext(node);
CSSNodeReset(node);
CSSNodeSetContext(node, context);
CSSNodeSetPrintFunc(node, _jniPrint);
}
void jni_CSSNodeInsertChild(alias_ref<jobject>,
jlong nativePointer,
jlong childPointer,
jint index) {
CSSNodeInsertChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer), index);
}
void jni_CSSNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
CSSNodeRemoveChild(_jlong2CSSNodeRef(nativePointer), _jlong2CSSNodeRef(childPointer));
}
void jni_CSSNodeCalculateLayout(alias_ref<jobject>, jlong nativePointer) {
const CSSNodeRef root = _jlong2CSSNodeRef(nativePointer);
CSSNodeCalculateLayout(root,
YGUndefined,
YGUndefined,
CSSNodeStyleGetDirection(_jlong2CSSNodeRef(nativePointer)));
_jniTransferLayoutOutputsRecursive(root);
}
void jni_CSSNodeMarkDirty(alias_ref<jobject>, jlong nativePointer) {
CSSNodeMarkDirty(_jlong2CSSNodeRef(nativePointer));
}
jboolean jni_CSSNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) CSSNodeIsDirty(_jlong2CSSNodeRef(nativePointer));
}
void jni_CSSNodeSetHasMeasureFunc(alias_ref<jobject>,
jlong nativePointer,
jboolean hasMeasureFunc) {
CSSNodeSetMeasureFunc(_jlong2CSSNodeRef(nativePointer), hasMeasureFunc ? _jniMeasureFunc : NULL);
}
jboolean jni_CSSNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) CSSNodeGetHasNewLayout(_jlong2CSSNodeRef(nativePointer));
}
void jni_CSSNodeMarkLayoutSeen(alias_ref<jobject>, jlong nativePointer) {
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) \
javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer)); \
} \
\
void jni_CSSNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, javatype value) { \
CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), static_cast<type>(value)); \
}
#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_CSSNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
return (javatype) CSSNodeStyleGet##name(_jlong2CSSNodeRef(nativePointer), \
static_cast<YGEdge>(edge)); \
} \
\
void jni_CSSNodeStyleSet##name(alias_ref<jobject>, \
jlong nativePointer, \
jint edge, \
javatype value) { \
CSSNodeStyleSet##name(_jlong2CSSNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<type>(value)); \
}
CSS_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
CSS_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
CSS_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
CSS_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
CSS_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
CSS_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
CSS_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
void jni_CSSNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
CSSNodeStyleSetFlex(_jlong2CSSNodeRef(nativePointer), static_cast<float>(value));
}
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding);
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, Width);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, Height);
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight);
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)
jint JNI_OnLoad(JavaVM *vm, void *) {
return initialize(vm, [] {
registerNatives("com/facebook/csslayout/CSSNode",
{
CSSMakeNativeMethod(jni_CSSNodeNew),
CSSMakeNativeMethod(jni_CSSNodeFree),
CSSMakeNativeMethod(jni_CSSNodeReset),
CSSMakeNativeMethod(jni_CSSNodeInsertChild),
CSSMakeNativeMethod(jni_CSSNodeRemoveChild),
CSSMakeNativeMethod(jni_CSSNodeCalculateLayout),
CSSMakeNativeMethod(jni_CSSNodeHasNewLayout),
CSSMakeNativeMethod(jni_CSSNodeMarkDirty),
CSSMakeNativeMethod(jni_CSSNodeIsDirty),
CSSMakeNativeMethod(jni_CSSNodeMarkLayoutSeen),
CSSMakeNativeMethod(jni_CSSNodeSetHasMeasureFunc),
CSSMakeNativeMethod(jni_CSSNodeCopyStyle),
CSSMakeNativeMethod(jni_CSSNodeStyleGetDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleSetDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexDirection),
CSSMakeNativeMethod(jni_CSSNodeStyleGetJustifyContent),
CSSMakeNativeMethod(jni_CSSNodeStyleSetJustifyContent),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignItems),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignItems),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignSelf),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignSelf),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAlignContent),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAlignContent),
CSSMakeNativeMethod(jni_CSSNodeStyleGetPositionType),
CSSMakeNativeMethod(jni_CSSNodeStyleSetPositionType),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexWrap),
CSSMakeNativeMethod(jni_CSSNodeStyleGetOverflow),
CSSMakeNativeMethod(jni_CSSNodeStyleSetOverflow),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlex),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexGrow),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexGrow),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexShrink),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexShrink),
CSSMakeNativeMethod(jni_CSSNodeStyleGetFlexBasis),
CSSMakeNativeMethod(jni_CSSNodeStyleSetFlexBasis),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMargin),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMargin),
CSSMakeNativeMethod(jni_CSSNodeStyleGetPadding),
CSSMakeNativeMethod(jni_CSSNodeStyleSetPadding),
CSSMakeNativeMethod(jni_CSSNodeStyleGetBorder),
CSSMakeNativeMethod(jni_CSSNodeStyleSetBorder),
CSSMakeNativeMethod(jni_CSSNodeStyleGetPosition),
CSSMakeNativeMethod(jni_CSSNodeStyleSetPosition),
CSSMakeNativeMethod(jni_CSSNodeStyleGetWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleSetWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleGetHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleSetHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMinWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMinWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMinHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMinHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxWidth),
CSSMakeNativeMethod(jni_CSSNodeStyleGetMaxHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleSetMaxHeight),
CSSMakeNativeMethod(jni_CSSNodeStyleGetAspectRatio),
CSSMakeNativeMethod(jni_CSSNodeStyleSetAspectRatio),
CSSMakeNativeMethod(jni_CSSNodeGetInstanceCount),
CSSMakeNativeMethod(jni_CSSLayoutSetLogger),
CSSMakeNativeMethod(jni_CSSLog),
CSSMakeNativeMethod(jni_CSSLayoutSetExperimentalFeatureEnabled),
CSSMakeNativeMethod(jni_CSSLayoutIsExperimentalFeatureEnabled),
});
});
}

333
java/jni/YGJNI.cpp Normal file
View File

@@ -0,0 +1,333 @@
/**
* 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/Yoga.h>
#include <fb/fbjni.h>
#include <iostream>
using namespace facebook::jni;
using namespace std;
static inline weak_ref<jobject> *YGNodeJobject(YGNodeRef node) {
return reinterpret_cast<weak_ref<jobject> *>(YGNodeGetContext(node));
}
static void YGTransferLayoutDirection(YGNodeRef node, alias_ref<jobject> javaNode) {
static auto layoutDirectionField = javaNode->getClass()->getField<jint>("mLayoutDirection");
javaNode->setFieldValue(layoutDirectionField, static_cast<jint>(YGNodeLayoutGetDirection(node)));
}
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
if (auto obj = YGNodeJobject(root)->lockLocal()) {
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
static auto topField = obj->getClass()->getField<jfloat>("mTop");
obj->setFieldValue(widthField, YGNodeLayoutGetWidth(root));
obj->setFieldValue(heightField, YGNodeLayoutGetHeight(root));
obj->setFieldValue(leftField, YGNodeLayoutGetLeft(root));
obj->setFieldValue(topField, YGNodeLayoutGetTop(root));
YGTransferLayoutDirection(root, obj);
for (uint32_t i = 0; i < YGNodeChildCount(root); i++) {
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
}
} else {
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
}
}
static void YGPrint(YGNodeRef node) {
if (auto obj = YGNodeJobject(node)->lockLocal()) {
cout << obj->toString() << endl;
} else {
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
}
}
static YGSize YGJNIMeasureFunc(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
if (auto obj = YGNodeJobject(node)->lockLocal()) {
static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode")
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
YGTransferLayoutDirection(node, obj);
const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode);
static_assert(sizeof(measureResult) == 8,
"Expected measureResult to be 8 bytes, or two 32 bit ints");
const float measuredWidth = static_cast<float>(0xFFFFFFFF & (measureResult >> 32));
const float measuredHeight = static_cast<float>(0xFFFFFFFF & measureResult);
return YGSize{measuredWidth, measuredHeight};
} else {
YGLog(YGLogLevelError, "Java YGNode was GCed during layout calculation\n");
return YGSize{
widthMode == YGMeasureModeUndefined ? 0 : width,
heightMode == YGMeasureModeUndefined ? 0 : height,
};
}
}
struct JYogaLogLevel : public JavaClass<JYogaLogLevel> {
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/YogaLogLevel;";
};
static global_ref<jobject> *jLogger;
static int YGLog(YGLogLevel level, const char *format, va_list args) {
char buffer[256];
int result = vsnprintf(buffer, sizeof(buffer), format, args);
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
static auto logLevelFromInt =
JYogaLogLevel::javaClassStatic()->getStaticMethod<JYogaLogLevel::javaobject(jint)>("fromInt");
logFunc(jLogger->get(),
logLevelFromInt(JYogaLogLevel::javaClassStatic(), static_cast<jint>(level)),
Environment::current()->NewStringUTF(buffer));
return result;
}
static inline YGNodeRef _jlong2YGNodeRef(jlong addr) {
return reinterpret_cast<YGNodeRef>(static_cast<intptr_t>(addr));
}
void jni_YGSetLogger(alias_ref<jclass> clazz, alias_ref<jobject> logger) {
if (jLogger) {
jLogger->releaseAlias();
delete jLogger;
}
if (logger) {
jLogger = new global_ref<jobject>(make_global(logger));
YGSetLogger(YGLog);
} else {
jLogger = NULL;
YGSetLogger(NULL);
}
}
void jni_YGLog(alias_ref<jclass> clazz, jint level, jstring message) {
const char *nMessage = Environment::current()->GetStringUTFChars(message, 0);
YGLog(static_cast<YGLogLevel>(level), "%s", nMessage);
Environment::current()->ReleaseStringUTFChars(message, nMessage);
}
void jni_YGSetExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature, jboolean enabled) {
YGSetExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature), enabled);
}
jboolean jni_YGIsExperimentalFeatureEnabled(alias_ref<jclass> clazz, jint feature) {
return YGIsExperimentalFeatureEnabled(static_cast<YGExperimentalFeature>(feature));
}
jint jni_YGNodeGetInstanceCount(alias_ref<jclass> clazz) {
return YGNodeGetInstanceCount();
}
jlong jni_YGNodeNew(alias_ref<jobject> thiz) {
const YGNodeRef node = YGNodeNew();
YGNodeSetContext(node, new weak_ref<jobject>(make_weak(thiz)));
YGNodeSetPrintFunc(node, YGPrint);
return reinterpret_cast<jlong>(node);
}
void jni_YGNodeFree(alias_ref<jobject> thiz, jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
delete YGNodeJobject(node);
YGNodeFree(node);
}
void jni_YGNodeReset(alias_ref<jobject> thiz, jlong nativePointer) {
const YGNodeRef node = _jlong2YGNodeRef(nativePointer);
void *context = YGNodeGetContext(node);
YGNodeReset(node);
YGNodeSetContext(node, context);
YGNodeSetPrintFunc(node, YGPrint);
}
void jni_YGNodeInsertChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer, jint index) {
YGNodeInsertChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer), index);
}
void jni_YGNodeRemoveChild(alias_ref<jobject>, jlong nativePointer, jlong childPointer) {
YGNodeRemoveChild(_jlong2YGNodeRef(nativePointer), _jlong2YGNodeRef(childPointer));
}
void jni_YGNodeCalculateLayout(alias_ref<jobject>, jlong nativePointer) {
const YGNodeRef root = _jlong2YGNodeRef(nativePointer);
YGNodeCalculateLayout(root,
YGUndefined,
YGUndefined,
YGNodeStyleGetDirection(_jlong2YGNodeRef(nativePointer)));
YGTransferLayoutOutputsRecursive(root);
}
void jni_YGNodeMarkDirty(alias_ref<jobject>, jlong nativePointer) {
YGNodeMarkDirty(_jlong2YGNodeRef(nativePointer));
}
jboolean jni_YGNodeIsDirty(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) YGNodeIsDirty(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeSetHasMeasureFunc(alias_ref<jobject>, jlong nativePointer, jboolean hasMeasureFunc) {
YGNodeSetMeasureFunc(_jlong2YGNodeRef(nativePointer), hasMeasureFunc ? YGJNIMeasureFunc : NULL);
}
jboolean jni_YGNodeHasNewLayout(alias_ref<jobject>, jlong nativePointer) {
return (jboolean) YGNodeGetHasNewLayout(_jlong2YGNodeRef(nativePointer));
}
void jni_YGNodeMarkLayoutSeen(alias_ref<jobject>, jlong nativePointer) {
YGNodeSetHasNewLayout(_jlong2YGNodeRef(nativePointer), false);
}
void jni_YGNodeCopyStyle(alias_ref<jobject>, jlong dstNativePointer, jlong srcNativePointer) {
YGNodeCopyStyle(_jlong2YGNodeRef(dstNativePointer), _jlong2YGNodeRef(srcNativePointer));
}
#define YG_NODE_JNI_STYLE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer)); \
} \
\
void jni_YGNodeStyleSet##name(alias_ref<jobject>, jlong nativePointer, javatype value) { \
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), static_cast<type>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
javatype jni_YGNodeStyleGet##name(alias_ref<jobject>, jlong nativePointer, jint edge) { \
return (javatype) YGNodeStyleGet##name(_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge)); \
} \
\
void jni_YGNodeStyleSet##name(alias_ref<jobject>, \
jlong nativePointer, \
jint edge, \
javatype value) { \
YGNodeStyleSet##name(_jlong2YGNodeRef(nativePointer), \
static_cast<YGEdge>(edge), \
static_cast<type>(value)); \
}
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
void jni_YGNodeStyleSetFlex(alias_ref<jobject>, jlong nativePointer, jfloat value) {
YGNodeStyleSetFlex(_jlong2YGNodeRef(nativePointer), static_cast<float>(value));
}
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
YG_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding);
YG_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
YG_NODE_JNI_STYLE_PROP(jfloat, float, Width);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxWidth);
YG_NODE_JNI_STYLE_PROP(jfloat, float, Height);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MinHeight);
YG_NODE_JNI_STYLE_PROP(jfloat, float, MaxHeight);
// Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
#define YGMakeNativeMethod(name) makeNativeMethod(#name, name)
jint JNI_OnLoad(JavaVM *vm, void *) {
return initialize(vm, [] {
registerNatives("com/facebook/csslayout/CSSNode",
{
YGMakeNativeMethod(jni_YGNodeNew),
YGMakeNativeMethod(jni_YGNodeFree),
YGMakeNativeMethod(jni_YGNodeReset),
YGMakeNativeMethod(jni_YGNodeInsertChild),
YGMakeNativeMethod(jni_YGNodeRemoveChild),
YGMakeNativeMethod(jni_YGNodeCalculateLayout),
YGMakeNativeMethod(jni_YGNodeHasNewLayout),
YGMakeNativeMethod(jni_YGNodeMarkDirty),
YGMakeNativeMethod(jni_YGNodeIsDirty),
YGMakeNativeMethod(jni_YGNodeMarkLayoutSeen),
YGMakeNativeMethod(jni_YGNodeSetHasMeasureFunc),
YGMakeNativeMethod(jni_YGNodeCopyStyle),
YGMakeNativeMethod(jni_YGNodeStyleGetDirection),
YGMakeNativeMethod(jni_YGNodeStyleSetDirection),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexDirection),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexDirection),
YGMakeNativeMethod(jni_YGNodeStyleGetJustifyContent),
YGMakeNativeMethod(jni_YGNodeStyleSetJustifyContent),
YGMakeNativeMethod(jni_YGNodeStyleGetAlignItems),
YGMakeNativeMethod(jni_YGNodeStyleSetAlignItems),
YGMakeNativeMethod(jni_YGNodeStyleGetAlignSelf),
YGMakeNativeMethod(jni_YGNodeStyleSetAlignSelf),
YGMakeNativeMethod(jni_YGNodeStyleGetAlignContent),
YGMakeNativeMethod(jni_YGNodeStyleSetAlignContent),
YGMakeNativeMethod(jni_YGNodeStyleGetPositionType),
YGMakeNativeMethod(jni_YGNodeStyleSetPositionType),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexWrap),
YGMakeNativeMethod(jni_YGNodeStyleGetOverflow),
YGMakeNativeMethod(jni_YGNodeStyleSetOverflow),
YGMakeNativeMethod(jni_YGNodeStyleSetFlex),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexGrow),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexGrow),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexShrink),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexShrink),
YGMakeNativeMethod(jni_YGNodeStyleGetFlexBasis),
YGMakeNativeMethod(jni_YGNodeStyleSetFlexBasis),
YGMakeNativeMethod(jni_YGNodeStyleGetMargin),
YGMakeNativeMethod(jni_YGNodeStyleSetMargin),
YGMakeNativeMethod(jni_YGNodeStyleGetPadding),
YGMakeNativeMethod(jni_YGNodeStyleSetPadding),
YGMakeNativeMethod(jni_YGNodeStyleGetBorder),
YGMakeNativeMethod(jni_YGNodeStyleSetBorder),
YGMakeNativeMethod(jni_YGNodeStyleGetPosition),
YGMakeNativeMethod(jni_YGNodeStyleSetPosition),
YGMakeNativeMethod(jni_YGNodeStyleGetWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetWidth),
YGMakeNativeMethod(jni_YGNodeStyleGetHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetHeight),
YGMakeNativeMethod(jni_YGNodeStyleGetMinWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMinWidth),
YGMakeNativeMethod(jni_YGNodeStyleGetMinHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMinHeight),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxWidth),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxWidth),
YGMakeNativeMethod(jni_YGNodeStyleGetMaxHeight),
YGMakeNativeMethod(jni_YGNodeStyleSetMaxHeight),
YGMakeNativeMethod(jni_YGNodeStyleGetAspectRatio),
YGMakeNativeMethod(jni_YGNodeStyleSetAspectRatio),
YGMakeNativeMethod(jni_YGNodeGetInstanceCount),
YGMakeNativeMethod(jni_YGSetLogger),
YGMakeNativeMethod(jni_YGLog),
YGMakeNativeMethod(jni_YGSetExperimentalFeatureEnabled),
YGMakeNativeMethod(jni_YGIsExperimentalFeatureEnabled),
});
});
}

View File

@@ -18,9 +18,9 @@ public class CSSNodeTest {
@Test
public void testInit() {
final int refCount = CSSNode.jni_CSSNodeGetInstanceCount();
final int refCount = CSSNode.jni_YGNodeGetInstanceCount();
final CSSNode node = new CSSNode();
assertEquals(refCount + 1, CSSNode.jni_CSSNodeGetInstanceCount());
assertEquals(refCount + 1, CSSNode.jni_YGNodeGetInstanceCount());
}
@Test
@@ -52,7 +52,7 @@ public class CSSNodeTest {
mLogMessage = message;
}
});
CSSNode.jni_CSSLog(YogaLogLevel.DEBUG.intValue(), "Hello");
CSSNode.jni_YGLog(YogaLogLevel.DEBUG.intValue(), "Hello");
assertEquals(YogaLogLevel.DEBUG, mLogLevel);
assertEquals("Hello", mLogMessage);
}
@@ -68,7 +68,7 @@ public class CSSNodeTest {
mLogMessage = message;
}
});
CSSNode.jni_CSSLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox");
CSSNode.jni_YGLog(YogaLogLevel.VERBOSE.intValue(), "Flexbox");
assertEquals(YogaLogLevel.VERBOSE, mLogLevel);
assertEquals("Flexbox", mLogMessage);
}

View File

@@ -9,286 +9,286 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, absolute_layout_width_height_start_top) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, absolute_layout_width_height_start_top) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, absolute_layout_width_height_end_bottom) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, absolute_layout_width_height_end_bottom) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeEnd, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, absolute_layout_start_top_end_bottom) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, absolute_layout_start_top_end_bottom) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeEnd, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, absolute_layout_width_height_start_top_end_bottom) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, absolute_layout_width_height_start_top_end_bottom) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeEnd, 10);
CSSNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeEnd, 10);
YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetOverflow(root, YGOverflowHidden);
CSSNodeStyleSetWidth(root, 50);
CSSNodeStyleSetHeight(root, 50);
TEST(YogaTest, do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetOverflow(root, YGOverflowHidden);
YGNodeStyleSetWidth(root, 50);
YGNodeStyleSetHeight(root, 50);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeStart, 0);
CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeStart, 0);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child0_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0_child0, 100);
CSSNodeStyleSetHeight(root_child0_child0, 100);
CSSNodeInsertChild(root_child0, root_child0_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0, 100);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(-50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, absolute_layout_within_border) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetMargin(root, YGEdgeLeft, 10);
CSSNodeStyleSetMargin(root, YGEdgeTop, 10);
CSSNodeStyleSetMargin(root, YGEdgeRight, 10);
CSSNodeStyleSetMargin(root, YGEdgeBottom, 10);
CSSNodeStyleSetPadding(root, YGEdgeLeft, 10);
CSSNodeStyleSetPadding(root, YGEdgeTop, 10);
CSSNodeStyleSetPadding(root, YGEdgeRight, 10);
CSSNodeStyleSetPadding(root, YGEdgeBottom, 10);
CSSNodeStyleSetBorder(root, YGEdgeLeft, 10);
CSSNodeStyleSetBorder(root, YGEdgeTop, 10);
CSSNodeStyleSetBorder(root, YGEdgeRight, 10);
CSSNodeStyleSetBorder(root, YGEdgeBottom, 10);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, absolute_layout_within_border) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetMargin(root, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root, YGEdgeTop, 10);
YGNodeStyleSetMargin(root, YGEdgeRight, 10);
YGNodeStyleSetMargin(root, YGEdgeBottom, 10);
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
YGNodeStyleSetPadding(root, YGEdgeBottom, 10);
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeLeft, 0);
CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child1, YGEdgeRight, 0);
CSSNodeStyleSetPosition(root_child1, YGEdgeBottom, 0);
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 50);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child1, YGEdgeRight, 0);
YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 0);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,391 +9,391 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, align_content_flex_start) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_content_flex_start) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 50);
CSSNodeStyleSetHeight(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 50);
CSSNodeStyleSetHeight(root_child3, 10);
CSSNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const CSSNodeRef root_child4 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child4, 50);
CSSNodeStyleSetHeight(root_child4, 10);
CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child4 = YGNodeNew();
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_content_flex_end) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, YGAlignFlexEnd);
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_content_flex_end) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignContent(root, YGAlignFlexEnd);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 50);
CSSNodeStyleSetHeight(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 50);
CSSNodeStyleSetHeight(root_child3, 10);
CSSNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const CSSNodeRef root_child4 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child4, 50);
CSSNodeStyleSetHeight(root_child4, 10);
CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child4 = YGNodeNew();
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_content_center) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, YGAlignCenter);
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_content_center) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignContent(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 50);
CSSNodeStyleSetHeight(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 50);
CSSNodeStyleSetHeight(root_child3, 10);
CSSNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 50);
YGNodeStyleSetHeight(root_child3, 10);
YGNodeInsertChild(root, root_child3, 3);
const CSSNodeRef root_child4 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child4, 50);
CSSNodeStyleSetHeight(root_child4, 10);
CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child4 = YGNodeNew();
YGNodeStyleSetWidth(root_child4, 50);
YGNodeStyleSetHeight(root_child4, 10);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_content_stretch) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignContent(root, YGAlignStretch);
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_content_stretch) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignContent(root, YGAlignStretch);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 50);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 50);
CSSNodeInsertChild(root, root_child3, 3);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 50);
YGNodeInsertChild(root, root_child3, 3);
const CSSNodeRef root_child4 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child4, 50);
CSSNodeInsertChild(root, root_child4, 4);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child4 = YGNodeNew();
YGNodeStyleSetWidth(root_child4, 50);
YGNodeInsertChild(root, root_child4, 4);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,151 +9,151 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, align_items_stretch) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_items_stretch) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_items_center) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignCenter);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_items_center) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_items_flex_start) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_items_flex_start) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_items_flex_end) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_items_flex_end) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,154 +9,154 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, align_self_center) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_self_center) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, YGAlignCenter);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_self_flex_end) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_self_flex_end) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_self_flex_start) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_self_flex_start) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexStart);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_self_flex_end_override_flex_start) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_self_flex_end_override_flex_start) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetAlignSelf(root_child0, YGAlignFlexEnd);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,401 +7,401 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
static CSSSize _measure(CSSNodeRef node,
static YGSize _measure(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
return CSSSize {
return YGSize {
.width = widthMode == YGMeasureModeExactly ? width : 50,
.height = heightMode == YGMeasureModeExactly ? height : 50,
};
}
TEST(CSSLayoutTest, aspect_ratio_cross_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_cross_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_main_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_main_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_both_dimensions_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_both_dimensions_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_align_stretch) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_align_stretch) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_flex_grow) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_flex_grow) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 50);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_flex_shrink) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_flex_shrink) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 150);
CSSNodeStyleSetFlexShrink(root_child0, 1);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 150);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_basis) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_basis) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexBasis(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_absolute_layout_width_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_absolute_layout_width_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeLeft, 0);
CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_absolute_layout_height_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_absolute_layout_height_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
CSSNodeStyleSetPosition(root_child0, YGEdgeLeft, 0);
CSSNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_max_cross_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_with_max_cross_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetMaxWidth(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 50);
YGNodeStyleSetMaxWidth(root_child0, 40);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(40, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_max_main_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_with_max_main_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetMaxHeight(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetMaxHeight(root_child0, 40);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(40, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_min_cross_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_with_min_cross_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 30);
CSSNodeStyleSetMinWidth(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 30);
YGNodeStyleSetMinWidth(root_child0, 40);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(30, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(40, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(30, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_min_main_defined) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_with_min_main_defined) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetMinHeight(root_child0, 40);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetMinHeight(root_child0, 40);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(40, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(40, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_double_cross) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_double_cross) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 2);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 2);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_half_cross) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_half_cross) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 100);
CSSNodeStyleSetAspectRatio(root_child0, 0.5);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 100);
YGNodeStyleSetAspectRatio(root_child0, 0.5);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_double_main) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_double_main) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetAspectRatio(root_child0, 2);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetAspectRatio(root_child0, 2);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_half_main) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_half_main) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 100);
CSSNodeStyleSetAspectRatio(root_child0, 0.5);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 100);
YGNodeStyleSetAspectRatio(root_child0, 0.5);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, aspect_ratio_with_measure_func) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, aspect_ratio_with_measure_func) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeStyleSetAspectRatio(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeStyleSetAspectRatio(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,186 +9,186 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, border_no_size) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetBorder(root, YGEdgeLeft, 10);
CSSNodeStyleSetBorder(root, YGEdgeTop, 10);
CSSNodeStyleSetBorder(root, YGEdgeRight, 10);
CSSNodeStyleSetBorder(root, YGEdgeBottom, 10);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
TEST(YogaTest, border_no_size) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_container_match_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetBorder(root, YGEdgeLeft, 10);
CSSNodeStyleSetBorder(root, YGEdgeTop, 10);
CSSNodeStyleSetBorder(root, YGEdgeRight, 10);
CSSNodeStyleSetBorder(root, YGEdgeBottom, 10);
TEST(YogaTest, border_container_match_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_flex_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetBorder(root, YGEdgeLeft, 10);
CSSNodeStyleSetBorder(root, YGEdgeTop, 10);
CSSNodeStyleSetBorder(root, YGEdgeRight, 10);
CSSNodeStyleSetBorder(root, YGEdgeBottom, 10);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, border_flex_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_stretch_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetBorder(root, YGEdgeLeft, 10);
CSSNodeStyleSetBorder(root, YGEdgeTop, 10);
CSSNodeStyleSetBorder(root, YGEdgeRight, 10);
CSSNodeStyleSetBorder(root, YGEdgeBottom, 10);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, border_stretch_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetBorder(root, YGEdgeLeft, 10);
YGNodeStyleSetBorder(root, YGEdgeTop, 10);
YGNodeStyleSetBorder(root, YGEdgeRight, 10);
YGNodeStyleSetBorder(root, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, border_center_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, YGJustifyCenter);
CSSNodeStyleSetAlignItems(root, YGAlignCenter);
CSSNodeStyleSetBorder(root, YGEdgeStart, 10);
CSSNodeStyleSetBorder(root, YGEdgeEnd, 20);
CSSNodeStyleSetBorder(root, YGEdgeBottom, 20);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, border_center_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetBorder(root, YGEdgeStart, 10);
YGNodeStyleSetBorder(root, YGEdgeEnd, 20);
YGNodeStyleSetBorder(root, YGEdgeBottom, 20);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,70 +7,70 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, assert_default_values) {
const CSSNodeRef root = CSSNodeNew();
TEST(YogaTest, assert_default_values) {
const YGNodeRef root = YGNodeNew();
ASSERT_EQ(0, CSSNodeChildCount(root));
ASSERT_EQ(NULL, CSSNodeGetChild(root, 1));
ASSERT_EQ(0, YGNodeChildCount(root));
ASSERT_EQ(NULL, YGNodeGetChild(root, 1));
ASSERT_EQ(YGDirectionInherit, CSSNodeStyleGetDirection(root));
ASSERT_EQ(YGFlexDirectionColumn, CSSNodeStyleGetFlexDirection(root));
ASSERT_EQ(YGJustifyFlexStart, CSSNodeStyleGetJustifyContent(root));
ASSERT_EQ(YGAlignFlexStart, CSSNodeStyleGetAlignContent(root));
ASSERT_EQ(YGAlignStretch, CSSNodeStyleGetAlignItems(root));
ASSERT_EQ(YGAlignAuto, CSSNodeStyleGetAlignSelf(root));
ASSERT_EQ(YGPositionTypeRelative, CSSNodeStyleGetPositionType(root));
ASSERT_EQ(YGWrapNoWrap, CSSNodeStyleGetFlexWrap(root));
ASSERT_EQ(YGOverflowVisible, CSSNodeStyleGetOverflow(root));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexGrow(root));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetFlexShrink(root));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetFlexBasis(root)));
ASSERT_EQ(YGDirectionInherit, YGNodeStyleGetDirection(root));
ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(root));
ASSERT_EQ(YGJustifyFlexStart, YGNodeStyleGetJustifyContent(root));
ASSERT_EQ(YGAlignFlexStart, YGNodeStyleGetAlignContent(root));
ASSERT_EQ(YGAlignStretch, YGNodeStyleGetAlignItems(root));
ASSERT_EQ(YGAlignAuto, YGNodeStyleGetAlignSelf(root));
ASSERT_EQ(YGPositionTypeRelative, YGNodeStyleGetPositionType(root));
ASSERT_EQ(YGWrapNoWrap, YGNodeStyleGetFlexWrap(root));
ASSERT_EQ(YGOverflowVisible, YGNodeStyleGetOverflow(root));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexGrow(root));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetFlexShrink(root));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetFlexBasis(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeLeft)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeTop)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeRight)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeBottom)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPosition(root, YGEdgeEnd)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeLeft)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeTop)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeRight)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeBottom)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPosition(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetMargin(root, YGEdgeBottom));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, YGEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMargin(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetMargin(root, YGEdgeBottom));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMargin(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetPadding(root, YGEdgeBottom));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, YGEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetPadding(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetPadding(root, YGEdgeBottom));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetPadding(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, CSSNodeStyleGetBorder(root, YGEdgeBottom));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, YGEdgeStart)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetBorder(root, YGEdgeEnd)));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeLeft));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeTop));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeRight));
ASSERT_FLOAT_EQ(0, YGNodeStyleGetBorder(root, YGEdgeBottom));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeStart)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetBorder(root, YGEdgeEnd)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetWidth(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetHeight(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMinWidth(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMinHeight(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxWidth(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetHeight(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMinHeight(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(root)));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetRight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetBottom(root));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetWidth(root)));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeLayoutGetHeight(root)));
ASSERT_EQ(YGDirectionInherit, CSSNodeLayoutGetDirection(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetRight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetBottom(root));
ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetWidth(root)));
ASSERT_TRUE(YGValueIsUndefined(YGNodeLayoutGetHeight(root)));
ASSERT_EQ(YGDirectionInherit, YGNodeLayoutGetDirection(root));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,90 +7,90 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, dirty_propagation) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, dirty_propagation) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 20);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
CSSNodeStyleSetWidth(root_child0, 20);
YGNodeStyleSetWidth(root_child0, 20);
EXPECT_TRUE(CSSNodeIsDirty(root_child0));
EXPECT_FALSE(CSSNodeIsDirty(root_child1));
EXPECT_TRUE(CSSNodeIsDirty(root));
EXPECT_TRUE(YGNodeIsDirty(root_child0));
EXPECT_FALSE(YGNodeIsDirty(root_child1));
EXPECT_TRUE(YGNodeIsDirty(root));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
EXPECT_FALSE(CSSNodeIsDirty(root_child0));
EXPECT_FALSE(CSSNodeIsDirty(root_child1));
EXPECT_FALSE(CSSNodeIsDirty(root));
EXPECT_FALSE(YGNodeIsDirty(root_child0));
EXPECT_FALSE(YGNodeIsDirty(root_child1));
EXPECT_FALSE(YGNodeIsDirty(root));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, dirty_propagation_only_if_prop_changed) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, dirty_propagation_only_if_prop_changed) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 20);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
CSSNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetWidth(root_child0, 50);
EXPECT_FALSE(CSSNodeIsDirty(root_child0));
EXPECT_FALSE(CSSNodeIsDirty(root_child1));
EXPECT_FALSE(CSSNodeIsDirty(root));
EXPECT_FALSE(YGNodeIsDirty(root_child0));
EXPECT_FALSE(YGNodeIsDirty(root_child1));
EXPECT_FALSE(YGNodeIsDirty(root));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, dirty_node_only_if_children_are_actually_removed) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 50);
CSSNodeStyleSetHeight(root, 50);
TEST(YogaTest, dirty_node_only_if_children_are_actually_removed) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 50);
YGNodeStyleSetHeight(root, 50);
const CSSNodeRef child0 = CSSNodeNew();
CSSNodeStyleSetWidth(child0, 50);
CSSNodeStyleSetHeight(child0, 25);
CSSNodeInsertChild(root, child0, 0);
const YGNodeRef child0 = YGNodeNew();
YGNodeStyleSetWidth(child0, 50);
YGNodeStyleSetHeight(child0, 25);
YGNodeInsertChild(root, child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const CSSNodeRef child1 = CSSNodeNew();
CSSNodeRemoveChild(root, child1);
EXPECT_FALSE(CSSNodeIsDirty(root));
CSSNodeFree(child1);
const YGNodeRef child1 = YGNodeNew();
YGNodeRemoveChild(root, child1);
EXPECT_FALSE(YGNodeIsDirty(root));
YGNodeFree(child1);
CSSNodeRemoveChild(root, child0);
EXPECT_TRUE(CSSNodeIsDirty(root));
CSSNodeFree(child0);
YGNodeRemoveChild(root, child0);
EXPECT_TRUE(YGNodeIsDirty(root));
YGNodeFree(child0);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,157 +7,157 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, start_overrides) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, start_overrides) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20);
CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetRight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, end_overrides) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, end_overrides) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20);
CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, horizontal_overridden) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, horizontal_overridden) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, vertical_overridden) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, vertical_overridden) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeVertical, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, horizontal_overrides_all) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, horizontal_overrides_all) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeHorizontal, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetBottom(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, vertical_overrides_all) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, vertical_overrides_all) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeVertical, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeVertical, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetRight(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetRight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, all_overridden) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, all_overridden) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeLeft, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeRight, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
CSSNodeStyleSetMargin(root_child0, YGEdgeAll, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetMargin(root_child0, YGEdgeAll, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetRight(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetBottom(root_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetRight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetBottom(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,385 +9,385 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, flex_direction_column_no_height) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
TEST(YogaTest, flex_direction_column_no_height) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_row_no_width) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_direction_row_no_width) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_column) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_direction_column) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_row) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_direction_row) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_column_reverse) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_direction_column_reverse) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumnReverse);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_direction_row_reverse) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_direction_row_reverse) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,389 +9,389 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, flex_basis_flex_grow_column) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_basis_flex_grow_column) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetFlexBasis(root_child0, 50);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_basis_flex_grow_row) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_basis_flex_grow_row) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetFlexBasis(root_child0, 50);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_basis_flex_shrink_column) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_basis_flex_shrink_column) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexShrink(root_child0, 1);
CSSNodeStyleSetFlexBasis(root_child0, 100);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexBasis(root_child1, 50);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexBasis(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_basis_flex_shrink_row) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_basis_flex_shrink_row) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexShrink(root_child0, 1);
CSSNodeStyleSetFlexBasis(root_child0, 100);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexBasis(root_child1, 50);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexBasis(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_shrink_to_zero) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetHeight(root, 75);
TEST(YogaTest, flex_shrink_to_zero) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetHeight(root, 75);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexShrink(root_child1, 1);
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 50);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexShrink(root_child1, 1);
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 50);
CSSNodeStyleSetHeight(root_child2, 50);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(75, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_basis_overrides_main_size) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_basis_overrides_main_size) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetFlexBasis(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeStyleSetHeight(root_child1, 10);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child2, 1);
CSSNodeStyleSetHeight(root_child2, 10);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child2, 1);
YGNodeStyleSetHeight(root_child2, 10);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_grow_shrink_at_most) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_grow_shrink_at_most) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child0_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0_child0, 1);
CSSNodeStyleSetFlexShrink(root_child0_child0, 1);
CSSNodeInsertChild(root_child0, root_child0_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexShrink(root_child0_child0, 1);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,334 +9,334 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, wrap_column) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, wrap_column) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetHeight(root_child0, 30);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 30);
CSSNodeStyleSetHeight(root_child1, 30);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 30);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 30);
CSSNodeStyleSetHeight(root_child2, 30);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 30);
CSSNodeStyleSetHeight(root_child3, 30);
CSSNodeInsertChild(root, root_child3, 3);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, wrap_row) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetWidth(root, 100);
TEST(YogaTest, wrap_row) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetHeight(root_child0, 30);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 30);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 30);
CSSNodeStyleSetHeight(root_child1, 30);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 30);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 30);
CSSNodeStyleSetHeight(root_child2, 30);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 30);
CSSNodeStyleSetHeight(root_child3, 30);
CSSNodeInsertChild(root, root_child3, 3);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, wrap_row_align_items_flex_end) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd);
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetWidth(root, 100);
TEST(YogaTest, wrap_row_align_items_flex_end) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 30);
CSSNodeStyleSetHeight(root_child1, 20);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 30);
CSSNodeStyleSetHeight(root_child2, 30);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 30);
CSSNodeStyleSetHeight(root_child3, 30);
CSSNodeInsertChild(root, root_child3, 3);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, wrap_row_align_items_center) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetAlignItems(root, YGAlignCenter);
CSSNodeStyleSetFlexWrap(root, YGWrapWrap);
CSSNodeStyleSetWidth(root, 100);
TEST(YogaTest, wrap_row_align_items_center) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetFlexWrap(root, YGWrapWrap);
YGNodeStyleSetWidth(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 30);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 30);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 30);
CSSNodeStyleSetHeight(root_child1, 20);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 30);
YGNodeStyleSetHeight(root_child1, 20);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 30);
CSSNodeStyleSetHeight(root_child2, 30);
CSSNodeInsertChild(root, root_child2, 2);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 30);
YGNodeStyleSetHeight(root_child2, 30);
YGNodeInsertChild(root, root_child2, 2);
const CSSNodeRef root_child3 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child3, 30);
CSSNodeStyleSetHeight(root_child3, 30);
CSSNodeInsertChild(root, root_child3, 3);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child3 = YGNodeNew();
YGNodeStyleSetWidth(root_child3, 30);
YGNodeStyleSetHeight(root_child3, 30);
YGNodeInsertChild(root, root_child3, 3);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(5, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(5, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(70, CSSNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child3));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

File diff suppressed because it is too large Load Diff

View File

@@ -9,398 +9,398 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, margin_start) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_start) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_top) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_top) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_end) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_end) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetMargin(root_child0, YGEdgeEnd, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_bottom) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_bottom) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_flex_row) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_and_flex_row) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_flex_column) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_and_flex_column) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_stretch_row) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_and_stretch_row) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_and_stretch_column) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_and_stretch_column) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMargin(root_child0, YGEdgeStart, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_with_sibling_row) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_with_sibling_row) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, margin_with_sibling_column) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, margin_with_sibling_column) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,127 +7,127 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
static CSSSize _measureMax(CSSNodeRef node,
static YGSize _measureMax(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
int *measureCount = (int *)CSSNodeGetContext(node);
int *measureCount = (int *)YGNodeGetContext(node);
(*measureCount)++;
return CSSSize {
return YGSize {
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : height,
};
}
static CSSSize _measureMin(CSSNodeRef node,
static YGSize _measureMin(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
int *measureCount = (int *)CSSNodeGetContext(node);
int *measureCount = (int *)YGNodeGetContext(node);
*measureCount = *measureCount + 1;
return CSSSize {
return YGSize {
.width = widthMode == YGMeasureModeUndefined || (widthMode == YGMeasureModeAtMost && width > 10) ? 10 : width,
.height = heightMode == YGMeasureModeUndefined || (heightMode == YGMeasureModeAtMost && height > 10) ? 10 : height,
};
}
TEST(CSSLayoutTest, measure_once_single_flexible_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, measure_once_single_flexible_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
int measureCount = 0;
CSSNodeSetContext(root_child0, &measureCount);
CSSNodeSetMeasureFunc(root_child0, _measureMax);
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
YGNodeSetContext(root_child0, &measureCount);
YGNodeSetMeasureFunc(root_child0, _measureMax);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, measureCount);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, remeasure_with_same_exact_width_larger_than_needed_height) {
const CSSNodeRef root = CSSNodeNew();
TEST(YogaTest, remeasure_with_same_exact_width_larger_than_needed_height) {
const YGNodeRef root = YGNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
int measureCount = 0;
CSSNodeSetContext(root_child0, &measureCount);
CSSNodeSetMeasureFunc(root_child0, _measureMin);
CSSNodeInsertChild(root, root_child0, 0);
YGNodeSetContext(root_child0, &measureCount);
YGNodeSetMeasureFunc(root_child0, _measureMin);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
CSSNodeCalculateLayout(root, 100, 50, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, 50, YGDirectionLTR);
ASSERT_EQ(1, measureCount);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, remeasure_with_same_atmost_width_larger_than_needed_height) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
TEST(YogaTest, remeasure_with_same_atmost_width_larger_than_needed_height) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
const CSSNodeRef root_child0 = CSSNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
int measureCount = 0;
CSSNodeSetContext(root_child0, &measureCount);
CSSNodeSetMeasureFunc(root_child0, _measureMin);
CSSNodeInsertChild(root, root_child0, 0);
YGNodeSetContext(root_child0, &measureCount);
YGNodeSetMeasureFunc(root_child0, _measureMin);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
CSSNodeCalculateLayout(root, 100, 50, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, 50, YGDirectionLTR);
ASSERT_EQ(1, measureCount);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, remeasure_with_computed_width_larger_than_needed_height) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
TEST(YogaTest, remeasure_with_computed_width_larger_than_needed_height) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
const CSSNodeRef root_child0 = CSSNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
int measureCount = 0;
CSSNodeSetContext(root_child0, &measureCount);
CSSNodeSetMeasureFunc(root_child0, _measureMin);
CSSNodeInsertChild(root, root_child0, 0);
YGNodeSetContext(root_child0, &measureCount);
YGNodeSetMeasureFunc(root_child0, _measureMin);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
CSSNodeStyleSetAlignItems(root, YGAlignStretch);
CSSNodeCalculateLayout(root, 10, 50, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
YGNodeStyleSetAlignItems(root, YGAlignStretch);
YGNodeCalculateLayout(root, 10, 50, YGDirectionLTR);
ASSERT_EQ(1, measureCount);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, remeasure_with_atmost_computed_width_undefined_height) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
TEST(YogaTest, remeasure_with_atmost_computed_width_undefined_height) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
const CSSNodeRef root_child0 = CSSNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
int measureCount = 0;
CSSNodeSetContext(root_child0, &measureCount);
CSSNodeSetMeasureFunc(root_child0, _measureMin);
CSSNodeInsertChild(root, root_child0, 0);
YGNodeSetContext(root_child0, &measureCount);
YGNodeSetMeasureFunc(root_child0, _measureMin);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR);
CSSNodeCalculateLayout(root, 10, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, 10, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, measureCount);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
struct _MeasureConstraint {
@@ -22,12 +22,12 @@ struct _MeasureConstraintList {
struct _MeasureConstraint *constraints;
};
static CSSSize _measure(CSSNodeRef node,
static YGSize _measure(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
struct _MeasureConstraintList *constraintList = (struct _MeasureConstraintList *)CSSNodeGetContext(node);
struct _MeasureConstraintList *constraintList = (struct _MeasureConstraintList *)YGNodeGetContext(node);
struct _MeasureConstraint *constraints = constraintList->constraints;
uint32_t currentIndex = constraintList->length;
(&constraints[currentIndex])->width = width;
@@ -36,28 +36,28 @@ static CSSSize _measure(CSSNodeRef node,
(&constraints[currentIndex])->heightMode = heightMode;
constraintList->length = currentIndex + 1;
return CSSSize {
return YGSize {
.width = widthMode == YGMeasureModeUndefined ? 10 : width,
.height = heightMode == YGMeasureModeUndefined ? 10 : width,
};
}
TEST(CSSLayoutTest, exactly_measure_stretched_child_column) {
TEST(YogaTest, exactly_measure_stretched_child_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
@@ -65,26 +65,26 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_column) {
ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].widthMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, exactly_measure_stretched_child_row) {
TEST(YogaTest, exactly_measure_stretched_child_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
@@ -92,25 +92,25 @@ TEST(CSSLayoutTest, exactly_measure_stretched_child_row) {
ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_main_axis_column) {
TEST(YogaTest, at_most_main_axis_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
@@ -118,26 +118,26 @@ TEST(CSSLayoutTest, at_most_main_axis_column) {
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_cross_axis_column) {
TEST(YogaTest, at_most_cross_axis_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
@@ -145,26 +145,26 @@ TEST(CSSLayoutTest, at_most_cross_axis_column) {
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_main_axis_row) {
TEST(YogaTest, at_most_main_axis_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
@@ -172,27 +172,27 @@ TEST(CSSLayoutTest, at_most_main_axis_row) {
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, at_most_cross_axis_row) {
TEST(YogaTest, at_most_cross_axis_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
@@ -200,25 +200,25 @@ TEST(CSSLayoutTest, at_most_cross_axis_row) {
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_child) {
TEST(YogaTest, flex_child) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(2, constraintList.length);
@@ -229,26 +229,26 @@ TEST(CSSLayoutTest, flex_child) {
ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[1].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_child_with_flex_basis) {
TEST(YogaTest, flex_child_with_flex_basis) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetHeight(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetFlexBasis(root_child0, 0);
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexBasis(root_child0, 0);
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
@@ -256,68 +256,68 @@ TEST(CSSLayoutTest, flex_child_with_flex_basis) {
ASSERT_EQ(YGMeasureModeExactly, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, overflow_scroll_column) {
TEST(YogaTest, overflow_scroll_column) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetOverflow(root, YGOverflowScroll);
CSSNodeStyleSetHeight(root, 100);
CSSNodeStyleSetWidth(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetOverflow(root, YGOverflowScroll);
YGNodeStyleSetHeight(root, 100);
YGNodeStyleSetWidth(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
ASSERT_FLOAT_EQ(100, constraintList.constraints[0].width);
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].widthMode);
ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].height));
ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].height));
ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, overflow_scroll_row) {
TEST(YogaTest, overflow_scroll_row) {
struct _MeasureConstraintList constraintList = _MeasureConstraintList {
.length = 0,
.constraints = (struct _MeasureConstraint *) malloc(10 * sizeof(struct _MeasureConstraint)),
};
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignFlexStart);
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetOverflow(root, YGOverflowScroll);
CSSNodeStyleSetHeight(root, 100);
CSSNodeStyleSetWidth(root, 100);
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetOverflow(root, YGOverflowScroll);
YGNodeStyleSetHeight(root, 100);
YGNodeStyleSetWidth(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &constraintList);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &constraintList);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(1, constraintList.length);
ASSERT_TRUE(CSSValueIsUndefined(constraintList.constraints[0].width));
ASSERT_TRUE(YGValueIsUndefined(constraintList.constraints[0].width));
ASSERT_EQ(YGMeasureModeUndefined, constraintList.constraints[0].widthMode);
ASSERT_FLOAT_EQ(100, constraintList.constraints[0].height);
ASSERT_EQ(YGMeasureModeAtMost, constraintList.constraints[0].heightMode);
free(constraintList.constraints);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,73 +7,73 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
static CSSSize _measure(CSSNodeRef node,
static YGSize _measure(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
int *measureCount = (int*) CSSNodeGetContext(node);
int *measureCount = (int*) YGNodeGetContext(node);
if (measureCount) {
(*measureCount)++;
}
return CSSSize {
return YGSize {
.width = 10,
.height = 10,
};
}
TEST(CSSLayoutTest, dont_measure_single_grow_shrink_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, dont_measure_single_grow_shrink_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
int measureCount = 0;
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetContext(root_child0, &measureCount);
CSSNodeSetMeasureFunc(root_child0, _measure);
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetFlexShrink(root_child0, 1);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetContext(root_child0, &measureCount);
YGNodeSetMeasureFunc(root_child0, _measure);
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetFlexShrink(root_child0, 1);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_EQ(0, measureCount);
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
#if GTEST_HAS_DEATH_TEST
TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeSetMeasureFunc(root, _measure);
TEST(YogaTest, cannot_add_child_to_node_with_measure_func) {
const YGNodeRef root = YGNodeNew();
YGNodeSetMeasureFunc(root, _measure);
const CSSNodeRef root_child0 = CSSNodeNew();
ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*");
CSSNodeFree(root_child0);
CSSNodeFreeRecursive(root);
const YGNodeRef root_child0 = YGNodeNew();
ASSERT_DEATH(YGNodeInsertChild(root, root_child0, 0), "Cannot add child.*");
YGNodeFree(root_child0);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, cannot_add_nonnull_measure_func_to_non_leaf_node) {
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeInsertChild(root, root_child0, 0);
TEST(YogaTest, cannot_add_nonnull_measure_func_to_non_leaf_node) {
const YGNodeRef root = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
YGNodeInsertChild(root, root_child0, 0);
ASSERT_DEATH(CSSNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*");
CSSNodeFreeRecursive(root);
ASSERT_DEATH(YGNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*");
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, can_nullify_measure_func_on_any_node) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeInsertChild(root, CSSNodeNew(), 0);
TEST(YogaTest, can_nullify_measure_func_on_any_node) {
const YGNodeRef root = YGNodeNew();
YGNodeInsertChild(root, YGNodeNew(), 0);
CSSNodeSetMeasureFunc(root, NULL);
ASSERT_TRUE(CSSNodeGetMeasureFunc(root) == NULL);
CSSNodeFreeRecursive(root);
YGNodeSetMeasureFunc(root, NULL);
ASSERT_TRUE(YGNodeGetMeasureFunc(root) == NULL);
YGNodeFreeRecursive(root);
}
#endif

View File

@@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
extern int32_t gNodeInstanceCount;
@@ -37,41 +37,41 @@ static void testFree(void *ptr) {
free(ptr);
}
TEST(CSSLayoutTest, memory_func_default) {
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL);
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeFreeRecursive(root);
TEST(YogaTest, memory_func_default) {
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
YGSetMemoryFuncs(NULL, NULL, NULL, NULL);
const YGNodeRef root = YGNodeNew();
const YGNodeRef root_child0 = YGNodeNew();
YGNodeInsertChild(root, root_child0, 0);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, memory_func_test_funcs) {
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree);
const CSSNodeRef root = CSSNodeNew();
TEST(YogaTest, memory_func_test_funcs) {
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
YGSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree);
const YGNodeRef root = YGNodeNew();
for (int i = 0; i < 10; i++) {
const CSSNodeRef child = CSSNodeNew();
CSSNodeInsertChild(root, child, 0);
const YGNodeRef child = YGNodeNew();
YGNodeInsertChild(root, child, 0);
}
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
ASSERT_NE(testMallocCount, 0);
ASSERT_NE(testCallocCount, 0);
ASSERT_NE(testReallocCount, 0);
ASSERT_NE(testFreeCount, 0);
CSSLayoutSetMemoryFuncs(NULL, NULL, NULL, NULL);
YGSetMemoryFuncs(NULL, NULL, NULL, NULL);
}
#if GTEST_HAS_DEATH_TEST
TEST(CSSLayoutTest, memory_func_assert_zero_nodes) {
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
const CSSNodeRef root = CSSNodeNew();
ASSERT_DEATH(CSSLayoutSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first");
CSSNodeFreeRecursive(root);
TEST(YogaTest, memory_func_assert_zero_nodes) {
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
const YGNodeRef root = YGNodeNew();
ASSERT_DEATH(YGSetMemoryFuncs(&testMalloc, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: all node must be freed first");
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, memory_func_assert_all_non_null) {
gNodeInstanceCount = 0; // Reset CSSNode instance count for memory func test
ASSERT_DEATH(CSSLayoutSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL");
TEST(YogaTest, memory_func_assert_all_non_null) {
gNodeInstanceCount = 0; // Reset YGNode instance count for memory func test
ASSERT_DEATH(YGSetMemoryFuncs(NULL, &testCalloc, &testRealloc, &testFree), "Cannot set memory functions: functions must be all NULL or Non-NULL");
}
#endif

View File

@@ -9,424 +9,424 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, max_width) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, max_width) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetMaxWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetMaxWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, max_height) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, max_height) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetMaxHeight(root_child0, 50);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetMaxHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(90, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, min_height) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, min_height) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMinHeight(root_child0, 60);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMinHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, min_width) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, min_width) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetMinWidth(root_child0, 60);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetMinWidth(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1);
CSSNodeInsertChild(root, root_child1, 1);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child1, 1);
YGNodeInsertChild(root, root_child1, 1);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_min_max) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, YGJustifyCenter);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetMinHeight(root, 100);
CSSNodeStyleSetMaxHeight(root, 200);
TEST(YogaTest, justify_content_min_max) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetMinHeight(root, 100);
YGNodeStyleSetMaxHeight(root, 200);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 60);
CSSNodeStyleSetHeight(root_child0, 60);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, align_items_min_max) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetAlignItems(root, YGAlignCenter);
CSSNodeStyleSetMinWidth(root, 100);
CSSNodeStyleSetMaxWidth(root, 200);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, align_items_min_max) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetMinWidth(root, 100);
YGNodeStyleSetMaxWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 60);
CSSNodeStyleSetHeight(root_child0, 60);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 60);
YGNodeStyleSetHeight(root_child0, 60);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, justify_content_overflow_min_max) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, YGJustifyCenter);
CSSNodeStyleSetMinHeight(root, 100);
CSSNodeStyleSetMaxHeight(root, 110);
TEST(YogaTest, justify_content_overflow_min_max) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetMinHeight(root, 100);
YGNodeStyleSetMaxHeight(root, 110);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 50);
CSSNodeStyleSetHeight(root_child0, 50);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 50);
YGNodeStyleSetHeight(root_child0, 50);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child1, 50);
CSSNodeStyleSetHeight(root_child1, 50);
CSSNodeInsertChild(root, root_child1, 1);
const YGNodeRef root_child1 = YGNodeNew();
YGNodeStyleSetWidth(root_child1, 50);
YGNodeStyleSetHeight(root_child1, 50);
YGNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child2, 50);
CSSNodeStyleSetHeight(root_child2, 50);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child2 = YGNodeNew();
YGNodeStyleSetWidth(root_child2, 50);
YGNodeStyleSetHeight(root_child2, 50);
YGNodeInsertChild(root, root_child2, 2);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(110, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(110, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-20, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_grow_within_max_width) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 200);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_grow_within_max_width) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
CSSNodeStyleSetMaxWidth(root_child0, 100);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetMaxWidth(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child0_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0_child0, 1);
CSSNodeStyleSetHeight(root_child0_child0, 20);
CSSNodeInsertChild(root_child0, root_child0_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetHeight(root_child0_child0, 20);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 200);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, flex_grow_within_constrained_max_width) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
CSSNodeStyleSetMaxWidth(root_child0, 300);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetMaxWidth(root_child0, 300);
YGNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child0_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0_child0, 1);
CSSNodeStyleSetHeight(root_child0_child0, 20);
CSSNodeInsertChild(root_child0, root_child0_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetHeight(root_child0_child0, 20);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -9,228 +9,228 @@
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, padding_no_size) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetPadding(root, YGEdgeLeft, 10);
CSSNodeStyleSetPadding(root, YGEdgeTop, 10);
CSSNodeStyleSetPadding(root, YGEdgeRight, 10);
CSSNodeStyleSetPadding(root, YGEdgeBottom, 10);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
TEST(YogaTest, padding_no_size) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
YGNodeStyleSetPadding(root, YGEdgeBottom, 10);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_container_match_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetPadding(root, YGEdgeLeft, 10);
CSSNodeStyleSetPadding(root, YGEdgeTop, 10);
CSSNodeStyleSetPadding(root, YGEdgeRight, 10);
CSSNodeStyleSetPadding(root, YGEdgeBottom, 10);
TEST(YogaTest, padding_container_match_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
YGNodeStyleSetPadding(root, YGEdgeBottom, 10);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_flex_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetPadding(root, YGEdgeLeft, 10);
CSSNodeStyleSetPadding(root, YGEdgeTop, 10);
CSSNodeStyleSetPadding(root, YGEdgeRight, 10);
CSSNodeStyleSetPadding(root, YGEdgeBottom, 10);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, padding_flex_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
YGNodeStyleSetPadding(root, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 1);
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetFlexGrow(root_child0, 1);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_stretch_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetPadding(root, YGEdgeLeft, 10);
CSSNodeStyleSetPadding(root, YGEdgeTop, 10);
CSSNodeStyleSetPadding(root, YGEdgeRight, 10);
CSSNodeStyleSetPadding(root, YGEdgeBottom, 10);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, padding_stretch_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetPadding(root, YGEdgeLeft, 10);
YGNodeStyleSetPadding(root, YGEdgeTop, 10);
YGNodeStyleSetPadding(root, YGEdgeRight, 10);
YGNodeStyleSetPadding(root, YGEdgeBottom, 10);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, padding_center_child) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, YGJustifyCenter);
CSSNodeStyleSetAlignItems(root, YGAlignCenter);
CSSNodeStyleSetPadding(root, YGEdgeStart, 10);
CSSNodeStyleSetPadding(root, YGEdgeEnd, 20);
CSSNodeStyleSetPadding(root, YGEdgeBottom, 20);
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 100);
TEST(YogaTest, padding_center_child) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
YGNodeStyleSetAlignItems(root, YGAlignCenter);
YGNodeStyleSetPadding(root, YGEdgeStart, 10);
YGNodeStyleSetPadding(root, YGEdgeEnd, 20);
YGNodeStyleSetPadding(root, YGEdgeBottom, 20);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetWidth(root_child0, 10);
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(40, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(50, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(35, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}
TEST(CSSLayoutTest, child_with_padding_align_end) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
CSSNodeStyleSetAlignItems(root, YGAlignFlexEnd);
CSSNodeStyleSetWidth(root, 200);
CSSNodeStyleSetHeight(root, 200);
TEST(YogaTest, child_with_padding_align_end) {
const YGNodeRef root = YGNodeNew();
YGNodeStyleSetJustifyContent(root, YGJustifyFlexEnd);
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
YGNodeStyleSetWidth(root, 200);
YGNodeStyleSetHeight(root, 200);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetPadding(root_child0, YGEdgeLeft, 20);
CSSNodeStyleSetPadding(root_child0, YGEdgeTop, 20);
CSSNodeStyleSetPadding(root_child0, YGEdgeRight, 20);
CSSNodeStyleSetPadding(root_child0, YGEdgeBottom, 20);
CSSNodeStyleSetWidth(root_child0, 100);
CSSNodeStyleSetHeight(root_child0, 100);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20);
YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20);
YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20);
YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 20);
YGNodeStyleSetWidth(root_child0, 100);
YGNodeStyleSetHeight(root_child0, 100);
YGNodeInsertChild(root, root_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
}

View File

@@ -7,25 +7,25 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) {
CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
TEST(YogaTest, dont_cache_computed_flex_basis_between_layouts) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, true);
const CSSNodeRef root = CSSNodeNew();
const YGNodeRef root = YGNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetHeight(root_child0, 10);
CSSNodeStyleSetFlexBasis(root_child0, 20);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeStyleSetHeight(root_child0, 10);
YGNodeStyleSetFlexBasis(root_child0, 20);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR);
CSSNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, 100, 100, YGDirectionLTR);
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, false);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureWebFlexBasis, false);
}

View File

@@ -7,67 +7,67 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
static CSSSize _measureFloor(CSSNodeRef node,
static YGSize _measureFloor(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
return CSSSize{
return YGSize{
width = 10.2,
height = 10.2,
};
}
static CSSSize _measureCeil(CSSNodeRef node,
static YGSize _measureCeil(YGNodeRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
return CSSSize{
return YGSize{
width = 10.5,
height = 10.5,
};
}
TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_floor) {
CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
TEST(YogaTest, rounding_feature_with_custom_measure_func_floor) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
const YGNodeRef root = YGNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measureFloor);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetMeasureFunc(root_child0, _measureFloor);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_ceil) {
CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
TEST(YogaTest, rounding_feature_with_custom_measure_func_ceil) {
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
const YGNodeRef root = YGNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measureCeil);
CSSNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0 = YGNodeNew();
YGNodeSetMeasureFunc(root_child0, _measureCeil);
YGNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(11, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(11, YGNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
YGNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}

File diff suppressed because it is too large Load Diff

View File

@@ -7,54 +7,54 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <CSSLayout/Yoga.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, copy_style_same) {
const CSSNodeRef node0 = CSSNodeNew();
const CSSNodeRef node1 = CSSNodeNew();
ASSERT_FALSE(CSSNodeIsDirty(node0));
TEST(YogaTest, copy_style_same) {
const YGNodeRef node0 = YGNodeNew();
const YGNodeRef node1 = YGNodeNew();
ASSERT_FALSE(YGNodeIsDirty(node0));
CSSNodeCopyStyle(node0, node1);
ASSERT_FALSE(CSSNodeIsDirty(node0));
YGNodeCopyStyle(node0, node1);
ASSERT_FALSE(YGNodeIsDirty(node0));
CSSNodeFree(node0);
CSSNodeFree(node1);
YGNodeFree(node0);
YGNodeFree(node1);
}
TEST(CSSLayoutTest, copy_style_modified) {
const CSSNodeRef node0 = CSSNodeNew();
ASSERT_FALSE(CSSNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(node0)));
TEST(YogaTest, copy_style_modified) {
const YGNodeRef node0 = YGNodeNew();
ASSERT_FALSE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionColumn, YGNodeStyleGetFlexDirection(node0));
ASSERT_TRUE(YGValueIsUndefined(YGNodeStyleGetMaxHeight(node0)));
const CSSNodeRef node1 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
CSSNodeStyleSetMaxHeight(node1, 10);
const YGNodeRef node1 = YGNodeNew();
YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
YGNodeStyleSetMaxHeight(node1, 10);
CSSNodeCopyStyle(node0, node1);
ASSERT_TRUE(CSSNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0));
ASSERT_FLOAT_EQ(10, CSSNodeStyleGetMaxHeight(node0));
YGNodeCopyStyle(node0, node1);
ASSERT_TRUE(YGNodeIsDirty(node0));
ASSERT_EQ(YGFlexDirectionRow, YGNodeStyleGetFlexDirection(node0));
ASSERT_FLOAT_EQ(10, YGNodeStyleGetMaxHeight(node0));
CSSNodeFree(node0);
CSSNodeFree(node1);
YGNodeFree(node0);
YGNodeFree(node1);
}
TEST(CSSLayoutTest, copy_style_modified_same) {
const CSSNodeRef node0 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(node0, YGFlexDirectionRow);
CSSNodeStyleSetMaxHeight(node0, 10);
CSSNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FALSE(CSSNodeIsDirty(node0));
TEST(YogaTest, copy_style_modified_same) {
const YGNodeRef node0 = YGNodeNew();
YGNodeStyleSetFlexDirection(node0, YGFlexDirectionRow);
YGNodeStyleSetMaxHeight(node0, 10);
YGNodeCalculateLayout(node0, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FALSE(YGNodeIsDirty(node0));
const CSSNodeRef node1 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
CSSNodeStyleSetMaxHeight(node1, 10);
const YGNodeRef node1 = YGNodeNew();
YGNodeStyleSetFlexDirection(node1, YGFlexDirectionRow);
YGNodeStyleSetMaxHeight(node1, 10);
CSSNodeCopyStyle(node0, node1);
ASSERT_FALSE(CSSNodeIsDirty(node0));
YGNodeCopyStyle(node0, node1);
ASSERT_FALSE(YGNodeIsDirty(node0));
CSSNodeFree(node0);
CSSNodeFree(node1);
YGNodeFree(node0);
YGNodeFree(node1);
}