浏览代码

Add tests for fadeIn & fadeOut

gero3 7 年之前
父节点
当前提交
afe2eec937
共有 1 个文件被更改,包括 26 次插入4 次删除
  1. 26 4
      test/unit/src/animation/AnimationAction.tests.js

+ 26 - 4
test/unit/src/animation/AnimationAction.tests.js

@@ -273,15 +273,37 @@ export default QUnit.module( 'Animation', () => {
 
 		} );
 
-		QUnit.todo( "fadeIn", ( assert ) => {
+		QUnit.test( "fadeIn", ( assert ) => {
 
-			assert.ok( false, "everything's gonna be alright" );
+		    var {mixer, animationAction} = createAnimation();
+            animationAction.fadeIn(1000);
+			animationAction.play();
+            assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeIn is started, EffectiveWeight is 1." );
+			mixer.update(250);
+			assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeIn happened 1/4, EffectiveWeight is 0.25." );
+			mixer.update(250);
+			assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeIn is halfway , EffectiveWeight is 0.5." );
+			mixer.update(250);
+			assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeIn is halfway , EffectiveWeight is 0.75." );
+			mixer.update(500);
+			assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeIn is ended , EffectiveWeight is 1." );
 
 		} );
 
-		QUnit.todo( "fadeOut", ( assert ) => {
+		QUnit.test( "fadeOut", ( assert ) => {
 
-			assert.ok( false, "everything's gonna be alright" );
+			var {mixer, animationAction} = createAnimation();
+            animationAction.fadeOut(1000);
+			animationAction.play();
+            assert.equal( animationAction.getEffectiveWeight(), 1 , "When an animation fadeOut is started, EffectiveWeight is 1." );
+			mixer.update(250);
+			assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );
+			mixer.update(250);
+			assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeOut is halfway , EffectiveWeight is 0.5." );
+			mixer.update(250);
+			assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25." );
+			mixer.update(500);
+			assert.equal( animationAction.getEffectiveWeight(), 0, "When an animation fadeOut is ended , EffectiveWeight is 0." );
 
 		} );