Summary: Fixes issue brought up in https://github.com/facebook/react-native/issues/10603 The gist of the problem is that in css it is fine for a child to overflow a parent if it feels the need to, we were not respecting this. Reviewed By: gkassabli Differential Revision: D4157971 fbshipit-source-id: 3cfae15ac8b65b70f01789444099ee684e1b099a
141 lines
5.0 KiB
C#
141 lines
5.0 KiB
C#
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
/**
|
|
* @Generated by gentest/gentest.sh with the following input
|
|
*
|
|
<div id="nested_overflowing_child" style="height: 100px; width: 100px;">
|
|
<div>
|
|
<div style="height: 200px; width: 200px;"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="nested_overflowing_child_in_constraint_parent" style="height: 100px; width: 100px;">
|
|
<div style="height: 100px; width: 100px;">
|
|
<div style="height: 200px; width: 200px;"></div>
|
|
</div>
|
|
</div>
|
|
*
|
|
*/
|
|
|
|
using System;
|
|
using NUnit.Framework;
|
|
|
|
namespace Facebook.CSSLayout
|
|
{
|
|
[TestFixture]
|
|
public class CSSSizeOverflowTest
|
|
{
|
|
[Test]
|
|
public void Test_nested_overflowing_child()
|
|
{
|
|
CSSNode root = new CSSNode();
|
|
root.StyleWidth = 100;
|
|
root.StyleHeight = 100;
|
|
|
|
CSSNode root_child0 = new CSSNode();
|
|
root.Insert(0, root_child0);
|
|
|
|
CSSNode root_child0_child0 = new CSSNode();
|
|
root_child0_child0.StyleWidth = 200;
|
|
root_child0_child0.StyleHeight = 200;
|
|
root_child0.Insert(0, root_child0_child0);
|
|
root.StyleDirection = CSSDirection.LeftToRight;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0, root.LayoutX);
|
|
Assert.AreEqual(0, root.LayoutY);
|
|
Assert.AreEqual(100, root.LayoutWidth);
|
|
Assert.AreEqual(100, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0, root_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0.LayoutY);
|
|
Assert.AreEqual(100, root_child0.LayoutWidth);
|
|
Assert.AreEqual(200, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = CSSDirection.RightToLeft;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0, root.LayoutX);
|
|
Assert.AreEqual(0, root.LayoutY);
|
|
Assert.AreEqual(100, root.LayoutWidth);
|
|
Assert.AreEqual(100, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0, root_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0.LayoutY);
|
|
Assert.AreEqual(100, root_child0.LayoutWidth);
|
|
Assert.AreEqual(200, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(-100, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutHeight);
|
|
}
|
|
|
|
[Test]
|
|
public void Test_nested_overflowing_child_in_constraint_parent()
|
|
{
|
|
CSSNode root = new CSSNode();
|
|
root.StyleWidth = 100;
|
|
root.StyleHeight = 100;
|
|
|
|
CSSNode root_child0 = new CSSNode();
|
|
root_child0.StyleWidth = 100;
|
|
root_child0.StyleHeight = 100;
|
|
root.Insert(0, root_child0);
|
|
|
|
CSSNode root_child0_child0 = new CSSNode();
|
|
root_child0_child0.StyleWidth = 200;
|
|
root_child0_child0.StyleHeight = 200;
|
|
root_child0.Insert(0, root_child0_child0);
|
|
root.StyleDirection = CSSDirection.LeftToRight;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0, root.LayoutX);
|
|
Assert.AreEqual(0, root.LayoutY);
|
|
Assert.AreEqual(100, root.LayoutWidth);
|
|
Assert.AreEqual(100, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0, root_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0.LayoutY);
|
|
Assert.AreEqual(100, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(0, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutHeight);
|
|
|
|
root.StyleDirection = CSSDirection.RightToLeft;
|
|
root.CalculateLayout();
|
|
|
|
Assert.AreEqual(0, root.LayoutX);
|
|
Assert.AreEqual(0, root.LayoutY);
|
|
Assert.AreEqual(100, root.LayoutWidth);
|
|
Assert.AreEqual(100, root.LayoutHeight);
|
|
|
|
Assert.AreEqual(0, root_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0.LayoutY);
|
|
Assert.AreEqual(100, root_child0.LayoutWidth);
|
|
Assert.AreEqual(100, root_child0.LayoutHeight);
|
|
|
|
Assert.AreEqual(-100, root_child0_child0.LayoutX);
|
|
Assert.AreEqual(0, root_child0_child0.LayoutY);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutWidth);
|
|
Assert.AreEqual(200, root_child0_child0.LayoutHeight);
|
|
}
|
|
|
|
}
|
|
}
|