From a49bd5a0051c713e78dfc2b463f4226cb5422097 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 15 Dec 2015 12:20:30 +0100 Subject: Add stateNames() method Change-Id: Ib53f532f6c8a14c51d4dc82d0c83c33455d36bce Reviewed-by: Erik Verbruggen --- tests/auto/auto.pro | 2 +- tests/auto/statemachine/statemachine.pro | 15 ++++++ tests/auto/statemachine/test1.scxml | 11 ++++ tests/auto/statemachine/tst_statemachine.cpp | 79 ++++++++++++++++++++++++++++ tests/auto/statemachine/tst_statemachine.qrc | 5 ++ 5 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 tests/auto/statemachine/statemachine.pro create mode 100644 tests/auto/statemachine/test1.scxml create mode 100644 tests/auto/statemachine/tst_statemachine.cpp create mode 100644 tests/auto/statemachine/tst_statemachine.qrc (limited to 'tests') diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 2e545dd..b4876f0 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = cmake parser scion +SUBDIRS = cmake parser scion statemachine diff --git a/tests/auto/statemachine/statemachine.pro b/tests/auto/statemachine/statemachine.pro new file mode 100644 index 0000000..c96ce21 --- /dev/null +++ b/tests/auto/statemachine/statemachine.pro @@ -0,0 +1,15 @@ +QT = core gui qml testlib scxml +CONFIG += testcase + +TARGET = tst_statemachine +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +RESOURCES += tst_statemachine.qrc + +SOURCES += \ + tst_statemachine.cpp + +load(qscxmlc) diff --git a/tests/auto/statemachine/test1.scxml b/tests/auto/statemachine/test1.scxml new file mode 100644 index 0000000..a8a9070 --- /dev/null +++ b/tests/auto/statemachine/test1.scxml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/auto/statemachine/tst_statemachine.cpp b/tests/auto/statemachine/tst_statemachine.cpp new file mode 100644 index 0000000..3ebed91 --- /dev/null +++ b/tests/auto/statemachine/tst_statemachine.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** 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 http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QScxmlError); + +class tst_StateMachine: public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void stateNames_data(); + void stateNames(); +}; + +void tst_StateMachine::stateNames_data() +{ + QTest::addColumn("scxmlFileName"); + QTest::addColumn("compressed"); + QTest::addColumn("expectedStates"); + + QTest::newRow("test1-compressed") << QString(":/tst_statemachine/test1.scxml") + << true + << (QStringList() << QString("a1") << QString("a2") << QString("final")); + QTest::newRow("test1-not-compressed") << QString(":/tst_statemachine/test1.scxml") + << false + << (QStringList() << QString("a") << QString("a1") << QString("a2") << QString("b") << QString("final")); + +} + +void tst_StateMachine::stateNames() +{ + QFETCH(QString, scxmlFileName); + QFETCH(bool, compressed); + QFETCH(QStringList, expectedStates); + + QScopedPointer stateMachine(QScxmlStateMachine::fromFile(scxmlFileName)); + QVERIFY(!stateMachine.isNull()); + + QCOMPARE(stateMachine->stateNames(compressed), expectedStates); +} + +QTEST_MAIN(tst_StateMachine) + +#include "tst_statemachine.moc" + + diff --git a/tests/auto/statemachine/tst_statemachine.qrc b/tests/auto/statemachine/tst_statemachine.qrc new file mode 100644 index 0000000..1210ef3 --- /dev/null +++ b/tests/auto/statemachine/tst_statemachine.qrc @@ -0,0 +1,5 @@ + + + test1.scxml + + -- cgit v1.2.3