diff --git a/src/components/animator/AnimatorFactory.brs b/src/components/animator/AnimatorFactory.brs index 0a3fdb1..aded763 100644 --- a/src/components/animator/AnimatorFactory.brs +++ b/src/components/animator/AnimatorFactory.brs @@ -1,5 +1,6 @@ ' @import /components/getProperty.brs ' @import /components/rokuComponents/Animation.brs +' @import /components/rokuComponents/ColorFieldInterpolator.brs ' @import /components/rokuComponents/FloatFieldInterpolator.brs ' @import /components/rokuComponents/Vector2DFieldInterpolator.brs @@ -65,6 +66,8 @@ function AnimatorFactory() as Object interpolator = FloatFieldInterpolator() else if (fieldOptions.type = "vector2d") interpolator = Vector2DFieldInterpolator() + else if (fieldOptions.type = "color") + interpolator = ColorFieldInterpolator() else print "Field ";fieldOptions.field;" cannot be animated. Unsupported type of a field." diff --git a/src/components/animator/_tests/AnimatorFactory.test.brs b/src/components/animator/_tests/AnimatorFactory.test.brs index e1e9cbd..cd06f99 100644 --- a/src/components/animator/_tests/AnimatorFactory.test.brs +++ b/src/components/animator/_tests/AnimatorFactory.test.brs @@ -1,5 +1,6 @@ ' @import /components/KopytkoTestSuite.brs from @dazn/kopytko-unit-testing-framework ' @mock /components/rokuComponents/Animation.brs +' @mock /components/rokuComponents/ColorFieldInterpolator.brs ' @mock /components/rokuComponents/FloatFieldInterpolator.brs ' @mock /components/rokuComponents/Vector2DFieldInterpolator.brs function TestSuite__AnimatorFactory() as Object @@ -85,6 +86,7 @@ function TestSuite__AnimatorFactory() as Object end function) ts.addParameterizedTests([ + { field: "color", key: [0.0, 1.0], keyValue: ["#000000", "#FFFFFF"], type: "color" }, { field: "opacity", key: [0.0, 1.0], keyValue: [0.0, 1.0], type: "float" }, { field: "translation", key: [0.0, 1.0], keyValue: [[0.0, 200.0], [400.0, 1200.0]], type: "vector2d" }, ], "it appends supported ${type} interpolator", function (ts as Object, params as Object) as String @@ -116,13 +118,19 @@ function TestSuite__AnimatorFactory() as Object return ts.assertEqual(constructedInterpolatorFields, expectedInterpolatorFields, "The interpolator has no expected config") end function) - ts.addTest("it creates two interpolators", function (ts as Object) as String + ts.addTest("it creates three interpolators", function (ts as Object) as String ' Given options = { delay: Csng(0.2), duration: Csng(20), easeFunction: "linear", fields: [ + { + field: "color", + key: [0.0, 1.0], + keyValue: ["#000000", "#FFFFFF"], + type: "color", + }, { field: "opacity", key: [0.0, 1.0], @@ -142,7 +150,7 @@ function TestSuite__AnimatorFactory() as Object ' Then - return ts.assertEqual(2, _animation.getChildCount(), "There is no two interpolators") + return ts.assertEqual(3, _animation.getChildCount(), "There is no three interpolators") end function) return ts diff --git a/src/components/rokuComponents/ColorFieldInterpolator.brs b/src/components/rokuComponents/ColorFieldInterpolator.brs new file mode 100644 index 0000000..6de649c --- /dev/null +++ b/src/components/rokuComponents/ColorFieldInterpolator.brs @@ -0,0 +1,5 @@ +' Wrapper function for creating native ColorFieldInterpolator component. +' @class +function ColorFieldInterpolator() as Object + return CreateObject("roSGNode", "ColorFieldInterpolator") +end function diff --git a/src/components/rokuComponents/_mocks/ColorFieldInterpolator.mock.brs b/src/components/rokuComponents/_mocks/ColorFieldInterpolator.mock.brs new file mode 100644 index 0000000..96eb65d --- /dev/null +++ b/src/components/rokuComponents/_mocks/ColorFieldInterpolator.mock.brs @@ -0,0 +1,17 @@ +' @import /components/_mocks/Mock.brs from @dazn/kopytko-unit-testing-framework + +' @returns {Mock} +function ColorFieldInterpolator() as Object + return Mock({ + testComponent: m, + name: "ColorFieldInterpolator", + fields: { + fieldToInterp: "", + key: [], + keyValue: [], + fraction: 0.0, + reverse: false, + __subtype: "ColorFieldInterpolator", + }, + }) +end function