/**
* @author TristanVALCKE / https://github.com/Itee
* @author Anonymous
*/
/* global QUnit */
import { PropertyBinding } from '../../../../src/animation/PropertyBinding';
import { BoxGeometry } from '../../../../src/geometries/BoxGeometry';
import { Mesh } from '../../../../src/objects/Mesh';
import { MeshBasicMaterial } from '../../../../src/materials/MeshBasicMaterial';
export default QUnit.module( 'Animation', () => {
QUnit.module( 'PropertyBinding', () => {
// INSTANCING
QUnit.todo( "Instancing", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
// STATIC STUFF
QUnit.todo( "Composite", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.todo( "create", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.test( 'sanitizeNodeName', ( assert ) => {
assert.equal(
PropertyBinding.sanitizeNodeName( 'valid-name-123_' ),
'valid-name-123_',
'Leaves valid name intact.'
);
assert.equal(
PropertyBinding.sanitizeNodeName( 'space separated name 123_ -' ),
'space_separated_name_123__-',
'Replaces spaces with underscores.'
);
assert.equal(
PropertyBinding.sanitizeNodeName( '"invalid" name %123%_' ),
'invalid_name_123_',
'Strips invalid characters.'
);
} );
QUnit.test( 'parseTrackName', ( assert ) => {
var paths = [
[
'.property',
{
nodeName: undefined,
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'nodeName.property',
{
nodeName: 'nodeName',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'a.property',
{
nodeName: 'a',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'no.de.Name.property',
{
nodeName: 'no.de.Name',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'no.d-e.Name.property',
{
nodeName: 'no.d-e.Name',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'nodeName.property[accessor]',
{
nodeName: 'nodeName',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: 'accessor'
}
],
[
'nodeName.material.property[accessor]',
{
nodeName: 'nodeName',
objectName: 'material',
objectIndex: undefined,
propertyName: 'property',
propertyIndex: 'accessor'
}
],
[
'no.de.Name.material.property',
{
nodeName: 'no.de.Name',
objectName: 'material',
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'no.de.Name.material[materialIndex].property',
{
nodeName: 'no.de.Name',
objectName: 'material',
objectIndex: 'materialIndex',
propertyName: 'property',
propertyIndex: undefined
}
],
[
'uuid.property[accessor]',
{
nodeName: 'uuid',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: 'accessor'
}
],
[
'uuid.objectName[objectIndex].propertyName[propertyIndex]',
{
nodeName: 'uuid',
objectName: 'objectName',
objectIndex: 'objectIndex',
propertyName: 'propertyName',
propertyIndex: 'propertyIndex'
}
],
[
'parentName/nodeName.property',
{
// directoryName is currently unused.
nodeName: 'nodeName',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'parentName/no.de.Name.property',
{
// directoryName is currently unused.
nodeName: 'no.de.Name',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: undefined
}
],
[
'parentName/parentName/nodeName.property[index]',
{
// directoryName is currently unused.
nodeName: 'nodeName',
objectName: undefined,
objectIndex: undefined,
propertyName: 'property',
propertyIndex: 'index'
}
],
[
'.bone[Armature.DEF_cog].position',
{
nodeName: undefined,
objectName: 'bone',
objectIndex: 'Armature.DEF_cog',
propertyName: 'position',
propertyIndex: undefined
}
],
[
'scene:helium_balloon_model:helium_balloon_model.position',
{
nodeName: 'helium_balloon_model',
objectName: undefined,
objectIndex: undefined,
propertyName: 'position',
propertyIndex: undefined
}
]
];
paths.forEach( function ( path ) {
assert.smartEqual(
PropertyBinding.parseTrackName( path[ 0 ] ),
path[ 1 ],
'Parses track name: ' + path[ 0 ]
);
} );
} );
QUnit.todo( "findNode", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
// PUBLIC STUFF
QUnit.todo( "BindingType", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.todo( "Versioning", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.todo( "GetterByBindingType", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.todo( "SetterByBindingTypeAndVersioning", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.todo( "getValue", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.test( 'setValue', ( assert ) => {
var paths = [
'.material.opacity',
'.material[opacity]'
];
paths.forEach( function ( path ) {
var originalValue = 0;
var expectedValue = 1;
var geometry = new BoxGeometry();
var material = new MeshBasicMaterial();
material.opacity = originalValue;
var mesh = new Mesh( geometry, material );
var binding = new PropertyBinding( mesh, path, null );
binding.bind();
assert.equal(
material.opacity,
originalValue,
'Sets property of material with "' + path + '" (pre-setValue)'
);
binding.setValue( [ expectedValue ], 0 );
assert.equal(
material.opacity,
expectedValue,
'Sets property of material with "' + path + '" (post-setValue)'
);
} );
} );
QUnit.todo( "bind", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
QUnit.todo( "unbind", ( assert ) => {
assert.ok( false, "everything's gonna be alright" );
} );
} );
} );
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function toValueGo(value) {
return value.toString().replace('px','').replace('%','');
}
function toMethodName(value) {
if (value.indexOf('%') >= 0){
return 'Percent';
} else if(value.indexOf('Auto') >= 0) {
return 'Auto';
}
return '';
}
function toExportName(name) {
name = name.replace(/(\_\w)/g, function(m) { return m[1].toUpperCase(); });
if (name.length > 0) {
name = name[0].toUpperCase() + name.substring(1);
}
return name;
}
var GoEmitter = function() {
Emitter.call(this, 'go', ' ');
};
GoEmitter.prototype = Object.create(Emitter.prototype, {
constructor:{value:GoEmitter},
emitPrologue:{value:function() {}},
emitTestPrologue:{value:function(name, experiments) {
this.push('func Test' + toExportName(name) + '(t *testing.T) {');
this.pushIndent();
this.push('config := NewConfig()')
this.push('defer config.Free()')
for (var i in experiments) {
this.push('config.SetExperimentalFeatureEnabled(Experiment' + experiments[i] +', true)');
}
this.push('');
}},
emitTestTreePrologue:{value:function(nodeName) {
this.push(nodeName + ' := NewNodeWithConfig(config)');
this.push('defer ' +nodeName + '.Free()')
}},
emitTestEpilogue:{value:function(experiments) {
this.popIndent();
this.push('}');
this.push('');
}},
emitEpilogue:{value:function(lines) {}},
AssertEQ:{value:function(v0, v1) {
this.push('assert.EqualValues(t, ' + v0 + ', ' + v1 + ')');
}},
YGAlignAuto:{value:'AlignAuto'},
YGAlignCenter:{value:'AlignCenter'},
YGAlignFlexEnd:{value:'AlignFlexEnd'},
YGAlignFlexStart:{value:'AlignFlexStart'},
YGAlignStretch:{value:'AlignStretch'},
YGAlignSpaceBetween:{value:'AlignSpaceBetween'},
YGAlignSpaceAround:{value:'AlignSpaceAround'},
YGAlignBaseline:{value:'AlignBaseline'},
YGDirectionInherit:{value:'DirectionInherit'},
YGDirectionLTR:{value:'DirectionLTR'},
YGDirectionRTL:{value:'DirectionRTL'},
YGEdgeBottom:{value:'EdgeBottom'},
YGEdgeEnd:{value:'EdgeEnd'},
YGEdgeLeft:{value:'EdgeLeft'},
YGEdgeRight:{value:'EdgeRight'},
YGEdgeStart:{value:'EdgeStart'},
YGEdgeTop:{value:'EdgeTop'},
YGFlexDirectionColumn:{value:'FlexDirectionColumn'},
YGFlexDirectionColumnReverse:{value:'FlexDirectionColumnReverse'},
YGFlexDirectionRow:{value:'FlexDirectionRow'},
YGFlexDirectionRowReverse:{value:'FlexDirectionRowReverse'},
YGJustifyCenter:{value:'JustifyCenter'},
YGJustifyFlexEnd:{value:'JustifyFlexEnd'},
YGJustifyFlexStart:{value:'JustifyFlexStart'},
YGJustifySpaceAround:{value:'JustifySpaceAround'},
YGJustifySpaceBetween:{value:'JustifySpaceBetween'},
YGJustifySpaceEvenly:{value:'JustifySpaceEvenly'},
YGOverflowHidden:{value:'OverflowHidden'},
YGOverflowVisible:{value:'OverflowVisible'},
YGPositionTypeAbsolute:{value:'PositionAbsolute'},
YGPositionTypeRelative:{value:'PositionRelative'},
YGUndefined:{value:'Undefined'},
YGDisplayFlex:{value:'DisplayFlex'},
YGDisplayNone:{value:'DisplayNone'},
YGAuto:{value:'Auto'},
YGWrapNoWrap:{value:'WrapNone'},
YGWrapWrap:{value:'WrapWrap'},
YGWrapWrapReverse:{value: 'WrapReverse'},
YGNodeCalculateLayout:{value:function(node, dir, experiments) {
this.push(node + '.Style().SetDirection(' + dir + ')');
this.push(node + '.CalculateLayout(Undefined, Undefined, ' + dir +')');
}},
YGNodeInsertChild:{value:function(parentName, nodeName, index) {
this.push(parentName + '.InsertChild(' + nodeName + ', ' + index + ')');
}},
YGNodeLayoutGetLeft:{value:function(nodeName) {
return nodeName + '.Layout().Left()';
}},
YGNodeLayoutGetTop:{value:function(nodeName) {
return nodeName + '.Layout().Top()';
}},
YGNodeLayoutGetWidth:{value:function(nodeName) {
return nodeName + '.Layout().Width()';
}},
YGNodeLayoutGetHeight:{value:function(nodeName) {
return nodeName + '.Layout().Height()';
}},
YGNodeStyleSetAlignContent:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetAlignContent(' + toValueGo(value) + ')');
}},
YGNodeStyleSetAlignItems:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetAlignItems(' + toValueGo(value) + ')');
}},
YGNodeStyleSetAlignSelf:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetAlignSelf(' + toValueGo(value) + ')');
}},
YGNodeStyleSetBorder:{value:function(nodeName, edge, value) {
this.push(nodeName + '.Style().SetBorder(' + edge + ', ' + toValueGo(value) + ')');
}},
YGNodeStyleSetDirection:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetDirection(' + toValueGo(value) + ')');
}},
YGNodeStyleSetDisplay:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetDisplay(' + toValueGo(value) + ')');
}},
YGNodeStyleSetFlexBasis:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetFlexBasis' + toMethodName(value) + '(' + toValueGo(value) + ')');
}},
YGNodeStyleSetFlexDirection:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetFlexDirection(' + toValueGo(value) + ')');
}},
YGNodeStyleSetFlexGrow:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetFlexGrow(' + toValueGo(value) + ')');
}},
YGNodeStyleSetFlexShrink:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetFlexShrink(' + toValueGo(value) + ')');
}},
YGNodeStyleSetFlexWrap:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetFlexWrap(' + toValueGo(value) + ')');
}},
YGNodeStyleSetHeight:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetHeight' + toMethodName(value) + '(' + toValueGo(value) + ')');
}},
YGNodeStyleSetJustifyContent:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetJustifyContent(' + toValueGo(value) + ')');
}},
YGNodeStyleSetMargin:{value:function(nodeName, edge, value) {
var valueStr = toValueGo(value);
if (valueStr != 'Auto') {
valueStr = ', ' + valueStr + '';
} else {
valueStr = '';
}
this.push(nodeName + '.Style().SetMargin' + toMethodName(value) + '(' + edge + valueStr + ')');
}},
YGNodeStyleSetMaxHeight:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetMaxHeight' + toMethodName(value) + '(' + toValueGo(value) + ')');
}},
YGNodeStyleSetMaxWidth:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetMaxWidth' + toMethodName(value) + '(' + toValueGo(value) + ')');
}},
YGNodeStyleSetMinHeight:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetMinHeight' + toMethodName(value) + '(' + toValueGo(value) + ')');
}},
YGNodeStyleSetMinWidth:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetMinWidth' + toMethodName(value) + '(' + toValueGo(value) + ')');
}},
YGNodeStyleSetOverflow:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetOverflow(' + toValueGo(value) + ')');
}},
YGNodeStyleSetPadding:{value:function(nodeName, edge, value) {
this.push(nodeName + '.Style().SetPadding' + toMethodName(value) + '(' + edge + ', ' + toValueGo(value) + ')');
}},
YGNodeStyleSetPosition:{value:function(nodeName, edge, value) {
this.push(nodeName + '.Style().SetPosition' + toMethodName(value) + '(' + edge + ', ' + toValueGo(value) + ')');
}},
YGNodeStyleSetPositionType:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetPositionType(' + toValueGo(value) + ')');
}},
YGNodeStyleSetWidth:{value:function(nodeName, value) {
this.push(nodeName + '.Style().SetWidth' + toMethodName(value) + '(' + toValueGo(value) + ')');
}},
});
/*
Copyright é 2001-2004 World Wide Web Consortium,
(Massachusetts Institute of Technology, European Research Consortium
for Informatics and Mathematics, Keio University). All
Rights Reserved. This work is distributed under the W3Cî Software License [1] in the
hope that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
*/
/**
* Gets URI that identifies the test.
* @return uri identifier of test
*/
function getTargetURI() {
return "http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodereplacechild30";
}
var docsLoaded = -1000000;
var builder = null;
//
// This function is called by the testing framework before
// running the test suite.
//
// If there are no configuration exceptions, asynchronous
// document loading is started. Otherwise, the status
// is set to complete and the exception is immediately
// raised when entering the body of the test.
//
function setUpPage() {
setUpPageStatus = 'running';
try {
//
// creates test document builder, may throw exception
//
builder = createConfiguredBuilder();
docsLoaded = 0;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
docsLoaded += preload(docRef, "doc", "hc_staff");
if (docsLoaded == 1) {
setUpPageStatus = 'complete';
}
} catch(ex) {
catchInitializationError(builder, ex);
setUpPageStatus = 'complete';
}
}
//
// This method is called on the completion of
// each asychronous load started in setUpTests.
//
// When every synchronous loaded document has completed,
// the page status is changed which allows the
// body of the test to be executed.
function loadComplete() {
if (++docsLoaded == 1) {
setUpPageStatus = 'complete';
}
}
/**
*
Using replaceChild on an Element node attempt to replace a new Element child node with
new child nodes and vice versa and in each case verify the name of the replaced node.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core#ID-785887307
*/
function nodereplacechild30() {
var success;
if(checkInitialization(builder, "nodereplacechild30") != null) return;
var doc;
var parent;
var oldChild;
var newElement;
var newText;
var newComment;
var newPI;
var newCdata;
var newERef;
var replaced;
var nodeName;
var appendedChild;
var docRef = null;
if (typeof(this.doc) != 'undefined') {
docRef = this.doc;
}
doc = load(docRef, "doc", "hc_staff");
parent = doc.createElementNS("http://www.w3.org/1999/xhtml","xhtml:html");
oldChild = doc.createElementNS("http://www.w3.org/1999/xhtml","xhtml:head");
newElement = doc.createElementNS("http://www.w3.org/1999/xhtml","xhtml:body");
appendedChild = parent.appendChild(oldChild);
appendedChild = parent.appendChild(newElement);
newText = doc.createTextNode("Text");
appendedChild = parent.appendChild(newText);
newComment = doc.createComment("Comment");
appendedChild = parent.appendChild(newComment);
newPI = doc.createProcessingInstruction("target","data");
appendedChild = parent.appendChild(newPI);
newCdata = doc.createCDATASection("Cdata");
appendedChild = parent.appendChild(newCdata);
newERef = doc.createEntityReference("delta");
appendedChild = parent.appendChild(newERef);
replaced = parent.replaceChild(newElement,oldChild);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_1","xhtml:head",nodeName);
replaced = parent.replaceChild(oldChild,newElement);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_2","xhtml:body",nodeName);
replaced = parent.replaceChild(newText,oldChild);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_3","xhtml:head",nodeName);
replaced = parent.replaceChild(oldChild,newText);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_4","#text",nodeName);
replaced = parent.replaceChild(newComment,oldChild);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_5","xhtml:head",nodeName);
replaced = parent.replaceChild(oldChild,newComment);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_6","#comment",nodeName);
replaced = parent.replaceChild(oldChild,newPI);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_7","target",nodeName);
replaced = parent.replaceChild(oldChild,newCdata);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_8","#cdata-section",nodeName);
replaced = parent.replaceChild(oldChild,newERef);
nodeName = replaced.nodeName;
assertEquals("nodereplacechild30_9","delta",nodeName);
}
function runTest() {
nodereplacechild30();
}
function xmlToJson(xml) {
var obj = {}, i, j, attribute, item, nodeName, old;
if (xml.nodeType === 1) { // element
// do attributes
if (xml.attributes.length > 0) {
obj["@attributes"] = {};
for (j = 0; j < xml.attributes.length; j = j + 1) {
attribute = xml.attributes.item(j);
obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
}
}
} else if (xml.nodeType === 3) { // text
obj = xml.nodeValue.trim();
}
// do children
if (xml.hasChildNodes()) {
for (i = 0; i < xml.childNodes.length; i = i + 1) {
item = xml.childNodes.item(i);
nodeName = item.nodeName;
if ((obj[nodeName]) === undefined) {
obj[nodeName] = xmlToJson(item);
} else {
if ((obj[nodeName].push) === undefined) {
old = obj[nodeName];
obj[nodeName] = [];
obj[nodeName].push(old);
}
obj[nodeName].push(xmlToJson(item));
}
}
}
return obj;
};
Accelerate Your Automation Test Cycles With LambdaTest
Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.