summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstatemachine
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-04-29 12:00:31 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-04-29 12:00:31 (GMT)
commitf7d69d7538fc77f65fb2f0223a5c3def03d3f9c8 (patch)
treeef701671997dc4d44b604cb01032d754baee75ec /tests/auto/qstatemachine
parent4bb51ce9c9e34058a1f9cefae9bf1c82ff4d3c5b (diff)
downloadQt-f7d69d7538fc77f65fb2f0223a5c3def03d3f9c8.zip
Qt-f7d69d7538fc77f65fb2f0223a5c3def03d3f9c8.tar.gz
Qt-f7d69d7538fc77f65fb2f0223a5c3def03d3f9c8.tar.bz2
kill source/target-specific animations
Result of API review. We don't have use cases for them yet. We can add them back if valid use cases do turn up.
Diffstat (limited to 'tests/auto/qstatemachine')
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp165
1 files changed, 85 insertions, 80 deletions
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index b380f6d..abe0c2b 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -144,19 +144,21 @@ private slots:
void nestedTargetStateForAnimation();
void animatedGlobalRestoreProperty();
void specificTargetValueOfAnimation();
+
void addDefaultAnimation();
void addDefaultAnimationWithUnusedAnimation();
- void addDefaultAnimationForSource();
- void addDefaultAnimationForTarget();
void removeDefaultAnimation();
- void removeDefaultAnimationForSource();
- void removeDefaultAnimationForTarget();
- void overrideDefaultAnimationWithSource();
- void overrideDefaultAnimationWithTarget();
void overrideDefaultAnimationWithSpecific();
- void overrideDefaultSourceAnimationWithSpecific();
- void overrideDefaultTargetAnimationWithSpecific();
- void overrideDefaultTargetAnimationWithSource();
+
+// void addDefaultAnimationForSource();
+// void addDefaultAnimationForTarget();
+// void removeDefaultAnimationForSource();
+// void removeDefaultAnimationForTarget();
+// void overrideDefaultAnimationWithSource();
+// void overrideDefaultAnimationWithTarget();
+// void overrideDefaultSourceAnimationWithSpecific();
+// void overrideDefaultTargetAnimationWithSpecific();
+// void overrideDefaultTargetAnimationWithSource();
};
tst_QStateMachine::tst_QStateMachine()
@@ -2417,28 +2419,71 @@ void tst_QStateMachine::addDefaultAnimationWithUnusedAnimation()
QCOMPARE(counter.counter, 1);
}
-void tst_QStateMachine::addDefaultAnimationForSource()
+void tst_QStateMachine::removeDefaultAnimation()
+{
+ QStateMachine machine;
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(this, "foo");
+
+ machine.addDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 1);
+ QVERIFY(machine.defaultAnimations().contains(anim));
+
+ machine.removeDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+
+ machine.addDefaultAnimation(anim);
+
+ QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo");
+ machine.addDefaultAnimation(anim2);
+
+ QCOMPARE(machine.defaultAnimations().size(), 2);
+ QVERIFY(machine.defaultAnimations().contains(anim));
+ QVERIFY(machine.defaultAnimations().contains(anim2));
+
+ machine.removeDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 1);
+ QVERIFY(machine.defaultAnimations().contains(anim2));
+
+ machine.removeDefaultAnimation(anim2);
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+}
+
+void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
{
QStateMachine machine;
QObject *object = new QObject();
object->setProperty("foo", 1.0);
+ SlotCalledCounter counter;
+
QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
QState *s2 = new QState(machine.rootState());
s2->assignProperty(object, "foo", 2.0);
QState *s3 = new QState(machine.rootState());
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
- s1->addTransition(new EventTransition(QEvent::User, s2));
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
- QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
- machine.addDefaultAnimationForSourceState(s1, pa);
- s2->addTransition(pa, SIGNAL(finished()), s3);
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimation(defaultAnimation);
+ at->addAnimation(moreSpecificAnimation);
- machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
@@ -2446,10 +2491,11 @@ void tst_QStateMachine::addDefaultAnimationForSource()
QCOREAPPLICATION_EXEC(5000);
QVERIFY(machine.configuration().contains(s3));
- QCOMPARE(object->property("foo").toDouble(), 2.0);
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
}
-void tst_QStateMachine::addDefaultAnimationForTarget()
+/*
+void tst_QStateMachine::addDefaultAnimationForSource()
{
QStateMachine machine;
@@ -2467,7 +2513,7 @@ void tst_QStateMachine::addDefaultAnimationForTarget()
s1->addTransition(new EventTransition(QEvent::User, s2));
QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
- machine.addDefaultAnimationForTargetState(s2, pa);
+ machine.addDefaultAnimationForSourceState(s1, pa);
s2->addTransition(pa, SIGNAL(finished()), s3);
machine.setInitialState(s1);
@@ -2481,39 +2527,36 @@ void tst_QStateMachine::addDefaultAnimationForTarget()
QCOMPARE(object->property("foo").toDouble(), 2.0);
}
-void tst_QStateMachine::removeDefaultAnimation()
+void tst_QStateMachine::addDefaultAnimationForTarget()
{
QStateMachine machine;
- QCOMPARE(machine.defaultAnimations().size(), 0);
-
- QPropertyAnimation *anim = new QPropertyAnimation(this, "foo");
-
- machine.addDefaultAnimation(anim);
-
- QCOMPARE(machine.defaultAnimations().size(), 1);
- QVERIFY(machine.defaultAnimations().contains(anim));
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
- machine.removeDefaultAnimation(anim);
+ QState *s1 = new QState(machine.rootState());
- QCOMPARE(machine.defaultAnimations().size(), 0);
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
- machine.addDefaultAnimation(anim);
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo");
- machine.addDefaultAnimation(anim2);
+ s1->addTransition(new EventTransition(QEvent::User, s2));
- QCOMPARE(machine.defaultAnimations().size(), 2);
- QVERIFY(machine.defaultAnimations().contains(anim));
- QVERIFY(machine.defaultAnimations().contains(anim2));
+ QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
+ machine.addDefaultAnimationForTargetState(s2, pa);
+ s2->addTransition(pa, SIGNAL(finished()), s3);
- machine.removeDefaultAnimation(anim);
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
- QCOMPARE(machine.defaultAnimations().size(), 1);
- QVERIFY(machine.defaultAnimations().contains(anim2));
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
- machine.removeDefaultAnimation(anim2);
- QCOMPARE(machine.defaultAnimations().size(), 0);
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
}
void tst_QStateMachine::removeDefaultAnimationForSource()
@@ -2685,46 +2728,6 @@ void tst_QStateMachine::overrideDefaultAnimationWithTarget()
}
-void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
-{
- QStateMachine machine;
-
- QObject *object = new QObject();
- object->setProperty("foo", 1.0);
-
- SlotCalledCounter counter;
-
- QState *s1 = new QState(machine.rootState());
- machine.setInitialState(s1);
-
- QState *s2 = new QState(machine.rootState());
- s2->assignProperty(object, "foo", 2.0);
-
- QState *s3 = new QState(machine.rootState());
- QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
-
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
-
- QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
- connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
-
- QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
- s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
- connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
-
- machine.addDefaultAnimation(defaultAnimation);
- at->addAnimation(moreSpecificAnimation);
-
- machine.start();
- QCoreApplication::processEvents();
-
- machine.postEvent(new QEvent(QEvent::User));
- QCOREAPPLICATION_EXEC(5000);
-
- QVERIFY(machine.configuration().contains(s3));
- QCOMPARE(counter.counter, 2); // specific animation started and stopped
-}
-
void tst_QStateMachine::overrideDefaultSourceAnimationWithSpecific()
{
QStateMachine machine;
@@ -2845,6 +2848,8 @@ void tst_QStateMachine::overrideDefaultTargetAnimationWithSource()
QCOMPARE(counter.counter, 2); // specific animation started and stopped
}
+*/
+
void tst_QStateMachine::parallelStateAssignmentsDone()
{
QStateMachine machine;