77 lines
No EOL
2.6 KiB
C++
77 lines
No EOL
2.6 KiB
C++
#include <huestream/effect/animation/data/Playables/PlayableRandomizer.h>
|
|
#include "gtest/gtest.h"
|
|
#include "gmock/gmock.h"
|
|
#include "TestSerializeBase.h"
|
|
|
|
namespace huestream {;
|
|
|
|
class TestPlayableRandomizer : public testing::Test, public TestSerializeBase {
|
|
virtual void SetUp() {}
|
|
virtual void TearDown() {}
|
|
|
|
public:
|
|
|
|
};
|
|
|
|
TEST_F(TestPlayableRandomizer, Serialize) {
|
|
auto c = PlayableRandomizer(10,20, 30, 40, TweenType::EaseInOutQuad, 50);
|
|
JSONNode node;
|
|
c.Serialize(&node);
|
|
ASSERT_PlayableRandomizerWithLength(node, 10, 20, 30, 40, TweenType::EaseInOutQuad, 50);
|
|
}
|
|
|
|
TEST_F(TestPlayableRandomizer, SerializeWithoutLength) {
|
|
auto c = PlayableRandomizer(10,20, 30, 40, TweenType::EaseInOutQuad, INF);
|
|
JSONNode node;
|
|
c.Serialize(&node);
|
|
ASSERT_PlayableRandomizerWithoutLength(node, 10, 20, 30, 40, TweenType::EaseInOutQuad);
|
|
}
|
|
|
|
TEST_F(TestPlayableRandomizer, Deserialize) {
|
|
JSONNode node;
|
|
AddStringAttribute(&node, Serializable::AttributeType, PlayableRandomizer::type);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMinValue, 10);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMaxValue, 20);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMinInterval, 30);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMaxInterval, 40);
|
|
AddStringAttribute(&node, PlayableRandomizer::AttributeTweenType, TweenTypeHelper::ToString(TweenType::Linear));
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeLength, 50);
|
|
|
|
auto c = PlayableRandomizer();
|
|
c.Deserialize(&node);
|
|
|
|
ASSERT_EQ(c.GetMinValue(), 10);
|
|
ASSERT_EQ(c.GetMaxValue(), 20);
|
|
ASSERT_EQ(c.GetMinInterval(), 30);
|
|
ASSERT_EQ(c.GetMaxInterval(), 40);
|
|
ASSERT_EQ(c.GetTweenType(), TweenType::Linear);
|
|
ASSERT_EQ(c.GetLength(), 50);
|
|
}
|
|
|
|
TEST_F(TestPlayableRandomizer, DeserializeWithoutLength) {
|
|
JSONNode node;
|
|
AddStringAttribute(&node, Serializable::AttributeType, PlayableRandomizer::type);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMinValue, 10);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMaxValue, 20);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMinInterval, 30);
|
|
AddDoubleAttribute(&node, PlayableRandomizer::AttributeMaxInterval, 40);
|
|
AddStringAttribute(&node, PlayableRandomizer::AttributeTweenType, TweenTypeHelper::ToString(TweenType::Linear));
|
|
|
|
auto c = PlayableRandomizer();
|
|
c.Deserialize(&node);
|
|
|
|
ASSERT_EQ(c.GetMinValue(), 10);
|
|
ASSERT_EQ(c.GetMaxValue(), 20);
|
|
ASSERT_EQ(c.GetMinInterval(), 30);
|
|
ASSERT_EQ(c.GetMaxInterval(), 40);
|
|
ASSERT_EQ(c.GetTweenType(), TweenType::Linear);
|
|
ASSERT_EQ(c.GetLength(), INF);
|
|
|
|
}
|
|
|
|
|
|
TEST_F(TestPlayableRandomizer, DeserializeFromJson) {
|
|
}
|
|
|
|
|
|
} // namespace huestream
|