[Ktutorial-commits] SF.net SVN: ktutorial:[105] trunk/ktutorial/ktutorial-library/test/StepTest .cp
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-02-25 05:02:51
|
Revision: 105
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=105&view=rev
Author: danxuliu
Date: 2010-02-25 05:02:43 +0000 (Thu, 25 Feb 2010)
Log Message:
-----------
Ensure that there are no conflicts between WaitFor and Options added to a Step in the normal way and during its setup.
Modified Paths:
--------------
trunk/ktutorial/ktutorial-library/test/StepTest.cpp
Modified: trunk/ktutorial/ktutorial-library/test/StepTest.cpp
===================================================================
--- trunk/ktutorial/ktutorial-library/test/StepTest.cpp 2010-02-25 01:16:52 UTC (rev 104)
+++ trunk/ktutorial/ktutorial-library/test/StepTest.cpp 2010-02-25 05:02:43 UTC (rev 105)
@@ -71,6 +71,7 @@
void testAddOptionWithoutSlotMacro();
void testAddOptionSeveralOptions();
void testAddOptionDuringSetup();
+ void testAddOptionNormalAndDuringSetup();
void testAddOptionTwice();
void testAddOptionDifferentOptionsWithSameName();
@@ -78,6 +79,7 @@
void testAddWaitForWithoutSlotMacro();
void testAddWaitForSeveralWaitFors();
void testAddWaitForDuringSetup();
+ void testAddWaitForNormalAndDuringSetup();
void testAddWaitForTwice();
void testRemoveOption();
@@ -295,6 +297,35 @@
QCOMPARE(destroyedSpy.count(), 1);
}
+void StepTest::testAddOptionNormalAndDuringSetup() {
+ StepWithOptionAddedInSetup step("doSomethingConstructive", this);
+
+ Option* option1 = new Option("Feed a toucan");
+
+ step.addOption(option1, this, SLOT(anotherDummySlot()));
+ connect(this, SIGNAL(anotherDummySignal()), option1, SIGNAL(selected()));
+
+ step.setActive(true);
+
+ connect(this, SIGNAL(dummySignal()), step.mOption, SIGNAL(selected()));
+
+ emit dummySignal();
+ QCOMPARE(mDummySlotCallCount, 1);
+
+ emit anotherDummySignal();
+ QCOMPARE(mAnotherDummySlotCallCount, 1);
+
+ QSignalSpy destroyedSpy(step.mOption, SIGNAL(destroyed(QObject*)));
+
+ step.setActive(false);
+
+ QCOMPARE(step.options().count(), 1);
+ QVERIFY(step.options().contains(option1));
+ QCOMPARE(step.mWaitsForToBeDeletedInTearDown.count(), 0);
+ QCOMPARE(step.mOptionsToBeDeletedInTearDown.count(), 0);
+ QCOMPARE(destroyedSpy.count(), 1);
+}
+
void StepTest::testAddOptionTwice() {
Step step("doSomethingConstructive");
@@ -453,6 +484,32 @@
QCOMPARE(destroyedSpy.count(), 1);
}
+void StepTest::testAddWaitForNormalAndDuringSetup() {
+ StepWithWaitForAddedInSetup step("doSomethingConstructive", this);
+
+ WaitFor* waitFor1 = new WaitForSignal(this, SIGNAL(anotherDummySignal()));
+
+ step.addWaitFor(waitFor1, this, SLOT(anotherDummySlot()));
+
+ step.setActive(true);
+
+ emit dummySignal();
+ QCOMPARE(mDummySlotCallCount, 1);
+
+ emit anotherDummySignal();
+ QCOMPARE(mAnotherDummySlotCallCount, 1);
+
+ QSignalSpy destroyedSpy(step.mWaitFor, SIGNAL(destroyed(QObject*)));
+
+ step.setActive(false);
+
+ QCOMPARE(step.mWaitsFor.count(), 1);
+ QVERIFY(step.mWaitsFor.contains(waitFor1));
+ QCOMPARE(step.mWaitsForToBeDeletedInTearDown.count(), 0);
+ QCOMPARE(step.mOptionsToBeDeletedInTearDown.count(), 0);
+ QCOMPARE(destroyedSpy.count(), 1);
+}
+
void StepTest::testAddWaitForTwice() {
Step step("doSomethingConstructive");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|