summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@theqtcompany.com>2015-12-15 12:20:30 +0100
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2015-12-17 10:22:32 +0000
commita49bd5a0051c713e78dfc2b463f4226cb5422097 (patch)
tree07df532b443806096316b6991fc8220aeaeb2661 /tests
parenta01e50a0f6be304c289bd0c1aea0eda6f1f83995 (diff)
Add stateNames() method
Change-Id: Ib53f532f6c8a14c51d4dc82d0c83c33455d36bce Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/statemachine/statemachine.pro15
-rw-r--r--tests/auto/statemachine/test1.scxml11
-rw-r--r--tests/auto/statemachine/tst_statemachine.cpp79
-rw-r--r--tests/auto/statemachine/tst_statemachine.qrc5
5 files changed, 111 insertions, 1 deletions
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 @@
+<?xml version="1.0" ?>
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
+ name="test1">
+ <state id="a">
+ <state id="a1"/>
+ <state id="a2"/>
+ </state>
+ <state id="b">
+ <final id="final"/>
+ </state>
+</scxml>
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 <QtTest>
+#include <QObject>
+#include <QXmlStreamReader>
+#include <QtScxml/qscxmlparser.h>
+#include <QtScxml/qscxmlstatemachine.h>
+
+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<QString>("scxmlFileName");
+ QTest::addColumn<bool>("compressed");
+ QTest::addColumn<QStringList>("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<QScxmlStateMachine> 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 @@
+<RCC>
+ <qresource prefix="/tst_statemachine">
+ <file>test1.scxml</file>
+ </qresource>
+</RCC>