2016-10-12 09:55:04 -07:00
|
|
|
/**
|
|
|
|
* 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 CSSNodeTest {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testInit() {
|
|
|
|
final int refCount = CSSNode.jni_CSSNodeGetInstanceCount();
|
|
|
|
final CSSNode node = new CSSNode();
|
|
|
|
assertEquals(refCount + 1, CSSNode.jni_CSSNodeGetInstanceCount());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testMeasure() {
|
|
|
|
final CSSNode node = new CSSNode();
|
|
|
|
node.setMeasureFunction(new CSSNodeAPI.MeasureFunction() {
|
2016-10-27 10:52:09 -07:00
|
|
|
public long measure(
|
2016-10-12 09:55:04 -07:00
|
|
|
CSSNodeAPI node,
|
|
|
|
float width,
|
|
|
|
CSSMeasureMode widthMode,
|
|
|
|
float height,
|
2016-10-27 10:52:09 -07:00
|
|
|
CSSMeasureMode heightMode) {
|
|
|
|
return MeasureOutput.make(100, 100);
|
2016-10-12 09:55:04 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
node.calculateLayout(null);
|
|
|
|
assertEquals(100, (int) node.getLayoutWidth());
|
|
|
|
assertEquals(100, (int) node.getLayoutHeight());
|
|
|
|
}
|
|
|
|
}
|