2022-06-08 12:47:24 +00:00
|
|
|
// Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
|
2024-02-23 14:41:04 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2017-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
#include <QtTest/QTest>
|
|
|
|
#include <Qt3DCore/qjoint.h>
|
|
|
|
#include <Qt3DCore/private/qjoint_p.h>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSignalSpy>
|
2019-12-20 11:41:04 +00:00
|
|
|
#include <testarbiter.h>
|
2017-06-27 13:18:17 +00:00
|
|
|
|
2025-07-04 08:00:18 +00:00
|
|
|
#include <QtGui/qquaternion.h>
|
|
|
|
|
2017-06-27 13:18:17 +00:00
|
|
|
using namespace Qt3DCore;
|
|
|
|
|
|
|
|
class tst_QJoint : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void checkDefaultConstruction()
|
|
|
|
{
|
|
|
|
// GIVEN
|
|
|
|
QJoint joint;
|
|
|
|
|
|
|
|
// THEN
|
2017-08-06 18:22:07 +00:00
|
|
|
QCOMPARE(joint.scale(), QVector3D(1.0f, 1.0f, 1.0f));
|
2017-06-27 13:18:17 +00:00
|
|
|
QCOMPARE(joint.rotation(), QQuaternion());
|
|
|
|
QCOMPARE(joint.translation(), QVector3D(0.0f, 0.0f, 0.0f));
|
2017-08-06 18:35:10 +00:00
|
|
|
QCOMPARE(joint.inverseBindMatrix(), QMatrix4x4());
|
2017-08-11 13:53:54 +00:00
|
|
|
QCOMPARE(joint.rotationX(), 0.0f);
|
|
|
|
QCOMPARE(joint.rotationY(), 0.0f);
|
|
|
|
QCOMPARE(joint.rotationZ(), 0.0f);
|
2017-06-27 13:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void checkPropertyChanges()
|
|
|
|
{
|
|
|
|
// GIVEN
|
|
|
|
QJoint joint;
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-09-28 11:50:28 +00:00
|
|
|
joint.setToIdentity();
|
2017-08-06 18:22:07 +00:00
|
|
|
QSignalSpy spy(&joint, SIGNAL(scaleChanged(QVector3D)));
|
|
|
|
const QVector3D newValue(2.5f, 2.0f, 1.3f);
|
2017-06-27 13:18:17 +00:00
|
|
|
joint.setScale(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QCOMPARE(joint.scale(), 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-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
joint.setScale(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(joint.scale(), 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-06-27 13:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-09-28 11:50:28 +00:00
|
|
|
joint.setToIdentity();
|
2017-06-27 13:18:17 +00:00
|
|
|
QSignalSpy spy(&joint, SIGNAL(rotationChanged(QQuaternion)));
|
|
|
|
const auto newValue = QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 45.0f);
|
|
|
|
joint.setRotation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QCOMPARE(joint.rotation(), 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-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
joint.setRotation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(joint.rotation(), 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-06-27 13:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-09-28 11:50:28 +00:00
|
|
|
joint.setToIdentity();
|
2017-06-27 13:18:17 +00:00
|
|
|
QSignalSpy spy(&joint, SIGNAL(translationChanged(QVector3D)));
|
|
|
|
const QVector3D newValue(1.0f, 2.0f, 3.0f);
|
|
|
|
joint.setTranslation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QCOMPARE(joint.translation(), 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-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
joint.setTranslation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(joint.translation(), 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-06-27 13:18:17 +00:00
|
|
|
}
|
2017-08-06 18:35:10 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-09-28 11:50:28 +00:00
|
|
|
joint.setToIdentity();
|
2017-08-06 18:35:10 +00:00
|
|
|
QSignalSpy spy(&joint, SIGNAL(inverseBindMatrixChanged(QMatrix4x4)));
|
|
|
|
QMatrix4x4 newValue;
|
|
|
|
newValue.scale(3.5f);
|
|
|
|
joint.setInverseBindMatrix(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QCOMPARE(joint.inverseBindMatrix(), 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-08-06 18:35:10 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
joint.setInverseBindMatrix(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(joint.inverseBindMatrix(), 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-08-06 18:35:10 +00:00
|
|
|
}
|
2017-08-11 13:53:54 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-09-28 11:50:28 +00:00
|
|
|
joint.setToIdentity();
|
2017-08-11 13:53:54 +00:00
|
|
|
QSignalSpy spy(&joint, SIGNAL(rotationChanged(QQuaternion)));
|
|
|
|
QSignalSpy spyEuler(&joint, SIGNAL(rotationXChanged(float)));
|
|
|
|
const auto newValue = 45.0f;
|
|
|
|
const auto newValueAsQuaternion = QQuaternion::fromEulerAngles(newValue, 0.0f, 0.0f);
|
|
|
|
joint.setRotationX(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QVERIFY(spyEuler.isValid());
|
|
|
|
QCOMPARE(joint.rotationX(), newValue);
|
|
|
|
QCOMPARE(joint.rotation(), newValueAsQuaternion);
|
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);
|
|
|
|
QCOMPARE(spyEuler.size(), 1);
|
2017-08-11 13:53:54 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
spyEuler.clear();
|
|
|
|
joint.setRotationX(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(joint.rotationX(), newValue);
|
|
|
|
QCOMPARE(joint.rotation(), newValueAsQuaternion);
|
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);
|
|
|
|
QCOMPARE(spyEuler.size(), 0);
|
2017-08-11 13:53:54 +00:00
|
|
|
|
|
|
|
joint.setRotationX(0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-09-28 11:50:28 +00:00
|
|
|
joint.setToIdentity();
|
2017-08-11 13:53:54 +00:00
|
|
|
QSignalSpy spy(&joint, SIGNAL(rotationChanged(QQuaternion)));
|
|
|
|
QSignalSpy spyEuler(&joint, SIGNAL(rotationYChanged(float)));
|
|
|
|
const auto newValue = 45.0f;
|
|
|
|
const auto newValueAsQuaternion = QQuaternion::fromEulerAngles(0.0f, newValue, 0.0f);
|
|
|
|
joint.setRotationY(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QVERIFY(spyEuler.isValid());
|
|
|
|
QCOMPARE(joint.rotationY(), newValue);
|
|
|
|
QCOMPARE(joint.rotation(), newValueAsQuaternion);
|
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);
|
|
|
|
QCOMPARE(spyEuler.size(), 1);
|
2017-08-11 13:53:54 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
spyEuler.clear();
|
|
|
|
joint.setRotationY(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(joint.rotationY(), newValue);
|
|
|
|
QCOMPARE(joint.rotation(), newValueAsQuaternion);
|
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);
|
|
|
|
QCOMPARE(spyEuler.size(), 0);
|
2017-08-11 13:53:54 +00:00
|
|
|
|
|
|
|
joint.setRotationY(0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-09-28 11:50:28 +00:00
|
|
|
joint.setToIdentity();
|
2017-08-11 13:53:54 +00:00
|
|
|
QSignalSpy spy(&joint, SIGNAL(rotationChanged(QQuaternion)));
|
|
|
|
QSignalSpy spyEuler(&joint, SIGNAL(rotationZChanged(float)));
|
|
|
|
const auto newValue = 45.0f;
|
|
|
|
const auto newValueAsQuaternion = QQuaternion::fromEulerAngles(0.0f, 0.0f, newValue);
|
|
|
|
joint.setRotationZ(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QVERIFY(spyEuler.isValid());
|
|
|
|
QCOMPARE(joint.rotationZ(), newValue);
|
|
|
|
QCOMPARE(joint.rotation(), newValueAsQuaternion);
|
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);
|
|
|
|
QCOMPARE(spyEuler.size(), 1);
|
2017-08-11 13:53:54 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
spy.clear();
|
|
|
|
spyEuler.clear();
|
|
|
|
joint.setRotationZ(newValue);
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
QCOMPARE(joint.rotationZ(), newValue);
|
|
|
|
QCOMPARE(joint.rotation(), newValueAsQuaternion);
|
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);
|
|
|
|
QCOMPARE(spyEuler.size(), 0);
|
2017-08-11 13:53:54 +00:00
|
|
|
|
|
|
|
joint.setRotationZ(0.0f);
|
|
|
|
}
|
2017-06-27 13:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void checkPropertyUpdateChanges()
|
|
|
|
{
|
|
|
|
// GIVEN
|
|
|
|
TestArbiter arbiter;
|
|
|
|
QJoint joint;
|
|
|
|
arbiter.setArbiterOnNode(&joint);
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
2017-08-06 18:22:07 +00:00
|
|
|
joint.setScale(QVector3D(2.0f, 1.0f, 3.0f));
|
2017-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 1);
|
|
|
|
QCOMPARE(arbiter.dirtyNodes().front(), &joint);
|
2017-06-27 13:18:17 +00:00
|
|
|
|
2019-12-20 11:41:04 +00:00
|
|
|
arbiter.clear();
|
2017-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// WHEN
|
2017-08-06 18:22:07 +00:00
|
|
|
joint.setScale(QVector3D(2.0f, 1.0f, 3.0f));
|
2017-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 0);
|
2017-06-27 13:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
const auto newValue = QQuaternion::fromAxisAndAngle(1.0f, 1.0f, 1.0f, 45.0f);
|
|
|
|
joint.setRotation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 1);
|
|
|
|
QCOMPARE(arbiter.dirtyNodes().front(), &joint);
|
2017-06-27 13:18:17 +00:00
|
|
|
|
2019-12-20 11:41:04 +00:00
|
|
|
arbiter.clear();
|
2017-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
joint.setRotation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 0);
|
2017-06-27 13:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
const QVector3D newValue(1.0f, 2.0f, 3.0f);
|
|
|
|
joint.setTranslation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 1);
|
|
|
|
QCOMPARE(arbiter.dirtyNodes().front(), &joint);
|
2017-06-27 13:18:17 +00:00
|
|
|
|
2019-12-20 11:41:04 +00:00
|
|
|
arbiter.clear();
|
2017-06-27 13:18:17 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
joint.setTranslation(newValue);
|
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 0);
|
2017-06-27 13:18:17 +00:00
|
|
|
}
|
2017-08-06 18:35:10 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// WHEN
|
|
|
|
QMatrix4x4 newValue;
|
|
|
|
newValue.rotate(90.0f, 1.0f, 0.0f, 0.0f);
|
|
|
|
joint.setInverseBindMatrix(newValue);
|
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 1);
|
|
|
|
QCOMPARE(arbiter.dirtyNodes().front(), &joint);
|
2017-08-06 18:35:10 +00:00
|
|
|
|
2019-12-20 11:41:04 +00:00
|
|
|
arbiter.clear();
|
2017-08-06 18:35:10 +00:00
|
|
|
|
|
|
|
// WHEN
|
|
|
|
joint.setInverseBindMatrix(newValue);
|
|
|
|
|
|
|
|
// THEN
|
2019-12-20 11:41:04 +00:00
|
|
|
QCOMPARE(arbiter.dirtyNodes().size(), 0);
|
2017-08-06 18:35:10 +00:00
|
|
|
}
|
2017-06-27 13:18:17 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_MAIN(tst_QJoint)
|
|
|
|
|
|
|
|
#include "tst_qjoint.moc"
|