Thread: [Ktutorial-commits] SF.net SVN: ktutorial:[83] trunk/ktutorial
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2010-02-08 20:03:39
|
Revision: 83 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=83&view=rev Author: danxuliu Date: 2010-02-08 20:03:32 +0000 (Mon, 08 Feb 2010) Log Message: ----------- Move StepWidget creation from Tutorial to KTutorial to keep the model GUI free. Modified Paths: -------------- trunk/ktutorial/src/KTutorial.cpp trunk/ktutorial/src/KTutorial.h trunk/ktutorial/src/Tutorial.cpp trunk/ktutorial/src/Tutorial.h trunk/ktutorial/src/TutorialManager.cpp trunk/ktutorial/src/TutorialManager.h trunk/ktutorial/test/TutorialManagerTest.cpp Modified: trunk/ktutorial/src/KTutorial.cpp =================================================================== --- trunk/ktutorial/src/KTutorial.cpp 2010-02-08 19:07:04 UTC (rev 82) +++ trunk/ktutorial/src/KTutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2009 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -21,12 +21,16 @@ #include <klocalizedstring.h> #include "KTutorial.h" +#include "Tutorial.h" +#include "TutorialInformation.h" #include "scripting/ScriptingModule.h" #include "scripting/ScriptManager.h" +#include "view/StepWidget.h" #include "view/TutorialManagerDialog.h" using scripting::ScriptingModule; using scripting::ScriptManager; +using view::StepWidget; using view::TutorialManagerDialog; //public: @@ -54,7 +58,10 @@ connect(mTutorialsAction, SIGNAL(triggered(bool)), this, SLOT(showTutorialManagerDialog())); - connect(mTutorialmanager, SIGNAL(started(const QString&)), + connect(mTutorialmanager, SIGNAL(started(Tutorial*)), + this, SLOT(showStepWidget(Tutorial*))); + + connect(mTutorialmanager, SIGNAL(started(Tutorial*)), this, SLOT(disableTutorialsAction())); connect(mTutorialmanager, SIGNAL(finished()), this, SLOT(enableTutorialsAction())); @@ -76,6 +83,15 @@ dialog->show(); } +void KTutorial::showStepWidget(Tutorial* tutorial) const { + QString tutorialName = tutorial->tutorialInformation()->name(); + + StepWidget* stepWidget = new StepWidget(tutorialName, mParent); + connect(tutorial, SIGNAL(stepActivated(Step*)), + stepWidget, SLOT(setStep(Step*))); + connect(stepWidget, SIGNAL(finished()), tutorial, SIGNAL(finished())); +} + void KTutorial::disableTutorialsAction() { mTutorialsAction->setEnabled(false); } Modified: trunk/ktutorial/src/KTutorial.h =================================================================== --- trunk/ktutorial/src/KTutorial.h 2010-02-08 19:07:04 UTC (rev 82) +++ trunk/ktutorial/src/KTutorial.h 2010-02-08 20:03:32 UTC (rev 83) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2009 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -176,6 +176,14 @@ void showTutorialManagerDialog() const; /** + * Shows the GUI for the given Tutorial. + * Called when the tutorial is about to be started. + * + * @param tutorial The tutorial to show its StepWidget. + */ + void showStepWidget(Tutorial* tutorial) const; + + /** * Disables mTutorialsAction. * Just a wrapper to be connected with signals that can't pass false to the * setEnabled(bool) slot. Modified: trunk/ktutorial/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/src/Tutorial.cpp 2010-02-08 19:07:04 UTC (rev 82) +++ trunk/ktutorial/src/Tutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -19,14 +19,9 @@ #include <kdebug.h> #include "Tutorial.h" -#include "KTutorial.h" #include "Step.h" #include "TutorialInformation.h" -#include "view/StepWidget.h" - -using view::StepWidget; - //public: Tutorial::~Tutorial() { @@ -52,12 +47,6 @@ return; } - StepWidget* stepWidget = new StepWidget(tutorialInformation()->name(), - KTutorial::self()->parentWidget()); - connect(this, SIGNAL(stepActivated(Step*)), - stepWidget, SLOT(setStep(Step*))); - connect(stepWidget, SIGNAL(finished()), this, SIGNAL(finished())); - setup(); nextStep("start"); Modified: trunk/ktutorial/src/Tutorial.h =================================================================== --- trunk/ktutorial/src/Tutorial.h 2010-02-08 19:07:04 UTC (rev 82) +++ trunk/ktutorial/src/Tutorial.h 2010-02-08 20:03:32 UTC (rev 83) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -109,7 +109,7 @@ /** * Starts this Tutorial. - * It creates the GUI for the Tutorial and activates the start step. + * It sets up the tutorial and activates the start step. * * This method is used internally. Do not call this method yourself. */ Modified: trunk/ktutorial/src/TutorialManager.cpp =================================================================== --- trunk/ktutorial/src/TutorialManager.cpp 2010-02-08 19:07:04 UTC (rev 82) +++ trunk/ktutorial/src/TutorialManager.cpp 2010-02-08 20:03:32 UTC (rev 83) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -49,14 +49,14 @@ return; } - emit started(id); - //TODO remove kDebug() << "Started: " << id; Tutorial* tutorial = mTutorials.value(mTutorialInformations.value(id)); connect(tutorial, SIGNAL(finished()), this, SLOT(finish())); + emit started(tutorial); + tutorial->start(); } Modified: trunk/ktutorial/src/TutorialManager.h =================================================================== --- trunk/ktutorial/src/TutorialManager.h 2010-02-08 19:07:04 UTC (rev 82) +++ trunk/ktutorial/src/TutorialManager.h 2010-02-08 20:03:32 UTC (rev 83) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -87,10 +87,9 @@ signals: /** - * This signal is emitted when the tutorial with the specified id is - * started. + * This signal is emitted when the given tutorial is about to be started. */ - void started(const QString& id); + void started(Tutorial* tutorial); /** * This signal is emitted when the started tutorial finishes, or if no Modified: trunk/ktutorial/test/TutorialManagerTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialManagerTest.cpp 2010-02-08 19:07:04 UTC (rev 82) +++ trunk/ktutorial/test/TutorialManagerTest.cpp 2010-02-08 20:03:32 UTC (rev 83) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -176,6 +176,9 @@ mTutorialInformation2); } +//Tutorial* must be declared as a metatype to be used in qvariant_cast +Q_DECLARE_METATYPE(Tutorial*); + void TutorialManagerTest::testStart() { mTutorialManager->registerTutorial(mTutorial1); @@ -187,12 +190,16 @@ Step* startStep = new Step("start"); tutorial2->addStep(startStep); - QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(QString))); + //Tutorial* must be registered in order to be used with QSignalSpy + int tutorialStarType = qRegisterMetaType<Tutorial*>("Tutorial*"); + QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(Tutorial*))); mTutorialManager->start("secondIdentifier"); QCOMPARE(startedSpy.count(), 1); - QCOMPARE(startedSpy.at(0).at(0).toString(), QString("secondIdentifier")); + QVariant argument = startedSpy.at(0).at(0); + QCOMPARE(argument.userType(), tutorialStarType); + QCOMPARE(qvariant_cast<Tutorial*>(argument), tutorial2); QVERIFY(startStep->isActive()); QSignalSpy finishedSpy(mTutorialManager, SIGNAL(finished())); @@ -206,7 +213,7 @@ mTutorialManager->registerTutorial(mTutorial1); mTutorialManager->registerTutorial(mTutorial2); - QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(QString))); + QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(Tutorial*))); QSignalSpy finishedSpy(mTutorialManager, SIGNAL(finished())); mTutorialManager->start("identifierNotRegistered"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-09 01:57:18
|
Revision: 84 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=84&view=rev Author: danxuliu Date: 2010-02-09 01:57:11 +0000 (Tue, 09 Feb 2010) Log Message: ----------- Ensure that the current step is deactivated when the tutorial finishes. Modified Paths: -------------- trunk/ktutorial/src/KTutorial.cpp trunk/ktutorial/src/Tutorial.cpp trunk/ktutorial/src/Tutorial.h trunk/ktutorial/test/TutorialTest.cpp Modified: trunk/ktutorial/src/KTutorial.cpp =================================================================== --- trunk/ktutorial/src/KTutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/KTutorial.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -89,7 +89,7 @@ StepWidget* stepWidget = new StepWidget(tutorialName, mParent); connect(tutorial, SIGNAL(stepActivated(Step*)), stepWidget, SLOT(setStep(Step*))); - connect(stepWidget, SIGNAL(finished()), tutorial, SIGNAL(finished())); + connect(stepWidget, SIGNAL(finished()), tutorial, SLOT(finish())); } void KTutorial::disableTutorialsAction() { Modified: trunk/ktutorial/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/src/Tutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/Tutorial.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -81,3 +81,13 @@ mCurrentStep = step; mCurrentStep->setActive(true); } + +//public slots: + +void Tutorial::finish() { + if (mCurrentStep != 0) { + mCurrentStep->setActive(false); + } + + emit finished(); +} Modified: trunk/ktutorial/src/Tutorial.h =================================================================== --- trunk/ktutorial/src/Tutorial.h 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/Tutorial.h 2010-02-09 01:57:11 UTC (rev 84) @@ -137,6 +137,17 @@ */ void nextStep(Step* step); +public slots: + + /** + * Finishes this Tutorial. + * The current step is deactivated and finished signal is emitted. + * + * This slot is used internally. Do not call or connect to this slot + * yourself. + */ + void finish(); + signals: /** Modified: trunk/ktutorial/test/TutorialTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialTest.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/test/TutorialTest.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -49,6 +49,8 @@ void testNextStepStep(); void testNextStepStepWithInvalidStep(); + void testFinish(); + }; class MockTutorial: public Tutorial { @@ -329,6 +331,21 @@ QVERIFY(step1->isActive()); } +void TutorialTest::testFinish() { + MockTutorial tutorial(new TutorialInformation("pearlOrientation")); + + Step* stepStart = new Step("start"); + tutorial.addStep(stepStart); + + QSignalSpy finishedSpy(&tutorial, SIGNAL(finished())); + + tutorial.start(); + tutorial.finish(); + + QVERIFY(!stepStart->isActive()); + QCOMPARE(finishedSpy.count(), 1); +} + QTEST_KDEMAIN(TutorialTest, GUI) #include "TutorialTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-10 18:29:56
|
Revision: 87 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=87&view=rev Author: danxuliu Date: 2010-02-10 18:29:49 +0000 (Wed, 10 Feb 2010) Log Message: ----------- Add tearDown() method to Tutorial to be executed after the tutorial finishes. Setup() is now executed when the tutorial is started even if there is no start step, to ensure that whenever a setup method is executed, a tearDown method will be executed, and whenever a tearDown method is executed, a setup method was executed. Modified Paths: -------------- trunk/ktutorial/src/Tutorial.cpp trunk/ktutorial/src/Tutorial.h trunk/ktutorial/src/scripting/ScriptedTutorial.cpp trunk/ktutorial/src/scripting/ScriptedTutorial.h trunk/ktutorial/test/TutorialTest.cpp trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp Modified: trunk/ktutorial/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/src/Tutorial.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/Tutorial.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -41,14 +41,14 @@ } void Tutorial::start() { + setup(); + if (!mSteps.contains("start")) { kError() << "No start step found in tutorial " << mTutorialInformation->id(); - emit finished(); + finish(); return; } - setup(); - nextStep("start"); } @@ -89,5 +89,7 @@ mCurrentStep->setActive(false); } + tearDown(); + emit finished(); } Modified: trunk/ktutorial/src/Tutorial.h =================================================================== --- trunk/ktutorial/src/Tutorial.h 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/Tutorial.h 2010-02-10 18:29:49 UTC (rev 87) @@ -58,7 +58,8 @@ * information about the Tutorial and add all the Steps with their WaitFors and * Options. Add as many slots as needed to the class to connect them with the * WaitFors and Options when added to their Steps. If something must be set - * before starting the Tutorial redefine setup(), and you are done. + * before starting the Tutorial redefine setup(), if something must be cleaned + * after finishing the tutorial redefine tearDown(), and you are done. */ class KTUTORIAL_EXPORT Tutorial: public QObject { Q_OBJECT @@ -141,7 +142,8 @@ /** * Finishes this Tutorial. - * The current step is deactivated and finished signal is emitted. + * The current step is deactivated, this tutorial is cleaned, and finished + * signal is emitted. * * This slot is used internally. Do not call or connect to this slot * yourself. @@ -182,6 +184,14 @@ virtual void setup() { } + /** + * Sets up the Tutorial before activating start Step. + * Tutorial subclasses can redefine it if they need to set up something + * before start. + */ + virtual void tearDown() { + } + private: /** Modified: trunk/ktutorial/src/scripting/ScriptedTutorial.cpp =================================================================== --- trunk/ktutorial/src/scripting/ScriptedTutorial.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/scripting/ScriptedTutorial.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -56,6 +56,10 @@ emit setup(this); } +void ScriptedTutorial::tearDown() { + emit tearDown(this); } +} + #include "ScriptedTutorial.moc" Modified: trunk/ktutorial/src/scripting/ScriptedTutorial.h =================================================================== --- trunk/ktutorial/src/scripting/ScriptedTutorial.h 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/scripting/ScriptedTutorial.h 2010-02-10 18:29:49 UTC (rev 87) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -45,6 +45,9 @@ * in the script and connect it to setup(QObject*) signal. Note that, although * the argument in the signal is declared as QObject*, it is in fact the * ScriptedStep that emitted the signal. It is a Kross limitation. + * + * You can do the same if something has to be cleaned after the Tutorial + * finishes using tearDown(QObject*) signal. */ class ScriptedTutorial: public Tutorial { Q_OBJECT @@ -99,6 +102,17 @@ */ void setup(QObject* scriptedTutorial); + /** + * Emitted when this ScriptedTutorial has to be cleaned. + * + * @param scriptedTutorial A pointer to this ScriptedTutorial. + * @see Tutorial::tearDown() + * @todo Change argument type to scripting::ScriptedTutorial* once all major + * Kross scripting backends support classes wrapped through + * WrapperInterface + */ + void tearDown(QObject* scriptedTutorial); + protected: /** @@ -107,6 +121,12 @@ */ virtual void setup(); + /** + * Emits tearDown(scripting::ScriptedTutorial*) signal using this + * ScriptedTutorial as parameter. + */ + virtual void tearDown(); + private: /** Modified: trunk/ktutorial/test/TutorialTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialTest.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/test/TutorialTest.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -57,10 +57,12 @@ public: int mSetupCount; + int mTearDownCount; MockTutorial(TutorialInformation* tutorialInformation): Tutorial(tutorialInformation) { mSetupCount = 0; + mTearDownCount = 0; } protected: @@ -69,6 +71,10 @@ mSetupCount++; } + virtual void tearDown() { + mTearDownCount++; + } + }; void TutorialTest::testConstructor() { @@ -195,6 +201,7 @@ QCOMPARE(tutorial.mCurrentStep, stepStart); QVERIFY(stepStart->isActive()); QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(tutorial.mTearDownCount, 0); } void TutorialTest::testStartNoStartStep() { @@ -212,10 +219,11 @@ tutorial.start(); - QCOMPARE(tutorial.mSetupCount, 0); + QCOMPARE(tutorial.mSetupCount, 1); QCOMPARE(stepActivatedSpy.count(), 0); QCOMPARE(tutorial.mCurrentStep, (Step*)0); QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(tutorial.mTearDownCount, 1); } void TutorialTest::testNextStepId() { @@ -344,6 +352,7 @@ QVERIFY(!stepStart->isActive()); QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(tutorial.mTearDownCount, 1); } QTEST_MAIN(TutorialTest) Modified: trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp =================================================================== --- trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -51,6 +51,9 @@ void testSetup(); void testSetupObjectArgument(); + void testTearDown(); + void testTearDownObjectArgument(); + private: KTemporaryFile* mTemporaryFile; @@ -161,8 +164,46 @@ QCOMPARE(qvariant_cast<QObject*>(argument), &scriptedTutorial); } +void ScriptedTutorialTest::testTearDown() { + QSKIP("Skipped until tearDown argument is set again to scripting::ScriptedTutorial*", SkipAll); + + ScriptedTutorial scriptedTutorial(mTemporaryFile->fileName()); + + //ScriptedTutorial* must be registered in order to be used with QSignalSpy. + //The name must contain the namespace, as it needs the full name used in the + //signal (and the signal has to be declared using the full namespace so the + //spied argument can be converted using qvariant_cast). + int scriptedTutorialStarType = + qRegisterMetaType<ScriptedTutorial*>("scripting::ScriptedTutorial*"); + QSignalSpy tearDownSpy(&scriptedTutorial, + SIGNAL(tearDown(scripting::ScriptedTutorial*))); + + scriptedTutorial.tearDown(); + + QCOMPARE(tearDownSpy.count(), 1); + QVariant argument = tearDownSpy.at(0).at(0); + QCOMPARE(argument.userType(), scriptedTutorialStarType); + QCOMPARE(qvariant_cast<ScriptedTutorial*>(argument), &scriptedTutorial); } +void ScriptedTutorialTest::testTearDownObjectArgument() { + ScriptedTutorial scriptedTutorial(mTemporaryFile->fileName()); + + QSignalSpy tearDownSpy(&scriptedTutorial, SIGNAL(tearDown(QObject*))); + + scriptedTutorial.tearDown(); + + QCOMPARE(tearDownSpy.count(), 1); + QVariant argument = tearDownSpy.at(0).at(0); + //From QVariant::Type documentation + //"Although this function is declared as returning QVariant::Type, the + //return value should be interpreted as QMetaType::Type" + QCOMPARE((QMetaType::Type)argument.type(), QMetaType::QObjectStar); + QCOMPARE(qvariant_cast<QObject*>(argument), &scriptedTutorial); +} + +} + QTEST_MAIN(scripting::ScriptedTutorialTest) #include "ScriptedTutorialTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-13 19:08:21
|
Revision: 88 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=88&view=rev Author: danxuliu Date: 2010-02-13 19:08:14 +0000 (Sat, 13 Feb 2010) Log Message: ----------- Restructure directories: separate library and test-app (CMakeLists.txt's will be adapted in the next commit). Added Paths: ----------- trunk/ktutorial/ktutorial-library/ trunk/ktutorial/ktutorial-library/CMakeLists.txt trunk/ktutorial/ktutorial-library/cmake/ trunk/ktutorial/ktutorial-library/po/ trunk/ktutorial/ktutorial-library/src/ trunk/ktutorial/ktutorial-library/test/ trunk/ktutorial/ktutorial-test-app/ trunk/ktutorial/ktutorial-test-app/po/ Removed Paths: ------------- trunk/ktutorial/CMakeLists.txt trunk/ktutorial/cmake/ trunk/ktutorial/po/ trunk/ktutorial/src/ trunk/ktutorial/test/ trunk/ktutorial/test-app/ Deleted: trunk/ktutorial/CMakeLists.txt =================================================================== --- trunk/ktutorial/CMakeLists.txt 2010-02-10 18:29:49 UTC (rev 87) +++ trunk/ktutorial/CMakeLists.txt 2010-02-13 19:08:14 UTC (rev 88) @@ -1,12 +0,0 @@ -project(ktutorial) - -set(QT_MIN_VERSION "4.5.3") -find_package(KDE4 REQUIRED) - -enable_testing() - -add_subdirectory(cmake) -add_subdirectory(po) -add_subdirectory(src) -add_subdirectory(test) -add_subdirectory(test-app) Copied: trunk/ktutorial/ktutorial-library/CMakeLists.txt (from rev 87, trunk/ktutorial/CMakeLists.txt) =================================================================== --- trunk/ktutorial/ktutorial-library/CMakeLists.txt (rev 0) +++ trunk/ktutorial/ktutorial-library/CMakeLists.txt 2010-02-13 19:08:14 UTC (rev 88) @@ -0,0 +1,12 @@ +project(ktutorial) + +set(QT_MIN_VERSION "4.5.3") +find_package(KDE4 REQUIRED) + +enable_testing() + +add_subdirectory(cmake) +add_subdirectory(po) +add_subdirectory(src) +add_subdirectory(test) +add_subdirectory(test-app) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-13 19:19:29
|
Revision: 89 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=89&view=rev Author: danxuliu Date: 2010-02-13 19:19:22 +0000 (Sat, 13 Feb 2010) Log Message: ----------- -Adjust CMakeLists.txt's to the new directory layout. -KTutorial test app can now be built without KTutorial library sources. However, in most cases the whole KTutorial project will be available, so KTutorial test app is built against a built but not installed yet KTutorial library. Modified Paths: -------------- trunk/ktutorial/ktutorial-library/CMakeLists.txt trunk/ktutorial/ktutorial-library/src/CMakeLists.txt trunk/ktutorial/ktutorial-test-app/CMakeLists.txt trunk/ktutorial/ktutorial-test-app/TestApp.cpp trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp trunk/ktutorial/ktutorial-test-app/TutorialClearText.h trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h Added Paths: ----------- trunk/ktutorial/CMakeLists.txt Added: trunk/ktutorial/CMakeLists.txt =================================================================== --- trunk/ktutorial/CMakeLists.txt (rev 0) +++ trunk/ktutorial/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) @@ -0,0 +1,6 @@ +project(ktutorial) + +find_package(KDE4 REQUIRED) + +macro_optional_add_subdirectory(ktutorial-library) +macro_optional_add_subdirectory(ktutorial-test-app) Property changes on: trunk/ktutorial/CMakeLists.txt ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-library/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/CMakeLists.txt 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-library/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) @@ -1,4 +1,4 @@ -project(ktutorial) +project(ktutorial-library) set(QT_MIN_VERSION "4.5.3") find_package(KDE4 REQUIRED) @@ -9,4 +9,3 @@ add_subdirectory(po) add_subdirectory(src) add_subdirectory(test) -add_subdirectory(test-app) Modified: trunk/ktutorial/ktutorial-library/src/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/src/CMakeLists.txt 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-library/src/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) @@ -50,6 +50,12 @@ WaitForSignal.h ) +# Hack to make headers available to other ktutorial modules (like +# ktutorial-test-app) when the library is built but not installed yet. +foreach(header ${ktutorial_LIB_HEADERS}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${header} ${ktutorial-library_BINARY_DIR}/includes/ktutorial/${header} COPYONLY) +endforeach(header) + install(FILES ${ktutorial_LIB_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/ktutorial) install(FILES ktutorialui.rc DESTINATION ${DATA_INSTALL_DIR}/ktutorial) Modified: trunk/ktutorial/ktutorial-test-app/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-test-app/CMakeLists.txt 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-test-app/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) @@ -1,5 +1,26 @@ -include_directories(${ktutorial_SOURCE_DIR}/src ${KDE4_INCLUDES}) +project(ktutorial-test-app) +find_package(KDE4 REQUIRED) +include_directories(${KDE4_INCLUDES}) + +add_subdirectory(po) + +# When KTutorial is built, the library isn't installed yet when the test-app is +# built. In that case, use the headers and libraries in the build directory +# of the library. +if(ktutorial-library_BINARY_DIR) + set(KTUTORIAL_FOUND TRUE) + include_directories(${ktutorial-library_BINARY_DIR}/includes) + set(KTUTORIAL_LIBRARIES ktutorial) +endif(ktutorial-library_BINARY_DIR) + +# If ktutorial-test-app is built in standalone mode, look for an installed +# KTutorial library. +if(NOT KTUTORIAL_FOUND) + find_package(KTutorial REQUIRED) + include_directories(${KTUTORIAL_INCLUDE_DIRS}) +endif(NOT KTUTORIAL_FOUND) + set(ktutorial_test_app_SRCS main.cpp TestApp.cpp @@ -9,7 +30,7 @@ kde4_add_executable(ktutorial-test-app ${ktutorial_test_app_SRCS}) -target_link_libraries(ktutorial-test-app ktutorial ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) +target_link_libraries(ktutorial-test-app ${KTUTORIAL_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) ####### Install the test application ####### Modified: trunk/ktutorial/ktutorial-test-app/TestApp.cpp =================================================================== --- trunk/ktutorial/ktutorial-test-app/TestApp.cpp 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-test-app/TestApp.cpp 2010-02-13 19:19:22 UTC (rev 89) @@ -27,7 +27,7 @@ #include <KSaveFile> #include <QTextStream> -#include "KTutorial.h" +#include <ktutorial/KTutorial.h> #include "TestApp.h" #include "TutorialClearText.h" Modified: trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp 2010-02-13 19:19:22 UTC (rev 89) @@ -20,11 +20,12 @@ #include <ktextedit.h> #include "TutorialClearText.h" -#include "KTutorial.h" -#include "Step.h" -#include "TutorialInformation.h" -#include "WaitForSignal.h" +#include <ktutorial/KTutorial.h> +#include <ktutorial/Step.h> +#include <ktutorial/TutorialInformation.h> +#include <ktutorial/WaitForSignal.h> + //public: TutorialClearText::TutorialClearText(): Tutorial(0) { Modified: trunk/ktutorial/ktutorial-test-app/TutorialClearText.h =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialClearText.h 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-test-app/TutorialClearText.h 2010-02-13 19:19:22 UTC (rev 89) @@ -19,7 +19,7 @@ #ifndef TUTORIALCLEARTEXT_H #define TUTORIALCLEARTEXT_H -#include "Tutorial.h" +#include <ktutorial/Tutorial.h> class TutorialClearText: public Tutorial { Q_OBJECT Modified: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp 2010-02-13 19:19:22 UTC (rev 89) @@ -23,14 +23,15 @@ #include <ktextedit.h> #include "TutorialMoveText.h" -#include "KTutorial.h" -#include "Option.h" -#include "Step.h" -#include "TutorialInformation.h" -#include "WaitForAnd.h" -#include "WaitForNot.h" -#include "WaitForSignal.h" +#include <ktutorial/KTutorial.h> +#include <ktutorial/Option.h> +#include <ktutorial/Step.h> +#include <ktutorial/TutorialInformation.h> +#include <ktutorial/WaitForAnd.h> +#include <ktutorial/WaitForNot.h> +#include <ktutorial/WaitForSignal.h> + //public: TutorialMoveText::TutorialMoveText(): Tutorial(0) { Modified: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h 2010-02-13 19:08:14 UTC (rev 88) +++ trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h 2010-02-13 19:19:22 UTC (rev 89) @@ -19,7 +19,7 @@ #ifndef TUTORIALMOVETEXT_H #define TUTORIALMOVETEXT_H -#include "Tutorial.h" +#include <ktutorial/Tutorial.h> class KTextEdit; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-13 19:41:15
|
Revision: 90 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=90&view=rev Author: danxuliu Date: 2010-02-13 19:41:09 +0000 (Sat, 13 Feb 2010) Log Message: ----------- Fix testing with the new layout (generate CTestTestfile.cmake in the root project build directory, fix included directories in tests). Modified Paths: -------------- trunk/ktutorial/CMakeLists.txt trunk/ktutorial/ktutorial-library/test/CMakeLists.txt trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt Modified: trunk/ktutorial/CMakeLists.txt =================================================================== --- trunk/ktutorial/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) +++ trunk/ktutorial/CMakeLists.txt 2010-02-13 19:41:09 UTC (rev 90) @@ -2,5 +2,7 @@ find_package(KDE4 REQUIRED) +enable_testing() + macro_optional_add_subdirectory(ktutorial-library) macro_optional_add_subdirectory(ktutorial-test-app) Modified: trunk/ktutorial/ktutorial-library/test/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/test/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) +++ trunk/ktutorial/ktutorial-library/test/CMakeLists.txt 2010-02-13 19:41:09 UTC (rev 90) @@ -4,7 +4,7 @@ # Used by kde4_add_unit_test to set the full path to test executables set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ktutorial_SOURCE_DIR}/src ${KDE4_INCLUDES}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ktutorial-library_SOURCE_DIR}/src ${KDE4_INCLUDES}) MACRO(UNIT_TESTS) FOREACH(_className ${ARGN}) Modified: trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) +++ trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt 2010-02-13 19:41:09 UTC (rev 90) @@ -1,7 +1,7 @@ # Used by kde4_add_unit_test to set the full path to test executables set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ktutorial_SOURCE_DIR}/src/scripting ${KDE4_INCLUDES}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ktutorial-library_SOURCE_DIR}/src/scripting ${KDE4_INCLUDES}) MACRO(UNIT_TESTS) FOREACH(_className ${ARGN}) Modified: trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt 2010-02-13 19:19:22 UTC (rev 89) +++ trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt 2010-02-13 19:41:09 UTC (rev 90) @@ -1,7 +1,7 @@ # Used by kde4_add_unit_test to set the full path to test executables set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ktutorial_SOURCE_DIR}/src/view ${ktutorial_BINARY_DIR}/src/view ${KDE4_INCLUDES}) +include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ktutorial-library_SOURCE_DIR}/src/view ${ktutorial-library_BINARY_DIR}/src/view ${KDE4_INCLUDES}) # Since Qt 4.6.0, this definition is needed for GUI testing. # It is backwards compatible with previous Qt versions, unlike the alternative This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-26 18:55:58
|
Revision: 108 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=108&view=rev Author: danxuliu Date: 2010-02-26 18:55:44 +0000 (Fri, 26 Feb 2010) Log Message: ----------- Added convenience methods addOption(Option*, QString) and addWaitFor(WaitFor*, QString) to Step that request a change to another step identified by its id. It avoids the burden of creating a slot just to change to another step, as shown in the tutorials adapted to use them. Modified Paths: -------------- trunk/ktutorial/ktutorial-library/src/Step.cpp trunk/ktutorial/ktutorial-library/src/Step.h trunk/ktutorial/ktutorial-library/src/Tutorial.cpp trunk/ktutorial/ktutorial-library/src/Tutorial.h trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.h trunk/ktutorial/ktutorial-library/test/StepTest.cpp trunk/ktutorial/ktutorial-library/test/TutorialTest.cpp trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp trunk/ktutorial/ktutorial-test-app/TutorialClearText.h trunk/ktutorial/ktutorial-test-app/TutorialClearText.js trunk/ktutorial/ktutorial-test-app/TutorialClearText.py trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h trunk/ktutorial/ktutorial-test-app/TutorialMoveText.py Modified: trunk/ktutorial/ktutorial-library/src/Step.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/Step.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/src/Step.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -41,56 +41,54 @@ } void Step::addOption(Option* option, QObject* receiver, const QString& slot) { - if (mOptions.contains(option)) { - kWarning() << "Option " << option->name() << " already added in step " << mId; + if (!addOption(option)) { return; } - QListIterator<Option*> it(mOptions); - while (it.hasNext()) { - if (it.next()->name() == option->name()) { - kWarning() << "Option named " << option->name() << " already added in step " << mId; - return; - } - } + bool deleteAddedObjectsInTearDownValue = mDeleteAddedObjectsInTearDown; + mDeleteAddedObjectsInTearDown = false; - option->setParent(this); + WaitForSignal* waitFor = new WaitForSignal(option, SIGNAL(selected())); + addWaitFor(waitFor, receiver, slot); - mOptions.append(option); + mOptionsWaitsFor.append(waitFor); + mDeleteAddedObjectsInTearDown = deleteAddedObjectsInTearDownValue; +} +void Step::addOption(Option* option, const QString& nextStepId) { + if (!addOption(option)) { + return; + } + bool deleteAddedObjectsInTearDownValue = mDeleteAddedObjectsInTearDown; mDeleteAddedObjectsInTearDown = false; WaitForSignal* waitFor = new WaitForSignal(option, SIGNAL(selected())); - addWaitFor(waitFor, receiver, slot); + addWaitFor(waitFor, nextStepId); mOptionsWaitsFor.append(waitFor); mDeleteAddedObjectsInTearDown = deleteAddedObjectsInTearDownValue; - - - if (mDeleteAddedObjectsInTearDown) { - mOptionsToBeDeletedInTearDown.append(option); - } } void Step::addWaitFor(WaitFor* waitFor, QObject* receiver, const QString& slot) { - if (mWaitsFor.contains(waitFor)) { - kWarning() << "Same WaitFor already added in step " << mId; + if (!addWaitFor(waitFor)) { return; } - waitFor->setActive(false); + connectWaitFor(waitFor, receiver, slot); +} - waitFor->setParent(this); +void Step::addWaitFor(WaitFor* waitFor, const QString& nextStepId) { + if (!addWaitFor(waitFor)) { + return; + } - mWaitsFor.append(waitFor); - connectWaitFor(waitFor, receiver, slot); + mNextStepForWaitFor.insert(waitFor, nextStepId); - if (mDeleteAddedObjectsInTearDown) { - mWaitsForToBeDeletedInTearDown.append(waitFor); - } + connect(waitFor, SIGNAL(waitEnded(WaitFor*)), + this, SLOT(requestNextStepForWaitFor(WaitFor*))); } void Step::removeOption(Option* option) { @@ -123,6 +121,12 @@ mWaitsFor.removeAt(mWaitsFor.indexOf(waitFor)); disconnectWaitFor(waitFor); + + if (mNextStepForWaitFor.contains(waitFor)) { + mNextStepForWaitFor.remove(waitFor); + disconnect(waitFor, SIGNAL(waitEnded(WaitFor*)), + this, SLOT(requestNextStepForWaitFor(WaitFor*))); + } } //protected: @@ -165,3 +169,55 @@ } mWaitsForToBeDeletedInTearDown.clear(); } + +bool Step::addOption(Option* option) { + if (mOptions.contains(option)) { + kWarning() << "Option " << option->name() << " already added in step " << mId; + return false; + } + + QListIterator<Option*> it(mOptions); + while (it.hasNext()) { + if (it.next()->name() == option->name()) { + kWarning() << "Option named " << option->name() << " already added in step " << mId; + return false; + } + } + + option->setParent(this); + + mOptions.append(option); + + if (mDeleteAddedObjectsInTearDown) { + mOptionsToBeDeletedInTearDown.append(option); + } + + return true; +} + +bool Step::addWaitFor(WaitFor* waitFor) { + if (mWaitsFor.contains(waitFor)) { + kWarning() << "Same WaitFor already added in step " << mId; + return false; + } + + waitFor->setActive(false); + + waitFor->setParent(this); + + mWaitsFor.append(waitFor); + + if (mDeleteAddedObjectsInTearDown) { + mWaitsForToBeDeletedInTearDown.append(waitFor); + } + + return true; +} + +//private slots: + +void Step::requestNextStepForWaitFor(WaitFor* waitFor) { + emit nextStepRequested(mNextStepForWaitFor.value(waitFor)); +} + +#include "Step.moc" Modified: trunk/ktutorial/ktutorial-library/src/Step.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/Step.h 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/src/Step.h 2010-02-26 18:55:44 UTC (rev 108) @@ -19,6 +19,7 @@ #ifndef STEP_H #define STEP_H +#include <QHash> #include <QList> #include <QObject> #include <QString> @@ -97,6 +98,14 @@ * } * \endcode * + * Sometimes, when a condition to wait for is met or an option is selected you + * may only want to change to another step, without further checks or actions. + * In these cases, you can create a slot that just changes to the next step and + * connect to it when adding the Option or WaitFor. But you can also use a + * shortcut: there are special versions of addOption and addWaitFor methods that + * receive the id of the next step to change to, which saves you the need to + * create a slot just for that. + * * When you need to perform something special when a Step is activated, you must * define a subclass of Step and redefine the setup() method in it. If something * must be performed when a Step is deactivated, you must redefine tearDown() @@ -218,6 +227,26 @@ const QString& slot); /** + * Adds an Option to this Step. + * When the Option is selected by the user, the tutorial this Step is part + * of will activate the step identified by nextStepId. + * + * This method only provides a shortcut to avoid creating an slot that + * just calls tutorial.nextStep(nextStepId). + * + * In evey other aspect, it behaves like + * addOption(Option*, QObject*, const QString&). See its documentation for + * further details. + * + * This method can be invoked from a script. + * + * @param option The Option to add. + * @param nextStep The id of the step to change to. + * @see addOption(Option*, QObject*, const QString&) + */ + Q_INVOKABLE void addOption(Option* option, const QString& nextStepId); + + /** * Adds a condition to wait for to this Step. * When the condition is met and this Step is active, the slot of the * receiver object is called. @@ -243,6 +272,26 @@ const QString& slot); /** + * Adds a condition to wait for to this Step. + * When the condition is met and this Step is active, the tutorial this Step + * is part of will activate the step identified by nextStepId. + * + * This method only provides a shortcut to avoid creating an slot that + * just calls tutorial.nextStep(nextStepId). + * + * In evey other aspect, it behaves like + * addWaitFor(WaitFor*, QObject*, const QString&). See its documentation for + * further details. + * + * This method can be invoked from a script. + * + * @param waitFor The condition to wait for. + * @param nextStep The id of the step to change to. + * @see addOption(Option*, QObject*, const QString&) + */ + Q_INVOKABLE void addWaitFor(WaitFor* waitFor, const QString& nextStepId); + + /** * Removes an Option from this Step. * The Option is reparented to null, so you must delete it explicitly. * @@ -258,8 +307,10 @@ * Removes a condition to wait for from this Step. * The slot of the receiver object associated when adding the WaitFor will * not be notified anymore when the condition is met (note that all the - * slots connected with waitEnded(WaitFor*) will be disconnected). The - * WaitFor will be also deactivated. + * slots connected with waitEnded(WaitFor*) will be disconnected). If the + * WaitFor was associated with a step id, the tutorial won't change to it + * anymore when the condition is met. In any case, the WaitFor will be also + * deactivated. * * The WaitFor is reparented to null, so you must delete it explicitly. * @@ -271,6 +322,17 @@ */ Q_INVOKABLE void removeWaitFor(WaitFor* waitFor); +Q_SIGNALS: + + /** + * Request a change to the next step. + * Don't connect nor emit this signal yourself. It is connected + * automatically by KTutorial. + * + * @param nextStepId The id of the Step to request a change to. + */ + void nextStepRequested(const QString& nextStepId); + protected: /** @@ -365,6 +427,12 @@ QList<WaitFor*> mWaitsForToBeDeletedInTearDown; /** + * Associates a condition to wait for with the id of the step to execute + * when the condition is met. + */ + QHash<WaitFor*, QString> mNextStepForWaitFor; + + /** * Wraps setup method to ensure that some code is executed before and after * inherited setup method. * It follows a Template Design Pattern. @@ -378,6 +446,35 @@ */ void tearDownWrapper(); + /** + * Adds a new Option. + * The Option is refused to be added if it is already added, or there is + * another Option with the same name. + * + * @param option The Option to add. + * @return True if the Option was added, false otherwise. + */ + bool addOption(Option* option); + + /** + * Adds a new WaitFor. + * The WaitFor is refused to be added if it is already added. + * + * @param waitFor The WaitFor to add. + * @return True if the WaitFor was added, false otherwise. + */ + bool addWaitFor(WaitFor* waitFor); + +private Q_SLOTS: + + /** + * Emits nextStepRequested(const QString&) with the id of the step + * associated to the given WaitFor. + * + * @param waitFor The WaitFor to request its associated step. + */ + void requestNextStepForWaitFor(WaitFor* waitFor); + }; #endif Modified: trunk/ktutorial/ktutorial-library/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/Tutorial.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/src/Tutorial.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -38,6 +38,9 @@ step->setParent(this); mSteps.insert(step->id(), step); + + connect(step, SIGNAL(nextStepRequested(QString)), + this, SLOT(nextStep(QString))); } void Tutorial::start() { Modified: trunk/ktutorial/ktutorial-library/src/Tutorial.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/Tutorial.h 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/src/Tutorial.h 2010-02-26 18:55:44 UTC (rev 108) @@ -46,7 +46,9 @@ * first one to be activated. * * To activate a Step, any of Tutorial::nextStep must be called. You are advised - * to use the QString version for convenience. + * to use the QString version for convenience. Steps can activate another step + * when a condition is met or an option selected using an overloaded version of + * addOption and addWaitFor methods provided for convenience. * * The Tutorial finishes when the user closes it. It can happen in an * intermediate Step or when there are no more Steps. When making a Tutorial, @@ -117,6 +119,17 @@ void start(); /** + * Activates the next step in the Tutorial. + * Call this method when the Tutorial has to pass to another Step. Consider + * using nextStep(const QString&) instead for convenience. + * + * @param step The Step to change to. + */ + void nextStep(Step* step); + +public slots: + + /** * Activates the next Step in the Tutorial. * The identifier must be of one of the Steps added to this Tutorial. * @@ -127,20 +140,9 @@ * @param id The identifier of the next Step to set. * @see nextStep(Step*) */ - Q_INVOKABLE void nextStep(const QString& id); + void nextStep(const QString& id); /** - * Activates the next step in the Tutorial. - * Call this method when the Tutorial has to pass to another Step. Consider - * using nextStep(const QString&) instead for convenience. - * - * @param step The Step to change to. - */ - void nextStep(Step* step); - -public slots: - - /** * Finishes this Tutorial. * The current step is deactivated, this tutorial is cleaned, and finished * signal is emitted. Modified: trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -81,9 +81,8 @@ Q_OBJECT public: - CloseTextEditStep(UsingKTutorial* usingKTutorial): - Step("closeTextEdit"), - mUsingKTutorial(usingKTutorial) { + CloseTextEditStep(): + Step("closeTextEdit") { } virtual void setup() { @@ -91,22 +90,17 @@ "usingKTutorialTextEdit"); addWaitFor(new WaitForEvent(textEdit, QEvent::Close), - mUsingKTutorial, SLOT(closeTextEditDone())); + "moveWidgetPress"); } -private: - - UsingKTutorial* mUsingKTutorial; - }; class MoveWidgetPressStep: public Step { Q_OBJECT public: - MoveWidgetPressStep(UsingKTutorial* usingKTutorial): - Step("moveWidgetPress"), - mUsingKTutorial(usingKTutorial) { + MoveWidgetPressStep(): + Step("moveWidgetPress") { } virtual void setup() { @@ -114,22 +108,17 @@ findObject<view::StepWidget*>("ktutorial_StepWidget"); addWaitFor(new WaitForLeftMouseButtonPressed(mStepWidget), - mUsingKTutorial, SLOT(moveWidgetPressDone())); + "moveWidgetRelease"); } -private: - - UsingKTutorial* mUsingKTutorial; - }; class MoveWidgetReleaseStep: public Step { Q_OBJECT public: - MoveWidgetReleaseStep(UsingKTutorial* usingKTutorial): - Step("moveWidgetRelease"), - mUsingKTutorial(usingKTutorial) { + MoveWidgetReleaseStep(): + Step("moveWidgetRelease") { } virtual void setup() { @@ -137,13 +126,9 @@ findObject<view::StepWidget*>("ktutorial_StepWidget"); addWaitFor(new WaitForEvent(mStepWidget, QEvent::MouseButtonRelease), - mUsingKTutorial, SLOT(moveWidgetReleaseDone())); + "end"); } -private: - - UsingKTutorial* mUsingKTutorial; - }; //public: @@ -163,7 +148,7 @@ "works, or how to accomplish some task.</para>")); startStep->addOption(new Option(i18nc("@action", "Continue")), - this, SLOT(startDone())); + "singleOption"); addStep(startStep); @@ -177,7 +162,7 @@ "step.</para>")); singleOptionStep->addOption(new Option(i18nc("@action", "Continue")), - this, SLOT(singleOptionDone())); + "severalOptions"); addStep(singleOptionStep); @@ -189,9 +174,9 @@ "part of the tutorial, etcetera. Which option do you prefer?</para>")); severalOptionsStep->addOption(new Option(i18nc("@action", "Option 1")), - this, SLOT(severalOptionsOption1Selected())); + "option1Selected"); severalOptionsStep->addOption(new Option(i18nc("@action", "Option 2")), - this, SLOT(severalOptionsOption2Selected())); + "option2Selected"); addStep(severalOptionsStep); @@ -205,7 +190,7 @@ "written.</para>", i18nc("@action", "Option 1"))); option1SelectedStep->addOption(new Option(i18nc("@action", "Continue")), - this, SLOT(optionSelectedDone())); + "clearText"); addStep(option1SelectedStep); @@ -219,7 +204,7 @@ "written.</para>", i18nc("@action", "Option 2"))); option2SelectedStep->addOption(new Option(i18nc("@action", "Continue")), - this, SLOT(optionSelectedDone())); + "clearText"); addStep(option2SelectedStep); @@ -238,7 +223,7 @@ addStep(clearTextStep); //Step closeTextEdit - Step* closeTextEditStep = new CloseTextEditStep(this); + Step* closeTextEditStep = new CloseTextEditStep(); closeTextEditStep->setText(i18nc("@info", "<para>Do you see? You are in a new step, but you didn't tell the tutorial to " "continue to the next step, and neither you had to select between several " @@ -254,7 +239,7 @@ addStep(closeTextEditStep); //Step moveWidgetPress - Step* moveWidgetPressStep = new MoveWidgetPressStep(this); + Step* moveWidgetPressStep = new MoveWidgetPressStep(); moveWidgetPressStep->setText(i18nc("@info", "<para>You may have noticed that the tutorial window has no border. Does that " "mean that it can't be moved? Not at all. It can be dragged using the mouse " @@ -270,7 +255,7 @@ addStep(moveWidgetPressStep); //Step moveWidgetRelease - Step* moveWidgetReleaseStep = new MoveWidgetReleaseStep(this); + Step* moveWidgetReleaseStep = new MoveWidgetReleaseStep(); moveWidgetReleaseStep->setText(i18nc("@info", "<para>Now, and without releasing the button, move the mouse and the window " "will be moved. Once you release the button, the window will be kept in the " @@ -299,26 +284,6 @@ //public slots: -void UsingKTutorial::startDone() { - nextStep("singleOption"); -} - -void UsingKTutorial::singleOptionDone() { - nextStep("severalOptions"); -} - -void UsingKTutorial::severalOptionsOption1Selected() { - nextStep("option1Selected"); -} - -void UsingKTutorial::severalOptionsOption2Selected() { - nextStep("option2Selected"); -} - -void UsingKTutorial::optionSelectedDone() { - nextStep("clearText"); -} - void UsingKTutorial::clearTextTextModified() { QTextEdit* textEdit = KTutorial::self()-> findObject<QTextEdit*>("usingKTutorialTextEdit"); @@ -328,18 +293,6 @@ } } -void UsingKTutorial::closeTextEditDone() { - nextStep("moveWidgetPress"); -} - -void UsingKTutorial::moveWidgetPressDone() { - nextStep("moveWidgetRelease"); -} - -void UsingKTutorial::moveWidgetReleaseDone() { - nextStep("end"); -} - //protected: void UsingKTutorial::tearDown() { Modified: trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.h 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.h 2010-02-26 18:55:44 UTC (rev 108) @@ -29,24 +29,8 @@ public Q_SLOTS: - void startDone(); - - void singleOptionDone(); - - void severalOptionsOption1Selected(); - - void severalOptionsOption2Selected(); - - void optionSelectedDone(); - void clearTextTextModified(); - void closeTextEditDone(); - - void moveWidgetPressDone(); - - void moveWidgetReleaseDone(); - protected: void tearDown(); Modified: trunk/ktutorial/ktutorial-library/test/StepTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/test/StepTest.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/test/StepTest.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -48,11 +48,15 @@ void thirdDummySignal(); + void fourthDummySignal(); + private: int mDummySlotCallCount; int mAnotherDummySlotCallCount; + void assertStepId(const QSignalSpy& spy, int index, const QString& stepId); + private slots: void init() { @@ -69,6 +73,7 @@ void testAddOption(); void testAddOptionWithoutSlotMacro(); + void testAddOptionAssociatedToStepId(); void testAddOptionSeveralOptions(); void testAddOptionDuringSetup(); void testAddOptionNormalAndDuringSetup(); @@ -77,15 +82,18 @@ void testAddWaitFor(); void testAddWaitForWithoutSlotMacro(); + void testAddWaitForAssociatedToStepId(); void testAddWaitForSeveralWaitFors(); void testAddWaitForDuringSetup(); void testAddWaitForNormalAndDuringSetup(); void testAddWaitForTwice(); void testRemoveOption(); + void testRemoveOptionAssociatedToStepId(); void testRemoveOptionSeveralOptions(); void testRemoveWaitFor(); + void testRemoveWaitForAssociatedToStepId(); void testRemoveWaitForSeveralWaitFors(); }; @@ -236,6 +244,30 @@ QCOMPARE(mDummySlotCallCount, 1); } +void StepTest::testAddOptionAssociatedToStepId() { + Step step("doSomethingConstructive"); + + Option* option1 = new Option("Bathe your iguana"); + + step.addOption(option1, "batheYourIguanaStep"); + connect(this, SIGNAL(dummySignal()), option1, SIGNAL(selected())); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + + QCOMPARE(option1->parent(), &step); + QCOMPARE(step.options().count(), 1); + QVERIFY(step.options().contains(option1)); + QCOMPARE(nextStepRequestedSpy.count(), 0); + + emit dummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 0); + + step.setActive(true); + emit dummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "batheYourIguanaStep"); +} + void StepTest::testAddOptionSeveralOptions() { Step step("doSomethingConstructive"); @@ -251,25 +283,45 @@ step.addOption(option3, this, SLOT(dummySlot())); connect(this, SIGNAL(dummySignal()), option3, SIGNAL(selected())); + Option* option4 = new Option("Lull the penguin"); + step.addOption(option4, "lullThePenguinStep"); + connect(this, SIGNAL(anotherDummySignal()), option4, SIGNAL(selected())); + + Option* option5 = new Option("Pamper the Tasmanian devil"); + step.addOption(option5, "pamperTheTasmanianDevilStep"); + connect(this, SIGNAL(dummySignal()), option5, SIGNAL(selected())); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + QCOMPARE(option1->parent(), &step); QCOMPARE(option2->parent(), &step); QCOMPARE(option3->parent(), &step); - QCOMPARE(step.options().count(), 3); + QCOMPARE(option4->parent(), &step); + QCOMPARE(option5->parent(), &step); + QCOMPARE(step.options().count(), 5); QVERIFY(step.options().contains(option1)); QVERIFY(step.options().contains(option2)); QVERIFY(step.options().contains(option3)); + QVERIFY(step.options().contains(option4)); + QVERIFY(step.options().contains(option5)); QCOMPARE(mDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 0); emit dummySignal(); emit anotherDummySignal(); QCOMPARE(mDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 0); step.setActive(true); emit anotherDummySignal(); QCOMPARE(mDummySlotCallCount, 1); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "lullThePenguinStep"); emit dummySignal(); QCOMPARE(mDummySlotCallCount, 3); + QCOMPARE(nextStepRequestedSpy.count(), 2); + assertStepId(nextStepRequestedSpy, 1, "pamperTheTasmanianDevilStep"); } void StepTest::testAddOptionDuringSetup() { @@ -333,12 +385,12 @@ step.addOption(option1, this, SLOT(dummySlot())); connect(this, SIGNAL(dummySignal()), option1, SIGNAL(selected())); - //This second option isn't really needed, but it is used to be sure that no - //strange side effects occur after adding the first option again Option* option2 = new Option("Feed a toucan"); - step.addOption(option2, this, SLOT(dummySlot())); + step.addOption(option2, "feedAToucanStep"); + connect(this, SIGNAL(dummySignal()), option2, SIGNAL(selected())); step.addOption(option1, this, SLOT(anotherDummySlot())); + step.addOption(option2, "feedAPigeonStep"); QCOMPARE(option1->parent(), &step); QCOMPARE(option2->parent(), &step); @@ -346,10 +398,14 @@ QVERIFY(step.options().contains(option1)); QVERIFY(step.options().contains(option2)); + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + step.setActive(true); emit dummySignal(); QCOMPARE(mDummySlotCallCount, 1); QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "feedAToucanStep"); } void StepTest::testAddOptionDifferentOptionsWithSameName() { @@ -359,29 +415,37 @@ step.addOption(option1, this, SLOT(dummySlot())); connect(this, SIGNAL(dummySignal()), option1, SIGNAL(selected())); - //This second option isn't really needed, but it is used to be sure that no - //strange side effects occur after adding the option with the repeated name Option* option2 = new Option("Feed a toucan"); - step.addOption(option2, this, SLOT(dummySlot())); + step.addOption(option2, "feedAToucanStep"); + connect(this, SIGNAL(dummySignal()), option2, SIGNAL(selected())); - //It will not be added and thus not deleted by parent Step, so it is created - //in stack + //They will not be added and thus not deleted by parent Step, so they are + //created in stack Option option3("Bathe your iguana"); + Option option4("Feed a toucan"); step.addOption(&option3, this, SLOT(anotherDummySlot())); connect(this, SIGNAL(dummySignal()), &option3, SIGNAL(selected())); + step.addOption(&option4, "feedAToucanStep2"); + connect(this, SIGNAL(dummySignal()), &option4, SIGNAL(selected())); + QCOMPARE(option1->parent(), &step); QCOMPARE(option2->parent(), &step); QCOMPARE(option3.parent(), (QObject*)0); + QCOMPARE(option4.parent(), (QObject*)0); QCOMPARE(step.options().count(), 2); QVERIFY(step.options().contains(option1)); QVERIFY(step.options().contains(option2)); + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + step.setActive(true); emit dummySignal(); QCOMPARE(mDummySlotCallCount, 1); QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "feedAToucanStep"); } void StepTest::testAddWaitFor() { @@ -424,6 +488,29 @@ QCOMPARE(mDummySlotCallCount, 1); } +void StepTest::testAddWaitForAssociatedToStepId() { + Step step("doSomethingConstructive"); + + WaitFor* waitFor1 = new WaitForSignal(this, SIGNAL(dummySignal())); + + step.addWaitFor(waitFor1, "batheYourIguanaStep"); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + + QCOMPARE(waitFor1->parent(), &step); + QCOMPARE(step.mWaitsFor.count(), 1); + QVERIFY(step.mWaitsFor.contains(waitFor1)); + QCOMPARE(nextStepRequestedSpy.count(), 0); + + emit dummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 0); + + step.setActive(true); + emit dummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "batheYourIguanaStep"); +} + void StepTest::testAddWaitForSeveralWaitFors() { Step step("doSomethingConstructive"); @@ -434,31 +521,50 @@ step.addWaitFor(waitFor2, this, SLOT(dummySlot())); WaitFor* waitFor3 = new WaitForSignal(this, SIGNAL(thirdDummySignal())); - step.addWaitFor(waitFor3, this, SLOT(dummySlot())); + step.addWaitFor(waitFor3, "batheYourIguanaStep"); + WaitFor* waitFor4 = new WaitForSignal(this, SIGNAL(fourthDummySignal())); + step.addWaitFor(waitFor4, "feedAToucanStep"); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + QCOMPARE(waitFor1->parent(), &step); QCOMPARE(waitFor2->parent(), &step); QCOMPARE(waitFor3->parent(), &step); - QCOMPARE(step.mWaitsFor.count(), 3); + QCOMPARE(waitFor4->parent(), &step); + QCOMPARE(step.mWaitsFor.count(), 4); QVERIFY(step.mWaitsFor.contains(waitFor1)); QVERIFY(step.mWaitsFor.contains(waitFor2)); QVERIFY(step.mWaitsFor.contains(waitFor3)); + QVERIFY(step.mWaitsFor.contains(waitFor4)); QCOMPARE(mDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 0); emit dummySignal(); emit anotherDummySignal(); emit thirdDummySignal(); + emit fourthDummySignal(); QCOMPARE(mDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 0); step.setActive(true); emit anotherDummySignal(); QCOMPARE(mDummySlotCallCount, 1); + QCOMPARE(nextStepRequestedSpy.count(), 0); emit dummySignal(); QCOMPARE(mDummySlotCallCount, 2); + QCOMPARE(nextStepRequestedSpy.count(), 0); emit thirdDummySignal(); - QCOMPARE(mDummySlotCallCount, 3); + QCOMPARE(mDummySlotCallCount, 2); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "batheYourIguanaStep"); + + emit fourthDummySignal(); + QCOMPARE(mDummySlotCallCount, 2); + QCOMPARE(nextStepRequestedSpy.count(), 2); + assertStepId(nextStepRequestedSpy, 1, "feedAToucanStep"); } void StepTest::testAddWaitForDuringSetup() { @@ -516,12 +622,11 @@ WaitFor* waitFor1 = new WaitForSignal(this, SIGNAL(dummySignal())); step.addWaitFor(waitFor1, this, SLOT(dummySlot())); - //This second WaitFor isn't really needed, but it is used to be sure that no - //strange side effects occur after adding the first WaitFor again WaitFor* waitFor2 = new WaitForSignal(this, SIGNAL(anotherDummySignal())); - step.addWaitFor(waitFor2, this, SLOT(dummySlot())); + step.addWaitFor(waitFor2, "batheYourIguanaStep"); step.addWaitFor(waitFor1, this, SLOT(anotherDummySlot())); + step.addWaitFor(waitFor2, "batheYourChameleonStep"); QCOMPARE(waitFor1->parent(), &step); QCOMPARE(waitFor2->parent(), &step); @@ -533,6 +638,12 @@ emit dummySignal(); QCOMPARE(mDummySlotCallCount, 1); QCOMPARE(mAnotherDummySlotCallCount, 0); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + + emit anotherDummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "batheYourIguanaStep"); } void StepTest::testRemoveOption() { @@ -564,6 +675,36 @@ QCOMPARE(mAnotherDummySlotCallCount, 0); } +void StepTest::testRemoveOptionAssociatedToStepId() { + Step step("doSomethingConstructive"); + + Option* option1 = new Option("Bathe your iguana"); + step.addOption(option1, "batheYourIguanaStep"); + connect(this, SIGNAL(dummySignal()), option1, SIGNAL(selected())); + + //It will be removed and not deleted by parent Step, so it is created in + //stack + Option option2("Feed a toucan"); + step.addOption(&option2, "feedAToucanStep"); + connect(this, SIGNAL(dummySignal()), &option2, SIGNAL(selected())); + + step.removeOption(&option2); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + + QCOMPARE(option1->parent(), &step); + QCOMPARE(option2.parent(), (QObject*)0); + QCOMPARE(step.options().count(), 1); + QVERIFY(step.options().contains(option1)); + QVERIFY(!step.options().contains(&option2)); + QCOMPARE(nextStepRequestedSpy.count(), 0); + + step.setActive(true); + emit dummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "batheYourIguanaStep"); +} + void StepTest::testRemoveOptionSeveralOptions() { Step step("doSomethingConstructive"); @@ -581,33 +722,65 @@ step.addOption(&option3, this, SLOT(anotherDummySlot())); connect(this, SIGNAL(dummySignal()), &option3, SIGNAL(selected())); + Option option4("Lull the penguin"); + step.addOption(&option4, "lullThePenguinStep"); + connect(this, SIGNAL(dummySignal()), &option4, SIGNAL(selected())); + + Option option5("Pamper the Tasmanian Devil"); + step.addOption(&option5, "pamperTheTasmanianDevilStep"); + connect(this, SIGNAL(dummySignal()), &option5, SIGNAL(selected())); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + step.removeOption(&option1); step.removeOption(&option3); + step.removeOption(&option5); QCOMPARE(option1.parent(), (QObject*)0); QCOMPARE(option2.parent(), &step); QCOMPARE(option3.parent(), (QObject*)0); - QCOMPARE(step.options().count(), 1); + QCOMPARE(option4.parent(), &step); + QCOMPARE(option5.parent(), (QObject*)0); + QCOMPARE(step.options().count(), 2); QVERIFY(step.options().contains(&option2)); + QVERIFY(step.options().contains(&option4)); QVERIFY(!step.options().contains(&option1)); QVERIFY(!step.options().contains(&option3)); + QVERIFY(!step.options().contains(&option5)); QCOMPARE(mDummySlotCallCount, 0); QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 0); step.setActive(true); emit dummySignal(); QCOMPARE(mDummySlotCallCount, 1); QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "lullThePenguinStep"); step.removeOption(&option2); QCOMPARE(option2.parent(), (QObject*)0); - QCOMPARE(step.options().count(), 0); + QCOMPARE(step.options().count(), 1); + QVERIFY(step.options().contains(&option4)); QVERIFY(!step.options().contains(&option2)); emit dummySignal(); QCOMPARE(mDummySlotCallCount, 1); QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 2); + assertStepId(nextStepRequestedSpy, 1, "lullThePenguinStep"); + + step.removeOption(&option4); + + QCOMPARE(option4.parent(), (QObject*)0); + QCOMPARE(step.options().count(), 0); + QVERIFY(!step.options().contains(&option4)); + + emit dummySignal(); + QCOMPARE(mDummySlotCallCount, 1); + QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 2); } void StepTest::testRemoveWaitFor() { @@ -642,6 +815,39 @@ QCOMPARE(mAnotherDummySlotCallCount, 0); } +void StepTest::testRemoveWaitForAssociatedToStepId() { + Step step("doSomethingConstructive"); + + WaitForSignal* waitFor1 = new WaitForSignal(this, SIGNAL(dummySignal())); + step.addWaitFor(waitFor1, "batheYourIguanaStep"); + + //It will be removed and not deleted by parent Step, so it is created in + //stack + WaitForSignal waitFor2(this, SIGNAL(anotherDummySignal())); + step.addWaitFor(&waitFor2, "feedAToucanStep"); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + + step.setActive(true); + + step.removeWaitFor(&waitFor2); + + QCOMPARE(waitFor1->parent(), &step); + QCOMPARE(waitFor2.parent(), (QObject*)0); + QCOMPARE(step.mWaitsFor.count(), 1); + QVERIFY(step.mWaitsFor.contains(waitFor1)); + QVERIFY(!step.mWaitsFor.contains(&waitFor2)); + QVERIFY(waitFor1->isActive()); + QVERIFY(!waitFor2.isActive()); + QCOMPARE(nextStepRequestedSpy.count(), 0); + + waitFor2.setActive(true); + emit dummySignal(); + emit anotherDummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "batheYourIguanaStep"); +} + void StepTest::testRemoveWaitForSeveralWaitFors() { Step step("doSomethingConstructive"); @@ -654,8 +860,13 @@ step.addWaitFor(&waitFor2, this, SLOT(dummySlot())); WaitForSignal waitFor3(this, SIGNAL(thirdDummySignal())); - step.addWaitFor(&waitFor3, this, SLOT(anotherDummySlot())); + step.addWaitFor(&waitFor3, "batheYourIguanaStep"); + WaitForSignal waitFor4(this, SIGNAL(fourthDummySignal())); + step.addWaitFor(&waitFor4, "feedAToucanStep"); + + QSignalSpy nextStepRequestedSpy(&step, SIGNAL(nextStepRequested(QString))); + step.setActive(true); step.removeWaitFor(&waitFor1); @@ -664,15 +875,19 @@ QCOMPARE(waitFor1.parent(), (QObject*)0); QCOMPARE(waitFor2.parent(), &step); QCOMPARE(waitFor3.parent(), (QObject*)0); - QCOMPARE(step.mWaitsFor.count(), 1); + QCOMPARE(waitFor4.parent(), &step); + QCOMPARE(step.mWaitsFor.count(), 2); QVERIFY(step.mWaitsFor.contains(&waitFor2)); + QVERIFY(step.mWaitsFor.contains(&waitFor4)); QVERIFY(!step.mWaitsFor.contains(&waitFor1)); QVERIFY(!step.mWaitsFor.contains(&waitFor3)); QVERIFY(!waitFor1.isActive()); QVERIFY(waitFor2.isActive()); QVERIFY(!waitFor3.isActive()); + QVERIFY(waitFor4.isActive()); QCOMPARE(mDummySlotCallCount, 0); QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 0); step.setActive(true); waitFor1.setActive(true); @@ -680,21 +895,45 @@ emit dummySignal(); emit anotherDummySignal(); emit thirdDummySignal(); + emit fourthDummySignal(); QCOMPARE(mDummySlotCallCount, 1); QCOMPARE(mAnotherDummySlotCallCount, 0); + QCOMPARE(nextStepRequestedSpy.count(), 1); + assertStepId(nextStepRequestedSpy, 0, "feedAToucanStep"); step.removeWaitFor(&waitFor2); QCOMPARE(waitFor2.parent(), (QObject*)0); - QCOMPARE(step.mWaitsFor.count(), 0); + QCOMPARE(step.mWaitsFor.count(), 1); + QVERIFY(step.mWaitsFor.contains(&waitFor4)); QVERIFY(!step.mWaitsFor.contains(&waitFor2)); QVERIFY(!waitFor2.isActive()); waitFor2.setActive(true); emit dummySignal(); QCOMPARE(mDummySlotCallCount, 1); + + step.removeWaitFor(&waitFor4); + + QCOMPARE(waitFor4.parent(), (QObject*)0); + QCOMPARE(step.mWaitsFor.count(), 0); + QVERIFY(!step.mWaitsFor.contains(&waitFor4)); + QVERIFY(!waitFor4.isActive()); + + waitFor4.setActive(true); + emit fourthDummySignal(); + QCOMPARE(nextStepRequestedSpy.count(), 1); } +/////////////////////////////////// Helpers //////////////////////////////////// + +void StepTest::assertStepId(const QSignalSpy& spy, int index, + const QString& stepId) { + QVariant argument = spy.at(index).at(0); + QCOMPARE(argument.type(), QVariant::String); + QCOMPARE(argument.toString(), stepId); +} + QTEST_MAIN(StepTest) #include "StepTest.moc" Modified: trunk/ktutorial/ktutorial-library/test/TutorialTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/test/TutorialTest.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/test/TutorialTest.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -44,6 +44,7 @@ void testStartNoStartStep(); void testNextStepId(); + void testNextStepIdRequestedFromStep(); void testNextStepIdWithInvalidId(); void testNextStepStep(); @@ -53,6 +54,18 @@ }; +class StepToRequestNextStep: public Step { +public: + + StepToRequestNextStep(const QString& id): Step(id) { + } + + void emitNextStepRequested(const QString& nextStepId) { + emit nextStepRequested(nextStepId); + } + +}; + class MockTutorial: public Tutorial { public: @@ -255,6 +268,35 @@ QVERIFY(step1->isActive()); } +void TutorialTest::testNextStepIdRequestedFromStep() { + Tutorial tutorial(new TutorialInformation("pearlOrientation")); + + StepToRequestNextStep* stepStart = new StepToRequestNextStep("start"); + tutorial.addStep(stepStart); + + Step* step1 = new Step("record"); + tutorial.addStep(step1); + + tutorial.addStep(new Step("roll")); + tutorial.addStep(new Step("send")); + + tutorial.start(); + + //Step* must be registered in order to be used with QSignalSpy + int stepStarType = qRegisterMetaType<Step*>("Step*"); + QSignalSpy stepActivatedSpy(&tutorial, SIGNAL(stepActivated(Step*))); + + stepStart->emitNextStepRequested("record"); + + QCOMPARE(stepActivatedSpy.count(), 1); + QVariant argument = stepActivatedSpy.at(0).at(0); + QCOMPARE(argument.userType(), stepStarType); + QCOMPARE(qvariant_cast<Step*>(argument), step1); + QCOMPARE(tutorial.mCurrentStep, step1); + QVERIFY(!stepStart->isActive()); + QVERIFY(step1->isActive()); +} + void TutorialTest::testNextStepIdWithInvalidId() { Tutorial tutorial(new TutorialInformation("pearlOrientation")); Modified: trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -207,8 +207,7 @@ out << "function option1Selected() { tutorial.nextStep(\"first\"); }\n"; out << "startStep.addOption(option1, self, \"option1Selected()\");\n"; - out << "function option2Selected() { tutorial.nextStep(\"second\"); }\n"; - out << "startStep.addOption(option2, self, \"option2Selected()\");\n"; + out << "startStep.addOption(option2, \"second\");\n"; out.flush(); ScriptedTutorial scriptedTutorial(mTemporaryFile->fileName()); @@ -243,11 +242,15 @@ out << "tutorial.addStep(startStep);\n"; out << "firstStep = ktutorial.newStep(\"first\");\n"; out << "tutorial.addStep(firstStep);\n"; + out << "secondStep = ktutorial.newStep(\"second\");\n"; + out << "tutorial.addStep(secondStep);\n"; out << "waitForDummy = ktutorial.newWaitFor(\"WaitForSignal\");\n"; out << "waitForDummy.setSignal(testObject, \"dummySignal()\");\n"; out << "waitForOtherDummy = ktutorial.newWaitFor(\"WaitForSignal\");\n"; out << "waitForOtherDummy.setSignal(testObject, \"otherDummySignal()\");\n"; + out << "waitForAnotherDummy = ktutorial.newWaitFor(\"WaitForSignal\");\n"; + out << "waitForAnotherDummy.setSignal(testObject, \"anotherDummySignal()\");\n"; out << "startStep.addWaitFor(waitForDummy, testObject, \"dummySlot()\");\n"; @@ -257,6 +260,8 @@ out << " }\n"; out << "};\n"; out << "startStep.addWaitFor(waitForOtherDummy, self, \"checkEnded()\");\n"; + + out << "firstStep.addWaitFor(waitForAnotherDummy, \"second\");\n"; out.flush(); ScriptedTutorial scriptedTutorial(mTemporaryFile->fileName()); @@ -283,6 +288,10 @@ QCOMPARE(scriptedTutorial.mCurrentStep->id(), QString("first")); QCOMPARE(mDummySlotCallCount, 1); + + emit anotherDummySignal(); + + QCOMPARE(scriptedTutorial.mCurrentStep->id(), QString("second")); } void ScriptingTest::fullTutorial() { @@ -342,11 +351,7 @@ out << "waitForChildAddedEvent = ktutorial.newWaitFor(\"WaitForEvent\");\n"; out << "waitForChildAddedEvent.setEvent(testObject, \"ChildAdded\");\n"; - out << "function thirdDone() {\n"; - out << " tutorial.nextStep(\"end\");\n"; - out << "};\n"; - out << "thirdStep.addWaitFor(waitForChildAddedEvent, \ -self, \"thirdDone\");\n"; + out << "thirdStep.addWaitFor(waitForChildAddedEvent, \"end\");\n"; out.flush(); Modified: trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -49,7 +49,7 @@ QObject* clearAction = KTutorial::self()->findObject<QObject*>("clear"); clearTextStep->addWaitFor(new WaitForSignal(clearAction, SIGNAL(triggered(bool))), - this, SLOT(clearTextDone())); + "end"); addStep(clearTextStep); @@ -70,7 +70,3 @@ nextStep("clearText"); } } - -void TutorialClearText::clearTextDone() { - nextStep("end"); -} Modified: trunk/ktutorial/ktutorial-test-app/TutorialClearText.h =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialClearText.h 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-test-app/TutorialClearText.h 2010-02-26 18:55:44 UTC (rev 108) @@ -31,8 +31,6 @@ void startDone(); - void clearTextDone(); - }; #endif Modified: trunk/ktutorial/ktutorial-test-app/TutorialClearText.js =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialClearText.js 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-test-app/TutorialClearText.js 2010-02-26 18:55:44 UTC (rev 108) @@ -47,12 +47,8 @@ waitForClearTriggered = ktutorial.newWaitFor("WaitForSignal"); waitForClearTriggered.setSignal(clearAction, "triggered(bool)"); -clearTextStep.addWaitFor(waitForClearTriggered, self, "clearTextDone()"); +clearTextStep.addWaitFor(waitForClearTriggered, "end"); -function clearTextDone() { - tutorial.nextStep("end"); -} - tutorial.addStep(clearTextStep); //Step 3 Modified: trunk/ktutorial/ktutorial-test-app/TutorialClearText.py =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialClearText.py 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-test-app/TutorialClearText.py 2010-02-26 18:55:44 UTC (rev 108) @@ -48,11 +48,8 @@ waitForClearTriggered = ktutorial.newWaitFor("WaitForSignal") waitForClearTriggered.setSignal(clearAction, "triggered(bool)") -clearTextStep.addWaitFor(waitForClearTriggered, self, "clearTextDone()") +clearTextStep.addWaitFor(waitForClearTriggered, "end") -def clearTextDone(): - tutorial.nextStep("end") - tutorial.addStep(clearTextStep) #Step 3 Modified: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp 2010-02-26 18:55:44 UTC (rev 108) @@ -95,7 +95,7 @@ KAction* cutAction = KTutorial::self()->findObject<KAction*>("edit_cut"); keyboardCutStep->addWaitFor(new WaitForSignal(cutAction, SIGNAL(triggered(bool))), - this, SLOT(keyboardCut())); + "keyboardMoveCursor"); addStep(keyboardCutStep); @@ -123,7 +123,7 @@ mousePressStep->setText(i18nc("@info", "Press with the left button of the mouse on the selected text. You must press on it, or the selection will change, and you will have to select it again. Don't release the button yet.")); mousePressStep->addWaitFor(new WaitForLeftMouseButtonPressed(mTextArea->viewport()), - this, SLOT(mousePress())); + "mouseRelease"); addStep(mousePressStep); @@ -141,7 +141,7 @@ showOtherWayStep->setText(i18nc("@info", "As explained, there are two ways to move text in a text area: using the mouse and using the keyboard. Do you want to see the other way?")); showOtherWayStep->addOption(new Option(i18n("Yes, please")), this, SLOT(showOtherWay())); - showOtherWayStep->addOption(new Option(i18n("No, thanks")), this, SLOT(end())); + showOtherWayStep->addOption(new Option(i18n("No, thanks")), "end"); addStep(showOtherWayStep); @@ -182,10 +182,6 @@ } } -void TutorialMoveText::keyboardCut() { - nextStep("keyboardMoveCursor"); -} - void TutorialMoveText::keyboardMoveCursor() { if (mTextArea->textCursor().position() == 0) { nextStep("keyboardPaste"); @@ -200,10 +196,6 @@ } } -void TutorialMoveText::mousePress() { - nextStep("mouseRelease"); -} - void TutorialMoveText::mouseRelease() { if (mSecondPath) { nextStep("end"); @@ -221,10 +213,6 @@ nextStep("write"); } -void TutorialMoveText::end() { - nextStep("end"); -} - //protected: void TutorialMoveText::setup() { Modified: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h 2010-02-26 18:55:44 UTC (rev 108) @@ -39,20 +39,14 @@ void select(); - void keyboardCut(); - void keyboardMoveCursor(); void keyboardPaste(); - void mousePress(); - void mouseRelease(); void showOtherWay(); - void end(); - protected: void setup(); Modified: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.py =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialMoveText.py 2010-02-25 06:02:45 UTC (rev 107) +++ trunk/ktutorial/ktutorial-test-app/TutorialMoveText.py 2010-02-26 18:55:44 UTC (rev 108) @@ -117,11 +117,8 @@ cutAction = ktutorial.findObject("edit_cut") waitForCutTriggered = ktutorial.newWaitFor("WaitForSignal") waitForCutTriggered.setSignal(cutAction, "triggered(bool)") -keyboardCutStep.addWaitFor(waitForCutTriggered, self, "keyboardCut()") +keyboardCutStep.addWaitFor(waitForCutTriggered, "keyboardMoveCursor") -def keyboardCut(): - tutorial.nextStep("keyboardMoveCursor") - tutorial.addStep(keyboardCutStep) #Step keyboardMoveCursor @@ -163,11 +160,8 @@ waitForMousePressed = ktutorial.newWaitFor("WaitForSignal") waitForMousePressed.setSignal(mouseFilter, "mousePressed()") -mousePressStep.addWaitFor(waitForMousePressed, self, "mousePress()") +mousePressStep.addWaitFor(waitForMousePressed, "mouseRelease") -def mousePress(): - tutorial.nextStep("mouseRelease") - tutorial.addStep(mousePressStep) #Step mouseRelease @@ -200,11 +194,8 @@ flags["mousePathSelected"] = not flags["mousePathSelected"] tutorial.nextStep("write") -showOtherWayStep.addOption(ktutorial.newOption(t.i18n("No, thanks")), self, "end()") +showOtherWayStep.addOption(ktutorial.newOption(t.i18n("No, thanks")), "end") -def end(): - tutorial.nextStep("end") - tutorial.addStep(showOtherWayStep) #Step end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-10-03 19:17:33
|
Revision: 273 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=273&view=rev Author: danxuliu Date: 2010-10-03 19:17:27 +0000 (Sun, 03 Oct 2010) Log Message: ----------- Fix Krazy2 i18ncheckarg issues. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.cpp trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.cpp Modified: trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.cpp 2010-10-03 19:14:30 UTC (rev 272) +++ trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.cpp 2010-10-03 19:17:27 UTC (rev 273) @@ -38,8 +38,8 @@ Q_ASSERT(url.isValid()); if (url.fileName(KUrl::ObeyTrailingSlash).isEmpty()) { - throw IOException(i18n("A file was expected, but '%1' is a folder", - url.prettyUrl())); + throw IOException(i18nc("@info/plain", "A file was expected, but '%1' " + "is a folder", url.prettyUrl())); } QString temporaryFileName; Modified: trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp 2010-10-03 19:14:30 UTC (rev 272) +++ trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp 2010-10-03 19:17:27 UTC (rev 273) @@ -64,7 +64,7 @@ textEdit->setAttribute(Qt::WA_DeleteOnClose); textEdit->setWindowFlags(Qt::Window); textEdit->setObjectName("usingKTutorialTextEdit"); - textEdit->setText(i18nc("Plain text in a QTextEdit", + textEdit->setText(i18nc("@info/plain Plain text in a QTextEdit", "Look at me! I am the text area!")); textEdit->show(); @@ -136,9 +136,10 @@ UsingKTutorial::UsingKTutorial(): Tutorial(0) { mTutorialInformation = new TutorialInformation("usingKTutorial"); - mTutorialInformation->setName(i18n("Using the tutorials")); - mTutorialInformation->setDescription(i18n("This tutorial shows how the " - "tutorial system works")); + mTutorialInformation->setName(i18nc("@info/plain", "Using the tutorials")); + mTutorialInformation->setDescription(i18nc("@info/plain", "This tutorial " + "shows how the tutorial system " + "works")); //Step start Step* startStep = new Step("start"); @@ -245,8 +246,8 @@ highlightTextEditStep->setText(i18nc("@info", "<para>Sometimes, a tutorial may provide a link to a <emphasis>widget" "</emphasis> (an element of the graphical user interface, like a button). For " -"example, <a href=\"widget:usingKTutorialTextEdit\">this is a link to the text " -"area</a>.</para>" +"example, <link url=\"widget:usingKTutorialTextEdit\">this is a link to the " +"text area</link>.</para>" "<para>When you click on a link to a widget, the widget is highlighted to help " "you to spot it. If you click again on it, the highlighting will be stopped. " "In this example it is pretty clear what the text area refers to, but it can " Modified: trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.cpp 2010-10-03 19:14:30 UTC (rev 272) +++ trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.cpp 2010-10-03 19:17:27 UTC (rev 273) @@ -44,7 +44,7 @@ ui->tutorialsList->setModel(new TutorialListModel(tutorialManager, this)); setButtonIcon(User1, KIcon("dialog-ok")); - setButtonText(User1, i18nc("@action:button", "Start")); + setButtonText(User1, i18nc("@action:button Used to start a tutorial", "Start")); setButtonToolTip(User1, i18nc("@info:tooltip", "Start the selected tutorial")); setButtonWhatsThis(User1, i18nc("@info:whatsthis", "Start the selected tutorial")); setDefaultButton(User1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-06-21 15:18:40
|
Revision: 329 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=329&view=rev Author: danxuliu Date: 2011-06-21 15:18:34 +0000 (Tue, 21 Jun 2011) Log Message: ----------- Remove applicationFilePath from the D-Bus exposed interface, as it is no longer needed since commit 320. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportAdaptorTest.cpp Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2011-06-17 01:51:56 UTC (rev 328) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2011-06-21 15:18:34 UTC (rev 329) @@ -226,10 +226,6 @@ public slots: - QString applicationFilePath() const { - return QApplication::applicationFilePath(); - } - int mainWindowObjectId() const { return 42; } Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp 2011-06-17 01:51:56 UTC (rev 328) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp 2011-06-21 15:18:34 UTC (rev 329) @@ -33,10 +33,6 @@ //public slots: -QString EditorSupportAdaptor::applicationFilePath() const { - return QCoreApplication::applicationFilePath(); -} - int EditorSupportAdaptor::mainWindowObjectId() const { return mEditorSupport->mainWindowObjectId(); } Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h 2011-06-17 01:51:56 UTC (rev 328) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h 2011-06-21 15:18:34 UTC (rev 329) @@ -48,13 +48,6 @@ public Q_SLOTS: /** - * Returns the path to the application file. - * - * @return The path to the application file. - */ - QString applicationFilePath() const; - - /** * Returns the object id of the application main window. * * @return The object id of the application main window. Modified: trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportAdaptorTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportAdaptorTest.cpp 2011-06-17 01:51:56 UTC (rev 328) +++ trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportAdaptorTest.cpp 2011-06-21 15:18:34 UTC (rev 329) @@ -51,8 +51,6 @@ void testConstructor(); - void testApplicationFilePath(); - void testMainWindowObjectId(); void testHighlight(); @@ -75,14 +73,6 @@ QCOMPARE(adaptor->parent(), &editorSupport); } -void EditorSupportAdaptorTest::testApplicationFilePath() { - EditorSupport editorSupport; - EditorSupportAdaptor* adaptor = new EditorSupportAdaptor(&editorSupport); - - QCOMPARE(adaptor->applicationFilePath(), - QCoreApplication::applicationFilePath()); -} - void EditorSupportAdaptorTest::testMainWindowObjectId() { EditorSupport editorSupport; QWidget window; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-23 16:17:04
|
Revision: 92 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=92&view=rev Author: danxuliu Date: 2010-02-23 16:16:57 +0000 (Tue, 23 Feb 2010) Log Message: ----------- Fix base path to extract messages (it should have been modified when the directories were restructured). Modified Paths: -------------- trunk/ktutorial/ktutorial-library/po/Messages.sh trunk/ktutorial/ktutorial-test-app/po/Messages.sh Modified: trunk/ktutorial/ktutorial-library/po/Messages.sh =================================================================== --- trunk/ktutorial/ktutorial-library/po/Messages.sh 2010-02-23 06:28:13 UTC (rev 91) +++ trunk/ktutorial/ktutorial-library/po/Messages.sh 2010-02-23 16:16:57 UTC (rev 92) @@ -1,6 +1,6 @@ #!/bin/sh -BASEDIR="../../src/" # root of translatable sources +BASEDIR="../src/" # root of translatable sources PROJECT="ktutorial" # project name BUGADDR="http://sourceforge.net/tracker/?group_id=301227&atid=1270278" # MSGID-Bugs WDIR=`pwd` # working dir Modified: trunk/ktutorial/ktutorial-test-app/po/Messages.sh =================================================================== --- trunk/ktutorial/ktutorial-test-app/po/Messages.sh 2010-02-23 06:28:13 UTC (rev 91) +++ trunk/ktutorial/ktutorial-test-app/po/Messages.sh 2010-02-23 16:16:57 UTC (rev 92) @@ -1,6 +1,6 @@ #!/bin/sh -BASEDIR="../../test-app/" # root of translatable sources +BASEDIR="../" # root of translatable sources PROJECT="ktutorial-test-app" # project name BUGADDR="http://sourceforge.net/tracker/?group_id=301227&atid=1270278" # MSGID-Bugs WDIR=`pwd` # working dir This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-25 06:02:52
|
Revision: 107 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=107&view=rev Author: danxuliu Date: 2010-02-25 06:02:45 +0000 (Thu, 25 Feb 2010) Log Message: ----------- Added WaitForEvent class to wait for events of some type sent to an object. It is used now in UsingKTutorial and TutorialMoveText tutorials. Modified Paths: -------------- trunk/ktutorial/ktutorial-library/src/CMakeLists.txt trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.cpp trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp trunk/ktutorial/ktutorial-library/test/CMakeLists.txt trunk/ktutorial/ktutorial-library/test/scripting/ScriptingModuleTest.cpp trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h Added Paths: ----------- trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp trunk/ktutorial/ktutorial-library/src/WaitForEvent.h trunk/ktutorial/ktutorial-library/test/WaitForEventTest.cpp Modified: trunk/ktutorial/ktutorial-library/src/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/src/CMakeLists.txt 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-library/src/CMakeLists.txt 2010-02-25 06:02:45 UTC (rev 107) @@ -18,6 +18,7 @@ WaitFor.cpp WaitForAnd.cpp WaitForComposed.cpp + WaitForEvent.cpp WaitForNot.cpp WaitForOr.cpp WaitForSignal.cpp @@ -42,6 +43,7 @@ WaitFor.h WaitForAnd.h WaitForComposed.h + WaitForEvent.h WaitForNot.h WaitForOr.h WaitForSignal.h Added: trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp (rev 0) +++ trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp 2010-02-25 06:02:45 UTC (rev 107) @@ -0,0 +1,90 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include "WaitForEvent.h" + +#include <QMetaEnum> + +#include <KDebug> + +//public: + +WaitForEvent::WaitForEvent(): + mObject(0), + mEventType(QEvent::None), + mConditionMet(false) { +} + +WaitForEvent::WaitForEvent(QObject* object, QEvent::Type type): + mObject(object), + mEventType(type), + mConditionMet(false) { + + object->installEventFilter(this); +} + +void WaitForEvent::setEvent(QObject* object, const QString& typeName) { + int index = QEvent::staticMetaObject.indexOfEnumerator("Type"); + QMetaEnum eventTypeEnumerator = QEvent::staticMetaObject.enumerator(index); + + int eventTypeValue = eventTypeEnumerator.keyToValue(qPrintable(typeName)); + if (eventTypeValue == -1) { + kWarning() << "QEvent::Type named \"" << typeName << "\" is unknown"; + return; + } + + mObject = object; + mEventType = static_cast<QEvent::Type>(eventTypeValue); + + mObject->installEventFilter(this); +} + +bool WaitForEvent::eventFilter(QObject* object, QEvent* event) { + if (!isActive()) { + return false; + } + + if (object == mObject && event->type() == mEventType) { + handleEvent(event); + } + + return false; +} + +bool WaitForEvent::conditionMet() const { + return mConditionMet; +} + +void WaitForEvent::setActive(bool active) { + WaitFor::setActive(active); + + if (active) { + mConditionMet = false; + } +} + +//protected: + +void WaitForEvent::handleEvent(QEvent* event) { + Q_UNUSED(event); + + mConditionMet = true; + emit waitEnded(this); +} + +#include "WaitForEvent.moc" Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-library/src/WaitForEvent.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForEvent.h (rev 0) +++ trunk/ktutorial/ktutorial-library/src/WaitForEvent.h 2010-02-25 06:02:45 UTC (rev 107) @@ -0,0 +1,154 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#ifndef WAITFOREVENT_H +#define WAITFOREVENT_H + +#include <QEvent> + +#include "ktutorial_export.h" + +#include "WaitFor.h" + +/** + * Waits for an event of some specific type to be sent to an object. + * When an event of the expected type is sent and the WaitForEvent is active, + * the wait ends. + * + * Note that if the event is sent while the WaitFor isn't active, it won't + * be registered and the condition won't be met. In order to met the condition, + * the event must be sent while the WaitForEvent is active. + * + * In some cases, just waiting for an event of some type isn't enough. For + * example, you may want to end the waiting if a QEvent::MouseButtonPress is + * sent, but only if the button pressed is the left. To do this, you can create + * a subclass of WaitForEvent and redefine handleEvent(QEvent*) method. + * \code + * void WaitForEventSubclass::handleEvent(QEvent* event) { + * QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); + * + * if (mouseEvent->button() == Qt::LeftButton) { + * WaitForEvent::handleEvent(event); + * } + * } + * \endcode + */ +class KTUTORIAL_EXPORT WaitForEvent: public WaitFor { +Q_OBJECT +public: + + /** + * Creates a new WaitForEvent. + * This constructor is needed to dynamically create WaitForEvent objects in + * scripts using ScriptingModule::newWaitFor(const QString&). Method + * setEvent(QObject*, const QString&) must be called to finish setting up + * the object. For C++ tutorials, use + * WaitForEvent(QObject*, QEvent::Type) constructor instead of this one. + */ + Q_INVOKABLE WaitForEvent(); + + /** + * Creates a new WaitForEvent. + * + * @param object The object to watch. + * @param typeName The name of the event type to wait for. + */ + WaitForEvent(QObject* object, QEvent::Type type); + + /** + * Sets the event to wait for. + * Note that the QEvent::Type has to be passed as a string. For example, to + * wait for a QEvent::Close you have to pass "Close" as the second + * parameter. + * This method can be invoked from a script. + * + * In fact, you should only invoke this method from a script, and only once, + * to set up the object. For C++ tutorials, use + * WaitForEvent(QObject*, QEvent::Type) constructor when creating this + * WaitForEvent. + * + * The type is passed as a string with its name instead of using a pure + * QEvent::Type due to a current limitation of Kross (enumeration in QObject + * classes seem supported. However, QEvent is not a QObject but a Q_GADGET). + * + * @param object The object to watch. + * @param typeName The name of the event type to wait for. + */ + Q_INVOKABLE void setEvent(QObject* object, const QString& typeName); + + /** + * Inspects the events sent to the watched object. + * If the event has the type expected by this WaitFor it is handled by + * handleEvent(QEvent*) which, by default, ends the waiting. + * + * @param object The object that the event was sent to. + * @param event The event sent. + * @return False, so the event can be handled further. + */ + virtual bool eventFilter(QObject* object, QEvent* event); + + /** + * Returns true if the event was received while active, false otherwise. + * + * @return True if the event was received while active, false otherwise. + */ + virtual bool conditionMet() const; + + /** + * Sets this WaitForEvent active or inactive. + * Activating it resets its condition. + * + * @param active True to set it active, false otherwise. + */ + virtual void setActive(bool active); + +protected: + + /** + * Handles the event ending the wait (if this WaitForEvent is active). + * WaitForEvent subclasses can redefine this method if just receiving an + * event of the type expected isn't enough to end the waiting and some + * special check has to be done. + * + * The event is assured to have the type expected by this WaitForEvent and + * to be sent to the watched object. + * + * @param event The event. + */ + virtual void handleEvent(QEvent* event); + +private: + + /** + * The watched object. + */ + QObject* mObject; + + /** + * The type of event expected. + */ + QEvent::Type mEventType; + + /** + * Whether the event was received when active or not. + */ + bool mConditionMet; + +}; + +#endif \ No newline at end of file Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForEvent.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.cpp 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.cpp 2010-02-25 06:02:45 UTC (rev 107) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -24,6 +24,7 @@ #include "../Option.h" #include "../WaitFor.h" #include "../WaitForAnd.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForOr.h" #include "../WaitForSignal.h" @@ -34,6 +35,7 @@ if (sSelf == 0) { sSelf = new ScriptingModule(); sSelf->registerWaitForMetaObject(WaitForAnd::staticMetaObject); + sSelf->registerWaitForMetaObject(WaitForEvent::staticMetaObject); sSelf->registerWaitForMetaObject(WaitForNot::staticMetaObject); sSelf->registerWaitForMetaObject(WaitForOr::staticMetaObject); sSelf->registerWaitForMetaObject(WaitForSignal::staticMetaObject); Modified: trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp 2010-02-25 06:02:45 UTC (rev 107) @@ -27,9 +27,29 @@ #include "../Option.h" #include "../Step.h" #include "../TutorialInformation.h" +#include "../WaitForEvent.h" #include "../WaitForSignal.h" #include "../view/StepWidget.h" +class WaitForLeftMouseButtonPressed: public WaitForEvent { +Q_OBJECT +public: + + WaitForLeftMouseButtonPressed(QObject* object): + WaitForEvent(object, QEvent::MouseButtonPress) { + } + +protected: + + virtual void handleEvent(QEvent* event) { + QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); + if (mouseEvent->button() == Qt::LeftButton) { + WaitForEvent::handleEvent(event); + } + } + +}; + class ClearTextStep: public Step { public: @@ -69,27 +89,11 @@ virtual void setup() { QTextEdit* textEdit = KTutorial::self()->findObject<QTextEdit*>( "usingKTutorialTextEdit"); - //The filter is removed when the text edit is deleted, that is, when it - //is closed. - textEdit->installEventFilter(this); - addWaitFor(new WaitForSignal(this, SIGNAL(textEditClosed())), + addWaitFor(new WaitForEvent(textEdit, QEvent::Close), mUsingKTutorial, SLOT(closeTextEditDone())); } - bool eventFilter(QObject* object, QEvent* event) { - Q_UNUSED(object); - if (event->type() == QEvent::Close) { - emit textEditClosed(); - } - - return false; - } - -Q_SIGNALS: - - void textEditClosed(); - private: UsingKTutorial* mUsingKTutorial; @@ -108,30 +112,11 @@ virtual void setup() { QWidget* mStepWidget = KTutorial::self()-> findObject<view::StepWidget*>("ktutorial_StepWidget"); - //The filter is removed when the widget is deleted, that is, when the - //tutorial is closed. - mStepWidget->installEventFilter(this); - addWaitFor(new WaitForSignal(this, SIGNAL(mousePressedOnWidget())), + addWaitFor(new WaitForLeftMouseButtonPressed(mStepWidget), mUsingKTutorial, SLOT(moveWidgetPressDone())); } - bool eventFilter(QObject* object, QEvent* event) { - Q_UNUSED(object); - if (event->type() == QEvent::MouseButtonPress) { - QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); - if (mouseEvent->button() == Qt::LeftButton) { - emit mousePressedOnWidget(); - } - } - - return false; - } - -Q_SIGNALS: - - void mousePressedOnWidget(); - private: UsingKTutorial* mUsingKTutorial; @@ -150,27 +135,11 @@ virtual void setup() { QWidget* mStepWidget = KTutorial::self()-> findObject<view::StepWidget*>("ktutorial_StepWidget"); - //The filter is removed when the widget is deleted, that is, when the - //tutorial is closed. - mStepWidget->installEventFilter(this); - addWaitFor(new WaitForSignal(this, SIGNAL(mouseReleasedOnWidget())), + addWaitFor(new WaitForEvent(mStepWidget, QEvent::MouseButtonRelease), mUsingKTutorial, SLOT(moveWidgetReleaseDone())); } - bool eventFilter(QObject* object, QEvent* event) { - Q_UNUSED(object); - if (event->type() == QEvent::MouseButtonRelease) { - emit mouseReleasedOnWidget(); - } - - return false; - } - -Q_SIGNALS: - - void mouseReleasedOnWidget(); - private: UsingKTutorial* mUsingKTutorial; Modified: trunk/ktutorial/ktutorial-library/test/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/test/CMakeLists.txt 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-library/test/CMakeLists.txt 2010-02-25 06:02:45 UTC (rev 107) @@ -14,7 +14,7 @@ ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) -unit_tests(Option Step Tutorial TutorialInformation TutorialManager WaitFor WaitForAnd WaitForComposed WaitForNot WaitForOr WaitForSignal) +unit_tests(Option Step Tutorial TutorialInformation TutorialManager WaitFor WaitForAnd WaitForComposed WaitForEvent WaitForNot WaitForOr WaitForSignal) MACRO(MEM_TESTS) FOREACH(_testname ${ARGN}) @@ -22,4 +22,4 @@ ENDFOREACH(_testname) ENDMACRO(MEM_TESTS) -mem_tests(Option Step Tutorial TutorialInformation TutorialManager WaitFor WaitForAnd WaitForComposed WaitForNot WaitForOr WaitForSignal) +mem_tests(Option Step Tutorial TutorialInformation TutorialManager WaitFor WaitForAnd WaitForComposed WaitForEvent WaitForNot WaitForOr WaitForSignal) Added: trunk/ktutorial/ktutorial-library/test/WaitForEventTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/test/WaitForEventTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-library/test/WaitForEventTest.cpp 2010-02-25 06:02:45 UTC (rev 107) @@ -0,0 +1,221 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include <QtTest> + +#define protected public +#define private public +#include "WaitForEvent.h" +#undef private +#undef protected + +class WaitForEventTest: public QObject { +Q_OBJECT +private slots: + + void testConstructor(); + void testConstructorDefault(); + + void testSetActive(); + + void testWaitEnded(); + void testWaitEndedWithDefaultConstructor(); + void testWaitEndedNotActive(); + + void testHandleEvent(); + void testHandleEventNotActive(); + void testHandleEventEventTypeNotExpected(); + + void testEventSentAfterWaitForDestruction(); + +}; + +class WaitForEventWithCustomHandling: public WaitForEvent { +public: + + QEvent::Type mType; + int mHandledEventsCount; + + WaitForEventWithCustomHandling(QObject* object, QEvent::Type type): + WaitForEvent(object, type), + mType(type), + mHandledEventsCount(0) { + } + +protected: + + virtual void handleEvent(QEvent* event) { + QCOMPARE(event->type(), mType); + + mHandledEventsCount++; + } + +}; + +void WaitForEventTest::testConstructor() { + WaitForEvent waitForEvent(this, QEvent::ChildAdded); + + QVERIFY(!waitForEvent.isActive()); + QVERIFY(!waitForEvent.conditionMet()); +} + +void WaitForEventTest::testConstructorDefault() { + WaitForEvent waitForEvent; + waitForEvent.setEvent(this, "ChildAdded"); + + QVERIFY(!waitForEvent.isActive()); + QVERIFY(!waitForEvent.conditionMet()); +} + +void WaitForEventTest::testSetActive() { + WaitForEvent waitForEvent(this, QEvent::ChildAdded); + waitForEvent.mConditionMet = true; + + waitForEvent.setActive(true); + + QVERIFY(waitForEvent.isActive()); + QVERIFY(!waitForEvent.conditionMet()); +} + +//WaitFor* must be declared as a metatype to be used in qvariant_cast +Q_DECLARE_METATYPE(WaitFor*); + +void WaitForEventTest::testWaitEnded() { + QObject parentObject; + + WaitForEvent waitForEvent(&parentObject, QEvent::ChildAdded); + waitForEvent.setActive(true); + + //WaitFor* must be registered in order to be used with QSignalSpy + int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*"); + QSignalSpy waitEndedSpy(&waitForEvent, SIGNAL(waitEnded(WaitFor*))); + + QObject* childObject = new QObject(); + childObject->setParent(&parentObject); + + QVERIFY(waitForEvent.conditionMet()); + QCOMPARE(waitEndedSpy.count(), 1); + QVariant argument = waitEndedSpy.at(0).at(0); + QCOMPARE(argument.userType(), waitForStarType); + QCOMPARE(qvariant_cast<WaitFor*>(argument), &waitForEvent); +} + +void WaitForEventTest::testWaitEndedWithDefaultConstructor() { + QObject parentObject; + + WaitForEvent waitForEvent; + waitForEvent.setEvent(&parentObject, "ChildAdded"); + waitForEvent.setActive(true); + + //WaitFor* must be registered in order to be used with QSignalSpy + int waitForStarType = qRegisterMetaType<WaitFor*>("WaitFor*"); + QSignalSpy waitEndedSpy(&waitForEvent, SIGNAL(waitEnded(WaitFor*))); + + QObject* childObject = new QObject(); + childObject->setParent(&parentObject); + + QVERIFY(waitForEvent.conditionMet()); + QCOMPARE(waitEndedSpy.count(), 1); + QVariant argument = waitEndedSpy.at(0).at(0); + QCOMPARE(argument.userType(), waitForStarType); + QCOMPARE(qvariant_cast<WaitFor*>(argument), &waitForEvent); +} + +void WaitForEventTest::testWaitEndedNotActive() { + QObject parentObject; + + WaitForEvent waitForEvent(&parentObject, QEvent::ChildAdded); + + qRegisterMetaType<WaitFor*>("WaitFor*"); + QSignalSpy waitEndedSpy(&waitForEvent, SIGNAL(waitEnded(WaitFor*))); + + QObject* childObject = new QObject(); + childObject->setParent(&parentObject); + + QVERIFY(!waitForEvent.conditionMet()); + QCOMPARE(waitEndedSpy.count(), 0); +} + +void WaitForEventTest::testHandleEvent() { + QObject parentObject; + + WaitForEventWithCustomHandling waitForEvent(&parentObject, + QEvent::ChildAdded); + waitForEvent.setActive(true); + + QObject* childObject = new QObject(); + childObject->setParent(&parentObject); + + QCOMPARE(waitForEvent.mHandledEventsCount, 1); +} + +void WaitForEventTest::testHandleEventNotActive() { + QObject parentObject; + + WaitForEventWithCustomHandling waitForEvent(&parentObject, + QEvent::ChildAdded); + + QObject* childObject = new QObject(); + childObject->setParent(&parentObject); + + QCOMPARE(waitForEvent.mHandledEventsCount, 0); +} + +void WaitForEventTest::testHandleEventEventTypeNotExpected() { + QObject parentObject; + + WaitForEventWithCustomHandling waitForEvent(&parentObject, + QEvent::ChildRemoved); + waitForEvent.setActive(true); + + QObject* childObject = new QObject(); + childObject->setParent(&parentObject); + + QCOMPARE(waitForEvent.mHandledEventsCount, 0); + + childObject->setParent(0); + + QCOMPARE(waitForEvent.mHandledEventsCount, 1); + + childObject->setParent(&parentObject); + + QCOMPARE(waitForEvent.mHandledEventsCount, 1); +} + +void WaitForEventTest::testEventSentAfterWaitForDestruction() { + QObject parentObject; + + WaitForEvent* waitForEvent = new WaitForEvent(&parentObject, + QEvent::ChildAdded); + waitForEvent->setActive(true); + + QObject* childObject = new QObject(); + childObject->setParent(&parentObject); + + delete waitForEvent; + + QObject* anotherChildObject = new QObject(); + anotherChildObject->setParent(&parentObject); + + //Nothing is checked explicitly. Implicitly, it is checked if deleting the + //event filter object and then sending another event crashes the application +} + +QTEST_MAIN(WaitForEventTest) + +#include "WaitForEventTest.moc" Property changes on: trunk/ktutorial/ktutorial-library/test/WaitForEventTest.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-library/test/scripting/ScriptingModuleTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/test/scripting/ScriptingModuleTest.cpp 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-library/test/scripting/ScriptingModuleTest.cpp 2010-02-25 06:02:45 UTC (rev 107) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -30,6 +30,7 @@ #include "../Option.h" #include "../WaitFor.h" #include "../WaitForAnd.h" +#include "../WaitForEvent.h" #include "../WaitForNot.h" #include "../WaitForOr.h" #include "../WaitForSignal.h" @@ -155,6 +156,10 @@ QMetaObject& type = metaObject(scriptingModule, "WaitForAnd"); QCOMPARE(type.className(), WaitForAnd::staticMetaObject.className()); + QVERIFY(containsMetaObject(scriptingModule, "WaitForEvent")); + type = metaObject(scriptingModule, "WaitForEvent"); + QCOMPARE(type.className(), WaitForEvent::staticMetaObject.className()); + QVERIFY(containsMetaObject(scriptingModule, "WaitForNot")); type = metaObject(scriptingModule, "WaitForNot"); QCOMPARE(type.className(), WaitForNot::staticMetaObject.className()); Modified: trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-library/test/scripting/ScriptingTest.cpp 2010-02-25 06:02:45 UTC (rev 107) @@ -303,6 +303,8 @@ out << "tutorial.addStep(firstStep);\n"; out << "secondStep = ktutorial.newStep(\"second\");\n"; out << "tutorial.addStep(secondStep);\n"; + out << "thirdStep = ktutorial.newStep(\"third\");\n"; + out << "tutorial.addStep(thirdStep);\n"; out << "endStep = ktutorial.newStep(\"end\");\n"; out << "endStep.setText(\"The tutorial has ended.\");\n"; out << "tutorial.addStep(endStep);\n"; @@ -330,13 +332,22 @@ out << "waitForAnd.add(waitForAnotherDummy);\n"; out << "waitForAnd.add(waitForOr);\n"; - out << "function checkEnded() {\n"; + out << "function checkThird() {\n"; out << " if (testObject.booleanValue()) {\n"; - out << " tutorial.nextStep(\"end\");\n"; + out << " tutorial.nextStep(\"third\");\n"; out << " }\n"; out << "};\n"; - out << "secondStep.addWaitFor(waitForAnd, self, \"checkEnded\");\n"; + out << "secondStep.addWaitFor(waitForAnd, self, \"checkThird\");\n"; + out << "waitForChildAddedEvent = ktutorial.newWaitFor(\"WaitForEvent\");\n"; + out << "waitForChildAddedEvent.setEvent(testObject, \"ChildAdded\");\n"; + + out << "function thirdDone() {\n"; + out << " tutorial.nextStep(\"end\");\n"; + out << "};\n"; + out << "thirdStep.addWaitFor(waitForChildAddedEvent, \ +self, \"thirdDone\");\n"; + out.flush(); ScriptedTutorial scriptedTutorial(mTemporaryFile->fileName()); @@ -376,6 +387,11 @@ emit anotherDummySignal(); + QCOMPARE(scriptedTutorial.mCurrentStep->id(), QString("third")); + + QObject* childObject = new QObject(); + childObject->setParent(this); + QCOMPARE(scriptedTutorial.mCurrentStep->id(), QString("end")); QCOMPARE(scriptedTutorial.mCurrentStep->text(), QString("The tutorial has ended.")); Modified: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp 2010-02-25 06:02:45 UTC (rev 107) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -29,9 +29,28 @@ #include <ktutorial/Step.h> #include <ktutorial/TutorialInformation.h> #include <ktutorial/WaitForAnd.h> +#include <ktutorial/WaitForEvent.h> #include <ktutorial/WaitForNot.h> #include <ktutorial/WaitForSignal.h> +class WaitForLeftMouseButtonPressed: public WaitForEvent { +public: + + WaitForLeftMouseButtonPressed(QObject* object): + WaitForEvent(object, QEvent::MouseButtonPress) { + } + +protected: + + virtual void handleEvent(QEvent* event) { + QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); + if (mouseEvent->button() == Qt::LeftButton) { + WaitForEvent::handleEvent(event); + } + } + +}; + //public: TutorialMoveText::TutorialMoveText(): Tutorial(0) { @@ -40,7 +59,6 @@ mTutorialInformation->setDescription(i18n("This tutorial shows how to move text in the text area")); mTextArea = KTutorial::self()->findObject<KTextEdit*>("textArea"); - mTextArea->viewport()->installEventFilter(this); mSecondPath = false; @@ -104,7 +122,7 @@ Step* mousePressStep = new Step("mousePress"); mousePressStep->setText(i18nc("@info", "Press with the left button of the mouse on the selected text. You must press on it, or the selection will change, and you will have to select it again. Don't release the button yet.")); - mousePressStep->addWaitFor(new WaitForSignal(this, SIGNAL(mousePressed())), + mousePressStep->addWaitFor(new WaitForLeftMouseButtonPressed(mTextArea->viewport()), this, SLOT(mousePress())); addStep(mousePressStep); @@ -113,7 +131,7 @@ Step* mouseReleaseStep = new Step("mouseRelease"); mouseReleaseStep->setText(i18nc("@info", "Without releasing the mouse button, move the cursor to the desired position, for example the beginning of the text.<nl/>Once the cursor is there, you can release the mouse button, and the text will be moved.")); - mouseReleaseStep->addWaitFor(new WaitForSignal(this, SIGNAL(mouseReleased())), + mouseReleaseStep->addWaitFor(new WaitForEvent(mTextArea->viewport(), QEvent::Drop), this, SLOT(mouseRelease())); addStep(mouseReleaseStep); @@ -134,20 +152,6 @@ addStep(endStep); } -bool TutorialMoveText::eventFilter(QObject* object, QEvent* event) { - if (event->type() == QEvent::MouseButtonPress) { - QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); - if (mouseEvent->button() == Qt::LeftButton) { - emit mousePressed(); - } - } else if (event->type() == QEvent::Drop) { - QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event); - emit mouseReleased(); - } - - return false; -} - //public slots: void TutorialMoveText::startKeyboardMove() { Modified: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h =================================================================== --- trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h 2010-02-25 05:40:00 UTC (rev 106) +++ trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h 2010-02-25 06:02:45 UTC (rev 107) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -29,8 +29,6 @@ TutorialMoveText(); - bool eventFilter(QObject* object, QEvent* event); - public slots: void startKeyboardMove(); @@ -55,12 +53,6 @@ void end(); -signals: - - void mousePressed(); - - void mouseReleased(); - protected: void setup(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-03-05 23:32:10
|
Revision: 109 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=109&view=rev Author: danxuliu Date: 2010-03-05 23:32:03 +0000 (Fri, 05 Mar 2010) Log Message: ----------- Initial import for KTutorial editor, with a basic directory layout and a dummy main window. Modified Paths: -------------- trunk/ktutorial/CMakeLists.txt Added Paths: ----------- trunk/ktutorial/ktutorial-editor/ trunk/ktutorial/ktutorial-editor/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/ trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc trunk/ktutorial/ktutorial-editor/src/main.cpp Modified: trunk/ktutorial/CMakeLists.txt =================================================================== --- trunk/ktutorial/CMakeLists.txt 2010-02-26 18:55:44 UTC (rev 108) +++ trunk/ktutorial/CMakeLists.txt 2010-03-05 23:32:03 UTC (rev 109) @@ -4,5 +4,6 @@ enable_testing() +macro_optional_add_subdirectory(ktutorial-editor) macro_optional_add_subdirectory(ktutorial-library) macro_optional_add_subdirectory(ktutorial-test-app) Added: trunk/ktutorial/ktutorial-editor/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/CMakeLists.txt (rev 0) +++ trunk/ktutorial/ktutorial-editor/CMakeLists.txt 2010-03-05 23:32:03 UTC (rev 109) @@ -0,0 +1,7 @@ +project(ktutorial-editor) + +find_package(KDE4 REQUIRED) + +include(KDE4Defaults) + +add_subdirectory(src) Property changes on: trunk/ktutorial/ktutorial-editor/CMakeLists.txt ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt 2010-03-05 23:32:03 UTC (rev 109) @@ -0,0 +1,24 @@ +# In x86_64, linking fails when a static library is added to a shared library. +# In order to work, they must be compiled using -fPIC +add_definitions("-fPIC") + +include_directories(${KDE4_INCLUDES}) + +set(ktutorial_editor_SRCS + KTutorialEditor.cpp +) + +# Instead of compiling the executable directly from the sources, the sources are +# compiled to a static library that is linked (and, being static, also embedded) +# in the editor executable. +# As everything but a tiny initialization code is in a library, the build system +# for the tests can be easily set up. +kde4_add_library(ktutorial_editor ${ktutorial_editor_SRCS}) + +kde4_add_executable(ktutorial-editor main.cpp) +target_link_libraries(ktutorial-editor ktutorial_editor ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) + +####### Install the editor ####### + +install(TARGETS ktutorial-editor DESTINATION ${BIN_INSTALL_DIR}) +install(FILES ktutorial-editorui.rc DESTINATION ${DATA_INSTALL_DIR}/ktutorial-editor) Property changes on: trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2010-03-05 23:32:03 UTC (rev 109) @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include "KTutorialEditor.h" + +#include <QTreeView> + +#include <KAction> +#include <KActionCollection> +#include <KApplication> + +//public: + +KTutorialEditor::KTutorialEditor(): KXmlGuiWindow(0) { + QTreeView* treeView = new QTreeView(); + treeView->setObjectName("centralTreeView"); + treeView->setHeaderHidden(true); + + setCentralWidget(treeView); + + setupActions(); + + //Don't use a status bar (which is setupGUI default behavior) + setupGUI(ToolBar | Keys | Save | Create); +} + +//private: + +void KTutorialEditor::setupActions() { + KStandardAction::quit(kapp, SLOT(quit()), actionCollection()); +} Property changes on: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2010-03-05 23:32:03 UTC (rev 109) @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#ifndef KTUTORIALEDITOR_H +#define KTUTORIALEDITOR_H + +#include <KXmlGuiWindow> + +/** + * KTutorial editor main window. + * It wires up all the components in the application. + */ +class KTutorialEditor: public KXmlGuiWindow { +Q_OBJECT +public: + + /** + * Creates a new KTutorialEditor. + */ + KTutorialEditor(); + +private: + + /** + * Sets up all the actions used in the application. + */ + void setupActions(); + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc =================================================================== --- trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc 2010-03-05 23:32:03 UTC (rev 109) @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<gui name="ktutorial-editor" version="1"> +</gui> Property changes on: trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc ___________________________________________________________________ Added: svn:executable + * Added: trunk/ktutorial/ktutorial-editor/src/main.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/main.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/main.cpp 2010-03-05 23:32:03 UTC (rev 109) @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2010 by Daniel Calviño Sánchez * + * dan...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; If not, see <http://www.gnu.org/licenses/>. * + ***************************************************************************/ + +#include <KApplication> +#include <KAboutData> +#include <KCmdLineArgs> + +#include "KTutorialEditor.h" + +int main (int argc, char *argv[]) { + KAboutData aboutData("ktutorial-editor", 0, + ki18nc("@title", "KTutorial"), + "0.1", + ki18nc("@info", "An editor to create tutorials for " + "<application>KTutorial</application>."), + KAboutData::License_GPL_V3, + ki18nc("@info:credit", "Copyright (c) 2010 Daniel Calviño Sánchez")); + aboutData.addAuthor(ki18nc("@info:credit", "Daniel Calviño Sánchez"), + ki18nc("@info:credit", "Main developer"), + "dan...@gm..."); + KCmdLineArgs::init(argc, argv, &aboutData); + + KApplication app; + + KTutorialEditor* window = new KTutorialEditor(); + window->show(); + + return app.exec(); +} Property changes on: trunk/ktutorial/ktutorial-editor/src/main.cpp ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-03-09 21:12:59
|
Revision: 140 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=140&view=rev Author: danxuliu Date: 2010-03-09 21:12:53 +0000 (Tue, 09 Mar 2010) Log Message: ----------- Change the list of classes to test in CMakeLists.txt from horizontal to vertical. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt trunk/ktutorial/ktutorial-library/test/CMakeLists.txt trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt Modified: trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt 2010-03-09 20:38:48 UTC (rev 139) +++ trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt 2010-03-09 21:12:53 UTC (rev 140) @@ -14,7 +14,10 @@ ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) -unit_tests(Step Tutorial) +unit_tests( + Step + Tutorial +) MACRO(MEM_TESTS) FOREACH(_testname ${ARGN}) @@ -22,4 +25,7 @@ ENDFOREACH(_testname) ENDMACRO(MEM_TESTS) -mem_tests(Step Tutorial) +mem_tests( + Step + Tutorial +) Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-09 20:38:48 UTC (rev 139) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2010-03-09 21:12:53 UTC (rev 140) @@ -16,7 +16,21 @@ ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) -unit_tests(EditionDialog LicenseWidget StepCustomCodeWidget StepDataWidget StepTreeItem TextTreeItem TreeItem TreeItemUtil TreeModel TutorialCustomCodeWidget TutorialInformationWidget TutorialTreeItem TutorialTreeSelectionManager) +unit_tests( + EditionDialog + LicenseWidget + StepCustomCodeWidget + StepDataWidget + StepTreeItem + TextTreeItem + TreeItem + TreeItemUtil + TreeModel + TutorialCustomCodeWidget + TutorialInformationWidget + TutorialTreeItem + TutorialTreeSelectionManager +) MACRO(MEM_TESTS) FOREACH(_testname ${ARGN}) @@ -24,4 +38,18 @@ ENDFOREACH(_testname) ENDMACRO(MEM_TESTS) -mem_tests(EditionDialog LicenseWidget StepCustomCodeWidget StepDataWidget StepTreeItem TextTreeItem TreeItem TreeItemUtil TreeModel TutorialCustomCodeWidget TutorialInformationWidget TutorialTreeItem TutorialTreeSelectionManager) +mem_tests( + EditionDialog + LicenseWidget + StepCustomCodeWidget + StepDataWidget + StepTreeItem + TextTreeItem + TreeItem + TreeItemUtil + TreeModel + TutorialCustomCodeWidget + TutorialInformationWidget + TutorialTreeItem + TutorialTreeSelectionManager +) Modified: trunk/ktutorial/ktutorial-library/test/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/test/CMakeLists.txt 2010-03-09 20:38:48 UTC (rev 139) +++ trunk/ktutorial/ktutorial-library/test/CMakeLists.txt 2010-03-09 21:12:53 UTC (rev 140) @@ -14,7 +14,20 @@ ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) -unit_tests(Option Step Tutorial TutorialInformation TutorialManager WaitFor WaitForAnd WaitForComposed WaitForEvent WaitForNot WaitForOr WaitForSignal) +unit_tests( + Option + Step + Tutorial + TutorialInformation + TutorialManager + WaitFor + WaitForAnd + WaitForComposed + WaitForEvent + WaitForNot + WaitForOr + WaitForSignal +) MACRO(MEM_TESTS) FOREACH(_testname ${ARGN}) @@ -22,4 +35,17 @@ ENDFOREACH(_testname) ENDMACRO(MEM_TESTS) -mem_tests(Option Step Tutorial TutorialInformation TutorialManager WaitFor WaitForAnd WaitForComposed WaitForEvent WaitForNot WaitForOr WaitForSignal) +mem_tests( + Option + Step + Tutorial + TutorialInformation + TutorialManager + WaitFor + WaitForAnd + WaitForComposed + WaitForEvent + WaitForNot + WaitForOr + WaitForSignal +) Modified: trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt 2010-03-09 20:38:48 UTC (rev 139) +++ trunk/ktutorial/ktutorial-library/test/scripting/CMakeLists.txt 2010-03-09 21:12:53 UTC (rev 140) @@ -11,7 +11,13 @@ ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) -unit_tests(ScriptedStep ScriptedTutorial Scripting ScriptingModule ScriptManager) +unit_tests( + ScriptedStep + ScriptedTutorial + Scripting + ScriptingModule + ScriptManager +) MACRO(MEM_TESTS) FOREACH(_testname ${ARGN}) @@ -19,4 +25,10 @@ ENDFOREACH(_testname) ENDMACRO(MEM_TESTS) -mem_tests(ScriptedStep ScriptedTutorial Scripting ScriptingModule ScriptManager) +mem_tests( + ScriptedStep + ScriptedTutorial + Scripting + ScriptingModule + ScriptManager +) Modified: trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt 2010-03-09 20:38:48 UTC (rev 139) +++ trunk/ktutorial/ktutorial-library/test/view/CMakeLists.txt 2010-03-09 21:12:53 UTC (rev 140) @@ -16,7 +16,11 @@ ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) -unit_tests(StepWidget TutorialListModel TutorialManagerDialog) +unit_tests( + StepWidget + TutorialListModel + TutorialManagerDialog +) MACRO(MEM_TESTS) FOREACH(_testname ${ARGN}) @@ -24,4 +28,8 @@ ENDFOREACH(_testname) ENDMACRO(MEM_TESTS) -mem_tests(StepWidget TutorialListModel TutorialManagerDialog) +mem_tests( + StepWidget + TutorialListModel + TutorialManagerDialog +) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-03-23 08:03:06
|
Revision: 185 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=185&view=rev Author: danxuliu Date: 2010-03-23 08:02:59 +0000 (Tue, 23 Mar 2010) Log Message: ----------- Remove svn:executable property from text files (I don't know how, when or why I added it...) Property Changed: ---------------- trunk/ktutorial/ktutorial-editor/CMakeLists.txt trunk/ktutorial/ktutorial-editor/po/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc trunk/ktutorial/ktutorial-editor/src/main.cpp trunk/ktutorial/ktutorial-editor/src/serialization/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/view/EditionDialog.cpp trunk/ktutorial/ktutorial-editor/src/view/EditionDialog.h trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/serialization/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt trunk/ktutorial/ktutorial-library/CMakeLists.txt trunk/ktutorial/ktutorial-library/po/CMakeLists.txt trunk/ktutorial/ktutorial-library/po/es.po trunk/ktutorial/ktutorial-library/po/ktutorial.pot trunk/ktutorial/ktutorial-library/src/CMakeLists.txt trunk/ktutorial/ktutorial-library/src/KTutorial.cpp trunk/ktutorial/ktutorial-library/src/KTutorial.h trunk/ktutorial/ktutorial-library/src/Option.cpp trunk/ktutorial/ktutorial-library/src/Option.h trunk/ktutorial/ktutorial-library/src/Step.cpp trunk/ktutorial/ktutorial-library/src/Step.h trunk/ktutorial/ktutorial-library/src/Tutorial.cpp trunk/ktutorial/ktutorial-library/src/Tutorial.h trunk/ktutorial/ktutorial-library/src/TutorialInformation.cpp trunk/ktutorial/ktutorial-library/src/TutorialInformation.h trunk/ktutorial/ktutorial-library/src/TutorialManager.cpp trunk/ktutorial/ktutorial-library/src/TutorialManager.h trunk/ktutorial/ktutorial-library/src/WaitFor.cpp trunk/ktutorial/ktutorial-library/src/WaitFor.h trunk/ktutorial/ktutorial-library/src/WaitForAnd.cpp trunk/ktutorial/ktutorial-library/src/WaitForAnd.h trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp trunk/ktutorial/ktutorial-library/src/WaitForComposed.h trunk/ktutorial/ktutorial-library/src/WaitForNot.cpp trunk/ktutorial/ktutorial-library/src/WaitForNot.h trunk/ktutorial/ktutorial-library/src/WaitForOr.cpp trunk/ktutorial/ktutorial-library/src/WaitForOr.h trunk/ktutorial/ktutorial-library/src/WaitForSignal.cpp trunk/ktutorial/ktutorial-library/src/WaitForSignal.h trunk/ktutorial/ktutorial-library/src/ktutorial_export.h trunk/ktutorial/ktutorial-library/src/ktutorialui.rc trunk/ktutorial/ktutorial-library/src/scripting/CMakeLists.txt trunk/ktutorial/ktutorial-library/src/tutorials/CMakeLists.txt trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.h trunk/ktutorial/ktutorial-library/src/view/CMakeLists.txt trunk/ktutorial/ktutorial-library/src/view/StepWidget.cpp trunk/ktutorial/ktutorial-library/src/view/StepWidget.h trunk/ktutorial/ktutorial-library/src/view/StepWidget.ui trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.cpp trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.h trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.cpp trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.h trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.ui trunk/ktutorial/ktutorial-library/tests/CMakeLists.txt trunk/ktutorial/ktutorial-library/tests/scripting/CMakeLists.txt trunk/ktutorial/ktutorial-library/tests/view/CMakeLists.txt trunk/ktutorial/ktutorial-test-app/CMakeLists.txt trunk/ktutorial/ktutorial-test-app/TestApp.cpp trunk/ktutorial/ktutorial-test-app/TestApp.h trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp trunk/ktutorial/ktutorial-test-app/TutorialClearText.h trunk/ktutorial/ktutorial-test-app/TutorialClearText.js trunk/ktutorial/ktutorial-test-app/TutorialClearText.py trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h trunk/ktutorial/ktutorial-test-app/TutorialMoveText.py trunk/ktutorial/ktutorial-test-app/ktutorial-test-appui.rc trunk/ktutorial/ktutorial-test-app/main.cpp trunk/ktutorial/ktutorial-test-app/po/CMakeLists.txt trunk/ktutorial/ktutorial-test-app/po/es.po trunk/ktutorial/ktutorial-test-app/po/ktutorial-test-app.pot Property changes on: trunk/ktutorial/ktutorial-editor/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/po/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/main.cpp ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/serialization/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/view/EditionDialog.cpp ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/src/view/EditionDialog.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/serialization/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-library/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/po/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/po/es.po ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/po/ktutorial.pot ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/KTutorial.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/KTutorial.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/Option.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/Option.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/Step.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/Step.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/Tutorial.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/Tutorial.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/TutorialInformation.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/TutorialInformation.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/TutorialManager.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/TutorialManager.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitFor.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitFor.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForAnd.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForAnd.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForComposed.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForNot.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForNot.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForOr.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForOr.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForSignal.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/WaitForSignal.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/ktutorial_export.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/ktutorialui.rc ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/scripting/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-library/src/tutorials/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.h ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-library/src/view/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/StepWidget.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/StepWidget.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/StepWidget.ui ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.ui ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-library/tests/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-library/tests/scripting/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-library/tests/view/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-test-app/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/TestApp.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/TestApp.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/TutorialClearText.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/TutorialClearText.js ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-test-app/TutorialClearText.py ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/TutorialMoveText.py ___________________________________________________________________ Deleted: svn:executable - * Property changes on: trunk/ktutorial/ktutorial-test-app/ktutorial-test-appui.rc ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/main.cpp ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/po/CMakeLists.txt ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/po/es.po ___________________________________________________________________ Deleted: svn:executable - Property changes on: trunk/ktutorial/ktutorial-test-app/po/ktutorial-test-app.pot ___________________________________________________________________ Deleted: svn:executable - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-04-26 07:08:12
|
Revision: 237 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=237&view=rev Author: danxuliu Date: 2010-04-26 05:30:40 +0000 (Mon, 26 Apr 2010) Log Message: ----------- Increase required Qt version, as QEvent::staticMetaObject and QScopedPointer were introduced in Qt 4.6. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/CMakeLists.txt trunk/ktutorial/ktutorial-library/CMakeLists.txt Modified: trunk/ktutorial/ktutorial-editor/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/CMakeLists.txt 2010-04-26 05:24:17 UTC (rev 236) +++ trunk/ktutorial/ktutorial-editor/CMakeLists.txt 2010-04-26 05:30:40 UTC (rev 237) @@ -1,5 +1,6 @@ project(ktutorial-editor) +set(QT_MIN_VERSION "4.6") find_package(KDE4 REQUIRED) include(KDE4Defaults) Modified: trunk/ktutorial/ktutorial-library/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/CMakeLists.txt 2010-04-26 05:24:17 UTC (rev 236) +++ trunk/ktutorial/ktutorial-library/CMakeLists.txt 2010-04-26 05:30:40 UTC (rev 237) @@ -1,6 +1,6 @@ project(ktutorial-library) -set(QT_MIN_VERSION "4.5.3") +set(QT_MIN_VERSION "4.6") find_package(KDE4 REQUIRED) enable_testing() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-10-03 19:14:36
|
Revision: 272 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=272&view=rev Author: danxuliu Date: 2010-10-03 19:14:30 +0000 (Sun, 03 Oct 2010) Log Message: ----------- Fix Krazy2 spelling issues. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/serialization/IOException.h trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.h trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.h Modified: trunk/ktutorial/ktutorial-editor/src/serialization/IOException.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/IOException.h 2010-10-03 16:33:21 UTC (rev 271) +++ trunk/ktutorial/ktutorial-editor/src/serialization/IOException.h 2010-10-03 19:14:30 UTC (rev 272) @@ -22,7 +22,7 @@ #include "../util/Exception.h" /** - * Thrown when an input/ouput operation fails (for example, writing to an + * Thrown when an input/output operation fails (for example, writing to an * unwritable file, or reading from a file that does not exist). */ class IOException: public Exception { Modified: trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.h 2010-10-03 16:33:21 UTC (rev 271) +++ trunk/ktutorial/ktutorial-editor/src/serialization/Serialization.h 2010-10-03 19:14:30 UTC (rev 272) @@ -44,7 +44,7 @@ * file in a remote computer). It will be also used to automatically cache * and discard that information. * - * @param window The window associated with the input/ouput jobs, if any. + * @param window The window associated with the input/output jobs, if any. */ explicit Serialization(QWidget* window = 0); Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2010-10-03 16:33:21 UTC (rev 271) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2010-10-03 19:14:30 UTC (rev 272) @@ -94,7 +94,7 @@ throw (DBusException) { Q_ASSERT(remoteObject); - //The remote object is no longer accesible, so name() can't be called + //The remote object is no longer accessible, so name() can't be called QString name = mRemoteObjectForName.key(remoteObject); KCompletion* completion = ui->objectNameLineEdit->completionObject(); Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui 2010-10-03 16:33:21 UTC (rev 271) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.ui 2010-10-03 19:14:30 UTC (rev 272) @@ -15,7 +15,7 @@ </property> <property name="whatsThis"> <string comment="@info:whatsthis"><para>Choose the name of the remote object.</para> -<para>If the name is known, it can be directly written. Else, it can be choosen from all the objects currently available in the target application.</para></string> +<para>If the name is known, it can be directly written. Else, it can be chosen from all the objects currently available in the target application.</para></string> </property> <layout class="QHBoxLayout" name="RemoteObjectNameWidgetHorizontalLayout"> <property name="margin"> Modified: trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.h 2010-10-03 16:33:21 UTC (rev 271) +++ trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.h 2010-10-03 19:14:30 UTC (rev 272) @@ -28,7 +28,7 @@ /** * A ListModel that fetchs its data from a TutorialManager. - * This is a very basic read-only model. It just shows the tutorial informations + * This is a very basic read-only model. It just shows the TutorialInformations * registered in a TutorialManager as a list where each element is the name of * a TutorialInformation. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-10-29 23:05:23
|
Revision: 283 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=283&view=rev Author: danxuliu Date: 2010-10-29 23:05:17 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Make QueuedActionsHelper objects child of the test objects instead of deleting them using QTimer::singleShot(..., SLOT(deleteLater())). Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForWindowTest.cpp trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp 2010-10-29 21:47:59 UTC (rev 282) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp 2010-10-29 23:05:17 UTC (rev 283) @@ -450,11 +450,14 @@ Q_OBJECT public: - QueuedActionsHelper(QWidget* widget = 0): - QObject(widget), - mWidget(widget) { + QueuedActionsHelper(QObject* parent = 0): QObject(parent), + mWidget(0) { } + void setWidget(QWidget* widget) { + mWidget = widget; + } + public slots: void closeInformation() const { @@ -497,22 +500,20 @@ }; void RemoteObjectChooserTest::closeInformationMessageBox(int timeToWait) { - QueuedActionsHelper* helper = new QueuedActionsHelper(); + QueuedActionsHelper* helper = new QueuedActionsHelper(this); QTimer::singleShot(timeToWait, helper, SLOT(closeInformation())); - QTimer::singleShot(timeToWait, helper, SLOT(deleteLater())); } void RemoteObjectChooserTest::closeSorryMessageBox(QWidget* widget, int timeToWait) { - QueuedActionsHelper* helper = new QueuedActionsHelper(widget); + QueuedActionsHelper* helper = new QueuedActionsHelper(this); + helper->setWidget(widget); QTimer::singleShot(timeToWait, helper, SLOT(closeSorry())); - QTimer::singleShot(timeToWait, helper, SLOT(deleteLater())); } void RemoteObjectChooserTest::killTargetApplication(int timeToWait) { - QueuedActionsHelper* helper = new QueuedActionsHelper(); + QueuedActionsHelper* helper = new QueuedActionsHelper(this); QTimer::singleShot(timeToWait, helper, SLOT(killTargetApplication())); - QTimer::singleShot(timeToWait, helper, SLOT(deleteLater())); } QTreeView* RemoteObjectChooserTest::remoteObjectsTreeView( Modified: trunk/ktutorial/ktutorial-library/tests/WaitForWindowTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/WaitForWindowTest.cpp 2010-10-29 21:47:59 UTC (rev 282) +++ trunk/ktutorial/ktutorial-library/tests/WaitForWindowTest.cpp 2010-10-29 23:05:17 UTC (rev 283) @@ -218,7 +218,7 @@ Q_OBJECT public: - QueuedActionsHelper(QObject* object = 0): QObject(object) { + QueuedActionsHelper(QObject* parent = 0): QObject(parent) { } void setWaitForWindow(WaitForWindow* waitForWindow) { @@ -246,11 +246,10 @@ void WaitForWindowTest::queueAssertConditionMet(WaitForWindow* waitForWindow, QSignalSpy* waitEndedSpy, int timeToWait) { - QueuedActionsHelper* helper = new QueuedActionsHelper(); + QueuedActionsHelper* helper = new QueuedActionsHelper(this); helper->setWaitForWindow(waitForWindow); helper->setWaitEndedSpy(waitEndedSpy); QTimer::singleShot(timeToWait, helper, SLOT(assertConditionMet())); - QTimer::singleShot(timeToWait, helper, SLOT(deleteLater())); } QTEST_MAIN(WaitForWindowTest) Modified: trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp 2010-10-29 21:47:59 UTC (rev 282) +++ trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp 2010-10-29 23:05:17 UTC (rev 283) @@ -362,7 +362,7 @@ Q_OBJECT public: - QueuedActionsHelper(QObject* object = 0): QObject(object) { + QueuedActionsHelper(QObject* parent = 0): QObject(parent) { } void setStepWidget(StepWidget* stepWidget) { @@ -407,10 +407,9 @@ void StepWidgetTest::queueAssertWidgetDragged(StepWidget* stepWidget, int timeToWait) { - QueuedActionsHelper* helper = new QueuedActionsHelper(); + QueuedActionsHelper* helper = new QueuedActionsHelper(this); helper->setStepWidget(stepWidget); QTimer::singleShot(timeToWait, helper, SLOT(assertWidgetDragged())); - QTimer::singleShot(timeToWait + 1000, helper, SLOT(deleteLater())); } } Modified: trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp 2010-10-29 21:47:59 UTC (rev 282) +++ trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp 2010-10-29 23:05:17 UTC (rev 283) @@ -780,7 +780,7 @@ Q_OBJECT public: - QueuedActionsHelper(QObject* object = 0): QObject(object) { + QueuedActionsHelper(QObject* parent = 0): QObject(parent) { } void setAssertWidget(QWidget* widget) { @@ -812,19 +812,17 @@ void WindowOnTopEnforcerTest::queueAssertParent(QWidget* widget, QWidget* parent, int timeToWait) { - QueuedActionsHelper* helper = new QueuedActionsHelper(); + QueuedActionsHelper* helper = new QueuedActionsHelper(this); helper->setAssertWidget(widget); helper->setAssertParent(parent); QTimer::singleShot(timeToWait, helper, SLOT(assertParent())); - QTimer::singleShot(timeToWait, helper, SLOT(deleteLater())); } void WindowOnTopEnforcerTest::queueAssertIsVisibleWindow(QWidget* widget, int timeToWait) { - QueuedActionsHelper* helper = new QueuedActionsHelper(); + QueuedActionsHelper* helper = new QueuedActionsHelper(this); helper->setAssertWidget(widget); QTimer::singleShot(timeToWait, helper, SLOT(assertIsVisibleWindow())); - QTimer::singleShot(timeToWait, helper, SLOT(deleteLater())); } void WindowOnTopEnforcerTest::assertWindow(QWidget* window, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-07-11 05:25:54
|
Revision: 335 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=335&view=rev Author: danxuliu Date: 2011-07-11 05:25:48 +0000 (Mon, 11 Jul 2011) Log Message: ----------- Fix "unused variable" compilation warnings. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighter.cpp Modified: trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp 2011-07-07 10:31:17 UTC (rev 334) +++ trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp 2011-07-11 05:25:48 UTC (rev 335) @@ -236,6 +236,8 @@ } void TutorialWriter::write(const WaitForStepActivation* waitForStepActivation) { + Q_UNUSED(waitForStepActivation); + mXmlWriter->writeEmptyElement("waitForStepActivation"); } Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp 2011-07-07 10:31:17 UTC (rev 334) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp 2011-07-11 05:25:48 UTC (rev 335) @@ -172,6 +172,8 @@ void WaitForWidget::handleSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { + Q_UNUSED(deselected); + //Only single selections are supported Q_ASSERT(selected.count() <= 1); Q_ASSERT(deselected.count() <= 1); Modified: trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp 2011-07-07 10:31:17 UTC (rev 334) +++ trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp 2011-07-11 05:25:48 UTC (rev 335) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -44,6 +44,8 @@ //public slots: void WaitForComposed::childWaitEnd(WaitFor* waitFor) { + Q_UNUSED(waitFor); + Q_ASSERT(mWaitFors.contains(waitFor)); if (!isActive()) { Modified: trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp 2011-07-07 10:31:17 UTC (rev 334) +++ trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp 2011-07-11 05:25:48 UTC (rev 335) @@ -60,6 +60,8 @@ //private slots: void WaitForStepActivation::checkStepActivatedToEndTheWait(Step* step) { + Q_UNUSED(step); + if (!isActive()) { return; } Modified: trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighter.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighter.cpp 2011-07-07 10:31:17 UTC (rev 334) +++ trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighter.cpp 2011-07-11 05:25:48 UTC (rev 335) @@ -87,6 +87,8 @@ //protected: void WidgetHighlighter::paintEvent(QPaintEvent* event) { + Q_UNUSED(event); + //Painting the WidgetHighlighter over its parent widget with a //semi-transparent color is the best I could get. However, it has some //flaws. For example, a QMenu does not highlight its menu button. And some This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-07-11 13:12:33
|
Revision: 336 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=336&view=rev Author: danxuliu Date: 2011-07-11 13:12:27 +0000 (Mon, 11 Jul 2011) Log Message: ----------- Fix doxygen documentation. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h trunk/ktutorial/ktutorial-editor/src/view/TreeModel.h trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h trunk/ktutorial/ktutorial-library/src/KTutorial.h trunk/ktutorial/ktutorial-library/src/Step.h trunk/ktutorial/ktutorial-library/src/WaitForEvent.h trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.h Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h 2011-07-11 13:12:27 UTC (rev 336) @@ -113,7 +113,7 @@ * an empty string. If the path is absolute but contains "." and ".." * components they are resolved and the clean path is set. * - * @param applicationFilePath The target application file path. + * @param targetApplicationFilePath The target application file path. */ void setTargetApplicationFilePath(const QString& targetApplicationFilePath); Modified: trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.h 2011-07-11 13:12:27 UTC (rev 336) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -35,7 +35,7 @@ /** * Creates a new TargetApplicationView for the given TargetApplication. * - * @param step The step to edit. + * @param targetApplication The target application to wrap. * @param parent The parent QWidget for the dialogs and message boxes. */ explicit TargetApplicationView(TargetApplication* targetApplication, Modified: trunk/ktutorial/ktutorial-editor/src/view/TreeModel.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/TreeModel.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-editor/src/view/TreeModel.h 2011-07-11 13:12:27 UTC (rev 336) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -80,6 +80,7 @@ * If the index is valid, the flags enable the item and allow it to be * selected. * + * @param index The index. * @return The flags for the given index. */ virtual Qt::ItemFlags flags(const QModelIndex& index) const; Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h 2011-07-11 13:12:27 UTC (rev 336) @@ -53,6 +53,7 @@ /** * Creates a new WaitForWidget. * + * @param waitFor The initial WaitFor. * @param parent The parent QWidget. */ explicit WaitForWidget(WaitFor* waitFor, QWidget* parent = 0); Modified: trunk/ktutorial/ktutorial-library/src/KTutorial.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/KTutorial.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-library/src/KTutorial.h 2011-07-11 13:12:27 UTC (rev 336) @@ -74,7 +74,7 @@ * Any WaitFor class has to be registered before calling * setup(KXmlGuiWindow*). * - * @param scriptedWaitFor The QMetaObject to create instances of. + * @param waitForMetaObject The QMetaObject to create instances of. * @param typeName A specific name to be used for the QMetaObject. * @return True if the type was successfully registered, false otherwise. * @see ScriptingModule::registerWaitForMetaObject(const QMetaObject&) Modified: trunk/ktutorial/ktutorial-library/src/Step.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/Step.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-library/src/Step.h 2011-07-11 13:12:27 UTC (rev 336) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -241,7 +241,7 @@ * This method can be invoked from a script. * * @param option The Option to add. - * @param nextStep The id of the step to change to. + * @param nextStepId The id of the step to change to. * @see addOption(Option*, QObject*, const QString&) */ Q_INVOKABLE void addOption(Option* option, const QString& nextStepId); @@ -286,7 +286,7 @@ * This method can be invoked from a script. * * @param waitFor The condition to wait for. - * @param nextStep The id of the step to change to. + * @param nextStepId The id of the step to change to. * @see addOption(Option*, QObject*, const QString&) */ Q_INVOKABLE void addWaitFor(WaitFor* waitFor, const QString& nextStepId); Modified: trunk/ktutorial/ktutorial-library/src/WaitForEvent.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForEvent.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-library/src/WaitForEvent.h 2011-07-11 13:12:27 UTC (rev 336) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -66,7 +66,7 @@ * Creates a new WaitForEvent. * * @param object The object to watch. - * @param typeName The name of the event type to wait for. + * @param type The type of the event to wait for. */ WaitForEvent(QObject* object, QEvent::Type type); Modified: trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.h 2011-07-11 05:25:48 UTC (rev 335) +++ trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.h 2011-07-11 13:12:27 UTC (rev 336) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -87,7 +87,7 @@ * with that name). However, if no name is specified, the full name of the * class is used (including namespaces and :: separators). * - * @param scriptedWaitFor The QMetaObject to create instances of. + * @param waitForMetaObject The QMetaObject to create instances of. * @param typeName A specific name to be used for the QMetaObject. * @return True if the type was successfully registered, false otherwise. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-10-13 12:48:34
|
Revision: 339 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=339&view=rev Author: danxuliu Date: 2011-10-13 12:48:24 +0000 (Thu, 13 Oct 2011) Log Message: ----------- Use QTest::qWaitForWindowShown instead of waiting a fixed time. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-10-13 09:13:34 UTC (rev 338) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-10-13 12:48:24 UTC (rev 339) @@ -382,8 +382,7 @@ //Focus is not set in hidden widgets until they are shown parent.show(); - //Give the parent widget time to be shown - QTest::qWait(500); + QTest::qWaitForWindowShown(&parent); otherLineEdit->setFocus(); @@ -409,8 +408,7 @@ //Focus is not set in hidden widgets until they are shown parent.show(); - //Give the parent widget time to be shown - QTest::qWait(500); + QTest::qWaitForWindowShown(&parent); otherLineEdit->setFocus(); Modified: trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2011-10-13 09:13:34 UTC (rev 338) +++ trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2011-10-13 12:48:24 UTC (rev 339) @@ -133,9 +133,11 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); + QTest::qWaitForWindowShown(&widget); + QPoint position = centerOfText(widget, "widget to highlight"); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, - position, 500); + position); QVERIFY(widgetToHighlight->findChild<WidgetHighlighter*>("")); } @@ -150,9 +152,11 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); + QTest::qWaitForWindowShown(&widget); + QPoint position = centerOfText(widget, "widget to highlight"); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, - position, 500); + position); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, position, 500); @@ -172,8 +176,7 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); - //Give the widget time to be shown - QTest::qWait(500); + QTest::qWaitForWindowShown(&widget); QPoint position = centerOfText(widget, "widget to highlight"); showContextMenuAndSelectFirstOption(widget, position); @@ -191,8 +194,7 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); - //Give the widget time to be shown - QTest::qWait(500); + QTest::qWaitForWindowShown(&widget); QPoint position = centerOfText(widget, "widget to highlight"); showContextMenuAndSelectFirstOption(widget, position); @@ -215,8 +217,7 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); - //Give the widget time to be shown - QTest::qWait(500); + QTest::qWaitForWindowShown(&widget); QPoint position = centerOfText(widget, "widget to highlight"); showContextMenuCheckFirstOptionAndCancel(widget, position, @@ -255,12 +256,14 @@ "<a href=\"widget:widget3\">third widget</a>"); widget.show(); + QTest::qWaitForWindowShown(&widget); + QPoint position1 = centerOfText(widget, "first widget"); QPoint position2 = centerOfText(widget, "second widget"); QPoint position3 = centerOfText(widget, "third widget"); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, - position1, 500); + position1); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, position2, 500); @@ -320,9 +323,11 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); + QTest::qWaitForWindowShown(&widget); + QPoint position = centerOfText(widget, "widget to highlight"); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, - position, 500); + position); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, position, 500); @@ -341,9 +346,11 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); + QTest::qWaitForWindowShown(&widget); + QPoint position = centerOfText(widget, "widget to highlight"); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, - position, 500); + position); //To get the focus, the parent window of the widget must be active mainWindow.activateWindow(); @@ -365,9 +372,11 @@ widget.setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget.show(); + QTest::qWaitForWindowShown(&widget); + QPoint position = centerOfText(widget, "widget to highlight"); QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, - position, 500); + position); widget.setText("Another text"); @@ -384,9 +393,11 @@ widget->setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget->show(); + QTest::qWaitForWindowShown(widget); + QPoint position = centerOfText(*widget, "widget to highlight"); QTest::mouseClick(widget->viewport(), Qt::LeftButton, Qt::NoModifier, - position, 500); + position); delete widget; @@ -403,9 +414,11 @@ widget->setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); widget->show(); + QTest::qWaitForWindowShown(widget); + QPoint position = centerOfText(*widget, "widget to highlight"); QTest::mouseClick(widget->viewport(), Qt::LeftButton, Qt::NoModifier, - position, 500); + position); delete widgetToHighlight; Modified: trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp 2011-10-13 09:13:34 UTC (rev 338) +++ trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp 2011-10-13 12:48:24 UTC (rev 339) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2010 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -215,7 +215,8 @@ StepWidget stepWidget("Test tutorial"); stepWidget.show(); - QTest::qWait(500); + QTest::qWaitForWindowShown(&stepWidget); + QPoint previousPosition = stepWidget.pos(); QPoint widgetCenter(stepWidget.size().width()/2, @@ -229,7 +230,7 @@ //isn't enabled stepWidget.setMouseTracking(true); QTest::mousePress(&stepWidget, Qt::LeftButton, - Qt::NoModifier, QPoint(), 500); + Qt::NoModifier, QPoint()); QCursor::setPos(previousPosition + widgetCenter + QPoint(42, 23)); QTest::mouseRelease(&stepWidget, Qt::LeftButton, Qt::NoModifier, QPoint(), 500); @@ -245,7 +246,8 @@ StepWidget stepWidget("Test tutorial"); stepWidget.show(); - QTest::qWait(500); + QTest::qWaitForWindowShown(&stepWidget); + QPoint previousPosition = stepWidget.pos(); QPoint widgetCenter(stepWidget.size().width()/2, @@ -259,7 +261,7 @@ //isn't enabled stepWidget.setMouseTracking(true); QTest::mousePress(&stepWidget, Qt::LeftButton, - Qt::NoModifier, QPoint(), 500); + Qt::NoModifier, QPoint()); QCursor::setPos(previousPosition + widgetCenter + QPoint(42, 23)); QTest::mouseRelease(&stepWidget, Qt::LeftButton, Qt::NoModifier, QPoint(), 500); @@ -278,8 +280,10 @@ StepWidget stepWidget("Test tutorial"); stepWidget.show(); - QTest::keyClick(&stepWidget, Qt::Key_F1, Qt::ShiftModifier, 500); + QTest::qWaitForWindowShown(&stepWidget); + QTest::keyClick(&stepWidget, Qt::Key_F1, Qt::ShiftModifier); + QVERIFY(QWhatsThis::inWhatsThisMode()); QWhatsThis::leaveWhatsThisMode(); } @@ -288,10 +292,12 @@ StepWidget* stepWidget = new StepWidget("Test tutorial"); stepWidget->show(); + QTest::qWaitForWindowShown(stepWidget); + QSignalSpy destroyedSpy(stepWidget, SIGNAL(destroyed(QObject*))); QTest::mouseClick(closeButton(stepWidget), Qt::LeftButton, - Qt::NoModifier, QPoint(), 500); + Qt::NoModifier, QPoint()); //Give it time to die QTest::qWait(500); @@ -302,12 +308,10 @@ StepWidget* stepWidget = new StepWidget("Test tutorial"); stepWidget->show(); + QTest::qWaitForWindowShown(stepWidget); + QSignalSpy destroyedSpy(stepWidget, SIGNAL(destroyed(QObject*))); - //The wait can't be made in the keyClick itself as, oddly, a crash happens - //in that case. It seems that the widget is tried to be used (I don't know - //for what) after being deleted if the wait is made in the keyClick. - QTest::qWait(500); QTest::keyClick(stepWidget, Qt::Key_Escape); //Give it time to die QTest::qWait(500); Modified: trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp 2011-10-13 09:13:34 UTC (rev 338) +++ trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp 2011-10-13 12:48:24 UTC (rev 339) @@ -173,10 +173,12 @@ mTutorialManagerDialog->show(); + QTest::qWaitForWindowShown(mTutorialManagerDialog); + tutorialList(mTutorialManagerDialog)->setFocus(); QTest::keyClick(tutorialList(mTutorialManagerDialog), Qt::Key_Space, - Qt::NoModifier, 500); + Qt::NoModifier); QItemSelectionModel* selectionModel = tutorialList(mTutorialManagerDialog)->selectionModel(); @@ -213,10 +215,12 @@ mTutorialManagerDialog->show(); + QTest::qWaitForWindowShown(mTutorialManagerDialog); + tutorialList(mTutorialManagerDialog)->setFocus(); QTest::keyClick(tutorialList(mTutorialManagerDialog), Qt::Key_Space, - Qt::NoModifier, 500); + Qt::NoModifier); QItemSelectionModel* selectionModel = tutorialList(mTutorialManagerDialog)->selectionModel(); @@ -255,13 +259,15 @@ mTutorialManagerDialog->show(); + QTest::qWaitForWindowShown(mTutorialManagerDialog); + QItemSelectionModel* selectionModel = tutorialList(mTutorialManagerDialog)->selectionModel(); selectionModel->select(selectionModel->model()->index(1, 0), QItemSelectionModel::Select); QTest::mouseClick(startButton(mTutorialManagerDialog), Qt::LeftButton, - Qt::NoModifier, QPoint(), 500); + Qt::NoModifier, QPoint()); QVERIFY(mTutorialManagerDialog->isHidden()); QVERIFY(mStartStep2->isActive()); @@ -304,7 +310,7 @@ QItemSelectionModel::Select); QTest::keyClick(tutorialList(mTutorialManagerDialog), Qt::Key_Enter, - Qt::NoModifier, 500); + Qt::NoModifier); QVERIFY(mTutorialManagerDialog->isHidden()); QVERIFY(mStartStep2->isActive()); @@ -327,9 +333,14 @@ TutorialManagerDialog tutorialManagerDialog(mTutorialManager); mTutorialManagerDialog->show(); + QTest::qWaitForWindowShown(mTutorialManagerDialog); + QTest::keyClick(tutorialList(mTutorialManagerDialog), Qt::Key_Escape, - Qt::NoModifier, 500); + Qt::NoModifier); + //Give Close button time to complete the press animation + QTest::qWait(500); + QVERIFY(mTutorialManagerDialog->isHidden()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-06-20 18:26:03
|
Revision: 342 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=342&view=rev Author: danxuliu Date: 2012-06-20 18:25:57 +0000 (Wed, 20 Jun 2012) Log Message: ----------- Fix DSO linking problems. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/util/CMakeLists.txt trunk/ktutorial/ktutorial-library/tests/CMakeLists.txt trunk/ktutorial/ktutorial-library/tests/scripting/CMakeLists.txt Modified: trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt 2011-10-16 18:07:26 UTC (rev 341) +++ trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt 2012-06-20 18:25:57 UTC (rev 342) @@ -7,7 +7,7 @@ FOREACH(_className ${ARGN}) set(_testName ${_className}Test) kde4_add_unit_test(${_testName} TESTNAME ktutorial-editor-unit-${_testName} ${_testName}.cpp) - target_link_libraries(${_testName} ktutorial_editor_data ${QT_QTTEST_LIBRARY}) + target_link_libraries(${_testName} ktutorial_editor_data ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY}) ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) Modified: trunk/ktutorial/ktutorial-editor/tests/unit/util/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/util/CMakeLists.txt 2011-10-16 18:07:26 UTC (rev 341) +++ trunk/ktutorial/ktutorial-editor/tests/unit/util/CMakeLists.txt 2012-06-20 18:25:57 UTC (rev 342) @@ -7,7 +7,7 @@ FOREACH(_className ${ARGN}) set(_testName ${_className}Test) kde4_add_unit_test(${_testName} TESTNAME ktutorial-editor-unit-${_testName} ${_testName}.cpp) - target_link_libraries(${_testName} ktutorial_editor_util ${QT_QTTEST_LIBRARY}) + target_link_libraries(${_testName} ktutorial_editor_util ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY}) ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) Modified: trunk/ktutorial/ktutorial-library/tests/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/tests/CMakeLists.txt 2011-10-16 18:07:26 UTC (rev 341) +++ trunk/ktutorial/ktutorial-library/tests/CMakeLists.txt 2012-06-20 18:25:57 UTC (rev 342) @@ -21,7 +21,7 @@ FOREACH(_className ${ARGN}) set(_testName ${_className}Test) kde4_add_unit_test(${_testName} TESTNAME ktutorial-${_testName} ${_testName}.cpp) - target_link_libraries(${_testName} ktutorial ${QT_QTTEST_LIBRARY}) + target_link_libraries(${_testName} ktutorial ${QT_QTTEST_LIBRARY} ${KDE4_KDEUI_LIBS}) ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) Modified: trunk/ktutorial/ktutorial-library/tests/scripting/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-library/tests/scripting/CMakeLists.txt 2011-10-16 18:07:26 UTC (rev 341) +++ trunk/ktutorial/ktutorial-library/tests/scripting/CMakeLists.txt 2012-06-20 18:25:57 UTC (rev 342) @@ -7,7 +7,7 @@ FOREACH(_className ${ARGN}) set(_testName ${_className}Test) kde4_add_unit_test(${_testName} TESTNAME ktutorial-${_testName} ${_testName}.cpp) - target_link_libraries(${_testName} ktutorial ktutorial_scripting ${QT_QTTEST_LIBRARY}) + target_link_libraries(${_testName} ktutorial ktutorial_scripting ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY}) ENDFOREACH(_className) ENDMACRO(UNIT_TESTS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-06-26 21:53:36
|
Revision: 343 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=343&view=rev Author: danxuliu Date: 2012-06-26 21:53:28 +0000 (Tue, 26 Jun 2012) Log Message: ----------- Get rid of several fixed time waits that could make the tests fail in slow systems. Now, instead of waiting a fixed amount of time, it is checked if some condition was met before continuing. If the condition was not met, it is checked again after a little time. The retries continue until the timeout expires. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp 2012-06-20 18:25:57 UTC (rev 342) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp 2012-06-26 21:53:28 UTC (rev 343) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -76,74 +76,9 @@ QString mTargetApplicationStubPath; -}; + bool waitForSignalCount(const QSignalSpy* spy, int count, + int timeout) const; -/** - * Modified version of private KSignalSpy found in - * kdelibs/kdecore/util/qtest_kde.cpp. - * Original KDESignalSpy, accessed through - * QTest::kWaitForSignal(QObject*, const char*, int), can miss a signal if it is - * emitted too quickly (that is, before the connect is reached). This modified - * version, instead of starting the wait in the constructor, has a specific - * method for it. So the object can be created before executing the call that - * emits the signal, enabling it to register the signal before starting to wait - * and thus ensuring that no signal will be missed. - * - * Moreover, this modified version allows to wait for up to n emitted signals - * instead of only the first one. Note that the count isn't reseted after - * receiving all the expected signals, so if you wait for more signals use an - * absolute value (that is, the already received signals plus those you want to - * wait for now). - */ -class SignalWait: public QObject { -Q_OBJECT -public: - - SignalWait(QObject* object, const char* signal): - QObject(0), - mSignalSpy(object, signal), - mExpectedCount(0) { - connect(object, signal, this, SLOT(signalEmitted())); - } - - bool waitForCount(int expectedCount, int timeout) { - if (mSignalSpy.count() < expectedCount) { - mExpectedCount = expectedCount; - - if (timeout > 0) { - QObject::connect(&mTimer, SIGNAL(timeout()), &mLoop, SLOT(quit())); - mTimer.setSingleShot(true); - mTimer.start(timeout); - } - mLoop.exec(); - } - - if (mSignalSpy.count() >= expectedCount) { - return true; - } - return false; - } - - const QSignalSpy& spy() const { - return mSignalSpy; - } - -private Q_SLOTS: - - void signalEmitted() { - if (mSignalSpy.count() >= mExpectedCount) { - mTimer.stop(); - mLoop.quit(); - } - } - -private: - - QSignalSpy mSignalSpy; - int mExpectedCount; - QEventLoop mLoop; - QTimer mTimer; - }; void TargetApplicationTest::initTestCase() { @@ -195,10 +130,10 @@ TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); - SignalWait startedWait(&targetApplication, SIGNAL(started())); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); targetApplication.start(); - QVERIFY(startedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&startedSpy, 1, 10000)); QVERIFY(targetApplication.remoteEditorSupport()); QCOMPARE(targetApplication.remoteEditorSupport()->mainWindow()->name(), QString("The object name 42")); @@ -210,10 +145,10 @@ QApplication::applicationDirPath() + "/TargetApplicationStubWithDelayedRegister"); - SignalWait startedWait(&targetApplication, SIGNAL(started())); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); targetApplication.start(); - QVERIFY(startedWait.waitForCount(1, 2000)); + QVERIFY(waitForSignalCount(&startedSpy, 1, 10000)); QVERIFY(targetApplication.remoteEditorSupport()); QCOMPARE(targetApplication.remoteEditorSupport()->mainWindow()->name(), QString("The object name 42")); @@ -223,16 +158,17 @@ TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); - SignalWait startedWait(&targetApplication, SIGNAL(started())); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); targetApplication.start(); - QVERIFY(startedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&startedSpy, 1, 10000)); RemoteEditorSupport* oldRemoteEditorSupport = targetApplication.remoteEditorSupport(); targetApplication.start(); - QVERIFY(!startedWait.waitForCount(2, 1000)); + //Give time to ensure that "started" signal is not sent again + QVERIFY(!waitForSignalCount(&startedSpy, 2, 1000)); QCOMPARE(targetApplication.remoteEditorSupport(), oldRemoteEditorSupport); QCOMPARE(targetApplication.remoteEditorSupport()->mainWindow()->name(), QString("The object name 42")); @@ -243,9 +179,9 @@ TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); - SignalWait startedWait(&targetApplication, SIGNAL(started())); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); targetApplication.start(); - QVERIFY(startedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&startedSpy, 1, 10000)); RemoteEditorSupport* oldRemoteEditorSupport = targetApplication.remoteEditorSupport(); @@ -255,7 +191,8 @@ targetApplication.start(); - QVERIFY(!startedWait.waitForCount(2, 1000)); + //Give time to ensure that "started" signal is not sent again + QVERIFY(!waitForSignalCount(&startedSpy, 2, 1000)); QCOMPARE(targetApplication.remoteEditorSupport(), oldRemoteEditorSupport); QCOMPARE(targetApplication.remoteEditorSupport()->mainWindow()->name(), QString("The object name 42")); @@ -269,28 +206,29 @@ TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); - SignalWait startedWait(&targetApplication, SIGNAL(started())); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); targetApplication.start(); - QVERIFY(startedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&startedSpy, 1, 10000)); QVERIFY(targetApplication.remoteEditorSupport()); targetApplication.setTargetApplicationFilePath("/other/executable"); - SignalWait finishedWait(&targetApplication, SIGNAL(finished())); + QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - SignalWait startFailedWait(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startFailedSpy(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); targetApplication.start(); - QVERIFY(finishedWait.waitForCount(1, 1000)); - QVERIFY(startFailedWait.waitForCount(1, 1000)); - QVariant argument = startFailedWait.spy().at(0).at(0); + QVERIFY(waitForSignalCount(&finishedSpy, 1, 10000)); + QVERIFY(waitForSignalCount(&startFailedSpy, 1, 10000)); + QVariant argument = startFailedSpy.at(0).at(0); QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), TargetApplication::InvalidPath); - QVERIFY(!startedWait.waitForCount(2, 1000)); + //Give time to ensure that "started" signal is not sent again + QVERIFY(!waitForSignalCount(&startedSpy, 2, 1000)); QVERIFY(!targetApplication.remoteEditorSupport()); } @@ -298,20 +236,20 @@ TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); - SignalWait startedWait(&targetApplication, SIGNAL(started())); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); targetApplication.start(); - QVERIFY(startedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&startedSpy, 1, 10000)); RemoteEditorSupport* oldRemoteEditorSupport = targetApplication.remoteEditorSupport(); - SignalWait finishedWait(&targetApplication, SIGNAL(finished())); + QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); targetApplication.mProcess->kill(); - QVERIFY(finishedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&finishedSpy, 1, 10000)); targetApplication.start(); - QVERIFY(startedWait.waitForCount(2, 1000)); + QVERIFY(waitForSignalCount(&startedSpy, 2, 10000)); QVERIFY(targetApplication.remoteEditorSupport()); QVERIFY(targetApplication.remoteEditorSupport() != oldRemoteEditorSupport); QCOMPARE(targetApplication.remoteEditorSupport()->mainWindow()->name(), @@ -325,15 +263,15 @@ //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - SignalWait startFailedWait(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startFailedSpy(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); targetApplication.start(); - QVERIFY(startFailedWait.waitForCount(1, 1000)); - QVariant argument = startFailedWait.spy().at(0).at(0); + QVERIFY(waitForSignalCount(&startFailedSpy, 1, 10000)); + QVariant argument = startFailedSpy.at(0).at(0); QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), TargetApplication::InvalidPath); QCOMPARE(startedSpy.count(), 0); @@ -347,15 +285,15 @@ //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - SignalWait startFailedWait(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startFailedSpy(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); targetApplication.start(); - QVERIFY(startFailedWait.waitForCount(1, 1000)); - QVariant argument = startFailedWait.spy().at(0).at(0); + QVERIFY(waitForSignalCount(&startFailedSpy, 1, 10000)); + QVariant argument = startFailedSpy.at(0).at(0); QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), TargetApplication::InvalidPath); QCOMPARE(startedSpy.count(), 0); @@ -370,16 +308,16 @@ //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - SignalWait startFailedWait(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startFailedSpy(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); targetApplication.start(); //Time out higher than the internal TargetApplication time out - QVERIFY(startFailedWait.waitForCount(1, 3500)); - QVariant argument = startFailedWait.spy().at(0).at(0); + QVERIFY(waitForSignalCount(&startFailedSpy, 1, 10000)); + QVariant argument = startFailedSpy.at(0).at(0); QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), TargetApplication::InvalidApplication); QCOMPARE(startedSpy.count(), 0); @@ -390,14 +328,14 @@ TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); - SignalWait startedWait(&targetApplication, SIGNAL(started())); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); targetApplication.start(); - QVERIFY(startedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&startedSpy, 1, 10000)); - SignalWait finishedWait(&targetApplication, SIGNAL(finished())); + QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); targetApplication.mProcess->kill(); - QVERIFY(finishedWait.waitForCount(1, 1000)); + QVERIFY(waitForSignalCount(&finishedSpy, 1, 10000)); QVERIFY(!targetApplication.remoteEditorSupport()); } @@ -409,8 +347,8 @@ //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - SignalWait startFailedWait(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startFailedSpy(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); @@ -422,8 +360,8 @@ targetApplication.mProcess->kill(); - QVERIFY(startFailedWait.waitForCount(1, 1000)); - QVariant argument = startFailedWait.spy().at(0).at(0); + QVERIFY(waitForSignalCount(&startFailedSpy, 1, 10000)); + QVariant argument = startFailedSpy.at(0).at(0); QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), TargetApplication::InvalidApplication); QVERIFY(!targetApplication.remoteEditorSupport()); @@ -433,7 +371,7 @@ QTest::qWait(3000); QCOMPARE(startedSpy.count(), 0); - QCOMPARE(startFailedWait.spy().count(), 1); + QCOMPARE(startFailedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); } @@ -446,8 +384,8 @@ //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - SignalWait startFailedWait(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startFailedSpy(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); @@ -459,8 +397,8 @@ targetApplication.mProcess->kill(); - QVERIFY(startFailedWait.waitForCount(1, 1000)); - QVariant argument = startFailedWait.spy().at(0).at(0); + QVERIFY(waitForSignalCount(&startFailedSpy, 1, 10000)); + QVariant argument = startFailedSpy.at(0).at(0); QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), TargetApplication::InvalidApplication); QVERIFY(!targetApplication.remoteEditorSupport()); @@ -470,10 +408,45 @@ QTest::qWait(3000); QCOMPARE(startedSpy.count(), 0); - QCOMPARE(startFailedWait.spy().count(), 1); + QCOMPARE(startFailedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); } +/////////////////////////////////// Helpers //////////////////////////////////// + +template <typename Class> +bool waitFor(Class &object, bool (Class::*condition)() const, int timeout) { + QElapsedTimer timer; + timer.start(); + do { + QTest::qWait(100); + } while (!(object.*condition)() && timer.elapsed() < timeout); + + if (timer.elapsed() >= timeout) { + return false; + } + + return true; +} + +class SignalCountCondition { +public: + const QSignalSpy* mSpy; + int mCount; + + bool condition() const { + return mSpy->count() == mCount; + } +}; + +bool TargetApplicationTest::waitForSignalCount(const QSignalSpy* spy, int count, + int timeout) const { + SignalCountCondition helper; + helper.mSpy = spy; + helper.mCount = count; + return waitFor(helper, &SignalCountCondition::condition, timeout); +} + QTEST_MAIN(TargetApplicationTest) #include "TargetApplicationTest.moc" Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp 2012-06-20 18:25:57 UTC (rev 342) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectChooserTest.cpp 2012-06-26 21:53:28 UTC (rev 343) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -82,6 +82,9 @@ void killTargetApplication(int timeToWait); + bool waitForTargetApplicationToStart(int timeout) const; + bool waitForTargetApplicationToStop(int timeout) const; + QCheckBox* showOnlyNamedObjectsCheckBox(RemoteObjectChooser* widget) const; QCheckBox* showOnlyWidgetsCheckBox(RemoteObjectChooser* widget) const; @@ -136,8 +139,7 @@ RemoteObjectChooser* chooser = new RemoteObjectChooser(dialog); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QVERIFY(chooser->isVisible()); QVERIFY(!window.isVisible()); @@ -152,8 +154,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QWidget window(0, Qt::Window); window.show(); @@ -239,16 +240,14 @@ QPointer<RemoteObjectChooser> chooser = new RemoteObjectChooser(dialog); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); //Queue closing the sorry message box closeSorryMessageBox(chooser, 1000); TargetApplication::self()->mProcess->kill(); - //Give the target application time to be killed - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStop(10000)); //Process deleteLater() QCoreApplication::sendPostedEvents(chooser, QEvent::DeferredDelete); @@ -309,8 +308,7 @@ QPointer<RemoteObjectChooser> chooser = new RemoteObjectChooser(dialog); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); chooser->close(); @@ -331,8 +329,7 @@ RemoteObjectChooser* chooser = new RemoteObjectChooser(&window); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QVERIFY(remoteObjectsTreeView(chooser)->model()); @@ -357,8 +354,7 @@ RemoteObjectChooser* chooser = new RemoteObjectChooser(&window); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QVERIFY(remoteObjectsTreeView(chooser)->model()); @@ -386,8 +382,7 @@ RemoteObjectChooser* chooser = new RemoteObjectChooser(&window); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QVERIFY(remoteObjectsTreeView(chooser)->model()); @@ -423,8 +418,7 @@ RemoteObjectChooser* chooser = new RemoteObjectChooser(&window); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QVERIFY(remoteObjectsTreeView(chooser)->model()); QModelIndex index = remoteObjectsTreeView(chooser)->model()->index(1, 0); @@ -471,8 +465,7 @@ QPointer<RemoteObjectChooser> chooser = new RemoteObjectChooser(dialog); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QVERIFY(remoteObjectsTreeView(chooser)->model()); QModelIndex index = remoteObjectsTreeView(chooser)->model()->index(1, 0); @@ -516,8 +509,7 @@ QPointer<RemoteObjectChooser> chooser = new RemoteObjectChooser(dialog); chooser->show(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QVERIFY(remoteObjectsTreeView(chooser)->model()); QModelIndex index = remoteObjectsTreeView(chooser)->model()->index(1, 0); @@ -615,6 +607,38 @@ QTimer::singleShot(timeToWait, helper, SLOT(killTargetApplication())); } +bool waitFor(bool (*condition)(), int timeout) { + QElapsedTimer timer; + timer.start(); + do { + QTest::qWait(100); + } while (!condition() && timer.elapsed() < timeout); + + if (timer.elapsed() >= timeout) { + return false; + } + + return true; +} + +bool isTargetApplicationStarted() { + return TargetApplication::self()->remoteEditorSupport(); +} + +bool isTargetApplicationStopped() { + return !TargetApplication::self()->remoteEditorSupport(); +} + +bool RemoteObjectChooserTest::waitForTargetApplicationToStart( + int timeout) const { + return waitFor(&isTargetApplicationStarted, timeout); +} + +bool RemoteObjectChooserTest::waitForTargetApplicationToStop( + int timeout) const { + return waitFor(&isTargetApplicationStopped, timeout); +} + QCheckBox* RemoteObjectChooserTest::showOnlyNamedObjectsCheckBox( RemoteObjectChooser* widget) const { return widget->findChild<QCheckBox*>("showOnlyNamedObjectsCheckBox"); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp 2012-06-20 18:25:57 UTC (rev 342) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp 2012-06-26 21:53:28 UTC (rev 343) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011 by Daniel Calviño Sánchez * + * Copyright (C) 2011-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -65,6 +65,9 @@ QString mPath; + bool waitForTargetApplicationToStart(int timeout) const; + bool waitForTargetApplicationToStop(int timeout) const; + void assertNames(const QStringList& names) const; }; @@ -88,8 +91,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -106,8 +108,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); assertNames(remoteObjectNameRegister.names()); QCOMPARE(nameAddedSpy.count(), 82); @@ -144,8 +145,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -156,8 +156,7 @@ TargetApplication::self()->mProcess->kill(); - //Give the target application time to stop - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStop(10000)); QVERIFY(remoteObjectNameRegister.names().isEmpty()); QCOMPARE(nameAddedSpy.count(), 0); @@ -174,8 +173,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -190,8 +188,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -207,8 +204,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -225,8 +221,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -242,8 +237,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -255,8 +249,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -273,8 +266,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -292,8 +284,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -311,8 +302,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -330,8 +320,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -349,8 +338,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -365,8 +353,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -385,8 +372,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameRegister remoteObjectNameRegister; @@ -399,6 +385,38 @@ /////////////////////////////////// Helpers //////////////////////////////////// +bool waitFor(bool (*condition)(), int timeout) { + QElapsedTimer timer; + timer.start(); + do { + QTest::qWait(100); + } while (!condition() && timer.elapsed() < timeout); + + if (timer.elapsed() >= timeout) { + return false; + } + + return true; +} + +bool isTargetApplicationStarted() { + return TargetApplication::self()->remoteEditorSupport(); +} + +bool isTargetApplicationStopped() { + return !TargetApplication::self()->remoteEditorSupport(); +} + +bool RemoteObjectNameRegisterTest::waitForTargetApplicationToStart( + int timeout) const { + return waitFor(&isTargetApplicationStarted, timeout); +} + +bool RemoteObjectNameRegisterTest::waitForTargetApplicationToStop( + int timeout) const { + return waitFor(&isTargetApplicationStopped, timeout); +} + void RemoteObjectNameRegisterTest::assertNames(const QStringList& names) const { QCOMPARE(names.count(), 82); QVERIFY(names.contains("The object name 42")); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2012-06-20 18:25:57 UTC (rev 342) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2012-06-26 21:53:28 UTC (rev 343) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -82,6 +82,9 @@ KLineEdit* objectNameLineEdit(RemoteObjectNameWidget* widget) const; + bool waitForTargetApplicationToStart(int timeout) const; + bool waitForTargetApplicationToStop(int timeout) const; + void assertRemoteObjectSignal(const QSignalSpy& spy, int index, const RemoteObject* remoteObject) const; @@ -113,8 +116,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); QWidget parent; RemoteObjectNameWidget* widget = new RemoteObjectNameWidget(&parent); @@ -129,8 +131,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; QSignalSpy remoteObjectChosenSpy(&widget, @@ -151,8 +152,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; QSignalSpy remoteObjectChosenSpy(&widget, @@ -173,8 +173,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; QSignalSpy remoteObjectChosenSpy(&widget, @@ -191,8 +190,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; QSignalSpy remoteObjectChosenSpy(&widget, @@ -214,8 +212,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; QSignalSpy remoteObjectChosenSpy(&widget, @@ -252,8 +249,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; @@ -281,8 +277,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; KLineEdit* lineEdit = objectNameLineEdit(&widget); @@ -323,8 +318,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); items = objectNameLineEdit(&widget)->completionObject()->items(); assertCompletionItems(items); @@ -344,8 +338,7 @@ TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; QSignalSpy remoteObjectChosenSpy(&widget, @@ -353,8 +346,7 @@ TargetApplication::self()->mProcess->kill(); - //Give the target application time to stop - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStop(10000)); QStringList items = objectNameLineEdit(&widget)->completionObject()-> items(); @@ -428,6 +420,38 @@ return widget->findChild<KLineEdit*>("objectNameLineEdit"); } +bool waitFor(bool (*condition)(), int timeout) { + QElapsedTimer timer; + timer.start(); + do { + QTest::qWait(100); + } while (!condition() && timer.elapsed() < timeout); + + if (timer.elapsed() >= timeout) { + return false; + } + + return true; +} + +bool isTargetApplicationStarted() { + return TargetApplication::self()->remoteEditorSupport(); +} + +bool isTargetApplicationStopped() { + return !TargetApplication::self()->remoteEditorSupport(); +} + +bool RemoteObjectNameWidgetTest::waitForTargetApplicationToStart( + int timeout) const { + return waitFor(&isTargetApplicationStarted, timeout); +} + +bool RemoteObjectNameWidgetTest::waitForTargetApplicationToStop( + int timeout) const { + return waitFor(&isTargetApplicationStopped, timeout); +} + //RemoteObject* must be declared as a metatype to be used in qvariant_cast Q_DECLARE_METATYPE(RemoteObject*); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp 2012-06-20 18:25:57 UTC (rev 342) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp 2012-06-26 21:53:28 UTC (rev 343) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011 by Daniel Calviño Sánchez * + * Copyright (C) 2011-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -54,6 +54,8 @@ KLineEdit* propertyNameLineEdit(WaitForPropertyWidget* widget) const; KLineEdit* valueLineEdit(WaitForPropertyWidget* widget) const; + bool waitForTargetApplicationToStart(int timeout) const; + }; void WaitForPropertyWidgetTest::init() { @@ -116,8 +118,7 @@ mTargetApplicationStubPath); TargetApplication::self()->start(); - //Give the target application time to start - QTest::qWait(1000); + QVERIFY(waitForTargetApplicationToStart(10000)); WaitForProperty waitFor; WaitForPropertyWidget widget(&waitFor); @@ -156,6 +157,29 @@ return widget->findChild<KLineEdit*>("valueLineEdit"); } +bool waitFor(bool (*condition)(), int timeout) { + QElapsedTimer timer; + timer.start(); + do { + QTest::qWait(100); + } while (!condition() && timer.elapsed() < timeout); + + if (timer.elapsed() >= timeout) { + return false; + } + + return true; +} + +bool isTargetApplicationStarted() { + return TargetApplication::self()->remoteEditorSupport(); +} + +bool WaitForPropertyWidgetTest::waitForTargetApplicationToStart( + int timeout) const { + return waitFor(&isTargetApplicationStarted, timeout); +} + QTEST_MAIN(WaitForPropertyWidgetTest) #include "WaitForPropertyWidgetTest.moc" Modified: trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2012-06-20 18:25:57 UTC (rev 342) +++ trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2012-06-26 21:53:28 UTC (rev 343) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -64,6 +64,8 @@ QPoint centerOfText(const StepTextWidget& widget, const QString& text); + bool waitForHighlighterToStop(const QWidget* widget, int timeout) const; + void showContextMenuAndSelectFirstOption(const StepTextWidget& widget, const QPoint& position); @@ -160,10 +162,7 @@ QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, position, 500); - //Give the highlighter time to stop - QTest::qWait(500); - - QVERIFY(!widgetToHighlight->findChild<WidgetHighlighter*>("")); + QVERIFY(waitForHighlighterToStop(widgetToHighlight, 10000)); } void StepTextWidgetTest::testHighlightWidgetUsingContextMenu() { @@ -198,13 +197,11 @@ QPoint position = centerOfText(widget, "widget to highlight"); showContextMenuAndSelectFirstOption(widget, position); + //Give the highlighter time to start QTest::qWait(500); showContextMenuAndSelectFirstOption(widget, position); - //Give the highlighter time to stop - QTest::qWait(1000); - - QVERIFY(!widgetToHighlight->findChild<WidgetHighlighter*>("")); + QVERIFY(waitForHighlighterToStop(widgetToHighlight, 10000)); } void StepTextWidgetTest::testCancelContextMenu() { @@ -267,8 +264,7 @@ QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, position2, 500); - //Give the highlighter time to stop - QTest::qWait(500); + QVERIFY(waitForHighlighterToStop(widgetToHighlight1, 10000)); QVERIFY(!widgetToHighlight1->findChild<WidgetHighlighter*>("")); QVERIFY(widgetToHighlight2->findChild<WidgetHighlighter*>("")); @@ -276,8 +272,7 @@ showContextMenuAndSelectFirstOption(widget, position3); - //Give the highlighter time to stop - QTest::qWait(500); + QVERIFY(waitForHighlighterToStop(widgetToHighlight2, 10000)); QVERIFY(!widgetToHighlight1->findChild<WidgetHighlighter*>("")); QVERIFY(!widgetToHighlight2->findChild<WidgetHighlighter*>("")); @@ -285,8 +280,7 @@ showContextMenuAndSelectFirstOption(widget, position1); - //Give the highlighter time to stop - QTest::qWait(500); + QVERIFY(waitForHighlighterToStop(widgetToHighlight3, 10000)); QVERIFY(widgetToHighlight1->findChild<WidgetHighlighter*>("")); QVERIFY(!widgetToHighlight2->findChild<WidgetHighlighter*>("")); @@ -295,8 +289,7 @@ QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, position1, 500); - //Give the highlighter time to stop - QTest::qWait(1000); + QVERIFY(waitForHighlighterToStop(widgetToHighlight1, 10000)); QVERIFY(!widgetToHighlight1->findChild<WidgetHighlighter*>("")); QVERIFY(!widgetToHighlight2->findChild<WidgetHighlighter*>("")); @@ -304,11 +297,11 @@ QTest::mouseClick(widget.viewport(), Qt::LeftButton, Qt::NoModifier, position2, 500); + //Give the highlighter time to start QTest::qWait(500); showContextMenuAndSelectFirstOption(widget, position2); - //Give the highlighter time to stop - QTest::qWait(1000); + QVERIFY(waitForHighlighterToStop(widgetToHighlight2, 10000)); QVERIFY(!widgetToHighlight1->findChild<WidgetHighlighter*>("")); QVERIFY(!widgetToHighlight2->findChild<WidgetHighlighter*>("")); @@ -356,10 +349,7 @@ mainWindow.activateWindow(); widgetToHighlight->setFocus(); - //Give the highlighter time to stop - QTest::qWait(500); - - QVERIFY(!widgetToHighlight->findChild<WidgetHighlighter*>("")); + QVERIFY(waitForHighlighterToStop(widgetToHighlight, 10000)); } void StepTextWidgetTest::testSetTextWhenWidgetIsBeingHighlighted() { @@ -440,6 +430,37 @@ return widget.cursorRect(cursor).center(); } +template <typename Class> +bool waitFor(Class &object, bool (Class::*condition)() const, int timeout) { + QElapsedTimer timer; + timer.start(); + do { + QTest::qWait(100); + } while (!(object.*condition)() && timer.elapsed() < timeout); + + if (timer.elapsed() >= timeout) { + return false; + } + + return true; +} + +class HighlighterStoppedCondition { +public: + const QWidget* mWidget; + + bool condition() const { + return !mWidget->findChild<WidgetHighlighter*>(""); + } +}; + +bool StepTextWidgetTest::waitForHighlighterToStop(const QWidget* widget, + int timeout) const { + HighlighterStoppedCondition helper; + helper.mWidget = widget; + return waitFor(helper, &HighlighterStoppedCondition::condition, timeout); +} + //The context menu contains its own event loop, so it won't return to the test //code until it is closed. Thus, the commands to execute on the menu must be //"queued", as calling QTest::keyClick after showing the menu won't work. Modified: trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp 2012-06-20 18:25:57 UTC (rev 342) +++ trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp 2012-06-26 21:53:28 UTC (rev 343) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2009-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -82,6 +82,9 @@ StepTextWidget* textWidget(StepWidget* stepWidget); KPushButton* closeButton(StepWidget* stepWidget); + bool waitForWidgetToMove(const QWidget* widget, + const QPoint& previousPosition, int timeout) const; + void queueAssertWidgetDragged(StepWidget* stepWidget, int timeToWait); }; @@ -232,6 +235,9 @@ QTest::mousePress(&stepWidget, Qt::LeftButton, Qt::NoModifier, QPoint()); QCursor::setPos(previousPosition + widgetCenter + QPoint(42, 23)); + + QVERIFY(waitForWidgetToMove(&stepWidget, previousPosition, 10000)); + QTest::mouseRelease(&stepWidget, Qt::LeftButton, Qt::NoModifier, QPoint(), 500); stepWidget.setMouseTracking(false); @@ -263,10 +269,14 @@ QTest::mousePress(&stepWidget, Qt::LeftButton, Qt::NoModifier, QPoint()); QCursor::setPos(previousPosition + widgetCenter + QPoint(42, 23)); + + QVERIFY(waitForWidgetToMove(&stepWidget, previousPosition, 10000)); + QTest::mouseRelease(&stepWidget, Qt::LeftButton, Qt::NoModifier, QPoint(), 500); QCursor::setPos(previousPosition + widgetCenter + QPoint(42, 23) + QPoint(16, 15)); + //Give the cursor time to move QTest::qWait(500); stepWidget.setMouseTracking(false); @@ -362,6 +372,43 @@ return stepWidget->ui->closeButton; } +template <typename Class> +bool waitFor(Class &object, bool (Class::*condition)() const, int timeout) { + QElapsedTimer timer; + timer.start(); + do { + QTest::qWait(100); + } while (!(object.*condition)() && timer.elapsed() < timeout); + + if (timer.elapsed() >= timeout) { + return false; + } + + return true; +} + +class WidgetMovedCondition { +public: + const QWidget* mWidget; + QPoint mPreviousPosition; + + bool condition() const { + return mPreviousPosition.x() + 41 <= mWidget->pos().x() && + mPreviousPosition.x() + 43 >= mWidget->pos().x() && + mPreviousPosition.y() + 22 <= mWidget->pos().y() && + mPreviousPosition.y() + 24 >= mWidget->pos().y(); + } +}; + +bool StepWidgetTest::waitForWidgetToMove(const QWidget* widget, + const QPoint& previousPosition, + int timeout) const { + WidgetMovedCondition helper; + helper.mWidget = widget; + helper.mPreviousPosition = previousPosition; + return waitFor(helper, &WidgetMovedCondition::condition, timeout); +} + //Modal dialogs don't return to the test code until they are closed. Thus, the //actions or asserts to be performed while a modal dialog is being shown (like //checking the position of the widget) must be "queued". @@ -394,16 +441,19 @@ //does if tracking isn't enabled mStepWidget->setMouseTracking(true); QTest::mousePress(mStepWidget, Qt::LeftButton, - Qt::NoModifier, QPoint(), 500); + Qt::NoModifier, QPoint()); QCursor::setPos(previousPosition + widgetCenter + QPoint(42, 23)); + + //waitForWidgetToMove is a method of StepWidgetTest, so it can not be + //called here + WidgetMovedCondition helper; + helper.mWidget = mStepWidget; + helper.mPreviousPosition = previousPosition; + QVERIFY(waitFor(helper, &WidgetMovedCondition::condition, 10000)); + QTest::mouseRelease(mStepWidget, Qt::LeftButton, Qt::NoModifier, QPoint(), 500); mStepWidget->setMouseTracking(false); - - QVERIFY(previousPosition.x() + 41 <= mStepWidget->pos().x() && - previousPosition.x() + 43 >= mStepWidget->pos().x()); - QVERIFY(previousPosition.y() + 22 <= mStepWidget->pos().y() && - previousPosition.y() + 24 >= mStepWidget->pos().y()); } private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-08-09 15:52:12
|
Revision: 358 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=358&view=rev Author: danxuliu Date: 2012-08-09 15:52:01 +0000 (Thu, 09 Aug 2012) Log Message: ----------- Add support for null objects in the editor support module. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.cpp trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectMapperTest.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h trunk/ktutorial/ktutorial-library/tests/editorsupport/ObjectRegisterTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.cpp 2012-08-09 09:40:28 UTC (rev 357) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.cpp 2012-08-09 15:52:01 UTC (rev 358) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -35,6 +35,10 @@ } RemoteObject* RemoteObjectMapper::remoteObject(int objectId) { + if (objectId == 0) { + return 0; + } + if (mRemoteObjects.contains(objectId)) { return mRemoteObjects.value(objectId); } Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.h 2012-08-09 09:40:28 UTC (rev 357) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.h 2012-08-09 15:52:01 UTC (rev 358) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -54,6 +54,8 @@ * Returns the RemoteObject associated with the given object id. * The RemoteObject is destroyed when this RemoteObjectMapper is cleared or * destroyed, so consider using QPointer to store it. + * The object id 0 is a special case, and it is associated to the null + * object; a null pointer is returned in this case. * * @param objectId The id of the remote object. * @return The RemoteObject. Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectMapperTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectMapperTest.cpp 2012-08-09 09:40:28 UTC (rev 357) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectMapperTest.cpp 2012-08-09 15:52:01 UTC (rev 358) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -37,6 +37,7 @@ void testRemoteObject(); void testRemoteObjectSeveralIds(); void testRemoteObjectTwice(); + void testRemoteNullObject(); void testRemoteClass(); void testRemoteClassSeveralIds(); @@ -101,6 +102,14 @@ QCOMPARE(remoteObject1->name(), QString("The object name 42")); } +void RemoteObjectMapperTest::testRemoteNullObject() { + RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); + + RemoteObject* remoteObject = mapper.remoteObject(0); + + QVERIFY(!remoteObject); +} + void RemoteObjectMapperTest::testRemoteClass() { RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp 2012-08-09 09:40:28 UTC (rev 357) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp 2012-08-09 15:52:01 UTC (rev 358) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -27,6 +27,10 @@ } int ObjectRegister::idForObject(QObject* object) { + if (!object) { + return 0; + } + int id = mRegisteredIds.value(object); if (!id) { Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h 2012-08-09 09:40:28 UTC (rev 357) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h 2012-08-09 15:52:01 UTC (rev 358) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -29,7 +29,7 @@ * The id for an object is assigned after the first time the id is requested * for that object, and are valid until the register is cleared or the object is * destroyed (if an object is destroyed it is automatically removed from the - * register). + * register). The null object is a special case, and its id is always 0. * * When an object is registered, its QMetaObject and the QMetaObject of all its * super classes are also registered. The QMetaObject can be got using the class Modified: trunk/ktutorial/ktutorial-library/tests/editorsupport/ObjectRegisterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/editorsupport/ObjectRegisterTest.cpp 2012-08-09 09:40:28 UTC (rev 357) +++ trunk/ktutorial/ktutorial-library/tests/editorsupport/ObjectRegisterTest.cpp 2012-08-09 15:52:01 UTC (rev 358) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -44,6 +44,7 @@ void testRegisterObject(); void testRegisterObjectSeveralObjects(); void testRegisterObjectTwice(); + void testRegisterNullObject(); void testObjectForIdWithDestroyedObject(); @@ -112,6 +113,14 @@ &QObject::staticMetaObject); } +void ObjectRegisterTest::testRegisterNullObject() { + ObjectRegister objectRegister; + + int id = objectRegister.idForObject(0); + + QCOMPARE(objectRegister.objectForId(id), (QObject*)0); +} + void ObjectRegisterTest::testObjectForIdWithDestroyedObject() { ObjectRegister objectRegister; QObject* object = new QObject(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-08-10 10:57:43
|
Revision: 360 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=360&view=rev Author: danxuliu Date: 2012-08-10 10:57:33 +0000 (Fri, 10 Aug 2012) Log Message: ----------- Improve the unique name generation to take into account ambiguity solving rules. Now only objects with a unique name (or a unique name after applying the ambiguity solving rules) can be chosen by the user; if he tries to chose an object that has no unique name a warning is shown. Also, the concept of "best name" is introduced, so the objects that have no unique name are still shown in the completion box with their full path to help the user identify them and fix the target application. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.cpp trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.h trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp trunk/ktutorial/ktutorial-library/src/KTutorial.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.h trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportAdaptorTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -49,6 +49,16 @@ return mMapper->remoteObject(reply.value()); } +RemoteObject* RemoteEditorSupport::findObject(const QString& name) + throw (DBusException) { + QDBusReply<int> reply = call("findObject", name); + if (!reply.isValid()) { + throw DBusException(reply.error().message()); + } + + return mMapper->remoteObject(reply.value()); +} + void RemoteEditorSupport::highlight(RemoteObject* remoteWidget) throw (DBusException) { QDBusReply<void> reply = call("highlight", remoteWidget->objectId()); Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h 2012-08-10 10:57:33 UTC (rev 360) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -70,6 +70,15 @@ RemoteObject* mainWindow() throw (DBusException); /** + * Returns the RemoteObject with the given name. + * The name can include ancestor names. + * + * @param name The name of the RemoteObject to find. + * @return The RemoteObject with the given name, or 0 if there is none. + */ + RemoteObject* findObject(const QString& name) throw (DBusException); + + /** * Highlights the widget represented by the given remote object. * If the object does not represent a widget nothing is highlighted. * Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -52,60 +52,58 @@ QString RemoteObjectNameRegister::uniqueName(RemoteObject* remoteObject) const throw (DBusException) { - QString name = remoteObject->name(); - if (name.isEmpty()) { - return ""; - } + QStringList reversedPath = bestNameAsReversedPath(remoteObject); + QString name = reversedPathAsName(reversedPath); QList<QStringList> reversedPathsToHomonyms = reversedPathsToHomonymsOf(remoteObject); - if (reversedPathsToHomonyms.count() == 0) { + if (isUniquePath(reversedPath, reversedPathsToHomonyms)) { return name; } - QStringList reversedFullPath = reversedPathTo(remoteObject); - - for (int i=1; i<reversedFullPath.size(); ++i) { - if (ancestorNotInPaths(reversedFullPath[i], reversedPathsToHomonyms)) { - return reversedFullPath[i] + '/' + reversedFullPath[0]; - } + //Although the name is ambiguous, it identifies the given remote object + if (findRemoteObject(name) == remoteObject) { + return name; } - QStringList reversedUniquePath; - reversedUniquePath.append(reversedFullPath[0]); - - for (int i=1; i<reversedFullPath.size(); ++i) { - reversedUniquePath.append(reversedFullPath[i]); - - if (isUniquePath(reversedUniquePath, reversedPathsToHomonyms)) { - return reversedPathAsName(reversedUniquePath); - } - } - - return reversedPathAsName(reversedUniquePath); + return ""; } -QStringList RemoteObjectNameRegister::uniqueNames(const QString& name) const +QStringList RemoteObjectNameRegister::bestNames(const QString& name) const throw (DBusException) { Q_ASSERT(mRemoteObjectForName.values(name).count() > 0); - QStringList uniqueNames; + QStringList bestNames; if (mRemoteObjectForName.values(name).count() <= 1) { - uniqueNames.append(name); - return uniqueNames; + bestNames.append(name); + return bestNames; } foreach (RemoteObject* remoteObject, mRemoteObjectForName.values(name)) { - uniqueNames.append(uniqueName(remoteObject)); + bestNames.append(bestName(remoteObject)); } - return uniqueNames; + return bestNames; } + +//As KTutorial applies several rules to resolve ambiguous names (a name that +//represents two or more objects), and querying the editor support is relatively +//quick (around 5-6 miliseconds on average for Showfoto on a computer from the +//year 2002), the target application itself is queried instead of reimplementing +//those rules in the editor, as they would be very cumbersome to be tested +//properly, and prevents having to duplicate the changes when some rule is +//modified in the library. RemoteObject* RemoteObjectNameRegister::findRemoteObject(const QString& name) - const { - return findRemoteObject(name, 0); + const +throw (DBusException) { + if (TargetApplication::self()->remoteEditorSupport()) { + return TargetApplication::self()->remoteEditorSupport()-> + findObject(name); + } + + return 0; } bool RemoteObjectNameRegister::isBeingUpdated() const { @@ -149,13 +147,78 @@ } } +QString RemoteObjectNameRegister::bestName(RemoteObject* remoteObject) const +throw (DBusException) { + return reversedPathAsName(bestNameAsReversedPath(remoteObject)); +} + +QStringList RemoteObjectNameRegister::bestNameAsReversedPath( + RemoteObject* remoteObject) const +throw (DBusException) { + QStringList reversedUniquePath; + + QString name = remoteObject->name(); + if (name.isEmpty()) { + return reversedUniquePath; + } + + reversedUniquePath.append(name); + + QList<QStringList> reversedPathsToHomonyms = + reversedPathsToHomonymsOf(remoteObject); + if (reversedPathsToHomonyms.count() == 0) { + return reversedUniquePath; + } + + QStringList reversedFullPath = reversedPathTo(remoteObject); + + //Get deepest ancestor with unique name + int uniqueAncestorIndex = -1; + for (int i=1; i<reversedFullPath.size() && uniqueAncestorIndex == -1; ++i) { + if (mRemoteObjectForName.values(reversedFullPath[i]).count() == 1) { + uniqueAncestorIndex = i; + } + } + + //If there is an ancestor with a unique name and it has only one descendant + //with the name of the remote object (that is, the remote object itself), + //return "ancestor/object". + if (uniqueAncestorIndex != -1 && + ancestorNotInPaths(reversedFullPath[uniqueAncestorIndex], + reversedPathsToHomonyms)) { + reversedUniquePath.append(reversedFullPath[uniqueAncestorIndex]); + return reversedUniquePath; + } + + //If there is more than one descendant with that name, mark the ancestor + //with the unique name as the limit to descend when looking for a unique + //path + int limit = uniqueAncestorIndex; + if (limit == -1) { + //If no ancestor has a unique name, mark the shallowest ancestor as the + //limit to descend + limit = reversedFullPath.size() - 1; + } + + //Add ancestors to the path until limit or until a unique path is found + for (int i=1; i <= limit; ++i) { + reversedUniquePath.append(reversedFullPath[i]); + + if (isUniquePath(reversedUniquePath, reversedPathsToHomonyms)) { + return reversedUniquePath; + } + } + + return reversedUniquePath; +} + QStringList RemoteObjectNameRegister::reversedPathTo( RemoteObject* remoteObject) const throw (DBusException) { QStringList reversedPath; RemoteObject* parent = remoteObject; - while (parent) { + while (parent && mRemoteObjectForParent.key(parent)) { QString name = parent->name(); if (!name.isEmpty() && !name.startsWith(QLatin1String("qt_"))) { reversedPath.append(name); @@ -222,6 +285,10 @@ QString RemoteObjectNameRegister::reversedPathAsName( const QStringList& reversedPath) const { + if (reversedPath.isEmpty()) { + return ""; + } + QString name = reversedPath[0]; for (int i=1; i<reversedPath.size(); ++i) { name = reversedPath[i] + '/' + name; @@ -230,56 +297,6 @@ return name; } -RemoteObject* RemoteObjectNameRegister::findRemoteObject(const QString& name, - RemoteObject* ancestor) const { - if (name.indexOf('/') == -1) { - QList<RemoteObject*> remoteObjects = mRemoteObjectForName.values(name); - foreach (RemoteObject* remoteObject, remoteObjects) { - if (isDescendantOf(remoteObject, ancestor)) { - return remoteObject; - } - } - - return 0; - } - - QRegExp slashPattern("/+"); - QString ancestorName = name.left(name.indexOf(slashPattern)); - QString descendantName = name.mid(ancestorName.length() + - slashPattern.matchedLength()); - - QList<RemoteObject*> namedAncestors = - mRemoteObjectForName.values(ancestorName); - - foreach (RemoteObject* namedAncestor, namedAncestors) { - if (isDescendantOf(namedAncestor, ancestor)) { - RemoteObject* remoteObject = findRemoteObject(descendantName, - namedAncestor); - if (remoteObject) { - return remoteObject; - } - } - } - - return 0; -} - -bool RemoteObjectNameRegister::isDescendantOf(RemoteObject* remoteObject, - RemoteObject* ancestor) const { - if (!ancestor) { - return true; - } - - QList<RemoteObject*> children = mRemoteObjectForParent.values(ancestor); - foreach (RemoteObject* child, children) { - if (child == remoteObject || isDescendantOf(remoteObject, child)) { - return true; - } - } - - return false; -} - void RemoteObjectNameRegister::startNameUpdate() { mIsBeingUpdated = true; emit nameUpdateStarted(); Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.h 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.h 2012-08-10 10:57:33 UTC (rev 360) @@ -41,9 +41,31 @@ * object can be got using uniqueName(RemoteObject*). Also, given a name, the * remote object that it represents can be got using findObject(QString). An * unqualified name (without any ancestor names, just the name of the remote - * object itself) can be used to get the unique names of all the remote objects + * object itself) can be used to get the best names of all the remote objects * represented by that unqualified name. * + * The best name and the unique name of a remote object are tightly related. + * When the name of a remote object is unique by itself, the best name of the + * remote object is the name itself. + * When there are other remote objects with the same name, but the remote object + * has an ancestor with a unique name, and the remote object is the only + * descendant of that ancestor with that name, its best name (which is also + * unique) is the name of the ancestor and the name of the remote object. The + * ancestor with a unique name used is the nearest one to the remote object + * (parent preferred to grandparent, grandparent preferred to great-grandparent + * and so on). + * If there are more descendants of the ancestor with that name, or if there + * is no ancestor with a unique name, the best name is composed by the name of + * the remote object itself and the name of as many ancestors as needed to + * obtain a unique name. + * If there is no unique name for the remote object, the best name is composed + * by the name of the remote object itself and the name of all of its ancestors + * from the remote object to the deepest ancestor with a unique name, or all its + * ancestors if none has a unique name. + * A best name that is ambiguous, that is, identifies more than one remote + * object, may become unique if the ambiguity solving rules from KTutorial are + * taken into account. + * * Note that a name and the remote object it represents depends on the state of * the target application. For example, if there is a dialog named * "Configuration dialog" with a button named "Ok button", its unique name could @@ -97,51 +119,40 @@ /** * Returns a unique name for the given remote object. - * When the remote object name is unique by itself, its name is returned. - * When there are other remote objects with the same name as the given one, - * but it has an ancestor with a unique name, the returned name includes - * both names. The ancestor with a unique name used is the nearest one to - * the remote object (parent preferred to grandparent, grandparent preferred - * to great-grandparent and so on). - * When there are other remote objects with the same name as the given one, - * and no ancestor has a unique name, the returned name includes as many - * ancestor names as necessary to create a name unique to the given remote - * object. - * + * If the best name of the given remote object is unique, or if it is not + * unique, but the object found when applying the ambiguity solving rules is + * the given remote object, the best name is returned. + * Otherwise, there is no unique name for the given remote object, and an + * empty string is returned instead. + * * @param remoteObject The remote object to get its unique name. - * @return A unique name for the given remote object. + * @return A unique name for the given remote object, if any. * @throws DBusException If a DBus error happens. */ QString uniqueName(RemoteObject* remoteObject) const throw (DBusException); /** - * Returns the unique names of the remote objects that have the given name. + * Returns the best names of the remote objects that have the given name. * The given name can not contain any ancestor names, and it must be a * registered name. * - * @param name The name of the remote objects to get their unique names. - * @return The unique names of the remote objects that have the given name. + * @param name The name of the remote objects to get their best names. + * @return The best names of the remote objects that have the given name. * @throws DBusException If a DBus error happens. */ - QStringList uniqueNames(const QString& name) const throw (DBusException); + QStringList bestNames(const QString& name) const throw (DBusException); /** * Returns the remote object with the given name, if any. - * When the name of the desired remote object is not unique the name of some - * ancestor must be included. Ancestor names are separated using a "/". That - * is, "Ancestor name/The remote object with a repeated name". As many - * ancestor names as desired can be included, not just one. - * The name of the ancestors does not need to be unique either; what has to - * be unique is the full path to the remote object to find. For example, - * "Ancestor name not unique/The remote object to find" is valid if, among - * all the remote objects called "Ancestor name not unique", there is only - * one that has a descendant called "The remote object to find". + * The editor support module in the target application is queried to find + * the object with the given name. * * @param name The name of the remote object to find. * @return The remote object with the specified name, or a null pointer if * there is none. */ - RemoteObject* findRemoteObject(const QString& name) const; + RemoteObject* findRemoteObject(const QString& name) const + throw (DBusException); /** * Returns whether the names are being registered or not. @@ -229,12 +240,32 @@ throw (DBusException); /** + * Returns the best name for the given remote object. + * + * @param remoteObject The remote object to get its best name. + * @return The best name of the given remote object. + * @throws DBusException If a DBus error happens. + */ + QString bestName(RemoteObject* remoteObject) const + throw (DBusException); + + /** + * Returns the best name for the given remote object as a reversed path. + * + * @param remoteObject The remote object to get its best name. + * @return The reversed path for the best name of the given remote object. + * @throws DBusException If a DBus error happens. + */ + QStringList bestNameAsReversedPath(RemoteObject* remoteObject) const + throw (DBusException); + + /** * Returns the reversed path to the given remote object. * The path contains the name of the remote object itself and all its named - * ancestors. The order of the items is reversed from the natural path, that - * is, the first item in the returned path is the remote object name, the - * second item is the name of its parent, the third is the name of its - * grandparent... + * ancestors (except for the root ancestor). The order of the items is + * reversed from the natural path, that is, the first item in the returned + * path is the remote object name, the second item is the name of its + * parent, the third is the name of its grandparent... * Empty names and Qt default names (like "qt_scrollarea_viewport") are not * included in the path. * @@ -311,6 +342,7 @@ * The name contains all the items in the path separated by "/". The order * of the items in the name is their natural order, that is, the last item * is the first one, the penultimate is the second one... + * If the given path is empty an empty string is returned. * * @param path The reversed path to get its equivalent name. * @return The name equivalent to the given reversed path. @@ -318,31 +350,6 @@ QString reversedPathAsName(const QStringList& reversedPath) const; /** - * Returns the remote object with the given name, if any. - * The name can contain also the ancestor names, separated by "/". The - * first object that matches the whole path is returned (note that ancestor - * are not necessarily direct parents). - * - * @param name The name of the remote object to find. - * @param ancestor The ancestor to look the remote object in. - * @return The remote object with the specified name, or a null pointer if - * there is none. - */ - RemoteObject* findRemoteObject(const QString& name, RemoteObject* ancestor) - const; - - /** - * Returns true if remoteObject is descendant of ancestor, false otherwise. - * When ancestor is null, it always returns true. - * - * @param remoteObject The remote object to check. - * @param ancestor The ancestor to check. - * @return True if remoteObject is descendant of ancestor, false otherwise. - */ - bool isDescendantOf(RemoteObject* remoteObject, - RemoteObject* ancestor) const; - - /** * Sets this RemoteObjectNameRegister as being updated and emits the * nameUpdateStarted() signal. */ Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -32,7 +32,10 @@ * The items added for completion should be the unqualified remote object names, * that is, just the name of the remote objects, without any ancestor. When a * match is found, and it represents more than one remote object, the match is - * replaced by the unique names of its remote objects. + * replaced by the best names of its remote objects. Note that an object without + * a unique name will have the same best name as another object. Showing two or + * more objects with the same best name in the completion list will hopefully + * help the user to identify problems with the names in the target application. */ class RemoteObjectNameCompletion: public KCompletion { public: @@ -64,30 +67,30 @@ /** * Processes the matches to provide unique names. * When a match is a name that represents several remote objects that match - * is replaced by all the unique names of the remote objects it represents. + * is replaced by the best names of the remote objects it represents. * * @param matches The matches to process. */ virtual void postProcessMatches(QStringList* matches) const { QMutableListIterator<QString> it(*matches); while (it.hasNext()) { - QStringList uniqueNames; + QStringList bestNames; try { - uniqueNames = mNameRegister->uniqueNames(it.next()); + bestNames = mNameRegister->bestNames(it.next()); } catch (DBusException e) { kWarning() << "The unique names for the remote objects named " << it.value() << "could not be added to the " << "completion matches (" << e.message() << ")"; } - if (uniqueNames.count() > 1) { + if (bestNames.count() > 1) { it.remove(); - qSort(uniqueNames); + qSort(bestNames); - foreach (const QString& uniqueName, uniqueNames) { - it.insert(uniqueName); + foreach (const QString& bestName, bestNames) { + it.insert(bestName); } } } @@ -193,16 +196,29 @@ return; } + QString uniqueName; try { - ui->objectNameLineEdit->setText( - mRemoteObjectNameRegister->uniqueName(remoteObject)); + uniqueName = mRemoteObjectNameRegister->uniqueName(remoteObject); } catch (DBusException e) { QString text = i18nc("@label", "The object name can not be set, there " "was a problem getting the name from the target application: %1", e.message()); QString title = i18nc("@title", "Can't communicate with the target " "application"); KMessageBox::sorry(this, text, title); + return; } + + if (uniqueName.isEmpty()) { + QString text = i18nc("@label", "There is no unique name for the chosen " +"object (at least, in the current state of the target application), so it is " +"not possible to refer to that object in a tutorial. The target application " +"must be modified to provide a unique name for that object."); + QString title = i18nc("@title", "The chosen object has no unique name"); + KMessageBox::sorry(this, text, title); + return; + } + + ui->objectNameLineEdit->setText(uniqueName); } void RemoteObjectNameWidget::handleNameChanged(const QString& name) { @@ -211,7 +227,16 @@ return; } - emit remoteObjectChosen(mRemoteObjectNameRegister->findRemoteObject(name)); + RemoteObject* remoteObject; + try { + remoteObject = mRemoteObjectNameRegister->findRemoteObject(name); + } catch (DBusException e) { + kWarning() << "There was a problem finding the remote object (" + << e.message() << ")."; + return; + } + + emit remoteObjectChosen(remoteObject); } void RemoteObjectNameWidget::handleCompletion() { Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h 2012-08-10 10:57:33 UTC (rev 360) @@ -39,7 +39,7 @@ * in the target application. If there is no target application running, no * completion is provided. As soon as it starts, the completion is enabled. * When the completion matches contain a name that represents several remote - * objects that match is replaced by the unique name of each remote object. + * objects that match is replaced by the best name of each remote object. * * When a name is set in the line edit the signal * remoteObjectChosen(RemoteObject*) is emitted. @@ -159,14 +159,17 @@ * If the name register is being updated, nothing will be done, but marking * setting the chosen remote object as a pending operation. * If the given remote object is null no name is set. + * If the given remote object has no unique name, no name is set and a + * message box is shown to inform the user that the target application must + * be modified in order to be able to use that object in a tutorial. * * @param remoteObject The chosen RemoteObject. */ void setChosenRemoteObject(RemoteObject* remoteObject); /** - * Emits remoteObjectChosen(RemoteObject*) with the remote object with the - * given name. + * Emits remoteObjectChosen(RemoteObject*) with the remote object found with + * the given name (which can include ancestor names). * If the name register is being updated, nothing will be done, but marking * handling the name change as a pending operation. * Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2012-08-10 10:57:33 UTC (rev 360) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -101,21 +101,36 @@ * | | |... * | |... * |-8: "The object name 8" - * |-80: "" (The class name 80) - * | |-800: "Duplicated object" - * | |-801: "The object name 801" - * | |-802: "" - * | |-803: "The object name 803" - * |-81: "" (QWidgetChildChild) - * | |-810: "" - * | |-811: "" - * | |-812: "" - * | |-813: "" - * |-82: "The object name 82" (ChildChildQWidget) - * | |-820: "The object name 820" + * | |-80: "" (The class name 80) + * | | |-800: "Duplicated object" + * | | |-801: "The object name 801" + * | | |-802: "" + * | | |-803: "The object name 803" + * | |-81: "" (QWidgetChildChild) + * | | |-810: "" + * | | |-811: "" + * | | |-812: "" + * | | |-813: "" + * | |-82: "The object name 82" (ChildChildQWidget) + * | | |-820: "The object name 820" + * | | |... + * | |-83: "The object name 83" (The class name 83) + * | |-830: "The object name 830" (ChildQWidget) + * | |... + * |-9: "Duplicated grandparent" + * |-90: "The object name 90" + * | |-900: "Duplicated object" + * | |-901: "Duplicated object" * | |... - * |-83: "The object name 83" (The class name 83) - * |-830: "The object name 830" (ChildQWidget) + * |-91: "Another duplicated parent" + * | |-910: "Duplicated object" + * | |... + * |-92: "Another duplicated parent" + * | |-920: "Duplicated object" + * | |... + * |-93: "" + * |-930: "Duplicated object" + * |-931: "Duplicated object" * |... */ class StubObjectRegisterAdaptor: public QDBusAbstractAdaptor { @@ -130,7 +145,9 @@ QString objectName(int objectId) { if (objectId == 500 || objectId == 600 || objectId == 700 || - objectId == 800) { + objectId == 800 || objectId == 900 || objectId == 901 || + objectId == 910 || objectId == 920 || objectId == 930 || + objectId == 931) { return "Duplicated object"; } @@ -138,13 +155,17 @@ return "Duplicated parent"; } - if (objectId == 5 || objectId == 6) { + if (objectId == 91 || objectId == 92) { + return "Another duplicated parent"; + } + + if (objectId == 5 || objectId == 6 || objectId == 9) { return "Duplicated grandparent"; } if (objectId == 80 || objectId == 81 || objectId == 802 || objectId == 810 || objectId == 811 || objectId == 812 || - objectId == 813) { + objectId == 813 || objectId == 93) { return ""; } @@ -186,6 +207,7 @@ ids.append(6); ids.append(7); ids.append(8); + ids.append(9); } return ids; @@ -230,6 +252,51 @@ return 42; } + int findObject(const QString& name) { + //Used in RemoteEditorSupportTest + if (name == "The object name 423") { + return 423; + } + + //Used in WaitForPropertyWidgetTest + if (name == "The object name 830") { + return 830; + } + + //Used in RemoteObjectNameRegisterTest/RemoteObjectNameWidgetTest + if (name == "The object name 50/Duplicated object") { + return 500; + } + + if (name == "The object name 501") { + return 501; + } + + if (name == "Duplicated grandparent/Duplicated parent/" + "Duplicated object") { + return 600; + } + + if (name == "The object name 7/Duplicated object") { + return 700; + } + + if (name == "The object name 90/Duplicated object") { + return 900; + } + + if (name == "Duplicated grandparent/Another duplicated parent/" + "Duplicated object") { + return 910; + } + + if (name == "Duplicated grandparent/Duplicated object") { + return 930; + } + + return 0; + } + void highlight(int objectId) { mHighlightRemoteWidgetIds.append(objectId); } Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -50,6 +50,9 @@ void testMainWindowTwice(); void testMainWindowWhenRemoteEditorSupportIsNotAvailable(); + void testFindObject(); + void testFindObjectWhenRemoteEditorSupportIsNotAvailable(); + void testHighlight(); void testHighlightWhenRemoteEditorSupportIsNotAvailable(); @@ -132,6 +135,28 @@ EXPECT_EXCEPTION(remoteEditorSupport.mainWindow(), DBusException); } +void RemoteEditorSupportTest::testFindObject() { + RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); + RemoteEditorSupport remoteEditorSupport( + QDBusConnection::sessionBus().baseService(), &mapper); + + RemoteObject* object = remoteEditorSupport.mainWindow()->children()[3]; + + QCOMPARE(remoteEditorSupport.findObject("The object name 423"), object); +} + +void RemoteEditorSupportTest:: +testFindObjectWhenRemoteEditorSupportIsNotAvailable() { + RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); + RemoteEditorSupport remoteEditorSupport( + QDBusConnection::sessionBus().baseService(), &mapper); + + QDBusConnection::sessionBus().unregisterObject("/ktutorial"); + + EXPECT_EXCEPTION(remoteEditorSupport.findObject("The object name 423"), + DBusException); +} + void RemoteEditorSupportTest::testHighlight() { RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); RemoteEditorSupport remoteEditorSupport( Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectTest.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectTest.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -122,7 +122,7 @@ RemoteObject remoteObject(mService, mMapper, 42); QList<RemoteObject*> children = remoteObject.children(); - QCOMPARE(children.count(), 8); + QCOMPARE(children.count(), 9); QCOMPARE(children[0]->objectId(), 420); QCOMPARE(children[1]->objectId(), 421); QCOMPARE(children[2]->objectId(), 422); @@ -131,6 +131,7 @@ QCOMPARE(children[5]->objectId(), 6); QCOMPARE(children[6]->objectId(), 7); QCOMPARE(children[7]->objectId(), 8); + QCOMPARE(children[8]->objectId(), 9); } void RemoteObjectTest::testChildrenWhenRemoteObjectIsNotAvailable() { Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -50,6 +50,9 @@ void testFindRemoteObjectWithParentName(); void testFindRemoteObjectWithGrandparentName(); void testFindRemoteObjectWithParentAndGrandparentNames(); + void testFindRemoteObjectWithAmbiguousNameAndUniqueParent(); + void testFindRemoteObjectWithAmbiguousNameAndDuplicatedParent(); + void testFindRemoteObjectWithAmbiguousNameAndEmptyParent(); void testFindRemoteObjectWithUnknownName(); void testUniqueName(); @@ -57,10 +60,14 @@ void testUniqueNameWhenUniqueGrandparentAndEmptyParent(); void testUniqueNameWhenUniqueGrandparentAndDuplicatedParent(); void testUniqueNameWhenUniqueUnionOfGrandparentAndParent(); + void testUniqueNameWhenAmbiguousNameWithUniqueParent(); + void testUniqueNameWhenAmbiguousNameWithDuplicatedParent(); + void testUniqueNameWhenAmbiguousNameWithEmptyParent(); void testUniqueNameWhenEmptyName(); + void testUniqueNameWhenNameNotUnique(); - void testUniqueNames(); - void testUniqueNamesWithSingleRemoteObject(); + void testBestNames(); + void testBestNamesWithSingleRemoteObject(); private: @@ -133,7 +140,7 @@ QCOMPARE(nameUpdateFinishedSpy.count(), 1); assertNames(remoteObjectNameRegister.names()); - QCOMPARE(nameAddedSpy.count(), 82); + QCOMPARE(nameAddedSpy.count(), 102); QCOMPARE(nameAddedSpy.at(0).at(0).toString(), QString("The object name 42")); QCOMPARE(nameAddedSpy.at(1).at(0).toString(), @@ -305,6 +312,63 @@ mainWindow->children()[5]->children()[0]->children()[0]); } +void RemoteObjectNameRegisterTest:: + testFindRemoteObjectWithAmbiguousNameAndUniqueParent() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + + QCOMPARE(remoteObjectNameRegister.findRemoteObject( + "The object name 90/Duplicated object"), + mainWindow->children()[8]->children()[0]->children()[0]); +} + +void RemoteObjectNameRegisterTest:: + testFindRemoteObjectWithAmbiguousNameAndDuplicatedParent() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + + QCOMPARE(remoteObjectNameRegister.findRemoteObject( + "Duplicated grandparent/Another duplicated parent/Duplicated object"), + mainWindow->children()[8]->children()[1]->children()[0]); +} + +void RemoteObjectNameRegisterTest:: + testFindRemoteObjectWithAmbiguousNameAndEmptyParent() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + + QCOMPARE(remoteObjectNameRegister.findRemoteObject( + "Duplicated grandparent/Duplicated object"), + mainWindow->children()[8]->children()[3]->children()[0]); +} + void RemoteObjectNameRegisterTest::testFindRemoteObjectWithUnknownName() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); @@ -418,6 +482,67 @@ "Duplicated object")); } +void RemoteObjectNameRegisterTest:: + testUniqueNameWhenAmbiguousNameWithUniqueParent() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + RemoteObject* remoteObject = + mainWindow->children()[8]->children()[0]->children()[0]; + + QCOMPARE(remoteObjectNameRegister.uniqueName(remoteObject), + QString("The object name 90/Duplicated object")); +} + +void RemoteObjectNameRegisterTest:: + testUniqueNameWhenAmbiguousNameWithDuplicatedParent() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + RemoteObject* remoteObject = + mainWindow->children()[8]->children()[1]->children()[0]; + + QCOMPARE(remoteObjectNameRegister.uniqueName(remoteObject), + QString("Duplicated grandparent/Another duplicated parent/" + "Duplicated object")); +} + +void RemoteObjectNameRegisterTest:: + testUniqueNameWhenAmbiguousNameWithEmptyParent() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + RemoteObject* remoteObject = + mainWindow->children()[8]->children()[3]->children()[0]; + + QCOMPARE(remoteObjectNameRegister.uniqueName(remoteObject), + QString("Duplicated grandparent/Duplicated object")); +} + void RemoteObjectNameRegisterTest::testUniqueNameWhenEmptyName() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); @@ -435,7 +560,7 @@ QCOMPARE(remoteObjectNameRegister.uniqueName(remoteObject), QString("")); } -void RemoteObjectNameRegisterTest::testUniqueNames() { +void RemoteObjectNameRegisterTest::testUniqueNameWhenNameNotUnique() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); @@ -445,18 +570,52 @@ QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); - QStringList uniqueNames = - remoteObjectNameRegister.uniqueNames("Duplicated object"); + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + RemoteObject* remoteObject = + mainWindow->children()[8]->children()[0]->children()[1]; - QCOMPARE(uniqueNames.count(), 4); - QVERIFY(uniqueNames.contains("The object name 50/Duplicated object")); - QVERIFY(uniqueNames.contains("Duplicated grandparent/Duplicated parent/" + QCOMPARE(remoteObjectNameRegister.uniqueName(remoteObject), QString("")); + + remoteObject = mainWindow->children()[8]->children()[2]->children()[0]; + + QCOMPARE(remoteObjectNameRegister.uniqueName(remoteObject), QString("")); + + remoteObject = mainWindow->children()[8]->children()[3]->children()[1]; + + QCOMPARE(remoteObjectNameRegister.uniqueName(remoteObject), QString("")); +} + +void RemoteObjectNameRegisterTest::testBestNames() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + QStringList bestNames = + remoteObjectNameRegister.bestNames("Duplicated object"); + + QCOMPARE(bestNames.count(), 10); + QVERIFY(bestNames.contains("The object name 50/Duplicated object")); + QVERIFY(bestNames.contains("Duplicated grandparent/Duplicated parent/" "Duplicated object")); - QVERIFY(uniqueNames.contains("The object name 7/Duplicated object")); - QVERIFY(uniqueNames.contains("The object name 8/Duplicated object")); + QVERIFY(bestNames.contains("The object name 7/Duplicated object")); + QVERIFY(bestNames.contains("The object name 8/Duplicated object")); + QVERIFY(bestNames.contains("The object name 90/Duplicated object")); + QVERIFY(bestNames.contains("The object name 90/Duplicated object")); + QVERIFY(bestNames.contains("Duplicated grandparent/Another duplicated " + "parent/Duplicated object")); + QVERIFY(bestNames.contains("Duplicated grandparent/Another duplicated " + "parent/Duplicated object")); + QVERIFY(bestNames.contains("Duplicated grandparent/Duplicated object")); + QVERIFY(bestNames.contains("Duplicated grandparent/Duplicated object")); } -void RemoteObjectNameRegisterTest::testUniqueNamesWithSingleRemoteObject() { +void RemoteObjectNameRegisterTest::testBestNamesWithSingleRemoteObject() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); @@ -466,11 +625,11 @@ QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); - QStringList uniqueNames = - remoteObjectNameRegister.uniqueNames("The object name 423"); + QStringList bestNames = + remoteObjectNameRegister.bestNames("The object name 423"); - QCOMPARE(uniqueNames.count(), 1); - QVERIFY(uniqueNames.contains("The object name 423")); + QCOMPARE(bestNames.count(), 1); + QVERIFY(bestNames.contains("The object name 423")); } /////////////////////////////////// Helpers //////////////////////////////////// @@ -541,7 +700,7 @@ } void RemoteObjectNameRegisterTest::assertNames(const QStringList& names) const { - QCOMPARE(names.count(), 82); + QCOMPARE(names.count(), 102); QVERIFY(names.contains("The object name 42")); QVERIFY(names.contains("The object name 420")); QVERIFY(names.contains("The object name 421")); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -29,6 +29,7 @@ #include <QtDBus/QtDBus> #include <KCompletionBox> +#include <KDialog> #include <KLineEdit> #include <KProcess> @@ -59,6 +60,7 @@ void testSetNameDuringNameRegisterUpdate(); void testSetChosenRemoteObject(); + void testSetChosenRemoteObjectWithUniqueComplexName(); void testSetChosenRemoteObjectWithNameNotUnique(); void testSetChosenRemoteObjectDuringNameRegisterUpdate(); void testSetChosenRemoteObjectDuringNameRegisterUpdateKillingApplication(); @@ -94,6 +96,8 @@ bool waitForNamesToBeRegistered(const RemoteObjectNameWidget* widget, int timeout) const; + void closeSorryMessageBox(QWidget* widget, int timeToWait); + void assertRemoteObjectSignal(const QSignalSpy& spy, int index, const RemoteObject* remoteObject) const; @@ -261,7 +265,8 @@ assertRemoteObjectSignal(remoteObjectChosenSpy, 0, remoteObject); } -void RemoteObjectNameWidgetTest::testSetChosenRemoteObjectWithNameNotUnique() { +void RemoteObjectNameWidgetTest:: + testSetChosenRemoteObjectWithUniqueComplexName() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); @@ -300,6 +305,38 @@ assertRemoteObjectSignal(remoteObjectChosenSpy, 2, remoteObject); } +void RemoteObjectNameWidgetTest::testSetChosenRemoteObjectWithNameNotUnique() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameWidget widget; + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + + widget.setName("An object name"); + + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + RemoteObject* remoteObject = + mainWindow->children()[8]->children()[0]->children()[1]; + + //The widget must be shown for a proper parenting of the sorry message box + widget.show(); + + //Queue closing the sorry message box + closeSorryMessageBox(&widget, 10000); + + widget.setChosenRemoteObject(remoteObject); + + QCOMPARE(widget.name(), QString("An object name")); + QCOMPARE(remoteObjectChosenSpy.count(), 0); +} + void RemoteObjectNameWidgetTest:: testSetChosenRemoteObjectDuringNameRegisterUpdate() { TargetApplication::self()->setTargetApplicationFilePath(mPath); @@ -429,16 +466,30 @@ QVERIFY(completionBox->isVisible()); - QCOMPARE(completionItems.count(), 4); + QCOMPARE(completionItems.count(), 10); QCOMPARE(completionItems[0], + QString("Duplicated grandparent/Another duplicated parent/" + "Duplicated object")); + QCOMPARE(completionItems[1], + QString("Duplicated grandparent/Another duplicated parent/" + "Duplicated object")); + QCOMPARE(completionItems[2], + QString("Duplicated grandparent/Duplicated object")); + QCOMPARE(completionItems[3], + QString("Duplicated grandparent/Duplicated object")); + QCOMPARE(completionItems[4], QString("Duplicated grandparent/Duplicated parent/" "Duplicated object")); - QCOMPARE(completionItems[1], + QCOMPARE(completionItems[5], QString("The object name 50/Duplicated object")); - QCOMPARE(completionItems[2], + QCOMPARE(completionItems[6], QString("The object name 7/Duplicated object")); - QCOMPARE(completionItems[3], + QCOMPARE(completionItems[7], QString("The object name 8/Duplicated object")); + QCOMPARE(completionItems[8], + QString("The object name 90/Duplicated object")); + QCOMPARE(completionItems[9], + QString("The object name 90/Duplicated object")); } void RemoteObjectNameWidgetTest::testNameCompletionDuringNameRegisterUpdate() { @@ -470,16 +521,30 @@ QVERIFY(completionBox->isVisible()); - QCOMPARE(completionItems.count(), 4); + QCOMPARE(completionItems.count(), 10); QCOMPARE(completionItems[0], + QString("Duplicated grandparent/Another duplicated parent/" + "Duplicated object")); + QCOMPARE(completionItems[1], + QString("Duplicated grandparent/Another duplicated parent/" + "Duplicated object")); + QCOMPARE(completionItems[2], + QString("Duplicated grandparent/Duplicated object")); + QCOMPARE(completionItems[3], + QString("Duplicated grandparent/Duplicated object")); + QCOMPARE(completionItems[4], QString("Duplicated grandparent/Duplicated parent/" "Duplicated object")); - QCOMPARE(completionItems[1], + QCOMPARE(completionItems[5], QString("The object name 50/Duplicated object")); - QCOMPARE(completionItems[2], + QCOMPARE(completionItems[6], QString("The object name 7/Duplicated object")); - QCOMPARE(completionItems[3], + QCOMPARE(completionItems[7], QString("The object name 8/Duplicated object")); + QCOMPARE(completionItems[8], + QString("The object name 90/Duplicated object")); + QCOMPARE(completionItems[9], + QString("The object name 90/Duplicated object")); } void RemoteObjectNameWidgetTest:: @@ -515,7 +580,7 @@ QVERIFY(completionBox->isVisible()); - QCOMPARE(completionItems.count(), 82); + QCOMPARE(completionItems.count(), 102); QVERIFY(completionItems.contains("The object name 42")); QVERIFY(completionItems.contains("The object name 420")); QVERIFY(completionItems.contains("The object name 421")); @@ -723,6 +788,101 @@ timeout); } +//The message boxes are modal, so they won't return to the test code until they +//are closed. Thus, the actions to be performed while the message boxes are +//being shown (like closing the message boxes themselves) must be "queued". +//Instead of queueing them to be performed after some fixed amount of time, +//it is checked if the action can be performed and, if not, the action is +//retried again after a little amount of time. The retries continue until the +//timeout expires. +class QueuedAction: public QObject { +Q_OBJECT +public: + + QueuedAction(int timeout, QObject* parent): QObject(parent), + mTimeout(timeout), + mFinished(false), + mActionDone(false) { + } + + void run() { + mElapsedTime.start(); + mFinished = false; + + checkAction(); + } + + bool isFinished() const { + return mFinished; + } + + bool isActionDone() const { + return mActionDone; + } + +public slots: + + void checkAction() { + mActionDone = action(); + if (!mActionDone && mElapsedTime.elapsed() < mTimeout) { + QTimer::singleShot(100, this, SLOT(checkAction())); + } else { + mFinished = true; + } + } + +protected: + + virtual bool action() = 0; + +private: + + int mTimeout; + QTime mElapsedTime; + bool mFinished; + bool mActionDone; + +}; + +class CloseSorryMessageBoxHelper: public QueuedAction { +public: + + CloseSorryMessageBoxHelper(int timeout, QObject* parent): + QueuedAction(timeout, parent), + mWidget(0) { + } + + void setWidget(QWidget* widget) { + mWidget = widget; + } + +protected: + + virtual bool action() { + KDialog* messageBox = mWidget->findChild<KDialog*>("sorry"); + if (!messageBox) { + return false; + } + + delete messageBox; + + return true; + } + +private: + + QWidget* mWidget; + +}; + +void RemoteObjectNameWidgetTest::closeSorryMessageBox(QWidget* widget, + int timeToWait) { + CloseSorryMessageBoxHelper* helper = new CloseSorryMessageBoxHelper( + timeToWait, this); + helper->setWidget(widget); + helper->run(); +} + //RemoteObject* must be declared as a metatype to be used in qvariant_cast Q_DECLARE_METATYPE(RemoteObject*); @@ -735,7 +895,7 @@ void RemoteObjectNameWidgetTest::assertCompletionItems( const QStringList& items) const { - QCOMPARE(items.count(), 77); + QCOMPARE(items.count(), 89); QVERIFY(items.contains("The object name 42")); QVERIFY(items.contains("The object name 420")); QVERIFY(items.contains("The object name 421")); Modified: trunk/ktutorial/ktutorial-library/src/KTutorial.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/KTutorial.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-library/src/KTutorial.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -86,6 +86,7 @@ #ifdef QT_QTDBUS_FOUND editorsupport::EditorSupport* editorSupport = new editorsupport::EditorSupport(this); + editorSupport->setObjectFinder(mObjectFinder); editorSupport->setup(window); connect(editorSupport, SIGNAL(started(Tutorial*)), this, SLOT(showStepWidget(Tutorial*))); Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp 2012-08-09 15:59:47 UTC (rev 359) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp 2012-08-10 10:57:33 UTC (rev 360) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -28,6 +28,7 @@ #include "EventSpyAdaptor.h" #include "ObjectRegister.h" #include "ObjectRegisterAdaptor.h" +#include "../ObjectFinder.h" #include ".... [truncated message content] |
From: <dan...@us...> - 2012-08-11 01:33:32
|
Revision: 368 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=368&view=rev Author: danxuliu Date: 2012-08-11 01:33:20 +0000 (Sat, 11 Aug 2012) Log Message: ----------- Include all the library classes in "ktutorial" namespace. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp trunk/ktutorial/ktutorial-library/src/KTutorial.cpp trunk/ktutorial/ktutorial-library/src/KTutorial.h trunk/ktutorial/ktutorial-library/src/ObjectFinder.cpp trunk/ktutorial/ktutorial-library/src/ObjectFinder.h trunk/ktutorial/ktutorial-library/src/Option.h trunk/ktutorial/ktutorial-library/src/Step.cpp trunk/ktutorial/ktutorial-library/src/Step.h trunk/ktutorial/ktutorial-library/src/Tutorial.cpp trunk/ktutorial/ktutorial-library/src/Tutorial.h trunk/ktutorial/ktutorial-library/src/TutorialInformation.h trunk/ktutorial/ktutorial-library/src/TutorialManager.cpp trunk/ktutorial/ktutorial-library/src/TutorialManager.h trunk/ktutorial/ktutorial-library/src/WaitFor.h trunk/ktutorial/ktutorial-library/src/WaitForAnd.cpp trunk/ktutorial/ktutorial-library/src/WaitForAnd.h trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp trunk/ktutorial/ktutorial-library/src/WaitForComposed.h trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp trunk/ktutorial/ktutorial-library/src/WaitForEvent.h trunk/ktutorial/ktutorial-library/src/WaitForNot.cpp trunk/ktutorial/ktutorial-library/src/WaitForNot.h trunk/ktutorial/ktutorial-library/src/WaitForOr.cpp trunk/ktutorial/ktutorial-library/src/WaitForOr.h trunk/ktutorial/ktutorial-library/src/WaitForProperty.cpp trunk/ktutorial/ktutorial-library/src/WaitForProperty.h trunk/ktutorial/ktutorial-library/src/WaitForSignal.cpp trunk/ktutorial/ktutorial-library/src/WaitForSignal.h trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.h trunk/ktutorial/ktutorial-library/src/WaitForWindow.cpp trunk/ktutorial/ktutorial-library/src/WaitForWindow.h trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.cpp trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.h trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.h trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.h trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.h trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.h trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.cpp trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.h trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighter.cpp trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighter.h trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighterManager.cpp trunk/ktutorial/ktutorial-library/src/extendedinformation/WidgetHighlighterManager.h trunk/ktutorial/ktutorial-library/src/scripting/ScriptManager.cpp trunk/ktutorial/ktutorial-library/src/scripting/ScriptManager.h trunk/ktutorial/ktutorial-library/src/scripting/ScriptedStep.cpp trunk/ktutorial/ktutorial-library/src/scripting/ScriptedStep.h trunk/ktutorial/ktutorial-library/src/scripting/ScriptedTutorial.cpp trunk/ktutorial/ktutorial-library/src/scripting/ScriptedTutorial.h trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.cpp trunk/ktutorial/ktutorial-library/src/scripting/ScriptingModule.h trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.cpp trunk/ktutorial/ktutorial-library/src/tutorials/UsingKTutorial.h trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.cpp trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h trunk/ktutorial/ktutorial-library/src/view/StepWidget.cpp trunk/ktutorial/ktutorial-library/src/view/StepWidget.h trunk/ktutorial/ktutorial-library/src/view/StepWidget.ui trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.cpp trunk/ktutorial/ktutorial-library/src/view/TutorialListModel.h trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.cpp trunk/ktutorial/ktutorial-library/src/view/TutorialManagerDialog.h trunk/ktutorial/ktutorial-library/src/view/WindowOnTopEnforcer.cpp trunk/ktutorial/ktutorial-library/src/view/WindowOnTopEnforcer.h trunk/ktutorial/ktutorial-library/tests/ObjectFinderTest.cpp trunk/ktutorial/ktutorial-library/tests/OptionTest.cpp trunk/ktutorial/ktutorial-library/tests/StepTest.cpp trunk/ktutorial/ktutorial-library/tests/TutorialInformationTest.cpp trunk/ktutorial/ktutorial-library/tests/TutorialManagerTest.cpp trunk/ktutorial/ktutorial-library/tests/TutorialTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForAndTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForComposedTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForEventTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForNotTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForOrTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForPropertyTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForSignalTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForStepActivationTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForTest.cpp trunk/ktutorial/ktutorial-library/tests/WaitForWindowTest.cpp trunk/ktutorial/ktutorial-library/tests/common/WindowVisibilitySpyTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/ClassRegisterAdaptorTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportAdaptorTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/EditorSupportTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/EventSpyAdaptorTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/EventSpyTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/ObjectRegisterAdaptorTest.cpp trunk/ktutorial/ktutorial-library/tests/editorsupport/ObjectRegisterTest.cpp trunk/ktutorial/ktutorial-library/tests/extendedinformation/WidgetHighlighterManagerTest.cpp trunk/ktutorial/ktutorial-library/tests/extendedinformation/WidgetHighlighterTest.cpp trunk/ktutorial/ktutorial-library/tests/scripting/ScriptManagerTest.cpp trunk/ktutorial/ktutorial-library/tests/scripting/ScriptedStepTest.cpp trunk/ktutorial/ktutorial-library/tests/scripting/ScriptedTutorialTest.cpp trunk/ktutorial/ktutorial-library/tests/scripting/ScriptingModuleTest.cpp trunk/ktutorial/ktutorial-library/tests/scripting/ScriptingTest.cpp trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/StepWidgetTest.cpp trunk/ktutorial/ktutorial-library/tests/view/TutorialListModelTest.cpp trunk/ktutorial/ktutorial-library/tests/view/TutorialManagerDialogTest.cpp trunk/ktutorial/ktutorial-library/tests/view/WindowOnTopEnforcerTest.cpp trunk/ktutorial/ktutorial-test-app/TestApp.cpp trunk/ktutorial/ktutorial-test-app/TutorialClearText.cpp trunk/ktutorial/ktutorial-test-app/TutorialClearText.h trunk/ktutorial/ktutorial-test-app/TutorialMoveText.cpp trunk/ktutorial/ktutorial-test-app/TutorialMoveText.h Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -68,7 +68,7 @@ mFileActions->newTutorial(); - KTutorial::self()->setup(this); + ktutorial::KTutorial::self()->setup(this); setupGUI(); } Modified: trunk/ktutorial/ktutorial-library/src/KTutorial.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/KTutorial.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/KTutorial.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -33,11 +33,13 @@ #include "editorsupport/EditorSupport.h" #endif -using scripting::ScriptingModule; -using scripting::ScriptManager; -using view::StepWidget; -using view::TutorialManagerDialog; +using ktutorial::scripting::ScriptingModule; +using ktutorial::scripting::ScriptManager; +using ktutorial::view::StepWidget; +using ktutorial::view::TutorialManagerDialog; +namespace ktutorial { + //public: //It inherits from QObject to be automatically destroyed when the parent @@ -133,5 +135,7 @@ mTutorialsAction->setEnabled(true); } +} + #include "moc_KTutorial.cpp" #include "KTutorial.moc" Modified: trunk/ktutorial/ktutorial-library/src/KTutorial.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/KTutorial.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/KTutorial.h 2012-08-11 01:33:20 UTC (rev 368) @@ -16,8 +16,8 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef KTUTORIAL_H -#define KTUTORIAL_H +#ifndef KTUTORIAL_KTUTORIAL_H +#define KTUTORIAL_KTUTORIAL_H #include <kxmlguiwindow.h> @@ -28,6 +28,8 @@ class KAction; +namespace ktutorial { + /** * Main class of KTutorial. * This class is used to setup KTutorial, register WaitFor classes to be created @@ -246,4 +248,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/ObjectFinder.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/ObjectFinder.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/ObjectFinder.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -18,6 +18,8 @@ #include "ObjectFinder.h" +namespace ktutorial { + //private: QList<QObject*> ObjectFinder::getBestMatches(const QString& name, @@ -159,3 +161,5 @@ return filteredPaths; } + +} Modified: trunk/ktutorial/ktutorial-library/src/ObjectFinder.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/ObjectFinder.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/ObjectFinder.h 2012-08-11 01:33:20 UTC (rev 368) @@ -16,14 +16,16 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef OBJECTFINDER_H -#define OBJECTFINDER_H +#ifndef KTUTORIAL_OBJECTFINDER_H +#define KTUTORIAL_OBJECTFINDER_H #include <QObject> #include <QRegExp> #include "ktutorial_export.h" +namespace ktutorial { + /** * Helper class to find objects. * This class is not intended to be used directly. Instead, use @@ -239,4 +241,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/Option.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/Option.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/Option.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef OPTION_H -#define OPTION_H +#ifndef KTUTORIAL_OPTION_H +#define KTUTORIAL_OPTION_H #include <QObject> #include "ktutorial_export.h" +namespace ktutorial { + /** * An option shown to the user. * An option is something a user can choose to do in a Step. For example, in the @@ -86,4 +88,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/Step.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/Step.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/Step.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -23,6 +23,8 @@ #include "WaitFor.h" #include "WaitForSignal.h" +namespace ktutorial { + //public: void Step::setActive(bool active) { @@ -220,4 +222,6 @@ emit nextStepRequested(mNextStepForWaitFor.value(waitFor)); } +} + #include "Step.moc" Modified: trunk/ktutorial/ktutorial-library/src/Step.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/Step.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/Step.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,8 +16,8 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef STEP_H -#define STEP_H +#ifndef KTUTORIAL_STEP_H +#define KTUTORIAL_STEP_H #include <QHash> #include <QList> @@ -26,9 +26,13 @@ #include "ktutorial_export.h" +namespace ktutorial { class Option; class WaitFor; +} +namespace ktutorial { + /** * A step in a Tutorial. * It is each of the tasks that must be accomplished when following a Tutorial. @@ -477,4 +481,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/Tutorial.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/Tutorial.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,8 @@ #include "Step.h" #include "TutorialInformation.h" +namespace ktutorial { + //public: Tutorial::~Tutorial() { @@ -116,3 +118,5 @@ emit stepActivated(step); } + +} Modified: trunk/ktutorial/ktutorial-library/src/Tutorial.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/Tutorial.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/Tutorial.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,17 +16,21 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef TUTORIAL_H -#define TUTORIAL_H +#ifndef KTUTORIAL_TUTORIAL_H +#define KTUTORIAL_TUTORIAL_H #include <QMap> #include <QObject> #include "ktutorial_export.h" +namespace ktutorial { class Step; class TutorialInformation; +} +namespace ktutorial { + /** * A tutorial. * A tutorial is composed by some information about it and several steps. The @@ -224,4 +228,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/TutorialInformation.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/TutorialInformation.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/TutorialInformation.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef TUTORIALINFORMATION_H -#define TUTORIALINFORMATION_H +#ifndef KTUTORIAL_TUTORIALINFORMATION_H +#define KTUTORIAL_TUTORIALINFORMATION_H #include <QObject> #include "ktutorial_export.h" +namespace ktutorial { + /** * Information about a Tutorial. * Contains the identifier, name and description of a Tutorial. @@ -112,4 +114,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/TutorialManager.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/TutorialManager.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/TutorialManager.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,8 @@ #include "Tutorial.h" #include "TutorialInformation.h" +namespace ktutorial { + //public: TutorialManager::~TutorialManager() { @@ -66,3 +68,5 @@ disconnect(this, SLOT(finish())); emit finished(); } + +} Modified: trunk/ktutorial/ktutorial-library/src/TutorialManager.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/TutorialManager.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/TutorialManager.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2010 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,8 +16,8 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef TUTORIALMANAGER_H -#define TUTORIALMANAGER_H +#ifndef KTUTORIAL_TUTORIALMANAGER_H +#define KTUTORIAL_TUTORIALMANAGER_H #include <QMap> #include <QObject> @@ -25,9 +25,13 @@ #include "ktutorial_export.h" +namespace ktutorial { class Tutorial; class TutorialInformation; +} +namespace ktutorial { + /** * Manager for tutorials. * A TutorialManager contains several tutorials and is responsible for start the @@ -120,4 +124,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitFor.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitFor.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitFor.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFOR_H -#define WAITFOR_H +#ifndef KTUTORIAL_WAITFOR_H +#define KTUTORIAL_WAITFOR_H #include <QObject> #include "ktutorial_export.h" +namespace ktutorial { + /** * Abstract base class for conditions to be waited for. * Classes derived from this one model a condition to be waited for. WaitFor @@ -108,4 +110,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForAnd.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForAnd.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForAnd.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -18,6 +18,8 @@ #include "WaitForAnd.h" +namespace ktutorial { + //public: bool WaitForAnd::conditionMet() const { @@ -34,3 +36,5 @@ return true; } + +} Modified: trunk/ktutorial/ktutorial-library/src/WaitForAnd.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForAnd.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForAnd.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFORAND_H -#define WAITFORAND_H +#ifndef KTUTORIAL_WAITFORAND_H +#define KTUTORIAL_WAITFORAND_H #include "ktutorial_export.h" #include "WaitForComposed.h" +namespace ktutorial { + /** * Composed WaitFor that performs an AND between its children. */ @@ -46,4 +48,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForComposed.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -18,6 +18,8 @@ #include "WaitForComposed.h" +namespace ktutorial { + //public: void WaitForComposed::setActive(bool active) { @@ -56,3 +58,5 @@ emit waitEnded(this); } } + +} Modified: trunk/ktutorial/ktutorial-library/src/WaitForComposed.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForComposed.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForComposed.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFORCOMPOSED_H -#define WAITFORCOMPOSED_H +#ifndef KTUTORIAL_WAITFORCOMPOSED_H +#define KTUTORIAL_WAITFORCOMPOSED_H #include "ktutorial_export.h" #include "WaitFor.h" +namespace ktutorial { + /** * Abstract base class for composed conditions to wait for. * Classes derived from this one model a composed condition to be waited for. @@ -94,4 +96,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForEvent.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,8 @@ #include <KDebug> +namespace ktutorial { + //public: WaitForEvent::WaitForEvent(): @@ -97,4 +99,6 @@ emit waitEnded(this); } +} + #include "WaitForEvent.moc" Modified: trunk/ktutorial/ktutorial-library/src/WaitForEvent.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForEvent.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForEvent.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,8 +16,8 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFOREVENT_H -#define WAITFOREVENT_H +#ifndef KTUTORIAL_WAITFOREVENT_H +#define KTUTORIAL_WAITFOREVENT_H #include <QEvent> @@ -25,6 +25,8 @@ #include "WaitFor.h" +namespace ktutorial { + /** * Waits for an event of some specific type to be sent to an object. * When an event of the expected type is sent and the WaitForEvent is active, @@ -151,4 +153,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForNot.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForNot.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForNot.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -18,6 +18,8 @@ #include "WaitForNot.h" +namespace ktutorial { + //public: WaitForNot::WaitForNot(): WaitFor(), @@ -32,3 +34,5 @@ mWaitFor = waitFor; mWaitFor->setParent(this); } + +} Modified: trunk/ktutorial/ktutorial-library/src/WaitForNot.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForNot.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForNot.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFORNOT_H -#define WAITFORNOT_H +#ifndef KTUTORIAL_WAITFORNOT_H +#define KTUTORIAL_WAITFORNOT_H #include "ktutorial_export.h" #include "WaitFor.h" +namespace ktutorial { + /** * Special WaitFor class to negate other WaitFor objects. * This WaitFor is intended to be used only as a child of WaitForComposed @@ -118,4 +120,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForOr.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForOr.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForOr.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -18,6 +18,8 @@ #include "WaitForOr.h" +namespace ktutorial { + //public: bool WaitForOr::conditionMet() const { @@ -30,3 +32,5 @@ return false; } + +} Modified: trunk/ktutorial/ktutorial-library/src/WaitForOr.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForOr.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForOr.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFOROR_H -#define WAITFOROR_H +#ifndef KTUTORIAL_WAITFOROR_H +#define KTUTORIAL_WAITFOROR_H #include "ktutorial_export.h" #include "WaitForComposed.h" +namespace ktutorial { + /** * Composed WaitFor that performs an OR between its children. */ @@ -48,4 +50,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForProperty.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForProperty.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForProperty.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011 by Daniel Calviño Sánchez * + * Copyright (C) 2011-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -22,6 +22,8 @@ #include <KDebug> +namespace ktutorial { + //public: WaitForProperty::WaitForProperty(): WaitFor() { @@ -98,3 +100,5 @@ emit waitEnded(this); } } + +} Modified: trunk/ktutorial/ktutorial-library/src/WaitForProperty.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForProperty.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForProperty.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011 by Daniel Calviño Sánchez * + * Copyright (C) 2011-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,8 +16,8 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFORPROPERTY_H -#define WAITFORPROPERTY_H +#ifndef KTUTORIAL_WAITFORPROPERTY_H +#define KTUTORIAL_WAITFORPROPERTY_H #include <QVariant> @@ -25,6 +25,8 @@ #include "WaitFor.h" +namespace ktutorial { + /** * Waits for a property to have a specific value. * When the property changes its value to the specified one and the @@ -160,4 +162,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForSignal.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForSignal.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForSignal.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -20,6 +20,8 @@ #include <KDebug> +namespace ktutorial { + //public: WaitForSignal::WaitForSignal(): WaitFor(), @@ -56,3 +58,5 @@ mConditionMet = true; emit waitEnded(this); } + +} Modified: trunk/ktutorial/ktutorial-library/src/WaitForSignal.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForSignal.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForSignal.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Daniel Calviño Sánchez * + * Copyright (C) 2008-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFORSIGNAL_H -#define WAITFORSIGNAL_H +#ifndef KTUTORIAL_WAITFORSIGNAL_H +#define KTUTORIAL_WAITFORSIGNAL_H #include "ktutorial_export.h" #include "WaitFor.h" +namespace ktutorial { + /** * Waits for a signal to be emitted. * When the signal is emitted and the WaitForSignal is active, the wait ends. @@ -113,4 +115,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011 by Daniel Calviño Sánchez * + * Copyright (C) 2011-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -24,6 +24,8 @@ #include "Tutorial.h" +namespace ktutorial { + //public: WaitForStepActivation::WaitForStepActivation(): WaitFor(), @@ -70,3 +72,5 @@ emit waitEnded(this); mDuringStepActivation = false; } + +} Modified: trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForStepActivation.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011 by Daniel Calviño Sánchez * + * Copyright (C) 2011-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,16 +16,20 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFORSTEPACTIVATION_H -#define WAITFORSTEPACTIVATION_H +#ifndef KTUTORIAL_WAITFORSTEPACTIVATION_H +#define KTUTORIAL_WAITFORSTEPACTIVATION_H #include "ktutorial_export.h" #include "WaitFor.h" +namespace ktutorial { class Step; class Tutorial; +} +namespace ktutorial { + /** * Waits for the activation of a step. * When the step is activated, the wait ends. @@ -116,4 +120,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/WaitForWindow.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForWindow.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForWindow.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -20,8 +20,10 @@ #include "KTutorial.h" #include "common/WindowVisibilitySpy.h" -using common::WindowVisibilitySpy; +using ktutorial::common::WindowVisibilitySpy; +namespace ktutorial { + //public: WaitForWindow::WaitForWindow(): WaitFor(), @@ -75,4 +77,6 @@ emit waitEnded(this); } +} + #include "WaitForWindow.moc" Modified: trunk/ktutorial/ktutorial-library/src/WaitForWindow.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/WaitForWindow.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/WaitForWindow.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,13 +16,15 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef WAITFORWINDOW_H -#define WAITFORWINDOW_H +#ifndef KTUTORIAL_WAITFORWINDOW_H +#define KTUTORIAL_WAITFORWINDOW_H #include "ktutorial_export.h" #include "WaitFor.h" +namespace ktutorial { + /** * Waits for a specific window to be shown. * When the window with the expected object name is shown and the WaitForEvent @@ -117,4 +119,6 @@ }; +} + #endif Modified: trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -21,6 +21,7 @@ #include "WindowVisibilitySpy.h" +namespace ktutorial { namespace common { //public: @@ -68,5 +69,6 @@ } } +} #include "WindowVisibilitySpy.moc" Modified: trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/common/WindowVisibilitySpy.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,11 +16,12 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef COMMON_WINDOWVISIBILITYSPY_H -#define COMMON_WINDOWVISIBILITYSPY_H +#ifndef KTUTORIAL_COMMON_WINDOWVISIBILITYSPY_H +#define KTUTORIAL_COMMON_WINDOWVISIBILITYSPY_H #include <QObject> +namespace ktutorial { namespace common { /** @@ -85,5 +86,6 @@ }; } +} #endif Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -21,6 +21,7 @@ #include "ClassRegisterAdaptor.h" #include "ObjectRegister.h" +namespace ktutorial { namespace editorsupport { //public: @@ -114,3 +115,4 @@ } } +} Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ClassRegisterAdaptor.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,16 +16,19 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef EDITORSUPPORT_CLASSREGISTERADAPTOR_H -#define EDITORSUPPORT_CLASSREGISTERADAPTOR_H +#ifndef KTUTORIAL_EDITORSUPPORT_CLASSREGISTERADAPTOR_H +#define KTUTORIAL_EDITORSUPPORT_CLASSREGISTERADAPTOR_H #include <QDBusAbstractAdaptor> #include <QStringList> +namespace ktutorial { namespace editorsupport { class ObjectRegister; } +} +namespace ktutorial { namespace editorsupport { /** @@ -120,5 +123,6 @@ }; } +} #endif Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -32,9 +32,10 @@ #include "../extendedinformation/WidgetHighlighterManager.h" #include "../scripting/ScriptedTutorial.h" -using extendedinformation::WidgetHighlighterManager; -using scripting::ScriptedTutorial; +using ktutorial::extendedinformation::WidgetHighlighterManager; +using ktutorial::scripting::ScriptedTutorial; +namespace ktutorial { namespace editorsupport { //public: @@ -147,3 +148,4 @@ } +} Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupport.h 2012-08-11 01:33:20 UTC (rev 368) @@ -16,20 +16,25 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef EDITORSUPPORT_EDITORSUPPORT_H -#define EDITORSUPPORT_EDITORSUPPORT_H +#ifndef KTUTORIAL_EDITORSUPPORT_EDITORSUPPORT_H +#define KTUTORIAL_EDITORSUPPORT_EDITORSUPPORT_H #include <QObject> +namespace ktutorial { class ObjectFinder; class Tutorial; +} +namespace ktutorial { namespace editorsupport { class EventSpy; class EventSupportAdaptor; class ObjectRegister; } +} +namespace ktutorial { namespace editorsupport { /** @@ -189,5 +194,6 @@ }; } +} #endif Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -22,6 +22,7 @@ #include "EditorSupport.h" #include "ObjectRegister.h" +namespace ktutorial { namespace editorsupport { //public: @@ -63,3 +64,4 @@ } } +} Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EditorSupportAdaptor.h 2012-08-11 01:33:20 UTC (rev 368) @@ -16,16 +16,19 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef EDITORSUPPORT_EDITORSUPPORTADAPTOR_H -#define EDITORSUPPORT_EDITORSUPPORTADAPTOR_H +#ifndef KTUTORIAL_EDITORSUPPORT_EDITORSUPPORTADAPTOR_H +#define KTUTORIAL_EDITORSUPPORT_EDITORSUPPORTADAPTOR_H #include <QDBusAbstractAdaptor> +namespace ktutorial { namespace editorsupport { class EditorSupport; class ObjectRegister; } +} +namespace ktutorial { namespace editorsupport { /** @@ -110,5 +113,6 @@ }; } +} #endif Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -20,6 +20,7 @@ #include "EventSpy.h" +namespace ktutorial { namespace editorsupport { //public: @@ -48,3 +49,4 @@ } } +} Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpy.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,11 +16,12 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef EDITORSUPPORT_EVENTSPY_H -#define EDITORSUPPORT_EVENTSPY_H +#ifndef KTUTORIAL_EDITORSUPPORT_EVENTSPY_H +#define KTUTORIAL_EDITORSUPPORT_EVENTSPY_H #include <QObject> +namespace ktutorial { namespace editorsupport { /** @@ -73,5 +74,6 @@ }; } +} #endif Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -23,6 +23,7 @@ #include "EventSpy.h" #include "ObjectRegister.h" +namespace ktutorial { namespace editorsupport { //public: @@ -48,3 +49,4 @@ } } +} Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/EventSpyAdaptor.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,16 +16,19 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef EDITORSUPPORT_EVENTSPYADAPTOR_H -#define EDITORSUPPORT_EVENTSPYADAPTOR_H +#ifndef KTUTORIAL_EDITORSUPPORT_EVENTSPYADAPTOR_H +#define KTUTORIAL_EDITORSUPPORT_EVENTSPYADAPTOR_H #include <QDBusAbstractAdaptor> +namespace ktutorial { namespace editorsupport { class EventSpy; class ObjectRegister; } +} +namespace ktutorial { namespace editorsupport { /** @@ -79,5 +82,6 @@ }; } +} #endif Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -18,6 +18,7 @@ #include "ObjectRegister.h" +namespace ktutorial { namespace editorsupport { //public: @@ -83,3 +84,4 @@ } } +} Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegister.h 2012-08-11 01:33:20 UTC (rev 368) @@ -16,12 +16,13 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifndef EDITORSUPPORT_OBJECTREGISTER_H -#define EDITORSUPPORT_OBJECTREGISTER_H +#ifndef KTUTORIAL_EDITORSUPPORT_OBJECTREGISTER_H +#define KTUTORIAL_EDITORSUPPORT_OBJECTREGISTER_H #include <QHash> #include <QObject> +namespace ktutorial { namespace editorsupport { /** @@ -119,5 +120,6 @@ }; } +} #endif Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.cpp 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.cpp 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -19,6 +19,7 @@ #include "ObjectRegisterAdaptor.h" #include "ObjectRegister.h" +namespace ktutorial { namespace editorsupport { //public: @@ -77,3 +78,4 @@ } } +} Modified: trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.h 2012-08-10 18:15:15 UTC (rev 367) +++ trunk/ktutorial/ktutorial-library/src/editorsupport/ObjectRegisterAdaptor.h 2012-08-11 01:33:20 UTC (rev 368) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2012 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -16,15 +16,18 @@ * along with this program; If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ -#ifnd... [truncated message content] |