2022-06-08 12:47:24 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2024-02-23 14:41:04 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
#include <QtTest/qtest.h>
|
|
|
|
#include <Qt3DAnimation/qkeyframeanimation.h>
|
|
|
|
#include <qobject.h>
|
|
|
|
#include <qsignalspy.h>
|
|
|
|
|
2025-07-04 08:00:18 +00:00
|
|
|
#include <QtGui/qquaternion.h>
|
|
|
|
|
2017-02-08 08:20:46 +00:00
|
|
|
class tst_QKeyframeAnimation : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
|
|
|
|
void initTestCase()
|
|
|
|
{
|
|
|
|
qRegisterMetaType<Qt3DAnimation::QKeyframeAnimation::RepeatMode>(
|
|
|
|
"QKeyframeAnimation::RepeatMode");
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkDefaultConstruction()
|
|
|
|
{
|
|
|
|
// GIVEN
|
|
|
|
Qt3DAnimation::QKeyframeAnimation keyframeAnimation;
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.target(), nullptr);
|
|
|
|
QCOMPARE(keyframeAnimation.easing(), QEasingCurve());
|
|
|
|
QCOMPARE(keyframeAnimation.targetName(), QString());
|
|
|
|
QCOMPARE(keyframeAnimation.startMode(), Qt3DAnimation::QKeyframeAnimation::Constant);
|
|
|
|
QCOMPARE(keyframeAnimation.endMode(), Qt3DAnimation::QKeyframeAnimation::Constant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void checkPropertyChanges()
|
|
|
|
{
|
|
|
|
// GIVEN
|
|
|
|
Qt3DAnimation::QKeyframeAnimation keyframeAnimation;
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
QScopedPointer<Qt3DCore::QTransform> transform(new Qt3DCore::QTransform);
|
2025-06-03 21:32:40 +00:00
|
|
|
QSignalSpy spy(&keyframeAnimation, SIGNAL(targetChanged(Qt3DCore::QTransform*)));
|
2017-02-08 08:20:46 +00:00
|
|
|
Qt3DCore::QTransform * newValue = transform.data();
|
|
|
|
keyframeAnimation.setTarget(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.target(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 1);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
keyframeAnimation.setTarget(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.target(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 0);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// WHEN
|
2025-06-03 21:32:40 +00:00
|
|
|
QSignalSpy spy(&keyframeAnimation, SIGNAL(easingChanged(QEasingCurve)));
|
2017-02-08 08:20:46 +00:00
|
|
|
const QEasingCurve newValue = QEasingCurve(QEasingCurve::CosineCurve);
|
|
|
|
keyframeAnimation.setEasing(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.easing(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 1);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
keyframeAnimation.setEasing(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.easing(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 0);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
QSignalSpy spy(&keyframeAnimation, SIGNAL(targetNameChanged(QString)));
|
|
|
|
const QString newValue = QString("target");
|
|
|
|
keyframeAnimation.setTargetName(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.targetName(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 1);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
keyframeAnimation.setTargetName(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.targetName(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 0);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
QSignalSpy spy(&keyframeAnimation,
|
|
|
|
SIGNAL(startModeChanged(QKeyframeAnimation::RepeatMode)));
|
|
|
|
const Qt3DAnimation::QKeyframeAnimation::RepeatMode newValue
|
|
|
|
= Qt3DAnimation::QKeyframeAnimation::Repeat;
|
|
|
|
keyframeAnimation.setStartMode(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.startMode(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 1);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
keyframeAnimation.setStartMode(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.startMode(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 0);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
QSignalSpy spy(&keyframeAnimation,
|
|
|
|
SIGNAL(endModeChanged(QKeyframeAnimation::RepeatMode)));
|
|
|
|
const Qt3DAnimation::QKeyframeAnimation::RepeatMode newValue
|
|
|
|
= Qt3DAnimation::QKeyframeAnimation::Repeat;
|
|
|
|
keyframeAnimation.setEndMode(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.endMode(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 1);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
keyframeAnimation.setEndMode(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(keyframeAnimation.endMode(), newValue);
|
Port from container::count() and length() to size() - V4
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'.
Change-Id: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2022-10-05 05:40:09 +00:00
|
|
|
QCOMPARE(spy.size(), 0);
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void testAnimating()
|
|
|
|
{
|
|
|
|
// GIVEN
|
|
|
|
Qt3DAnimation::QKeyframeAnimation keyframeAnimation;
|
|
|
|
Qt3DCore::QTransform targetTransform;
|
|
|
|
keyframeAnimation.setTarget(&targetTransform);
|
|
|
|
|
|
|
|
const float positions[3] = {0.0f, 1.0f, 2.0f};
|
|
|
|
|
|
|
|
Qt3DCore::QTransform keyframes[3];
|
|
|
|
keyframes[0].setScale(1.0f);
|
|
|
|
keyframes[1].setScale(2.0f);
|
|
|
|
keyframes[2].setScale(3.0f);
|
|
|
|
|
|
|
|
keyframes[0].setTranslation(QVector3D(0.0f, 0.0f, 0.0f));
|
|
|
|
keyframes[1].setTranslation(QVector3D(1.0f, 1.0f, 0.0f));
|
|
|
|
keyframes[2].setTranslation(QVector3D(2.0f, 0.0f, 2.0f));
|
|
|
|
|
|
|
|
keyframes[0].setRotationX(0.0f);
|
|
|
|
keyframes[1].setRotationY(45.0f);
|
|
|
|
keyframes[2].setRotationZ(90.0f);
|
|
|
|
|
2020-07-08 12:17:04 +00:00
|
|
|
const QList<float> framePositions = { positions[0], positions[1], positions[2] };
|
|
|
|
|
|
|
|
const QList<Qt3DCore::QTransform*> frames = { &keyframes[0], &keyframes[1], &keyframes[2] };
|
2017-02-08 08:20:46 +00:00
|
|
|
|
|
|
|
keyframeAnimation.setFramePositions(framePositions);
|
|
|
|
keyframeAnimation.setKeyframes(frames);
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setPosition(0.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(1.0f, 1.0f, 1.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(0.0f, 0.0f, 0.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 0.0f))));
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setPosition(1.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(2.0f, 2.0f, 2.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(1.0f, 1.0f, 0.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 45.0f, 0.0f))));
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setPosition(2.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setPosition(3.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setStartMode(Qt3DAnimation::QKeyframeAnimation::None);
|
|
|
|
keyframeAnimation.setEndMode(Qt3DAnimation::QKeyframeAnimation::None);
|
|
|
|
keyframeAnimation.setPosition(-1.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setPosition(5.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(3.0f, 3.0f, 3.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(2.0f, 0.0f, 2.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 90.0f))));
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setStartMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
|
|
|
|
keyframeAnimation.setEndMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
|
|
|
|
keyframeAnimation.setPosition(-1.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(2.0f, 2.0f, 2.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(1.0f, 1.0f, 0.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 45.0f, 0.0f))));
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
keyframeAnimation.setStartMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
|
|
|
|
keyframeAnimation.setEndMode(Qt3DAnimation::QKeyframeAnimation::Repeat);
|
|
|
|
keyframeAnimation.setPosition(4.0f);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.scale3D(), QVector3D(1.0f, 1.0f, 1.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.translation(), QVector3D(0.0f, 0.0f, 0.0f)));
|
|
|
|
QVERIFY(qFuzzyCompare(targetTransform.rotation(),
|
|
|
|
QQuaternion::fromEulerAngles(QVector3D(0.0f, 0.0f, 0.0f))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_APPLESS_MAIN(tst_QKeyframeAnimation)
|
|
|
|
|
|
|
|
#include "tst_qkeyframeanimation.moc"
|