aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickanimations
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@jollamobile.com>2014-03-12 10:44:28 -0500
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-13 16:39:34 +0100
commit11e9c49e5420bf749e4da48b1f14fa7dc9e4716f (patch)
treee98e44253850ec299f07dd8e7fb3d67165b02bad /tests/auto/quick/qquickanimations
parentef635d410dada5c8eaa963d127ccb53eae3194fb (diff)
Don't crash if a ScriptAction changes state mid-transition.
Change-Id: Ia85cb128c7410e2276bf4da02f946d3d0bf44989 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'tests/auto/quick/qquickanimations')
-rw-r--r--tests/auto/quick/qquickanimations/data/scriptActionCrash.qml72
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp15
2 files changed, 87 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickanimations/data/scriptActionCrash.qml b/tests/auto/quick/qquickanimations/data/scriptActionCrash.qml
new file mode 100644
index 0000000000..0a428e2e6c
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/data/scriptActionCrash.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd.
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ width: 400; height: 400
+
+ Component.onCompleted: rect.state = "wide"
+
+ Rectangle {
+ id: rect
+
+ color: "green"
+ width: 50
+ height: 50
+ anchors.centerIn: parent
+
+ states: State {
+ name: "wide"
+ PropertyChanges {
+ target: rect
+ width: 100
+ }
+ }
+ transitions: Transition {
+ to: "wide"
+ SequentialAnimation {
+ NumberAnimation { duration: 200; property: "width" }
+ ScriptAction { script: { rect.state = ""; rect.state = "wide" } }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
index 21872a5528..c167aa66d4 100644
--- a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -111,6 +111,7 @@ private slots:
void pathAnimationInOutBackBug();
void scriptActionBug();
void groupAnimationNullChildBug();
+ void scriptActionCrash();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -1478,6 +1479,20 @@ void tst_qquickanimations::groupAnimationNullChildBug()
}
}
+//ScriptAction should not crash if changing a state in a transition
+void tst_qquickanimations::scriptActionCrash()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("scriptActionCrash.qml"));
+ QObject *obj = c.create();
+
+ //just testing that we don't crash
+ QTest::qWait(1000); //5x transition duration
+
+ delete obj;
+}
+
+
QTEST_MAIN(tst_qquickanimations)