summaryrefslogtreecommitdiffstats
path: root/tests/auto/parser
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@theqtcompany.com>2016-03-31 14:48:28 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2016-04-13 12:29:54 +0000
commit181928775bb5456c88e0528c639274bc7da259c2 (patch)
tree74c3995c2cd791e0745c182a51f74e9a9ae0a365 /tests/auto/parser
parent9968c72f7cac511235ab6aab2e948d29da4ff059 (diff)
Validate IDs and event names, and handle them well in C++ generation.
Change-Id: I2e4e15496e7b2adc2f452745b1341f8fa0140b12 Task-number: QTBUG-51818 Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'tests/auto/parser')
-rw-r--r--tests/auto/parser/eventnames.scxml55
-rw-r--r--tests/auto/parser/ids1.scxml37
-rw-r--r--tests/auto/parser/ids2.scxml38
-rw-r--r--tests/auto/parser/namespaces1.scxml2
-rw-r--r--tests/auto/parser/tst_parser.cpp22
-rw-r--r--tests/auto/parser/tst_parser.qrc3
6 files changed, 154 insertions, 3 deletions
diff --git a/tests/auto/parser/eventnames.scxml b/tests/auto/parser/eventnames.scxml
new file mode 100644
index 0000000..d5e4ff7
--- /dev/null
+++ b/tests/auto/parser/eventnames.scxml
@@ -0,0 +1,55 @@
+<?xml version="1.0" ?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtScxml 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$
+**
+****************************************************************************/
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="eventnames">
+ <state id="a">
+ <onentry>
+ <send event="valid"/>
+ <send event="still.valid"/>
+ <send event="still-valid"/>
+ <send event="still:valid"/>
+ <send event="-valid-"/>
+ <send event=".invalid"/>
+ <send event="invalid."/>
+ <send event="in valid"/>
+ <send event="&#x00ff;valid"/>
+ </onentry>
+
+ <transition event="valid"/>
+ <transition event="still.valid"/>
+ <transition event="still-valid"/>
+ <transition event="still:valid"/>
+ <transition event="-valid-"/>
+ <transition event=".invalid"/>
+ <transition event="invalid."/>
+ <transition event="also valid"/>
+ <transition event="&#x00ff;valid"/>
+ </state>
+</scxml>
diff --git a/tests/auto/parser/ids1.scxml b/tests/auto/parser/ids1.scxml
new file mode 100644
index 0000000..7e8bd15
--- /dev/null
+++ b/tests/auto/parser/ids1.scxml
@@ -0,0 +1,37 @@
+<?xml version="1.0" ?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtScxml 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$
+**
+****************************************************************************/
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="ids1">
+ <state id="foo.bar"/>
+ <state id="foo-bar"/>
+ <state id="foo_bar"/>
+ <state id="mooze_1"/>
+ <state id="_"/>
+</scxml>
diff --git a/tests/auto/parser/ids2.scxml b/tests/auto/parser/ids2.scxml
new file mode 100644
index 0000000..228b487
--- /dev/null
+++ b/tests/auto/parser/ids2.scxml
@@ -0,0 +1,38 @@
+<?xml version="1.0" ?>
+<!--
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtScxml 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$
+**
+****************************************************************************/
+-->
+<!-- enable-qt-mode: yes -->
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" name="ids2">
+ <state id="foo.bar"/>
+ <state id="foo-bar"/>
+ <state id="foo_bar"/>
+ <state id="1"/>
+ <state id="_"/>
+</scxml>
diff --git a/tests/auto/parser/namespaces1.scxml b/tests/auto/parser/namespaces1.scxml
index c691302..551c130 100644
--- a/tests/auto/parser/namespaces1.scxml
+++ b/tests/auto/parser/namespaces1.scxml
@@ -33,7 +33,7 @@
<qt:editorinfo initialGeometry="135;83;-20;-20;40;40"/>
<state id="State_1">
<qt:editorinfo geometry="134;218;-60;-50;122;100" scenegeometry="134;218;74;168;122;100"/>
- <transition type="external" event="Transition_2" target="State_2">
+ <transition type="external" event="Transition-2" target="State_2">
<qt:editorinfo movePoint="-26;0"/>
</transition>
</state>
diff --git a/tests/auto/parser/tst_parser.cpp b/tests/auto/parser/tst_parser.cpp
index 9fc24a7..68ca9db 100644
--- a/tests/auto/parser/tst_parser.cpp
+++ b/tests/auto/parser/tst_parser.cpp
@@ -49,10 +49,28 @@ void tst_Parser::error_data()
QTest::addColumn<QVector<QScxmlError> >("expectedErrors");
QVector<QScxmlError> errors;
- errors << QScxmlError(QString(":/tst_parser/test1.scxml"), 34, 46, QString("unknown state 'b' in target"));
+ errors << QScxmlError(QString(":/tst_parser/test1.scxml"), 34, 46,
+ QString("unknown state 'b' in target"));
QTest::newRow("test1") << QString(":/tst_parser/test1.scxml") << errors;
- QTest::newRow("namespaces 1") << QStringLiteral(":/tst_parser/namespaces1.scxml") << QVector<QScxmlError>();
+ QTest::newRow("namespaces 1") << QStringLiteral(":/tst_parser/namespaces1.scxml")
+ << QVector<QScxmlError>();
+ QTest::newRow("IDs 1") << QStringLiteral(":/tst_parser/ids1.scxml") << QVector<QScxmlError>();
+ QTest::newRow("IDs 2") << QStringLiteral(":/tst_parser/ids2.scxml") << (QVector<QScxmlError>()
+ << QScxmlError(":/tst_parser/ids2.scxml", 33, 25,
+ "state id 'foo.bar' is not a valid C++ identifier in Qt mode")
+ << QScxmlError(":/tst_parser/ids2.scxml", 34, 25,
+ "state id 'foo-bar' is not a valid C++ identifier in Qt mode")
+ << QScxmlError(":/tst_parser/ids2.scxml", 36, 19, "'1' is not a valid XML ID")
+ );
+ QTest::newRow("eventnames") << QStringLiteral(":/tst_parser/eventnames.scxml")
+ << (QVector<QScxmlError>()
+ << QScxmlError(":/tst_parser/eventnames.scxml", 50, 38, "'.invalid' is not a valid event")
+ << QScxmlError(":/tst_parser/eventnames.scxml", 51, 38, "'invalid.' is not a valid event")
+ << QScxmlError(":/tst_parser/eventnames.scxml", 39, 36, "'.invalid' is not a valid event")
+ << QScxmlError(":/tst_parser/eventnames.scxml", 40, 36, "'invalid.' is not a valid event")
+ << QScxmlError(":/tst_parser/eventnames.scxml", 41, 36, "'in valid' is not a valid event")
+ );
}
void tst_Parser::error()
diff --git a/tests/auto/parser/tst_parser.qrc b/tests/auto/parser/tst_parser.qrc
index d7c6124..3c6c944 100644
--- a/tests/auto/parser/tst_parser.qrc
+++ b/tests/auto/parser/tst_parser.qrc
@@ -2,5 +2,8 @@
<qresource prefix="/tst_parser">
<file>test1.scxml</file>
<file>namespaces1.scxml</file>
+ <file>ids1.scxml</file>
+ <file>ids2.scxml</file>
+ <file>eventnames.scxml</file>
</qresource>
</RCC>