gentest for Java and C#
Summary: - Revise scripts to generate Java and C# unittests using the same HTML fixtures as well as C for code coverage. - Add wrap_column test workaround in gentest.js. - Add checkDefaultValues for sanity check of the CSSLayout default values by test-template.html - Add `align-content: flex-start;` in default div to align with CSSLayout default $ cd csharp/gentest $ ruby gentest.rb - macOS example for C# $ cd csharp/tests/Facebook.CSSLayout $ clang -DCSS_ASSERT_FAIL_ENABLED -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -g -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp $ mcs -debug -t:library -r:nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs $ mono64 --debug nunit-console.exe CSSLayoutTest.dll Reviewed By: emilsjolander Differential Revision: D4053777 fbshipit-source-id: 84450208015e65baf604987bd56c6a268598b545
This commit is contained in:
committed by
Facebook Github Bot
parent
1488f822c3
commit
dc5e613285
218
gentest/gentest-cs.js
Normal file
218
gentest/gentest-cs.js
Normal file
@@ -0,0 +1,218 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var CSEmitter = function() {
|
||||
Emitter.call(this, 'cs', ' ');
|
||||
};
|
||||
|
||||
CSEmitter.prototype = Object.create(Emitter.prototype, {
|
||||
constructor:{value:CSEmitter},
|
||||
|
||||
emitPrologue:{value:function() {
|
||||
this.push([
|
||||
'using System;',
|
||||
'using NUnit.Framework;',
|
||||
'',
|
||||
'namespace Facebook.CSSLayout',
|
||||
'{',
|
||||
]);
|
||||
this.pushIndent();
|
||||
this.push([
|
||||
'[TestFixture]',
|
||||
'public class CSSNodeLayoutTest',
|
||||
'{',
|
||||
]);
|
||||
this.pushIndent();
|
||||
}},
|
||||
|
||||
emitTestPrologue:{value:function(name) {
|
||||
this.push('[Test]');
|
||||
this.push('public void Test_' + name + '()');
|
||||
this.push('{');
|
||||
this.pushIndent();
|
||||
}},
|
||||
|
||||
emitTestTreePrologue:{value:function(nodeName) {
|
||||
this.push('CSSNode ' + nodeName + ' = new CSSNode();');
|
||||
}},
|
||||
|
||||
emitTestEpilogue:{value:function() {
|
||||
this.popIndent();
|
||||
this.push([
|
||||
'}',
|
||||
'',
|
||||
]);
|
||||
}},
|
||||
|
||||
emitEpilogue:{value:function(lines) {
|
||||
this.popIndent();
|
||||
this.push('}');
|
||||
this.popIndent();
|
||||
this.push([
|
||||
'}',
|
||||
'',
|
||||
]);
|
||||
}},
|
||||
|
||||
AssertEQ:{value:function(v0, v1) {
|
||||
this.push('Assert.AreEqual(' + v0 + ', ' + v1 + ');');
|
||||
}},
|
||||
|
||||
CSSAlignAuto:{value:'CSSAlign.Auto'},
|
||||
CSSAlignCenter:{value:'CSSAlign.Center'},
|
||||
CSSAlignFlexEnd:{value:'CSSAlign.FlexEnd'},
|
||||
CSSAlignFlexStart:{value:'CSSAlign.FlexStart'},
|
||||
CSSAlignStretch:{value:'CSSAlign.Stretch'},
|
||||
|
||||
CSSDirectionInherit:{value:'CSSDirection.Inherit'},
|
||||
CSSDirectionLTR:{value:'CSSDirection.LeftToRight'},
|
||||
CSSDirectionRTL:{value:'CSSDirection.RightToLeft'},
|
||||
|
||||
CSSEdgeBottom:{value:'CSSEdge.Bottom'},
|
||||
CSSEdgeEnd:{value:'CSSEdge.End'},
|
||||
CSSEdgeLeft:{value:'CSSEdge.Left'},
|
||||
CSSEdgeRight:{value:'CSSEdge.Right'},
|
||||
CSSEdgeStart:{value:'CSSEdge.Start'},
|
||||
CSSEdgeTop:{value:'CSSEdge.Top'},
|
||||
|
||||
CSSFlexDirectionColumn:{value:'CSSFlexDirection.Column'},
|
||||
CSSFlexDirectionColumnReverse:{value:'CSSFlexDirection.ColumnReverse'},
|
||||
CSSFlexDirectionRow:{value:'CSSFlexDirection.Row'},
|
||||
CSSFlexDirectionRowReverse:{value:'CSSFlexDirection.RowReverse'},
|
||||
|
||||
CSSJustifyCenter:{value:'CSSJustify.Center'},
|
||||
CSSJustifyFlexEnd:{value:'CSSJustify.FlexEnd'},
|
||||
CSSJustifyFlexStart:{value:'CSSJustify.FlexStart'},
|
||||
CSSJustifySpaceAround:{value:'CSSJustify.SpaceAround'},
|
||||
CSSJustifySpaceBetween:{value:'CSSJustify.SpaceBetween'},
|
||||
|
||||
CSSOverflowHidden:{value:'CSSOverflow.Hidden'},
|
||||
CSSOverflowVisible:{value:'CSSOverflow.Visible'},
|
||||
|
||||
CSSPositionTypeAbsolute:{value:'CSSPositionType.Absolute'},
|
||||
CSSPositionTypeRelative:{value:'CSSPositionType.Relative'},
|
||||
|
||||
CSSUndefined:{value:'CSSConstants.Undefined'},
|
||||
|
||||
CSSWrapTypeNoWrap:{value:'CSSWrap.NoWrap'},
|
||||
CSSWrapTypeWrap:{value:'CSSWrap.Wrap'},
|
||||
|
||||
CSSNodeCalculateLayout:{value:function(node, dir) {
|
||||
this.push(node + '.StyleDirection = ' + dir + ';');
|
||||
this.push(node + '.CalculateLayout();');
|
||||
}},
|
||||
|
||||
CSSNodeInsertChild:{value:function(parentName, nodeName, index) {
|
||||
this.push(parentName + '.Insert(' + index + ', ' + nodeName + ');');
|
||||
}},
|
||||
|
||||
CSSNodeLayoutGetLeft:{value:function(nodeName) {
|
||||
return nodeName + '.LayoutX';
|
||||
}},
|
||||
|
||||
CSSNodeLayoutGetTop:{value:function(nodeName) {
|
||||
return nodeName + '.LayoutY';
|
||||
}},
|
||||
|
||||
CSSNodeLayoutGetWidth:{value:function(nodeName) {
|
||||
return nodeName + '.LayoutWidth';
|
||||
}},
|
||||
|
||||
CSSNodeLayoutGetHeight:{value:function(nodeName) {
|
||||
return nodeName + '.LayoutHeight';
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetAlignContent:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.AlignContent = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetAlignItems:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.AlignItems = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetAlignSelf:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.AlignSelf = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetBorder:{value:function(nodeName, edge, value) {
|
||||
this.push(nodeName + '.SetBorder(' + edge + ', ' + value + ');');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetDirection:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.StyleDirection = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetFlexBasis:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.FlexBasis = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetFlexDirection:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.FlexDirection = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetFlexGrow:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.FlexGrow = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetFlexShrink:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.FlexShrink = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetFlexWrap:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.Wrap = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetHeight:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.StyleHeight = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetJustifyContent:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.JustifyContent = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetMargin:{value:function(nodeName, edge, value) {
|
||||
this.push(nodeName + '.SetMargin(' + edge + ', ' + value + ');');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetMaxHeight:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.StyleMaxHeight = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetMaxWidth:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.StyleMaxWidth = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetMinHeight:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.StyleMinHeight = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetMinWidth:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.StyleMinWidth = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetOverflow:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.Overflow = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetPadding:{value:function(nodeName, edge, value) {
|
||||
this.push(nodeName + '.SetPadding(' + edge + ', ' + value + ');');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetPosition:{value:function(nodeName, edge, value) {
|
||||
this.push(nodeName + '.SetPosition(' + edge + ', ' + value + ');');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetPositionType:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.PositionType = ' + value + ';');
|
||||
}},
|
||||
|
||||
CSSNodeStyleSetWidth:{value:function(nodeName, value) {
|
||||
this.push(nodeName + '.StyleWidth = ' + value + ';');
|
||||
}},
|
||||
});
|
Reference in New Issue
Block a user