[Ktutorial-commits] SF.net SVN: ktutorial:[311] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2011-05-24 14:48:30
|
Revision: 311 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=311&view=rev Author: danxuliu Date: 2011-05-24 14:48:23 +0000 (Tue, 24 May 2011) Log Message: ----------- Add support for WaitForStepActivation to wait for its step to be activated. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/data/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.cpp trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.h trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.h trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialReaderTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialWriterTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp Added Paths: ----------- trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.cpp trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.h trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.h trunk/ktutorial/ktutorial-editor/tests/unit/data/WaitForStepActivationTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForStepActivationTreeItemTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/data/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/src/data/CMakeLists.txt 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/data/CMakeLists.txt 2011-05-24 14:48:23 UTC (rev 311) @@ -8,6 +8,7 @@ WaitForNot.cpp WaitForProperty.cpp WaitForSignal.cpp + WaitForStepActivation.cpp WaitForWindow.cpp ) Added: trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -0,0 +1,36 @@ +/*************************************************************************** + * Copyright (C) 2011 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 "WaitForStepActivation.h" + +//public: + +WaitForStepActivation::WaitForStepActivation(QObject* parent): WaitFor(parent) { +} + +WaitFor* WaitForStepActivation::clone() const { + return new WaitForStepActivation(); +} + +bool WaitForStepActivation::equals(const WaitFor& waitFor) const { + if (!qobject_cast<const WaitForStepActivation*>(&waitFor)) { + return false; + } + + return true; +} Property changes on: trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.h 2011-05-24 14:48:23 UTC (rev 311) @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2011 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 WAITFORSTEPACTIVATION_H +#define WAITFORSTEPACTIVATION_H + +#include "WaitFor.h" + +/** + * Container for conditions that wait for their step to be activated data. + * It stores the data used in KTutorial WaitForStepActivation, but it has + * nothing to do with it (they don't even know each other). Its purpose is store + * the data needed to generate the code to initialize a true + * KTutorial::WaitForStepActivation object. + * + * However, it contains no attributes as WaitForStepActivation only makes sense + * to be used with the step and tutorial that contains it, and those are set + * when the tutorial is exported without needing a explicit attribute. + */ +class WaitForStepActivation: public WaitFor { +Q_OBJECT +public: + + /** + * Creates a new WaitForStepActivation. + * + * @param parent The parent QObject. + */ + WaitForStepActivation(QObject* parent = 0); + + virtual WaitFor* clone() const; + virtual bool equals(const WaitFor& waitFor) const; + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/data/WaitForStepActivation.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -31,6 +31,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" //public: @@ -277,6 +278,9 @@ if (qobject_cast<const WaitForSignal*>(waitFor)) { return writeWaitFor(static_cast<const WaitForSignal*>(waitFor)); } + if (qobject_cast<const WaitForStepActivation*>(waitFor)) { + return writeWaitFor(static_cast<const WaitForStepActivation*>(waitFor)); + } if (qobject_cast<const WaitForWindow*>(waitFor)) { return writeWaitFor(static_cast<const WaitForWindow*>(waitFor)); } @@ -408,6 +412,19 @@ return variable; } +QString JavascriptExporter::writeWaitFor( + const WaitForStepActivation* waitForStepActivation) { + Q_UNUSED(waitForStepActivation); + + QString variable = addVariable("waitForStepActivation"); + + out() << variable + << " = ktutorial.newWaitFor(\"WaitForStepActivation\");\n"; + out() << variable << ".setStep(tutorial, step);\n"; + + return variable; +} + QString JavascriptExporter::writeWaitFor(const WaitForWindow* waitForWindow) { if (waitForWindow->windowObjectName().isEmpty()) { out() << "//Error: WaitForWindow without window object name!\n"; Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2011-05-24 14:48:23 UTC (rev 311) @@ -32,6 +32,7 @@ class WaitForNot; class WaitForProperty; class WaitForSignal; +class WaitForStepActivation; class WaitForWindow; /** @@ -230,6 +231,14 @@ QString writeWaitFor(const WaitForSignal* waitForSignal); /** + * Writes the code to create and set a WaitForStepActivation. + * + * @param waitForStepActivation The WaitForStepActivation. + * @return The name of the variable that holds the WaitFor. + */ + QString writeWaitFor(const WaitForStepActivation* waitForStepActivation); + + /** * Writes the code to create and set a WaitForWindow. * If the window object name isn't set, an error message is written instead, * and an empty string returned. Modified: trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -30,6 +30,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" //public: @@ -172,6 +173,9 @@ if (element.tagName() == "waitForSignal") { return readWaitForSignal(element); } + if (element.tagName() == "waitForStepActivation") { + return readWaitForStepActivation(element); + } if (element.tagName() == "waitForWindow") { return readWaitForWindow(element); } @@ -262,6 +266,12 @@ return waitForSignal; } +WaitFor* TutorialReader::readWaitForStepActivation(const QDomElement& element) { + Q_UNUSED(element); + + return new WaitForStepActivation(); +} + WaitFor* TutorialReader::readWaitForWindow(const QDomElement& element) { WaitForWindow* waitForWindow = new WaitForWindow(); @@ -279,6 +289,7 @@ element.tagName() != "waitForNot" && element.tagName() != "waitForProperty" && element.tagName() != "waitForSignal" && + element.tagName() != "waitForStepActivation" && element.tagName() != "waitForWindow") { return false; } Modified: trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.h 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/serialization/TutorialReader.h 2011-05-24 14:48:23 UTC (rev 311) @@ -33,6 +33,7 @@ class WaitForNot; class WaitForProperty; class WaitForSignal; +class WaitForStepActivation; class WaitForWindow; /** @@ -145,6 +146,15 @@ WaitFor* readWaitForSignal(const QDomElement& element); /** + * Reads a new WaitForStepActivation from the "waitForStepActivation" XML + * element. + * + * @param element The element to read the WaitForStepActivation from. + * @return The new WaitForStepActivation. + */ + WaitFor* readWaitForStepActivation(const QDomElement& element); + + /** * Reads a new WaitForWindow from the "waitForWindow" XML element. * * @param element The element to read the WaitForWindow from. Modified: trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -26,6 +26,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" //public: @@ -158,6 +159,10 @@ write(static_cast<const WaitForSignal*>(waitFor)); return; } + if (qobject_cast<const WaitForStepActivation*>(waitFor)) { + write(static_cast<const WaitForStepActivation*>(waitFor)); + return; + } if (qobject_cast<const WaitForWindow*>(waitFor)) { write(static_cast<const WaitForWindow*>(waitFor)); return; @@ -230,6 +235,10 @@ } } +void TutorialWriter::write(const WaitForStepActivation* waitForStepActivation) { + mXmlWriter->writeEmptyElement("waitForStepActivation"); +} + void TutorialWriter::write(const WaitForWindow* waitForWindow) { mXmlWriter->writeEmptyElement("waitForWindow"); Modified: trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.h 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/serialization/TutorialWriter.h 2011-05-24 14:48:23 UTC (rev 311) @@ -30,6 +30,7 @@ class WaitForNot; class WaitForProperty; class WaitForSignal; +class WaitForStepActivation; class WaitForWindow; /** @@ -131,6 +132,14 @@ void write(const WaitForSignal* waitForSignal); /** + * Writes the XML serialization of the given WaitForStepActivation. + * + * @param waitForStepActivation The WaitForStepActivation to get its XML + * serialization. + */ + void write(const WaitForStepActivation* WaitForStepActivation); + + /** * Writes the XML serialization of the given WaitForWindow. * * @param waitForWindow The WaitForWindow to get its XML serialization. Modified: trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/view/CMakeLists.txt 2011-05-24 14:48:23 UTC (rev 311) @@ -31,6 +31,7 @@ WaitForPropertyWidget.cpp WaitForSignalTreeItem.cpp WaitForSignalWidget.cpp + WaitForStepActivationTreeItem.cpp WaitForTreeItem.cpp WaitForWidget.cpp WaitForWindowTreeItem.cpp Modified: trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -24,6 +24,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" //public: @@ -58,6 +59,8 @@ return new WaitForWindow(); } else if (index == 6) { return new WaitForProperty(); + } else if (index == 7) { + return new WaitForStepActivation(); } return 0; Modified: trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/view/NewWaitForWidget.ui 2011-05-24 14:48:23 UTC (rev 311) @@ -76,6 +76,11 @@ <string comment="@item:inlistbox">The specified property has certain value</string> </property> </item> + <item> + <property name="text"> + <string comment="@item:inlistbox">The step is activated</string> + </property> + </item> </widget> </item> </layout> Added: trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -0,0 +1,35 @@ +/*************************************************************************** + * Copyright (C) 2011 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 "WaitForStepActivationTreeItem.h" + +#include <KLocalizedString> + +#include "../data/WaitForStepActivation.h" + +//public: + +WaitForStepActivationTreeItem::WaitForStepActivationTreeItem( + WaitForStepActivation* waitForStepActivation, + TreeItem* parent): + WaitForTreeItem(waitForStepActivation, parent) { +} + +QString WaitForStepActivationTreeItem::text() const { + return i18nc("@item", "When the step is activated"); +} Property changes on: trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.h 2011-05-24 14:48:23 UTC (rev 311) @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (C) 2011 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 WAITFORSTEPACTIVATIONTREEITEM_H +#define WAITFORSTEPACTIVATIONTREEITEM_H + +#include "WaitForTreeItem.h" + +class WaitForStepActivation; + +/** + * A TreeItem that represents a WaitForStepActivation. + * The tree representation of a WaitForStepActivation is a plain text: + * When the step is activated + */ +class WaitForStepActivationTreeItem: public WaitForTreeItem { +Q_OBJECT +public: + + /** + * Creates a new WaitForStepActivationTreeItem for the given + * WaitForStepActivation and with the given parent. + * + * @param waitForStepActivation The WaitForStepActivation to represent. + * @param parent The parent TreeItem. + */ + explicit WaitForStepActivationTreeItem( + WaitForStepActivation* waitForStepActivation, + TreeItem* parent = 0); + + /** + * Returns the description of the WaitForStepActivation. + * + * @return The text for this TreeItem. + */ + virtual QString text() const; + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/view/WaitForStepActivationTreeItem.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForTreeItem.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -22,12 +22,14 @@ #include "WaitForNotTreeItem.h" #include "WaitForPropertyTreeItem.h" #include "WaitForSignalTreeItem.h" +#include "WaitForStepActivationTreeItem.h" #include "WaitForWindowTreeItem.h" #include "../data/WaitForComposed.h" #include "../data/WaitForEvent.h" #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" //public: @@ -59,6 +61,11 @@ parent); } + if (qobject_cast<WaitForStepActivation*>(waitFor)) { + return new WaitForStepActivationTreeItem( + static_cast<WaitForStepActivation*>(waitFor), parent); + } + if (qobject_cast<WaitForWindow*>(waitFor)) { return new WaitForWindowTreeItem(static_cast<WaitForWindow*>(waitFor), parent); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -34,6 +34,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" //public: @@ -150,6 +151,14 @@ return; } + if (qobject_cast<WaitForStepActivation*>(selectedWaitFor)) { + ui->addButton->setEnabled(false); + ui->editButton->setEnabled(false); + ui->removeButton->setEnabled(true); + + return; + } + if (qobject_cast<WaitForWindow*>(selectedWaitFor)) { ui->addButton->setEnabled(false); ui->editButton->setEnabled(true); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWidget.h 2011-05-24 14:48:23 UTC (rev 311) @@ -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 * @@ -38,7 +38,7 @@ * as a child of a composed WaitFor (selecting the one that will be its parent). * * A WaitFor can be edited if it is a plain condition, that is, it is not - * composed from other WaitFors. + * composed from other WaitFors, and it is not a WaitForStepActivation. * * Finally, any WaitFor can be removed. * Modified: trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/data/CMakeLists.txt 2011-05-24 14:48:23 UTC (rev 311) @@ -21,6 +21,7 @@ WaitForNot WaitForProperty WaitForSignal + WaitForStepActivation WaitForWindow ) @@ -40,5 +41,6 @@ WaitForNot WaitForProperty WaitForSignal + WaitForStepActivation WaitForWindow ) Added: trunk/ktutorial/ktutorial-editor/tests/unit/data/WaitForStepActivationTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/data/WaitForStepActivationTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/data/WaitForStepActivationTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -0,0 +1,91 @@ +/*************************************************************************** + * Copyright (C) 2011 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> + +#include "WaitForStepActivation.h" + +class WaitForStepActivationTest: public QObject { +Q_OBJECT + +private slots: + + void testConstructor(); + + void testClone(); + + void testEquals(); + +}; + +class StubWaitFor: public WaitFor { +Q_OBJECT +public: + + int mValue; + + StubWaitFor(int value = 0): mValue(value) { + } + + virtual WaitFor* clone() const { + return new StubWaitFor(mValue); + } + + virtual bool equals(const WaitFor& waitFor) const { + if (!qobject_cast<const StubWaitFor*>(&waitFor)) { + return false; + } + + return mValue == static_cast<const StubWaitFor*>(&waitFor)->mValue; + } +}; + +void WaitForStepActivationTest::testConstructor() { + QObject parent; + WaitForStepActivation* waitForStepActivation = + new WaitForStepActivation(&parent); + + QCOMPARE(waitForStepActivation->parent(), &parent); +} + +void WaitForStepActivationTest::testClone() { + WaitForStepActivation waitForStepActivation; + + WaitForStepActivation* cloned = static_cast<WaitForStepActivation*> + (waitForStepActivation.clone()); + + QVERIFY(cloned); + QVERIFY(cloned != &waitForStepActivation); + delete cloned; +} + +void WaitForStepActivationTest::testEquals() { + WaitForStepActivation waitForStepActivation1; + WaitForStepActivation waitForStepActivation2; + + QCOMPARE(waitForStepActivation1 == waitForStepActivation2, true); + QCOMPARE(waitForStepActivation2 == waitForStepActivation1, true); + + StubWaitFor stubWaitFor; + + QCOMPARE(waitForStepActivation1 == stubWaitFor, false); +} + +QTEST_MAIN(WaitForStepActivationTest) + +#include "WaitForStepActivationTest.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/data/WaitForStepActivationTest.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -28,6 +28,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" #define TUTORIAL_EMPTY_INFORMATION_CODE \ @@ -96,6 +97,7 @@ void testWaitForSignal(); void testWaitForSignalWithEscapeSequences(); void testWaitForSignalWithoutEmitterNameOrSignalName(); + void testWaitForStepActivation(); void testWaitForWindow(); void testWaitForWindowWithEscapeSequences(); void testWaitForWindowWithoutWindowObjectName(); @@ -1410,6 +1412,38 @@ QCOMPARE(exportedTutorial, expected); } +void JavascriptExporterTest::testWaitForStepActivation() { + Tutorial tutorial; + Step* step = new Step(); + step->setId("The id"); + tutorial.addStep(step); + + WaitForStepActivation* waitForStepActivation = new WaitForStepActivation(); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForStepActivation); + reaction->setResponseType(Reaction::NextStep); + reaction->setNextStepId("Another step"); + step->addReaction(reaction); + + JavascriptExporter exporter; + QString exportedTutorial = exporter.exportTutorial(&tutorial); + + QString expected = +TUTORIAL_EMPTY_INFORMATION_CODE +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE +"function theIdStepSetup(step) {\n" +" waitForStepActivation = ktutorial.newWaitFor(\"WaitForStepActivation\");\n" +" waitForStepActivation.setStep(tutorial, step);\n" +" step.addWaitFor(waitForStepActivation, \"Another step\");\n" +"}\n" +CONNECT_STEP_SETUP +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; + + QCOMPARE(exportedTutorial, expected); +} + void JavascriptExporterTest::testWaitForWindow() { Tutorial tutorial; Step* step = new Step(); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialReaderTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialReaderTest.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialReaderTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -30,6 +30,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" #define HEADER_XML \ @@ -92,6 +93,7 @@ void testWaitForPropertyEmpty(); void testWaitForSignal(); void testWaitForSignalEmpty(); + void testWaitForStepActivation(); void testWaitForWindow(); void testWaitForWindowEmpty(); void testWaitForComposed(); @@ -441,6 +443,21 @@ assertWaitForSignal(waitFor, "", ""); } +void TutorialReaderTest::testWaitForStepActivation() { + QString data = +WAITFOR_PARENT_START +" <waitForStepActivation/>\n" +WAITFOR_PARENT_END; + + TutorialReader reader; + QScopedPointer<Tutorial> tutorial(reader.readTutorial(data)); + WaitFor* waitFor = tutorial->steps()[0]->reactions()[0]->waitFor(); + + WaitForStepActivation* waitForStepActivation = + qobject_cast<WaitForStepActivation*>(waitFor); + QVERIFY(waitForStepActivation); +} + void TutorialReaderTest::testWaitForWindow() { QString data = WAITFOR_PARENT_START Modified: trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialWriterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialWriterTest.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/serialization/TutorialWriterTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -28,6 +28,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" #define HEADER_XML \ @@ -90,6 +91,7 @@ void testWaitForPropertyEmpty(); void testWaitForSignal(); void testWaitForSignalEmpty(); + void testWaitForStepActivation(); void testWaitForWindow(); void testWaitForWindowEmpty(); void testWaitForComposed(); @@ -499,6 +501,30 @@ QCOMPARE(savedTutorial, expected); } +void TutorialWriterTest::testWaitForStepActivation() { + Tutorial tutorial; + Step* step = new Step(); + tutorial.addStep(step); + + WaitForStepActivation* waitForStepActivation = new WaitForStepActivation(); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForStepActivation); + reaction->setResponseType(Reaction::NextStep); + step->addReaction(reaction); + + TutorialWriter saver; + QString savedTutorial = saver.writeTutorial(&tutorial); + + QString expected = +WAITFOR_PARENT_START +" <waitForStepActivation/>\n" +WAITFOR_PARENT_END; + + QCOMPARE(savedTutorial, expected); +} + void TutorialWriterTest::testWaitForWindow() { Tutorial tutorial; Step* step = new Step(); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/CMakeLists.txt 2011-05-24 14:48:23 UTC (rev 311) @@ -48,6 +48,7 @@ WaitForPropertyWidget WaitForSignalTreeItem WaitForSignalWidget + WaitForStepActivationTreeItem WaitForTreeItem WaitForWidget WaitForWindowTreeItem @@ -106,6 +107,7 @@ WaitForPropertyWidget WaitForSignalTreeItem WaitForSignalWidget + WaitForStepActivationTreeItem WaitForTreeItem WaitForWidget WaitForWindowTreeItem Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/NewWaitForWidgetTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -27,6 +27,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" class NewWaitForWidgetTest: public QObject { @@ -43,6 +44,7 @@ void testWaitForWhenEventConditionIsSelected(); void testWaitForWhenWindowConditionIsSelected(); void testWaitForWhenPropertyConditionIsSelected(); + void testWaitForWhenStepActivationConditionIsSelected(); private: @@ -129,6 +131,17 @@ delete waitFor; } +void NewWaitForWidgetTest::testWaitForWhenStepActivationConditionIsSelected() { + NewWaitForWidget widget; + + selectOption(&widget, 7); + + WaitForStepActivation* waitFor = + qobject_cast<WaitForStepActivation*>(widget.waitFor()); + QVERIFY(waitFor); + delete waitFor; +} + /////////////////////////////////// Helpers //////////////////////////////////// void NewWaitForWidgetTest::selectOption(NewWaitForWidget* widget, Added: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForStepActivationTreeItemTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForStepActivationTreeItemTest.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForStepActivationTreeItemTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2011 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> + +#include "WaitForStepActivationTreeItem.h" + +#include <KLocalizedString> + +#include "../data/WaitForStepActivation.h" + +class WaitForStepActivationTreeItemTest: public QObject { +Q_OBJECT + +private slots: + + void testConstructor(); + +}; + +class StubTreeItem: public TreeItem { +public: + virtual QString text() const { + return ""; + } +}; + +void WaitForStepActivationTreeItemTest::testConstructor() { + WaitForStepActivation waitForStepActivation; + + StubTreeItem parent; + WaitForStepActivationTreeItem item(&waitForStepActivation, &parent); + + QCOMPARE(item.parent(), &parent); + QCOMPARE(item.waitFor(), &waitForStepActivation); + QCOMPARE(item.text(), i18nc("@item", "When the step is activated")); +} + +QTEST_MAIN(WaitForStepActivationTreeItemTest) + +#include "WaitForStepActivationTreeItemTest.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForStepActivationTreeItemTest.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForTreeItemTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -25,6 +25,7 @@ #include "WaitForNotTreeItem.h" #include "WaitForPropertyTreeItem.h" #include "WaitForSignalTreeItem.h" +#include "WaitForStepActivationTreeItem.h" #include "WaitForWindowTreeItem.h" #include "../data/WaitFor.h" #include "../data/WaitForComposed.h" @@ -32,6 +33,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" class WaitForTreeItemTest: public QObject { @@ -46,6 +48,7 @@ void testTreeItemForWaitForNot(); void testTreeItemForWaitForProperty(); void testTreeItemForWaitForSignal(); + void testTreeItemForWaitForStepActivation(); void testTreeItemForWaitForWindow(); }; @@ -164,6 +167,20 @@ delete item; } +void WaitForTreeItemTest::testTreeItemForWaitForStepActivation() { + WaitForStepActivation waitFor; + StubTreeItem parent; + + WaitForTreeItem* item = WaitForTreeItem::treeItemForWaitFor(&waitFor, + &parent); + + QVERIFY(qobject_cast<WaitForStepActivationTreeItem*>(item)); + QCOMPARE(item->parent(), &parent); + QCOMPARE(item->waitFor(), &waitFor); + + delete item; +} + void WaitForTreeItemTest::testTreeItemForWaitForWindow() { WaitForWindow waitFor; StubTreeItem parent; Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp 2011-05-24 14:41:54 UTC (rev 310) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForWidgetTest.cpp 2011-05-24 14:48:23 UTC (rev 311) @@ -32,6 +32,7 @@ #include "../data/WaitForNot.h" #include "../data/WaitForProperty.h" #include "../data/WaitForSignal.h" +#include "../data/WaitForStepActivation.h" #include "../data/WaitForWindow.h" class WaitForWidgetTest: public QObject { @@ -61,6 +62,7 @@ void testSelectWaitForEvent(); void testSelectWaitForProperty(); void testSelectWaitForSignal(); + void testSelectWaitForStepActivation(); void testSelectWaitForWindow(); void testClearSelection(); @@ -86,6 +88,7 @@ WaitForEvent* mWaitFor2_1; WaitForWindow* mWaitFor2_2; WaitForProperty* mWaitFor2_3; + WaitForStepActivation* mWaitFor2_4; WaitForNot* mWaitFor3; WaitForSignal* mWaitFor3_1; WaitForNot* mWaitFor4; @@ -134,6 +137,9 @@ mWaitFor2_3->setValue("value"); mWaitFor2->addWaitFor(mWaitFor2_3); + mWaitFor2_4 = new WaitForStepActivation(); + mWaitFor2->addWaitFor(mWaitFor2_4); + mWaitFor3 = new WaitForNot(); mWaitFor->addWaitFor(mWaitFor3); @@ -213,6 +219,12 @@ assertButtonEnabled(false, true, true); } +void WaitForWidgetTest::testSelectWaitForStepActivation() { + selectItem(getIndex(3, getIndex(1, getIndex(0)))); + + assertButtonEnabled(false, false, true); +} + void WaitForWidgetTest::testSelectWaitForWindow() { selectItem(getIndex(1, getIndex(1, getIndex(0)))); @@ -267,12 +279,13 @@ QCOMPARE(mWaitFor->waitFors()[2], mWaitFor3); QCOMPARE(mWaitFor->waitFors()[3], mWaitFor4); QVERIFY(qobject_cast<WaitForSignal*>(mWaitFor->waitFors()[4])); - QCOMPARE(mWaitFor2->waitFors().count(), 4); + QCOMPARE(mWaitFor2->waitFors().count(), 5); QCOMPARE(mWaitFor2->waitFors()[0], mWaitFor2_1); QCOMPARE(mWaitFor2->waitFors()[1], mWaitFor2_2); QCOMPARE(mWaitFor2->waitFors()[2], mWaitFor2_3); - QVERIFY(qobject_cast<WaitForSignal*>(mWaitFor2->waitFors()[3])); - QVERIFY(mWaitFor->waitFors()[4] != mWaitFor2->waitFors()[3]); + QCOMPARE(mWaitFor2->waitFors()[3], mWaitFor2_4); + QVERIFY(qobject_cast<WaitForSignal*>(mWaitFor2->waitFors()[4])); + QVERIFY(mWaitFor->waitFors()[4] != mWaitFor2->waitFors()[4]); } void WaitForWidgetTest::testAddWaitForToWaitForNot() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |