From 544567054ebc9f9fdc3a152581a45697c7a3b5d2 Mon Sep 17 00:00:00 2001 From: Franck Arrecot Date: Fri, 4 Mar 2016 14:32:45 +0100 Subject: Class QSortMethod renamed to QSortPolicy Task-number: QTBUG-51471 Change-Id: I41e9c547a86ff0918ceb2f1e4f2eed75ac948662 Reviewed-by: Sean Harmer --- tests/auto/render/qsortmethod/qsortmethod.pro | 10 -- tests/auto/render/qsortmethod/tst_qsortmethod.cpp | 162 ---------------------- tests/auto/render/qsortpolicy/qsortpolicy.pro | 10 ++ tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp | 162 ++++++++++++++++++++++ tests/auto/render/render.pro | 2 +- 5 files changed, 173 insertions(+), 173 deletions(-) delete mode 100644 tests/auto/render/qsortmethod/qsortmethod.pro delete mode 100644 tests/auto/render/qsortmethod/tst_qsortmethod.cpp create mode 100644 tests/auto/render/qsortpolicy/qsortpolicy.pro create mode 100644 tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp (limited to 'tests') diff --git a/tests/auto/render/qsortmethod/qsortmethod.pro b/tests/auto/render/qsortmethod/qsortmethod.pro deleted file mode 100644 index ca9537aa6..000000000 --- a/tests/auto/render/qsortmethod/qsortmethod.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = app - -TARGET = tst_qsortmethod -QT += core-private 3dcore 3dcore-private 3drender 3drender-private testlib - -CONFIG += testcase - -SOURCES += tst_qsortmethod.cpp - -include(../commons/commons.pri) diff --git a/tests/auto/render/qsortmethod/tst_qsortmethod.cpp b/tests/auto/render/qsortmethod/tst_qsortmethod.cpp deleted file mode 100644 index 840f06235..000000000 --- a/tests/auto/render/qsortmethod/tst_qsortmethod.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -#include -#include - -#include "testpostmanarbiter.h" - -// We need to call QNode::clone which is protected -// So we sublcass QNode instead of QObject -class tst_QSortMethod: public Qt3DCore::QNode -{ - Q_OBJECT -public: - ~tst_QSortMethod() - { - QNode::cleanup(); - } - -private Q_SLOTS: - - void checkSaneDefaults() - { - QScopedPointer defaultsortMethod(new Qt3DRender::QSortMethod); - - QVERIFY(defaultsortMethod->criteria().isEmpty()); - } - - void checkCloning_data() - { - QTest::addColumn("sortMethod"); - QTest::addColumn >("criteria"); - - Qt3DRender::QSortMethod *defaultConstructed = new Qt3DRender::QSortMethod(); - QTest::newRow("defaultConstructed") << defaultConstructed << QList(); - - Qt3DRender::QSortMethod *sortMethodWithCriteria = new Qt3DRender::QSortMethod(); - Qt3DRender::QSortCriterion *criterion1 = new Qt3DRender::QSortCriterion(); - Qt3DRender::QSortCriterion *criterion2 = new Qt3DRender::QSortCriterion(); - criterion1->setSort(Qt3DRender::QSortCriterion::BackToFront); - criterion2->setSort(Qt3DRender::QSortCriterion::Material); - QList criteria = QList() << criterion1 << criterion2; - sortMethodWithCriteria->addCriterion(criterion1); - sortMethodWithCriteria->addCriterion(criterion2); - QTest::newRow("sortMethodWithCriteria") << sortMethodWithCriteria << criteria; - } - - void checkCloning() - { - // GIVEN - QFETCH(Qt3DRender::QSortMethod*, sortMethod); - QFETCH(QList, criteria); - - // THEN - QCOMPARE(sortMethod->criteria(), criteria); - - // WHEN - Qt3DRender::QSortMethod *clone = static_cast(QNode::clone(sortMethod)); - - // THEN - QVERIFY(clone != Q_NULLPTR); - QCOMPARE(sortMethod->id(), clone->id()); - - QCOMPARE(sortMethod->criteria().count(), clone->criteria().count()); - - for (int i = 0, m = criteria.count(); i < m; ++i) { - Qt3DRender::QSortCriterion *cClone = clone->criteria().at(i); - Qt3DRender::QSortCriterion *cOrig = criteria.at(i); - QCOMPARE(cOrig->id(),cClone->id()); - QCOMPARE(cOrig->sort(), cClone->sort()); - QVERIFY(cClone->parent() == clone); - QVERIFY(cOrig->parent() == sortMethod); - } - - delete sortMethod; - delete clone; - } - - void checkPropertyUpdates() - { - // GIVEN - QScopedPointer sortMethod(new Qt3DRender::QSortMethod()); - TestArbiter arbiter(sortMethod.data()); - - // WHEN - Qt3DRender::QSortCriterion *criterion1 = new Qt3DRender::QSortCriterion(); - sortMethod->addCriterion(criterion1); - QCoreApplication::processEvents(); - - // THEN - QCOMPARE(arbiter.events.size(), 1); - Qt3DCore::QScenePropertyChangePtr change = arbiter.events.first().staticCast(); - QCOMPARE(change->propertyName(), "sortCriterion"); - QCOMPARE(change->subjectId(),sortMethod->id()); - QCOMPARE(change->value().value(), criterion1->id()); - QCOMPARE(change->type(), Qt3DCore::NodeAdded); - - arbiter.events.clear(); - - // WHEN - sortMethod->addCriterion(criterion1); - QCoreApplication::processEvents(); - - // THEN - QCOMPARE(arbiter.events.size(), 0); - - // WHEN - sortMethod->removeCriterion(criterion1); - QCoreApplication::processEvents(); - - // THEN - QCOMPARE(arbiter.events.size(), 1); - change = arbiter.events.first().staticCast(); - QCOMPARE(change->propertyName(), "sortCriterion"); - QCOMPARE(change->subjectId(), sortMethod->id()); - QCOMPARE(change->value().value(), criterion1->id()); - QCOMPARE(change->type(), Qt3DCore::NodeRemoved); - - arbiter.events.clear(); - } - -protected: - Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE - { - return Q_NULLPTR; - } - -}; - -QTEST_MAIN(tst_QSortMethod) - -#include "tst_qsortmethod.moc" diff --git a/tests/auto/render/qsortpolicy/qsortpolicy.pro b/tests/auto/render/qsortpolicy/qsortpolicy.pro new file mode 100644 index 000000000..1f955d2f0 --- /dev/null +++ b/tests/auto/render/qsortpolicy/qsortpolicy.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +TARGET = tst_qsortmethod +QT += core-private 3dcore 3dcore-private 3drender 3drender-private testlib + +CONFIG += testcase + +SOURCES += tst_qsortpolicy.cpp + +include(../commons/commons.pri) diff --git a/tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp b/tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp new file mode 100644 index 000000000..f91eb325f --- /dev/null +++ b/tests/auto/render/qsortpolicy/tst_qsortpolicy.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include +#include + +#include "testpostmanarbiter.h" + +// We need to call QNode::clone which is protected +// So we sublcass QNode instead of QObject +class tst_QSortPolicy: public Qt3DCore::QNode +{ + Q_OBJECT +public: + ~tst_QSortPolicy() + { + QNode::cleanup(); + } + +private Q_SLOTS: + + void checkSaneDefaults() + { + QScopedPointer defaultsortPolicy(new Qt3DRender::QSortPolicy); + + QVERIFY(defaultsortPolicy->criteria().isEmpty()); + } + + void checkCloning_data() + { + QTest::addColumn("sortPolicy"); + QTest::addColumn >("criteria"); + + Qt3DRender::QSortPolicy *defaultConstructed = new Qt3DRender::QSortPolicy(); + QTest::newRow("defaultConstructed") << defaultConstructed << QList(); + + Qt3DRender::QSortPolicy *sortPolicyWithCriteria = new Qt3DRender::QSortPolicy(); + Qt3DRender::QSortCriterion *criterion1 = new Qt3DRender::QSortCriterion(); + Qt3DRender::QSortCriterion *criterion2 = new Qt3DRender::QSortCriterion(); + criterion1->setSort(Qt3DRender::QSortCriterion::BackToFront); + criterion2->setSort(Qt3DRender::QSortCriterion::Material); + QList criteria = QList() << criterion1 << criterion2; + sortPolicyWithCriteria->addCriterion(criterion1); + sortPolicyWithCriteria->addCriterion(criterion2); + QTest::newRow("sortPolicyWithCriteria") << sortPolicyWithCriteria << criteria; + } + + void checkCloning() + { + // GIVEN + QFETCH(Qt3DRender::QSortPolicy*, sortPolicy); + QFETCH(QList, criteria); + + // THEN + QCOMPARE(sortPolicy->criteria(), criteria); + + // WHEN + Qt3DRender::QSortPolicy *clone = static_cast(QNode::clone(sortPolicy)); + + // THEN + QVERIFY(clone != Q_NULLPTR); + QCOMPARE(sortPolicy->id(), clone->id()); + + QCOMPARE(sortPolicy->criteria().count(), clone->criteria().count()); + + for (int i = 0, m = criteria.count(); i < m; ++i) { + Qt3DRender::QSortCriterion *cClone = clone->criteria().at(i); + Qt3DRender::QSortCriterion *cOrig = criteria.at(i); + QCOMPARE(cOrig->id(),cClone->id()); + QCOMPARE(cOrig->sort(), cClone->sort()); + QVERIFY(cClone->parent() == clone); + QVERIFY(cOrig->parent() == sortPolicy); + } + + delete sortPolicy; + delete clone; + } + + void checkPropertyUpdates() + { + // GIVEN + QScopedPointer sortPolicy(new Qt3DRender::QSortPolicy()); + TestArbiter arbiter(sortPolicy.data()); + + // WHEN + Qt3DRender::QSortCriterion *criterion1 = new Qt3DRender::QSortCriterion(); + sortPolicy->addCriterion(criterion1); + QCoreApplication::processEvents(); + + // THEN + QCOMPARE(arbiter.events.size(), 1); + Qt3DCore::QScenePropertyChangePtr change = arbiter.events.first().staticCast(); + QCOMPARE(change->propertyName(), "sortCriterion"); + QCOMPARE(change->subjectId(),sortPolicy->id()); + QCOMPARE(change->value().value(), criterion1->id()); + QCOMPARE(change->type(), Qt3DCore::NodeAdded); + + arbiter.events.clear(); + + // WHEN + sortPolicy->addCriterion(criterion1); + QCoreApplication::processEvents(); + + // THEN + QCOMPARE(arbiter.events.size(), 0); + + // WHEN + sortPolicy->removeCriterion(criterion1); + QCoreApplication::processEvents(); + + // THEN + QCOMPARE(arbiter.events.size(), 1); + change = arbiter.events.first().staticCast(); + QCOMPARE(change->propertyName(), "sortCriterion"); + QCOMPARE(change->subjectId(), sortPolicy->id()); + QCOMPARE(change->value().value(), criterion1->id()); + QCOMPARE(change->type(), Qt3DCore::NodeRemoved); + + arbiter.events.clear(); + } + +protected: + Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE + { + return Q_NULLPTR; + } + +}; + +QTEST_MAIN(tst_QSortPolicy) + +#include "tst_qsortpolicy.moc" diff --git a/tests/auto/render/render.pro b/tests/auto/render/render.pro index 9df90bde5..0f4ba3035 100644 --- a/tests/auto/render/render.pro +++ b/tests/auto/render/render.pro @@ -32,7 +32,7 @@ contains(QT_CONFIG, private_tests) { qrenderpassfilter \ qrendertargetselector \ qsortcriterion \ - qsortmethod \ + qsortpolicy \ qrenderstateset \ qtechniquefilter \ qviewport \ -- cgit v1.2.3