Remove tests for CSSNodeDEPRECATED

Summary: Remove tests for CSSNodeDEPRECATED. Java tests will be replaced by jni binding tests in upcoming diff.

Reviewed By: lucasr

Differential Revision: D3992821

fbshipit-source-id: d4877674c96f667f5acf92aab58af02aa27da4c2
This commit is contained in:
Emil Sjolander
2016-10-12 05:59:12 -07:00
committed by Facebook Github Bot
parent 41b64478c4
commit 29fa232129
6 changed files with 0 additions and 10280 deletions

View File

@@ -1,54 +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.
*/
package com.facebook.csslayout;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class CSSLayoutFlexBasisTest {
@Test
public void testFlexBasis() {
final CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
root.setFlexDirection(CSSFlexDirection.ROW);
root.setStyleWidth(300);
root.setStyleHeight(100);
final CSSNodeDEPRECATED root_child0 = new CSSNodeDEPRECATED();
root_child0.setFlexGrow(1);
root_child0.setFlexBasis(100);
root_child0.setStyleWidth(200);
root_child0.setStyleHeight(100);
root.addChildAt(root_child0, 0);
final CSSNodeDEPRECATED root_child1 = new CSSNodeDEPRECATED();
root_child1.setFlexGrow(1);
root_child1.setStyleWidth(100);
root_child1.setStyleHeight(100);
root.addChildAt(root_child1, 1);
root.calculateLayout(new CSSLayoutContext());
assertEquals(0, root.getLayoutX(), 0.001);
assertEquals(0, root.getLayoutY(), 0.001);
assertEquals(300, root.getLayoutWidth(), 0.001);
assertEquals(100, root.getLayoutHeight(), 0.001);
assertEquals(0, root_child0.getLayoutX(), 0.001);
assertEquals(0, root_child0.getLayoutY(), 0.001);
assertEquals(200, root_child0.getLayoutWidth(), 0.001);
assertEquals(100, root_child0.getLayoutHeight(), 0.001);
assertEquals(200, root_child1.getLayoutX(), 0.001);
assertEquals(0, root_child1.getLayoutY(), 0.001);
assertEquals(100, root_child1.getLayoutWidth(), 0.001);
assertEquals(100, root_child1.getLayoutHeight(), 0.001);
}
}

View File

@@ -1,51 +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.
*/
package com.facebook.csslayout;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* Tests for {@link CSSNodeDEPRECATED}.
*/
public class CSSNodeTest {
@Test
public void testAddChildGetParent() {
CSSNodeDEPRECATED parent = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED child = new CSSNodeDEPRECATED();
assertNull(child.getParent());
assertEquals(0, parent.getChildCount());
parent.addChildAt(child, 0);
assertEquals(1, parent.getChildCount());
assertEquals(child, parent.getChildAt(0));
assertEquals(parent, child.getParent());
parent.removeChildAt(0);
assertNull(child.getParent());
assertEquals(0, parent.getChildCount());
}
@Test(expected = IllegalStateException.class)
public void testCannotAddChildToMultipleParents() {
CSSNodeDEPRECATED parent1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED parent2 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED child = new CSSNodeDEPRECATED();
parent1.addChildAt(child, 0);
parent2.addChildAt(child, 0);
}
}

View File

@@ -1,241 +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.
*/
package com.facebook.csslayout;
import org.junit.Test;
import static junit.framework.Assert.*;
/**
* Tests for {@link LayoutEngine} and {@link CSSNodeDEPRECATED} to make sure layouts are only generated when
* needed.
*/
public class LayoutCachingTest {
private void assertTreeHasNewLayout(boolean expectedHasNewLayout, CSSNodeDEPRECATED root) {
assertEquals(expectedHasNewLayout, root.hasNewLayout());
for (int i = 0; i < root.getChildCount(); i++) {
assertTreeHasNewLayout(expectedHasNewLayout, root.getChildAt(i));
}
}
private void markLayoutAppliedForTree(CSSNodeDEPRECATED root) {
root.markLayoutSeen();
for (int i = 0; i < root.getChildCount(); i++) {
markLayoutAppliedForTree(root.getChildAt(i));
}
}
@Test
public void testCachesFullTree() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0);
root.calculateLayout(layoutContext);
assertTreeHasNewLayout(true, root);
markLayoutAppliedForTree(root);
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTreeHasNewLayout(false, c0);
assertTreeHasNewLayout(false, c1);
}
@Test
public void testInvalidatesCacheWhenChildAdded() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1c0 = new CSSNodeDEPRECATED();
c0c1.setStyleWidth(200);
c0c1.setStyleHeight(200);
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0);
c0c0.addChildAt(c1c0, 0);
root.calculateLayout(layoutContext);
markLayoutAppliedForTree(root);
c0.addChildAt(c0c1, 1);
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTrue(c0.hasNewLayout());
assertTrue(c0c1.hasNewLayout());
assertTrue(c0c0.hasNewLayout());
assertTrue(c1.hasNewLayout());
assertTrue(c1c0.hasNewLayout());
}
@Test
public void testInvalidatesCacheWhenEnumPropertyChanges() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0);
root.calculateLayout(layoutContext);
markLayoutAppliedForTree(root);
c1.setAlignSelf(CSSAlign.CENTER);
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTrue(c1.hasNewLayout());
assertTrue(c0.hasNewLayout());
assertFalse(c0c0.hasNewLayout());
}
@Test
public void testInvalidatesCacheWhenFloatPropertyChanges() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0);
root.calculateLayout(layoutContext);
markLayoutAppliedForTree(root);
c1.setMargin(Spacing.LEFT, 10);
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTrue(c1.hasNewLayout());
assertTrue(c0.hasNewLayout());
assertTrue(c0c0.hasNewLayout());
}
@Test
public void testInvalidatesFullTreeWhenParentWidthChanges() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0);
c1.addChildAt(c1c0, 0);
root.calculateLayout(layoutContext);
markLayoutAppliedForTree(root);
c0.setStyleWidth(200);
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTrue(c0.hasNewLayout());
assertTrue(c0c0.hasNewLayout());
assertTrue(c1.hasNewLayout());
assertTrue(c1c0.hasNewLayout());
}
@Test
public void testDoesNotInvalidateCacheWhenPropertyIsTheSame() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0);
root.setStyleWidth(200);
root.calculateLayout(layoutContext);
markLayoutAppliedForTree(root);
root.setStyleWidth(200);
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTreeHasNewLayout(false, c0);
assertTreeHasNewLayout(false, c1);
}
@Test
public void testInvalidateCacheWhenHeightChangesPosition() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c1.addChildAt(c1c0, 0);
root.calculateLayout(layoutContext);
markLayoutAppliedForTree(root);
c0.setStyleHeight(100);
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTrue(c0.hasNewLayout());
assertTrue(c1.hasNewLayout());
assertFalse(c1c0.hasNewLayout());
}
@Test
public void testInvalidatesOnNewMeasureFunction() {
CSSLayoutContext layoutContext = new CSSLayoutContext();
CSSNodeDEPRECATED root = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c1 = new CSSNodeDEPRECATED();
CSSNodeDEPRECATED c0c0 = new CSSNodeDEPRECATED();
root.addChildAt(c0, 0);
root.addChildAt(c1, 1);
c0.addChildAt(c0c0, 0);
root.calculateLayout(layoutContext);
markLayoutAppliedForTree(root);
c1.setMeasureFunction(new CSSNodeAPI.MeasureFunction() {
@Override
public void measure(CSSNodeAPI node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode, MeasureOutput measureOutput) {
measureOutput.width = 100;
measureOutput.height = 20;
}
});
root.calculateLayout(layoutContext);
assertTrue(root.hasNewLayout());
assertTrue(c1.hasNewLayout());
assertTrue(c0.hasNewLayout());
assertTrue(c0c0.hasNewLayout());
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +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.
*/
package com.facebook.csslayout;
public class TestConstants {
public static final float SMALL_WIDTH = 35f;
public static final float SMALL_HEIGHT = 18f;
public static final float BIG_WIDTH = 172f;
public static final float BIG_HEIGHT = 36f;
public static final String SMALL_TEXT = "small";
public static final String LONG_TEXT = "loooooooooong with space";
public static final String MEASURE_WITH_RATIO_2 = "measureWithRatio2";
public static final String MEASURE_WITH_MATCH_PARENT = "measureWithMatchParent";
}