Thread: [Ktutorial-commits] SF.net SVN: ktutorial:[308] trunk/ktutorial/ktutorial-editor (Page 4)
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2011-05-16 22:44:42
|
Revision: 308 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=308&view=rev Author: danxuliu Date: 2011-05-16 22:44:36 +0000 (Mon, 16 May 2011) Log Message: ----------- Provide completion in the property line edit in WaitForPropertyWidget with the properties of the chosen RemoteObject. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.cpp trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.h trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.cpp 2011-05-16 22:42:33 UTC (rev 307) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.cpp 2011-05-16 22:44:36 UTC (rev 308) @@ -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 * @@ -50,6 +50,15 @@ return mMapper->remoteClass(reply.value()); } +QStringList RemoteClass::propertyList() throw (DBusException) { + QDBusReply<QStringList> reply = call("propertyList", mClassName); + if (!reply.isValid()) { + throw DBusException(reply.error().message()); + } + + return reply.value(); +} + QStringList RemoteClass::signalList() throw (DBusException) { QDBusReply<QStringList> reply = call("signalList", mClassName); if (!reply.isValid()) { Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.h 2011-05-16 22:42:33 UTC (rev 307) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteClass.h 2011-05-16 22:44:36 UTC (rev 308) @@ -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 * @@ -73,6 +73,16 @@ RemoteClass* superClass() throw (DBusException); /** + * Returns a list with the properties defined in the remote class. + * The list only includes the properties from the class itself, but not its + * super classes. + * + * @return The properties. + * @throws DBusException If a DBus error happens. + */ + QStringList propertyList() throw (DBusException); + + /** * Returns a list with the signals defined in the remote class. * The list only includes the signals from the class itself, but not its * super classes. Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp 2011-05-16 22:42:33 UTC (rev 307) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp 2011-05-16 22:44:36 UTC (rev 308) @@ -22,7 +22,11 @@ #include "../data/WaitForProperty.h" #ifdef QT_QTDBUS_FOUND +#include <KDebug> + #include "RemoteObjectNameWidget.h" +#include "../targetapplication/RemoteClass.h" +#include "../targetapplication/RemoteObject.h" #endif //public: @@ -48,6 +52,9 @@ ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + connect(mRemoteObjectNameWidget, SIGNAL(remoteObjectChosen(RemoteObject*)), + this, SLOT(setChosenRemoteObject(RemoteObject*))); + mRemoteObjectNameWidget->setName(waitForProperty->objectName()); #else ui->objectNameLineEdit->setText(waitForProperty->objectName()); @@ -82,3 +89,41 @@ mWaitForProperty->setValue(value); } } + +//private: + +#ifdef QT_QTDBUS_FOUND +void WaitForPropertyWidget::setPropertyCompletion(RemoteClass* remoteClass) +throw (DBusException) { + KCompletion* completion = ui->propertyNameLineEdit->completionObject(); + completion->clear(); + completion->setOrder(KCompletion::Sorted); + + while (remoteClass) { + foreach (const QString& property, remoteClass->propertyList()) { + completion->addItem(property); + } + + remoteClass = remoteClass->superClass(); + } +} +#endif + +//private slots: + +#ifdef QT_QTDBUS_FOUND +void WaitForPropertyWidget::setChosenRemoteObject(RemoteObject* remoteObject) { + if (!remoteObject) { + setPropertyCompletion(0); + return; + } + + try { + setPropertyCompletion(remoteObject->remoteClass()); + } catch (DBusException e) { + kWarning() << "The property completion could not be set, there was a " + << "problem getting the class of the remote object (" + << e.message() << ")."; + } +} +#endif Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.h 2011-05-16 22:42:33 UTC (rev 307) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.h 2011-05-16 22:44:36 UTC (rev 308) @@ -22,6 +22,10 @@ #include "EditionWidget.h" #ifdef QT_QTDBUS_FOUND +#include "../targetapplication/DBusException.h" + +class RemoteClass; +class RemoteObject; class RemoteObjectNameWidget; #endif @@ -75,8 +79,28 @@ * The widget to get the name of a remote object. */ RemoteObjectNameWidget* mRemoteObjectNameWidget; + + /** + * Sets the completion of the property line edit to the properties contained + * in the given remote class and its super classes. + * + * @param remoteClass The class to get its property list. + */ + void setPropertyCompletion(RemoteClass* remoteClass) throw (DBusException); #endif +private slots: + +#ifdef QT_QTDBUS_FOUND + /** + * Sets the completion for the property names based in the chosen remote + * object. + * + * @param remoteObject The chosen RemoteObject. + */ + void setChosenRemoteObject(RemoteObject* remoteObject); +#endif + }; #endif Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2011-05-16 22:42:33 UTC (rev 307) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2011-05-16 22:44:36 UTC (rev 308) @@ -59,6 +59,15 @@ return ""; } + QStringList propertyList(const QString& className) { + QStringList propertyList; + for (int i=0; i<3; ++i) { + propertyList.append(className + "Property" + QString::number(i)); + } + + return propertyList; + } + QStringList signalList(const QString& className) { QStringList signalList; for (int i=0; i<3; ++i) { Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassTest.cpp 2011-05-16 22:42:33 UTC (rev 307) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassTest.cpp 2011-05-16 22:44:36 UTC (rev 308) @@ -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 * @@ -49,6 +49,9 @@ void testSuperClass(); void testSuperClassWhenRemoteClassIsNotAvailable(); + void testPropertyList(); + void testPropertyListWhenRemoteClassIsNotAvailable(); + void testSignalList(); void testSignalListWhenRemoteClassIsNotAvailable(); @@ -100,6 +103,24 @@ EXPECT_EXCEPTION(remoteClass.superClass(), DBusException); } +void RemoteClassTest::testPropertyList() { + RemoteClass remoteClass(mService, mMapper, "Class"); + + QStringList propertyList = remoteClass.propertyList(); + QCOMPARE(propertyList.count(), 3); + QCOMPARE(propertyList[0], QString("ClassProperty0")); + QCOMPARE(propertyList[1], QString("ClassProperty1")); + QCOMPARE(propertyList[2], QString("ClassProperty2")); +} + +void RemoteClassTest::testPropertyListWhenRemoteClassIsNotAvailable() { + RemoteClass remoteClass(mService, mMapper, "Class"); + + QDBusConnection::sessionBus().unregisterObject("/ktutorial/ObjectRegister"); + + EXPECT_EXCEPTION(remoteClass.propertyList(), DBusException); +} + void RemoteClassTest::testSignalList() { RemoteClass remoteClass(mService, mMapper, "Class"); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp 2011-05-16 22:42:33 UTC (rev 307) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp 2011-05-16 22:44:36 UTC (rev 308) @@ -24,23 +24,57 @@ #include "../data/WaitForProperty.h" +#ifdef QT_QTDBUS_FOUND +#define protected public +#define private public +#include "../targetapplication/TargetApplication.h" +#undef private +#undef protected +#endif + class WaitForPropertyWidgetTest: public QObject { Q_OBJECT private slots: + void init(); + void cleanup(); + void testConstructor(); void testSaveChanges(); + void testPropertyNameCompletion(); + private: + QString mTargetApplicationStubPath; + KLineEdit* objectNameLineEdit(WaitForPropertyWidget* widget) const; KLineEdit* propertyNameLineEdit(WaitForPropertyWidget* widget) const; KLineEdit* valueLineEdit(WaitForPropertyWidget* widget) const; }; +void WaitForPropertyWidgetTest::init() { +#ifdef QT_QTDBUS_FOUND + mTargetApplicationStubPath = QApplication::applicationDirPath() + + "/../targetapplication/TargetApplicationStub"; + + //Avoid signals from previous tests to be delivered to the next ones + //setting a new TargetApplication + delete TargetApplication::sSelf; + TargetApplication::sSelf = new TargetApplication(); +#endif +} + +void WaitForPropertyWidgetTest::cleanup() { +#ifdef QT_QTDBUS_FOUND + delete TargetApplication::sSelf; + TargetApplication::sSelf = 0; +#endif +} + void WaitForPropertyWidgetTest::testConstructor() { WaitForProperty waitFor; waitFor.setObjectName("The object name"); @@ -76,6 +110,35 @@ QCOMPARE(waitFor.value(), QString("The new value")); } +void WaitForPropertyWidgetTest::testPropertyNameCompletion() { +#ifdef QT_QTDBUS_FOUND + TargetApplication::self()->setTargetApplicationFilePath( + mTargetApplicationStubPath); + TargetApplication::self()->start(); + + //Give the target application time to start + QTest::qWait(1000); + + WaitForProperty waitFor; + WaitForPropertyWidget widget(&waitFor); + + objectNameLineEdit(&widget)->setText("The object name 830"); + + KCompletion* completion = propertyNameLineEdit(&widget)->completionObject(); + QStringList items = completion->items(); + QCOMPARE(items.count(), 6); + QCOMPARE(items[0], QString("ChildQWidgetProperty0")); + QCOMPARE(items[1], QString("ChildQWidgetProperty1")); + QCOMPARE(items[2], QString("ChildQWidgetProperty2")); + QCOMPARE(items[3], QString("QWidgetProperty0")); + QCOMPARE(items[4], QString("QWidgetProperty1")); + QCOMPARE(items[5], QString("QWidgetProperty2")); +#else + QSKIP("Property name completion is only available when KTutorial editor is " + "compiled with DBus support", SkipAll); +#endif +} + /////////////////////////////////// Helpers //////////////////////////////////// KLineEdit* WaitForPropertyWidgetTest::objectNameLineEdit( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-05-24 14:33:14
|
Revision: 309 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=309&view=rev Author: danxuliu Date: 2011-05-24 14:33:07 +0000 (Tue, 24 May 2011) Log Message: ----------- Change WaitForPropertyTreeItem text from "When the property (...) changes to the value (...)" to "When the property (...) has the value (...)". Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.h trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyTreeItemTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.cpp 2011-05-16 22:44:36 UTC (rev 308) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.cpp 2011-05-24 14:33:07 UTC (rev 309) @@ -58,8 +58,8 @@ value = mValue; } - return i18nc("@item", "When the property %1 in the object %2 changes to " - "the value %3", propertyName, objectName, value); + return i18nc("@item", "When the property %1 in the object %2 has the value " + "%3", propertyName, objectName, value); } //private: Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.h 2011-05-16 22:44:36 UTC (rev 308) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyTreeItem.h 2011-05-24 14:33:07 UTC (rev 309) @@ -26,8 +26,8 @@ /** * A TreeItem that represents a WaitForProperty. * The tree representation of a WaitForProperty is a plain text: - * When the property "property name" in the object "object name" changes to the - * value value + * When the property "property name" in the object "object name" has the value + * value * * If the property, the object name or the value aren't set yet, a placeholder * is put instead. Property placeholder is "(property not set)", the object name Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyTreeItemTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyTreeItemTest.cpp 2011-05-16 22:44:36 UTC (rev 308) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyTreeItemTest.cpp 2011-05-24 14:33:07 UTC (rev 309) @@ -74,8 +74,7 @@ QCOMPARE(item.waitFor(), &waitForProperty); QCOMPARE(item.text(), i18nc("@item", "When the property (property not set) " "in the object (object name not set) " - "changes to the value (value not " - "set)")); + "has the value (value not set)")); } void WaitForPropertyTreeItemTest::testConstructorFull() { @@ -90,8 +89,8 @@ QCOMPARE(item.parent(), &parent); QCOMPARE(item.waitFor(), &waitForProperty); QCOMPARE(item.text(), i18nc("@item", "When the property \"propertyName\" " - "in the object \"objectName\" changes " - "to the value theValue")); + "in the object \"objectName\" has the " + "value theValue")); } void WaitForPropertyTreeItemTest::testWaitForPropertySetObjectName() { @@ -101,8 +100,8 @@ WaitForPropertyTreeItem item(&waitForProperty); QCOMPARE(item.text(), i18nc("@item", "When the property (property not set) " - "in the object \"objectName\" changes " - "to the value (value not set)")); + "in the object \"objectName\" has the " + "value (value not set)")); } void WaitForPropertyTreeItemTest::testWaitForPropertySetObjectNameChange() { @@ -117,8 +116,7 @@ QCOMPARE(item.text(), i18nc("@item", "When the property (property not set) " "in the object \"objectNameChanged\" " - "changes to the value (value not " - "set)")); + "has the value (value not set)")); QCOMPARE(dataChangedSpy.count(), 1); assertDataChanged(dataChangedSpy, 0, &item); } @@ -131,8 +129,7 @@ QCOMPARE(item.text(), i18nc("@item", "When the property \"propertyName\" " "in the object (object name not set) " - "changes to the value (value not " - "set)")); + "has the value (value not set)")); } void WaitForPropertyTreeItemTest::testWaitForPropertySetPropertyNameChange() { @@ -147,8 +144,8 @@ QCOMPARE(item.text(), i18nc("@item", "When the property " "\"propertyNameChanged\" in the " - "object (object name not set) changes " - "to the value (value not set)")); + "object (object name not set) has the " + "value (value not set)")); QCOMPARE(dataChangedSpy.count(), 1); assertDataChanged(dataChangedSpy, 0, &item); } @@ -161,7 +158,7 @@ QCOMPARE(item.text(), i18nc("@item", "When the property (property not set) " "in the object (object name not set) " - "changes to the value theValue")); + "has the value theValue")); } void WaitForPropertyTreeItemTest::testWaitForPropertySetValueChange() { @@ -176,8 +173,7 @@ QCOMPARE(item.text(), i18nc("@item", "When the property (property not set) " "in the object (object name not set) " - "changes to the value " - "\"theValueChanged\"")); + "has the value \"theValueChanged\"")); QCOMPARE(dataChangedSpy.count(), 1); assertDataChanged(dataChangedSpy, 0, &item); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <dan...@us...> - 2011-05-24 21:36:49
|
Revision: 313 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=313&view=rev Author: danxuliu Date: 2011-05-24 21:36:42 +0000 (Tue, 24 May 2011) Log Message: ----------- Set the buddy for object name labels. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -111,6 +111,9 @@ ui = new Ui::RemoteObjectNameWidget(); ui->setupUi(this); + setFocusPolicy(Qt::StrongFocus); + setFocusProxy(ui->objectNameLineEdit); + connect(ui->objectNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(handleNameChanged(QString))); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -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 * @@ -50,6 +50,7 @@ delete ui->receiverNameLineEdit; ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->receiverNameLabel->setBuddy(mRemoteObjectNameWidget); mRemoteObjectNameWidget->setName(waitForEvent->receiverName()); #else Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForEventWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>receiverNameLineEdit</cstring> + </property> </widget> </item> <item> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -51,6 +51,7 @@ delete ui->objectNameLineEdit; ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->objectNameLabel->setBuddy(mRemoteObjectNameWidget); connect(mRemoteObjectNameWidget, SIGNAL(remoteObjectChosen(RemoteObject*)), this, SLOT(setChosenRemoteObject(RemoteObject*))); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForPropertyWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>objectNameLineEdit</cstring> + </property> </widget> </item> <item> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -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 * @@ -53,6 +53,7 @@ delete ui->emitterNameLineEdit; ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->emitterNameLabel->setBuddy(mRemoteObjectNameWidget); connect(mRemoteObjectNameWidget, SIGNAL(remoteObjectChosen(RemoteObject*)), this, SLOT(setChosenRemoteObject(RemoteObject*))); Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForSignalWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>emitterNameLineEdit</cstring> + </property> </widget> </item> <item> Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -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 * @@ -42,6 +42,7 @@ mRemoteObjectNameWidget = new RemoteObjectNameWidget(this); ui->valueVerticalLayout->insertWidget(0, mRemoteObjectNameWidget); + ui->windowObjectNameLabel->setBuddy(mRemoteObjectNameWidget); mRemoteObjectNameWidget->setName(waitForWindow->windowObjectName()); #else Modified: trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/src/view/WaitForWindowWidget.ui 2011-05-24 21:36:42 UTC (rev 313) @@ -33,6 +33,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>windowObjectNameLineEdit</cstring> + </property> </widget> </item> </layout> Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-05-24 16:01:19 UTC (rev 312) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-05-24 21:36:42 UTC (rev 313) @@ -25,6 +25,7 @@ #undef private #undef protected +#include <QLabel> #include <QtDBus/QtDBus> #include <KCompletionBox> @@ -65,6 +66,10 @@ void testAddingOrRemovingRemoteObjects(); + void testSetFocus(); + + void testWidgetAsBuddyOfLabel(); + private: QString mPath; @@ -338,6 +343,56 @@ "burdensome so the test must be done manually", SkipAll); } +void RemoteObjectNameWidgetTest::testSetFocus() { + QWidget parent; + QLineEdit* otherLineEdit = new QLineEdit(&parent); + + RemoteObjectNameWidget* widget = new RemoteObjectNameWidget(&parent); + + //Focus is not set in hidden widgets until they are shown + parent.show(); + + //Give the parent widget time to be shown + QTest::qWait(500); + + otherLineEdit->setFocus(); + + QVERIFY(!widget->hasFocus()); + QVERIFY(!objectNameLineEdit(widget)->hasFocus()); + + widget->setFocus(); + + QVERIFY(widget->hasFocus()); + QVERIFY(objectNameLineEdit(widget)->hasFocus()); +} + +void RemoteObjectNameWidgetTest::testWidgetAsBuddyOfLabel() { + QWidget parent; + QLineEdit* otherLineEdit = new QLineEdit(&parent); + + RemoteObjectNameWidget* widget = new RemoteObjectNameWidget(&parent); + + QLabel* widgetLabel = new QLabel(&parent); + widgetLabel->setText("&Widget label:"); + widgetLabel->setBuddy(widget); + + //Focus is not set in hidden widgets until they are shown + parent.show(); + + //Give the parent widget time to be shown + QTest::qWait(500); + + otherLineEdit->setFocus(); + + QVERIFY(!widget->hasFocus()); + QVERIFY(!objectNameLineEdit(widget)->hasFocus()); + + QTest::keyClick(&parent, Qt::Key_W, Qt::AltModifier); + + QVERIFY(widget->hasFocus()); + QVERIFY(objectNameLineEdit(widget)->hasFocus()); +} + /////////////////////////////////// Helpers //////////////////////////////////// KLineEdit* RemoteObjectNameWidgetTest::objectNameLineEdit( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-05-28 04:00:22
|
Revision: 315 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=315&view=rev Author: danxuliu Date: 2011-05-28 04:00:15 +0000 (Sat, 28 May 2011) Log Message: ----------- Provide completion in the step id line edits. StepDataWidget proposes the unused ids from all the reactions (except for the reactions of the own step), and ReactionWidget proposes the ids of all the steps (except for the step that the reaction belongs to). Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/EditActions.cpp trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.h trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.h trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/EditActions.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/EditActions.cpp 2011-05-25 03:00:55 UTC (rev 314) +++ trunk/ktutorial/ktutorial-editor/src/EditActions.cpp 2011-05-28 04:00:15 UTC (rev 315) @@ -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 * @@ -264,7 +264,8 @@ parentCommand->setText(i18nc("@action", "Add step")); TutorialCommands(mTutorialEditor->tutorial()).addStep(step, parentCommand); - CommandWidget* widget = new StepDataWidget(step); + StepDataWidget* widget = new StepDataWidget(step); + widget->enableStepIdCompletion(mTutorialEditor->tutorial()); widget->setParentUndoCommand(parentCommand); if (showEditionDialog(widget) == QDialog::Rejected) { delete parentCommand; @@ -274,7 +275,9 @@ void EditActions::setStepData() { Q_ASSERT(mCurrentStep); - showEditionDialog(new StepDataWidget(mCurrentStep)); + StepDataWidget* widget = new StepDataWidget(mCurrentStep); + widget->enableStepIdCompletion(mTutorialEditor->tutorial()); + showEditionDialog(widget); } void EditActions::setStepSetup() { @@ -303,7 +306,8 @@ parentCommand->setText(i18nc("@action", "Add reaction")); StepCommands(mCurrentStep).addReaction(reaction, parentCommand); - CommandWidget* widget = new ReactionWidget(reaction); + ReactionWidget* widget = new ReactionWidget(reaction); + widget->enableStepIdCompletion(mTutorialEditor->tutorial(), mCurrentStep); widget->setParentUndoCommand(parentCommand); if (showEditionDialog(widget) == QDialog::Rejected) { delete parentCommand; @@ -313,7 +317,9 @@ void EditActions::setReactionData() { Q_ASSERT(mCurrentReaction); - showEditionDialog(new ReactionWidget(mCurrentReaction)); + ReactionWidget* widget = new ReactionWidget(mCurrentReaction); + widget->enableStepIdCompletion(mTutorialEditor->tutorial()); + showEditionDialog(widget); } void EditActions::removeReaction() { Modified: trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp 2011-05-25 03:00:55 UTC (rev 314) +++ trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.cpp 2011-05-28 04:00:15 UTC (rev 315) @@ -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 * @@ -22,6 +22,8 @@ #include "WaitForWidget.h" #include "../commands/ReactionCommands.h" #include "../data/Reaction.h" +#include "../data/Step.h" +#include "../data/Tutorial.h" #include "../data/WaitFor.h" //public: @@ -75,6 +77,20 @@ delete ui; } +void ReactionWidget::enableStepIdCompletion(const Tutorial* tutorial, + const Step* ownStep /*= 0*/) { + QStringList stepIds; + + foreach (Step* step, tutorial->steps()) { + if (step != ownStep && !step->reactions().contains(mReaction) && + !step->id().isEmpty()) { + stepIds.append(step->id()); + } + } + + ui->responseStepLineEdit->completionObject()->setItems(stepIds); +} + //protected: QList<QUndoCommand*> ReactionWidget::createSaveCommands(QUndoCommand* parent) { Modified: trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.h 2011-05-25 03:00:55 UTC (rev 314) +++ trunk/ktutorial/ktutorial-editor/src/view/ReactionWidget.h 2011-05-28 04:00:15 UTC (rev 315) @@ -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 * @@ -24,6 +24,8 @@ #include "CommandWidget.h" #include "../data/Reaction.h" +class Step; +class Tutorial; class WaitFor; class WaitForWidget; @@ -51,6 +53,17 @@ */ virtual ~ReactionWidget(); + /** + * Enables the text completion for the id of the next step. + * The proposed ids are the ids of every step, except for the one that the + * reaction belongs to or is going to be added to. + * + * @param tutorial The tutorial to get the step ids from. + * @param ownStep The step that the reaction is going to be added to. + */ + void enableStepIdCompletion(const Tutorial* tutorial, + const Step* ownStep = 0); + protected: /** Modified: trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp 2011-05-25 03:00:55 UTC (rev 314) +++ trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.cpp 2011-05-28 04:00:15 UTC (rev 315) @@ -24,7 +24,9 @@ #include "ui_StepDataWidget.h" #include "SemanticMarkupEdition.h" #include "../commands/StepCommands.h" +#include "../data/Reaction.h" #include "../data/Step.h" +#include "../data/Tutorial.h" //public: @@ -53,6 +55,37 @@ delete ui; } +void StepDataWidget::enableStepIdCompletion(const Tutorial* tutorial) { + QStringList usedStepIds; + QStringList nextStepIds; + + foreach (Step* step, tutorial->steps()) { + if (!step->id().isEmpty()) { + usedStepIds.append(step->id()); + } + + if (step == mStep) { + continue; + } + + foreach (Reaction* reaction, step->reactions()) { + if (!reaction->nextStepId().isEmpty()) { + nextStepIds.append(reaction->nextStepId()); + } + } + } + + QStringList unusedStepIds; + + foreach (QString nextStepId, nextStepIds) { + if (!usedStepIds.contains(nextStepId)) { + unusedStepIds.append(nextStepId); + } + } + + ui->idLineEdit->completionObject()->setItems(unusedStepIds); +} + //protected: QList<QUndoCommand*> StepDataWidget::createSaveCommands(QUndoCommand* parent) { Modified: trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.h 2011-05-25 03:00:55 UTC (rev 314) +++ trunk/ktutorial/ktutorial-editor/src/view/StepDataWidget.h 2011-05-28 04:00:15 UTC (rev 315) @@ -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 * @@ -22,6 +22,7 @@ #include "CommandWidget.h" class Step; +class Tutorial; namespace Ui { class StepDataWidget; @@ -47,6 +48,16 @@ */ virtual ~StepDataWidget(); + /** + * Enables the text completion for the id of the step. + * The proposed ids are the unused ids from all the reactions, except for + * those that belong to the step of this StepDataWidget. + * An id is unused if it is not the id of any step added in the tutorial. + * + * @param tutorial The tutorial to get the step ids from. + */ + void enableStepIdCompletion(const Tutorial* tutorial); + protected: /** Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp 2011-05-25 03:00:55 UTC (rev 314) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/ReactionWidgetTest.cpp 2011-05-28 04:00:15 UTC (rev 315) @@ -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 * @@ -31,9 +31,11 @@ #include <KTextEdit> #include "WaitForWidget.h" +#include "../data/Reaction.h" +#include "../data/Step.h" +#include "../data/Tutorial.h" #include "../data/WaitForComposed.h" #include "../data/WaitForSignal.h" -#include "../data/Reaction.h" class ReactionWidgetTest: public QObject { Q_OBJECT @@ -43,6 +45,8 @@ void testConstructor(); void testConstructorWithRichText(); + void testEnableStepIdCompletion(); + void testSelectTriggerTypeOption(); void testSelectTriggerTypeCondition(); @@ -132,6 +136,48 @@ QString("<p>The custom code</p>")); } +void ReactionWidgetTest::testEnableStepIdCompletion() { + Reaction* reaction = new Reaction(); + + ReactionWidget widget(reaction); + + Tutorial tutorial; + + Step* emptyIdStep = new Step(); + emptyIdStep->setId(""); + tutorial.addStep(emptyIdStep); + + Step* firstStep = new Step(); + firstStep->setId("First step"); + tutorial.addStep(firstStep); + + Step* secondStep = new Step(); + secondStep->setId("Second step"); + tutorial.addStep(secondStep); + + Step* thirdStep = new Step(); + thirdStep->setId("Third step"); + tutorial.addStep(thirdStep); + + widget.enableStepIdCompletion(&tutorial, firstStep); + + QStringList completionItems = + responseStepLineEdit(&widget)->completionObject()->items(); + QCOMPARE(completionItems.count(), 2); + QVERIFY(completionItems.contains("Second step")); + QVERIFY(completionItems.contains("Third step")); + + secondStep->addReaction(reaction); + + widget.enableStepIdCompletion(&tutorial); + + completionItems = + responseStepLineEdit(&widget)->completionObject()->items(); + QCOMPARE(completionItems.count(), 2); + QVERIFY(completionItems.contains("First step")); + QVERIFY(completionItems.contains("Third step")); +} + void ReactionWidgetTest::testSelectTriggerTypeOption() { Reaction reaction; reaction.setTriggerType(Reaction::ConditionMet); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp 2011-05-25 03:00:55 UTC (rev 314) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/StepDataWidgetTest.cpp 2011-05-28 04:00:15 UTC (rev 315) @@ -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 * @@ -23,7 +23,9 @@ #include <KLineEdit> #include <KTextEdit> +#include "../data/Reaction.h" #include "../data/Step.h" +#include "../data/Tutorial.h" class StepDataWidgetTest: public QObject { Q_OBJECT @@ -33,6 +35,8 @@ void testConstructor(); void testConstructorWithRichText(); + void testEnableStepIdCompletion(); + void testSaveChanges(); private: @@ -68,6 +72,63 @@ QCOMPARE(textTextEdit(widget)->toPlainText(), QString("<p>The text</p>")); } +void StepDataWidgetTest::testEnableStepIdCompletion() { + Step* step = new Step; + + StepDataWidget widget(step); + + Tutorial tutorial; + tutorial.addStep(step); + + Reaction* stepFirstReaction = new Reaction(); + stepFirstReaction->setNextStepId("Unused id in the step of the widget"); + step->addReaction(stepFirstReaction); + + Step* emptyStep = new Step(); + emptyStep->setId(""); + tutorial.addStep(emptyStep); + + Step* firstStep = new Step(); + firstStep->setId("First step"); + tutorial.addStep(firstStep); + + Reaction* firstStepFirstReaction = new Reaction(); + firstStepFirstReaction->setNextStepId("Second step"); + firstStep->addReaction(firstStepFirstReaction); + + Reaction* firstStepSecondReaction = new Reaction(); + firstStepSecondReaction->setNextStepId("Unused id"); + firstStep->addReaction(firstStepSecondReaction); + + Reaction* firstStepThirdReaction = new Reaction(); + firstStepThirdReaction->setNextStepId("Duplicated unused id"); + firstStep->addReaction(firstStepThirdReaction); + + Reaction* firstStepEmptyReaction = new Reaction(); + firstStep->addReaction(firstStepEmptyReaction); + + Step* secondStep = new Step(); + secondStep->setId("Second step"); + tutorial.addStep(secondStep); + + Reaction* secondStepFirstReaction = new Reaction(); + secondStepFirstReaction->setNextStepId("Duplicated unused id"); + secondStep->addReaction(secondStepFirstReaction); + + Reaction* secondStepSecondReaction = new Reaction(); + secondStepSecondReaction->setNextStepId("Another unused id"); + secondStep->addReaction(secondStepSecondReaction); + + widget.enableStepIdCompletion(&tutorial); + + QStringList completionItems = + idLineEdit(&widget)->completionObject()->items(); + QCOMPARE(completionItems.count(), 3); + QVERIFY(completionItems.contains("Unused id")); + QVERIFY(completionItems.contains("Duplicated unused id")); + QVERIFY(completionItems.contains("Another unused id")); +} + void StepDataWidgetTest::testSaveChanges() { Step step; step.setId("The id"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-06-08 13:23:46
|
Revision: 317 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=317&view=rev Author: danxuliu Date: 2011-06-08 12:48:46 +0000 (Wed, 08 Jun 2011) Log Message: ----------- Add support for testing a tutorial from the currently selected step instead of just from the start. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt trunk/ktutorial/ktutorial-editor/src/EditActions.cpp trunk/ktutorial/ktutorial-editor/src/EditActions.h trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h trunk/ktutorial/ktutorial-editor/src/TutorialTester.cpp trunk/ktutorial/ktutorial-editor/src/TutorialTester.h trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp Added Paths: ----------- trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.cpp trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.h Modified: trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/CMakeLists.txt 2011-06-08 12:48:46 UTC (rev 317) @@ -41,6 +41,7 @@ if (QT_QTDBUS_FOUND) set(ktutorial_editor_SRCS ${ktutorial_editor_SRCS} + TestTutorialActions.cpp TutorialTester.cpp ) endif (QT_QTDBUS_FOUND) Modified: trunk/ktutorial/ktutorial-editor/src/EditActions.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/EditActions.cpp 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/EditActions.cpp 2011-06-08 12:48:46 UTC (rev 317) @@ -37,10 +37,6 @@ #include "view/TutorialCustomCodeWidget.h" #include "view/TutorialInformationWidget.h" -#ifdef QT_QTDBUS_FOUND -#include "TutorialTester.h" -#endif - //public: EditActions::EditActions(KTutorialEditor* tutorialEditor): @@ -211,18 +207,6 @@ action->setEnabled(false); actionCollection->addAction("removeReaction", action); connect(action, SIGNAL(triggered(bool)), this, SLOT(removeReaction())); - -#ifdef QT_QTDBUS_FOUND - action = new KAction(this); - action->setText(i18nc("@action", "Test tutorial")); - action->setStatusTip(i18nc("@info:status", "Starts the tutorial in the " -"target application.")); - action->setIcon(KIcon("document-preview")); - action->setEnabled(true); - actionCollection->addAction("testTutorial", action); - connect(action, SIGNAL(triggered(bool)), - new TutorialTester(mTutorialEditor), SLOT(testTutorial())); -#endif } int EditActions::showEditionDialog(CommandWidget* commandWidget) { Modified: trunk/ktutorial/ktutorial-editor/src/EditActions.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/EditActions.h 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/EditActions.h 2011-06-08 12:48:46 UTC (rev 317) @@ -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 * @@ -30,8 +30,7 @@ /** * Edition related actions. * EditActions provide the actions to edit a tutorial (set the setup code, add a - * step...), actions to undo and redo the edition, and also an action to test - * the current tutorial in the target application. + * step...), and actions to undo and redo the edition. * * KTutorialEditor notifies EditActions when a step or reaction is selected, so * it can know which step or reaction have to be edited. EditActions provides Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.cpp 2011-06-08 12:48:46 UTC (rev 317) @@ -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,6 +38,7 @@ #include "view/TutorialTreeSelectionManager.h" #ifdef QT_QTDBUS_FOUND +#include "TestTutorialActions.h" #include "targetapplication/TargetApplication.h" #endif @@ -145,6 +146,10 @@ mEditActions, SLOT(selectStep(Step*))); connect(selectionManager, SIGNAL(reactionSelected(Reaction*)), mEditActions, SLOT(selectReaction(Reaction*))); +#ifdef QT_QTDBUS_FOUND + connect(selectionManager, SIGNAL(stepSelected(Step*)), + mTestTutorialActions, SLOT(selectStep(Step*))); +#endif mEditActions->clearCommands(); @@ -179,6 +184,10 @@ mEditActions = new EditActions(this); +#ifdef QT_QTDBUS_FOUND + mTestTutorialActions = new TestTutorialActions(this); +#endif + actionCollection()->addAction("showEditTutorialDock", mTutorialActionDock->toggleViewAction()); actionCollection()->addAction("showEditStepDock", Modified: trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/KTutorialEditor.h 2011-06-08 12:48:46 UTC (rev 317) @@ -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 * @@ -27,6 +27,10 @@ class QTreeView; class Tutorial; +#ifdef QT_QTDBUS_FOUND +class TestTutorialActions; +#endif + /** * KTutorial editor main window. * It wires up all the components in the application. @@ -152,7 +156,14 @@ */ EditActions* mEditActions; +#ifdef QT_QTDBUS_FOUND /** + * The test tutorial related actions and data. + */ + TestTutorialActions* mTestTutorialActions; +#endif + + /** * The tutorial being edited. */ Tutorial* mTutorial; Added: trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.cpp 2011-06-08 12:48:46 UTC (rev 317) @@ -0,0 +1,108 @@ +/*************************************************************************** + * 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 "TestTutorialActions.h" + +#include <KAction> +#include <KActionCollection> +#include <KLocalizedString> + +#include "KTutorialEditor.h" +#include "TutorialTester.h" +#include "data/Step.h" + +//public: + +TestTutorialActions::TestTutorialActions(KTutorialEditor* tutorialEditor): + QObject(tutorialEditor), + mTutorialEditor(tutorialEditor), + mCurrentStep(0) { + + setupActions(); +} + +//public slots: + +void TestTutorialActions::selectStep(Step* step) { + if (mCurrentStep) { + disconnect(mCurrentStep, SIGNAL(dataChanged(Step*)), + this, SLOT(updateTestTutorialFromCurrentStepActionState())); + } + + mCurrentStep = step; + + if (mCurrentStep) { + connect(mCurrentStep, SIGNAL(dataChanged(Step*)), + this, SLOT(updateTestTutorialFromCurrentStepActionState())); + } + + updateTestTutorialFromCurrentStepActionState(); +} + +//private: + +void TestTutorialActions::setupActions() { + KActionCollection* actionCollection = mTutorialEditor->actionCollection(); + + KAction* action = new KAction(this); + action = new KAction(this); + action->setText(i18nc("@action", "Test tutorial")); + action->setStatusTip(i18nc("@info:status", "Starts the tutorial in the " +"target application.")); + action->setIcon(KIcon("document-preview")); + action->setEnabled(true); + actionCollection->addAction("testTutorial", action); + connect(action, SIGNAL(triggered(bool)), + this, SLOT(testTutorial())); + + action = new KAction(this); + action->setText(i18nc("@action", "Test tutorial from current step")); + action->setStatusTip(i18nc("@info:status", "Starts the tutorial in the " +"target application from the current step.")); + action->setIcon(KIcon("document-preview")); + action->setEnabled(false); + actionCollection->addAction("testTutorialFromCurrentStep", action); + connect(action, SIGNAL(triggered(bool)), + this, SLOT(testTutorialFromCurrentStep())); +} + +//private slots: + +void TestTutorialActions::updateTestTutorialFromCurrentStepActionState() { + KActionCollection* actionCollection = mTutorialEditor->actionCollection(); + QAction* action = actionCollection->action("testTutorialFromCurrentStep"); + + if (mCurrentStep && !mCurrentStep->id().isEmpty()) { + action->setEnabled(true); + } else { + action->setEnabled(false); + } +} + +void TestTutorialActions::testTutorial() { + TutorialTester* tutorialTester = new TutorialTester(mTutorialEditor); + tutorialTester->testTutorial(); +} + +void TestTutorialActions::testTutorialFromCurrentStep() { + Q_ASSERT(mCurrentStep); + + TutorialTester* tutorialTester = new TutorialTester(mTutorialEditor); + tutorialTester->setStepToTestFrom(mCurrentStep->id()); + tutorialTester->testTutorial(); +} Property changes on: trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.h (rev 0) +++ trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.h 2011-06-08 12:48:46 UTC (rev 317) @@ -0,0 +1,95 @@ +/*************************************************************************** + * 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 TESTTUTORIALACTIONS_H +#define TESTTUTORIALACTIONS_H + +#include <QObject> + +class KTutorialEditor; +class Step; + +/** + * Test tutorial related actions. + * TestTutorialActions provide the actions to test the current tutorial in the + * target application (from the start or from the selected step). + * + * KTutorialEditor notifies TestTutorialActions when a step is selected, so it + * can know from which step test the tutorial. + */ +class TestTutorialActions: public QObject { +Q_OBJECT +public: + + /** + * Creates a new TestTutorialActions for the given KTutorialEditor. + * All the actions are set up and added to the KTutorialEditor. + * + * @param tutorialEditor The KTutorialEditor to work with. + */ + explicit TestTutorialActions(KTutorialEditor* tutorialEditor); + +public Q_SLOTS: + + /** + * Sets the current step and enables or disables the actions that depend on + * a step as needed. + * + * @param step The step to select, or null to deselect the current one. + */ + void selectStep(Step* step); + +private: + + /** + * The KTutorialEditor to work with. + */ + KTutorialEditor* mTutorialEditor; + + /** + * The currently selected step. + */ + Step* mCurrentStep; + + /** + * Sets up all the edit related actions. + */ + void setupActions(); + +private Q_SLOTS: + + /** + * Enables or disables the "test tutorial from current step" action based on + * the current step. + */ + void updateTestTutorialFromCurrentStepActionState(); + + /** + * Tests the current tutorial in the target application. + */ + void testTutorial(); + + /** + * Tests the current tutorial from the current step in the target + * application. + */ + void testTutorialFromCurrentStep(); + +}; + +#endif Property changes on: trunk/ktutorial/ktutorial-editor/src/TestTutorialActions.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/src/TutorialTester.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/TutorialTester.cpp 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/TutorialTester.cpp 2011-06-08 12:48:46 UTC (rev 317) @@ -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 * @@ -33,21 +33,26 @@ TutorialTester::TutorialTester(KTutorialEditor* tutorialEditor): QObject(tutorialEditor), mTutorialEditor(tutorialEditor) { +} - mTargetApplicationView = - new TargetApplicationView(TargetApplication::self(), mTutorialEditor); +void TutorialTester::setStepToTestFrom(const QString& stepId) { + mStepId = stepId; } -//public slots: - void TutorialTester::testTutorial() { if (TargetApplication::self()->remoteEditorSupport()) { sendTutorialToTargetApplication(); } else { connect(TargetApplication::self(), SIGNAL(started()), this, SLOT(sendTutorialToTargetApplication())); + connect(TargetApplication::self(), + SIGNAL(startFailed(TargetApplication::Error)), + this, SLOT(deleteLater())); - mTargetApplicationView->start(); + TargetApplicationView* targetApplicationView = + new TargetApplicationView(TargetApplication::self(), + mTutorialEditor); + targetApplicationView->start(); } } @@ -80,8 +85,13 @@ } try { - TargetApplication::self()->remoteEditorSupport()->testScriptedTutorial( - temporaryFile->fileName()); + if (mStepId.isEmpty()) { + TargetApplication::self()->remoteEditorSupport()-> + testScriptedTutorial(temporaryFile->fileName()); + } else { + TargetApplication::self()->remoteEditorSupport()-> + testScriptedTutorial(temporaryFile->fileName(), mStepId); + } } catch (DBusException e) { QString text = i18nc("@label", "There was a problem when trying to " "tell the target application to start the tutorial:<nl/>%1", e.message()); Modified: trunk/ktutorial/ktutorial-editor/src/TutorialTester.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/TutorialTester.h 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/TutorialTester.h 2011-06-08 12:48:46 UTC (rev 317) @@ -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 * @@ -22,7 +22,6 @@ #include <QObject> class KTutorialEditor; -class TargetApplicationView; /** * Utility class to test a tutorial in the target application, starting it if @@ -39,7 +38,13 @@ */ explicit TutorialTester(KTutorialEditor* tutorialEditor); -public Q_SLOTS: + /** + * Sets the step to test the tutorial from. + * After starting the tutorial, it will be changed to the given step. + * + * @param stepId The id of the step to test the tutorial from. + */ + void setStepToTestFrom(const QString& stepId); /** * Tests the current tutorial in the target application. @@ -56,15 +61,16 @@ KTutorialEditor* mTutorialEditor; /** - * The TargetApplicationView used to start the target application. + * The id of the step to test the tutorial from, if any. */ - TargetApplicationView* mTargetApplicationView; + QString mStepId; private Q_SLOTS: /** * Exports the current tutorial to a temporary Javascript file and sends the - * file name to the target application to test the tutorial. + * file name (and, if set, the step id) to the target application to test + * the tutorial. */ void sendTutorialToTargetApplication(); Modified: trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc =================================================================== --- trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/ktutorial-editorui.rc 2011-06-08 12:48:46 UTC (rev 317) @@ -29,6 +29,7 @@ </Menu> <Separator/> <Action name="testTutorial"/> + <Action name="testTutorialFromCurrentStep"/> </Menu> <Menu name="view"> <Menu name="panels"> Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.cpp 2011-06-08 12:48:46 UTC (rev 317) @@ -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 * @@ -100,9 +100,16 @@ mRemoteEventSpy = 0; } -void RemoteEditorSupport::testScriptedTutorial(const QString& filename) +void RemoteEditorSupport::testScriptedTutorial(const QString& filename, + const QString& stepId) throw (DBusException) { - QDBusReply<void> reply = call("testScriptedTutorial", filename); + QDBusReply<void> reply; + if (stepId.isEmpty()) { + reply = call("testScriptedTutorial", filename); + } else { + reply = call("testScriptedTutorial", filename, stepId); + } + if (!reply.isValid()) { throw DBusException(reply.error().message()); } Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteEditorSupport.h 2011-06-08 12:48:46 UTC (rev 317) @@ -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 * @@ -117,10 +117,15 @@ /** * Tests the scripted tutorial stored in the file with the given name. * The target application just starts the tutorial and shows it to the user. + * If a step id is given, the tutorial is changed to that step after + * starting. * * @param filename The name of the file that contains the tutorial to test. + * @param stepId The id of the step to change to after starting. */ - void testScriptedTutorial(const QString& filename) throw (DBusException); + void testScriptedTutorial(const QString& filename, + const QString& stepId = QString()) + throw (DBusException); private: Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteClassStubs.h 2011-06-08 12:48:46 UTC (rev 317) @@ -216,6 +216,7 @@ int mEnableEventSpyCount; int mDisableEventSpyCount; QList<QString> mTestScriptedTutorialFilenames; + QList<QString> mTestScriptedTutorialStepIds; StubEditorSupport(QObject* parent = 0): QObject(parent), mEventSpy(0), @@ -255,8 +256,13 @@ QDBusConnection::sessionBus().unregisterObject("/ktutorial/EventSpy"); } - void testScriptedTutorial(const QString& filename) { + void testScriptedTutorial(const QString& filename, + const QString& stepId = QString()) { mTestScriptedTutorialFilenames.append(filename); + + if (!stepId.isEmpty()) { + mTestScriptedTutorialStepIds.append(stepId); + } } }; Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp 2011-06-08 12:46:04 UTC (rev 316) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteEditorSupportTest.cpp 2011-06-08 12:48:46 UTC (rev 317) @@ -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,9 @@ void testDisableEventSpyWhenRemoteEditorSupportIsNotAvailable(); void testTestScriptedTutorial(); + void testTestScriptedTutorialWithStepId(); void testTestScriptedTutorialWhenRemoteEditorSupportIsNotAvailable(); + void testTestScriptedTutorialWithStepIdWhenRemoteEditorSupportIsNotAvailable(); private: @@ -341,8 +343,24 @@ QCOMPARE(mEditorSupport->mTestScriptedTutorialFilenames.count(), 1); QCOMPARE(mEditorSupport->mTestScriptedTutorialFilenames[0], QString("/some/file")); + QCOMPARE(mEditorSupport->mTestScriptedTutorialStepIds.count(), 0); } +void RemoteEditorSupportTest::testTestScriptedTutorialWithStepId() { + RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); + RemoteEditorSupport remoteEditorSupport( + QDBusConnection::sessionBus().baseService(), &mapper); + + remoteEditorSupport.testScriptedTutorial("/some/file", "some step id"); + + QCOMPARE(mEditorSupport->mTestScriptedTutorialFilenames.count(), 1); + QCOMPARE(mEditorSupport->mTestScriptedTutorialFilenames[0], + QString("/some/file")); + QCOMPARE(mEditorSupport->mTestScriptedTutorialStepIds.count(), 1); + QCOMPARE(mEditorSupport->mTestScriptedTutorialStepIds[0], + QString("some step id")); +} + void RemoteEditorSupportTest:: testTestScriptedTutorialWhenRemoteEditorSupportIsNotAvailable() { RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); @@ -355,6 +373,19 @@ DBusException); } +void RemoteEditorSupportTest:: + testTestScriptedTutorialWithStepIdWhenRemoteEditorSupportIsNotAvailable() { + RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); + RemoteEditorSupport remoteEditorSupport( + QDBusConnection::sessionBus().baseService(), &mapper); + + QDBusConnection::sessionBus().unregisterObject("/ktutorial"); + + EXPECT_EXCEPTION(remoteEditorSupport.testScriptedTutorial("/some/file", + "some step id"), + DBusException); +} + QTEST_MAIN(RemoteEditorSupportTest) #include "RemoteEditorSupportTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-06-10 16:17:17
|
Revision: 320 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=320&view=rev Author: danxuliu Date: 2011-06-10 16:17:10 +0000 (Fri, 10 Jun 2011) Log Message: ----------- Change how the target application is detected. Before, every D-Bus service that appeared in the bus was queried for the applicationFilePath in its ktutorial object. However, an application can provide a D-Bus service before the ktutorial object is registered in it, so a valid application could be seen as invalid just because the KTutorial module was not registered yet. Now, the service of the target application is found using the PID of its process, and if the ktutorial object is not registered yet, the service is queried again until the object is found (or the timer to find the application times out). Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/CMakeLists.txt trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp Added Paths: ----------- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationStubWithDelayedRegister.cpp Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp 2011-06-08 14:49:14 UTC (rev 319) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp 2011-06-10 16:17:10 UTC (rev 320) @@ -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 * @@ -95,11 +95,11 @@ connect(mProcess, SIGNAL(finished(int)), this, SLOT(clean())); - mServiceDiscoveryTimer.setInterval(3000); - mServiceDiscoveryTimer.setSingleShot(true); + mKTutorialSupportModuleDiscoveryTimer.setInterval(3000); + mKTutorialSupportModuleDiscoveryTimer.setSingleShot(true); connect(mProcess, SIGNAL(started()), - &mServiceDiscoveryTimer, SLOT(start())); - connect(&mServiceDiscoveryTimer, SIGNAL(timeout()), + &mKTutorialSupportModuleDiscoveryTimer, SLOT(start())); + connect(&mKTutorialSupportModuleDiscoveryTimer, SIGNAL(timeout()), this, SLOT(handleTargetApplicationDoesNotSupportKTutorial())); mProcess->start(); @@ -118,33 +118,53 @@ //private slots: void TargetApplication::checkNewService(const QString& service) { - QDBusInterface interface(service, "/ktutorial", - "org.kde.ktutorial.EditorSupport"); - if (!interface.isValid()) { + QDBusInterface mainDBusInterface("org.freedesktop.DBus", "/", + "org.freedesktop.DBus"); + if (!mainDBusInterface.isValid()) { return; } - QDBusReply<QString> reply = interface.call("applicationFilePath"); - if (!reply.isValid()) { + QDBusReply<uint> pidReply = + mainDBusInterface.call("GetConnectionUnixProcessID", service); + if (!pidReply.isValid()) { return; } - if (reply.value() != mTargetApplicationFilePath) { + if (pidReply.value() != (uint)mProcess->pid()) { return; } - mServiceDiscoveryTimer.stop(); - - //The bus must be disconnected before executing other code to ensure that - //no other services are handled, as when an application starts it can create - //more than one valid service: one like ":1.42" and another like - //"org.freedesktop.DBus". - //So this method could be called again before finishing its current - //execution if serviceRegistered(QSignal) is emitted, which could happen if - //other event loops are created (like in a message box). disconnect(QDBusConnection::sessionBus().interface(), 0, this, 0); mServiceName = service; + + checkKTutorialSupportModule(); +} + +void TargetApplication::checkKTutorialSupportModule() { + //Prevent pending checks from being executed after the timeout of the + //discovery timer + if (!mKTutorialSupportModuleDiscoveryTimer.isActive()) { + return; + } + + QDBusInterface interface(mServiceName, "/ktutorial", + "org.freedesktop.DBus.Introspectable"); + if (!interface.isValid()) { + QTimer::singleShot(500, this, SLOT(checkKTutorialSupportModule())); + return; + } + + //Just a generic DBus call to check whether /ktutorial is already available + //or not + QDBusReply<QString> reply = interface.call("Introspect"); + if (!reply.isValid()) { + QTimer::singleShot(500, this, SLOT(checkKTutorialSupportModule())); + return; + } + + mKTutorialSupportModuleDiscoveryTimer.stop(); + mMapper = new RemoteObjectMapper(mServiceName); mRemoteEditorSupport = new RemoteEditorSupport(mServiceName, mMapper); @@ -156,7 +176,7 @@ return; } - mServiceDiscoveryTimer.stop(); + mKTutorialSupportModuleDiscoveryTimer.stop(); emit startFailed(InvalidPath); } Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h 2011-06-08 14:49:14 UTC (rev 319) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h 2011-06-10 16:17:10 UTC (rev 320) @@ -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 * @@ -174,12 +174,12 @@ KProcess* mProcess; /** - * Timer to give time to "/ktutorial" object to appear in some new service - * of the bus. + * Timer to give time to "/ktutorial" object to appear in the service of + * the target application. * If the timer ends and the object was not found, the target application * seems to not to support KTutorial editor. */ - QTimer mServiceDiscoveryTimer; + QTimer mKTutorialSupportModuleDiscoveryTimer; /** * The D-Bus service name provided by the target application, if any. @@ -208,14 +208,23 @@ /** * Checks if the new service found in the session bus is the one from the * started target application. - * When the service is found, the target application has started from - * KTutorial editor point of view. Signal started() is emitted in that case. + * If the service is provided by the target application, it is checked if it + * contains the support module from KTutorial. * * @param service The D-Bus service to check. */ void checkNewService(const QString& service); /** + * Checks if the service of the target application provides the "/ktutorial" + * object. + * If the object is not found, the service will be checked again later. + * When the object is found, the target application has started from + * KTutorial editor point of view. Signal started() is emitted in that case. + */ + void checkKTutorialSupportModule(); + + /** * Checks if the process could not be started. * Signal startFailed(Error), with InvalidPath, is emitted in that case. * @@ -224,7 +233,7 @@ void handleProcessError(QProcess::ProcessError error); /** - * Called when the time out to find the D-Bus service expired. + * Called when the time to find the "/ktutorial" object expired. * Signal startFailed(Error), with InvalidApplication, is emitted in that * case. */ Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/CMakeLists.txt =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/CMakeLists.txt 2011-06-08 14:49:14 UTC (rev 319) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/CMakeLists.txt 2011-06-10 16:17:10 UTC (rev 320) @@ -14,6 +14,12 @@ add_executable(TargetApplicationStub TargetApplicationStub.cpp ${dbus_interface_stubs_MOC}) target_link_libraries(TargetApplicationStub ${KDE4_KDEUI_LIBS} ${QT_QTDBUS_LIBRARY}) +# Target application stub with delayed register to be executed in TargetApplication test +set(TargetApplicationStubWithDelayedRegister_MOC ${CMAKE_CURRENT_BINARY_DIR}/TargetApplicationStubWithDelayedRegister.moc) +qt4_generate_moc(TargetApplicationStubWithDelayedRegister.cpp ${TargetApplicationStubWithDelayedRegister_MOC}) +add_executable(TargetApplicationStubWithDelayedRegister TargetApplicationStubWithDelayedRegister.cpp ${TargetApplicationStubWithDelayedRegister_MOC} ${dbus_interface_stubs_MOC}) +target_link_libraries(TargetApplicationStubWithDelayedRegister ${KDE4_KDEUI_LIBS} ${QT_QTDBUS_LIBRARY}) + MACRO(UNIT_TESTS) FOREACH(_className ${ARGN}) set(_testName ${_className}Test) Added: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationStubWithDelayedRegister.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationStubWithDelayedRegister.cpp (rev 0) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationStubWithDelayedRegister.cpp 2011-06-10 16:17:10 UTC (rev 320) @@ -0,0 +1,60 @@ +/*************************************************************************** + * 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 <KApplication> +#include <KCmdLineArgs> +#include <KMainWindow> + +#include "RemoteClassStubs.h" + +class MainWindow: public KMainWindow { +Q_OBJECT +public: + + MainWindow() { + QTimer::singleShot(1000, this, SLOT(registerKTutorialInDBus())); + } + +private slots: + + void registerKTutorialInDBus() { + StubEditorSupport* editorSupport = new StubEditorSupport(); + QDBusConnection::sessionBus().registerObject("/ktutorial", + editorSupport, QDBusConnection::ExportAllSlots); + + StubObjectRegister* objectRegister = new StubObjectRegister(); + QDBusConnection::sessionBus().registerObject( + "/ktutorial/ObjectRegister", objectRegister, + QDBusConnection::ExportAdaptors); + } + +}; + +int main (int argc, char *argv[]) { + KCmdLineArgs::init(argc, argv, "TargetApplicationStubWithDelayedRegister", + "", ki18n(""), ""); + + KApplication app; + + KMainWindow* window = new MainWindow(); + window->show(); + + return app.exec(); +} + +#include "TargetApplicationStubWithDelayedRegister.moc" Property changes on: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationStubWithDelayedRegister.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp 2011-06-08 14:49:14 UTC (rev 319) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp 2011-06-10 16:17:10 UTC (rev 320) @@ -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 * @@ -59,6 +59,7 @@ void testSetTargetApplicationFilePathRelative(); void testStart(); + void testStartApplicationWithDelayedRegister(); void testStartAlreadyStarted(); void testStartAfterSettingAgainTargetApplicationFilePath(); void testStartAfterChangingTargetApplicationFilePath(); @@ -203,6 +204,21 @@ QString("The object name 42")); } +void TargetApplicationTest::testStartApplicationWithDelayedRegister() { + TargetApplication targetApplication; + targetApplication.setTargetApplicationFilePath( + QApplication::applicationDirPath() + + "/TargetApplicationStubWithDelayedRegister"); + + SignalWait startedWait(&targetApplication, SIGNAL(started())); + targetApplication.start(); + + QVERIFY(startedWait.waitForCount(1, 2000)); + QVERIFY(targetApplication.remoteEditorSupport()); + QCOMPARE(targetApplication.remoteEditorSupport()->mainWindow()->name(), + QString("The object name 42")); +} + void TargetApplicationTest::testStartAlreadyStarted() { TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-06-12 15:29:33
|
Revision: 324 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=324&view=rev Author: danxuliu Date: 2011-06-12 15:29:27 +0000 (Sun, 12 Jun 2011) Log Message: ----------- Change TargetApplication signals behaviour. Now, finished() signal is only emitted if started() was previously emitted, and startFailed(Error) is now emitted whenever the target application ends before being able to determine if it uses KTutorial or not. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp 2011-06-10 22:19:57 UTC (rev 323) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.cpp 2011-06-12 15:29:27 UTC (rev 324) @@ -202,11 +202,16 @@ } mProcess->kill(); - - emit startFailed(InvalidApplication); } void TargetApplication::clean() { + bool wasStartedSuccessfully = true; + if (!mRemoteEditorSupport) { + wasStartedSuccessfully = false; + + emit startFailed(InvalidApplication); + } + //Don't delete it directly, as waitForFinished crashes somewhere internally //due to an event problem mProcess->deleteLater(); @@ -216,5 +221,7 @@ delete mMapper; mMapper = 0; - emit finished(); + if (wasStartedSuccessfully) { + emit finished(); + } } Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h 2011-06-10 22:19:57 UTC (rev 323) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/TargetApplication.h 2011-06-12 15:29:27 UTC (rev 324) @@ -42,13 +42,13 @@ * * The TargetApplication can be started using method start(). The method returns * immediately, and when the application is really running the started() signal - * is emitted. If the application could not be executed, or it was executed but - * other problem happened (for example, if the target application does not - * support KTutorial), startFailed(Error) signal is emitted instead. + * is emitted (if it uses KTutorial). If the application could not be executed, + * or it was executed but other problem happened (for example, if the target + * application does not use KTutorial), startFailed(Error) signal is emitted + * instead. * - * Note that started() and startFailed(Error) signals may not be emitted if the - * target application is closed too soon to realize that it was successfully - * started or that it does not support KTutorial. + * Note that startFailed(Error) signal is also emitted if the target application + * is closed too soon to check if it uses KTutorial. * * Once the target application has been started, remoteEditorSupport * returns a RemoteEditorSupport connected to the remote @@ -58,7 +58,8 @@ * The target application will be killed when the TargetApplication is * destroyed, or when the start method is called again after setting a different * application file path. In any of those cases, or if the target application - * was closed externally (by the user), finished() signal is emitted. + * was closed externally (by the user), finished() signal is emitted (but only + * if, preiously, it was successfully started). */ class TargetApplication: public QObject { Q_OBJECT @@ -70,7 +71,7 @@ enum Error { /** - * The application was started, but it does not support KTutorial. + * The application was started, but it does not use KTutorial. */ InvalidApplication, @@ -128,8 +129,9 @@ * Starts a new TargetApplication. * When the target application is running, started() signal is emitted. If * there is no application file path, the application file path is not valid - * or the application does not support KTutorial editor, startFailed(Error) - * signal is emitted instead. + * or the application does not support KTutorial editor (or it was closed + * before being able to determine it), startFailed(Error) signal is emitted + * instead. * * If the target application was already started nothing is done (even * started() signal is not emitted). @@ -139,8 +141,8 @@ Q_SIGNALS: /** - * Emitted when the target application was started and there is a D-Bus - * connection to it. + * Emitted when the target application was started, it uses KTutorial and + * there is a D-Bus connection to it. */ void started(); @@ -152,7 +154,10 @@ void startFailed(TargetApplication::Error error); /** - * Emitted when the target application was finished for any reason. + * Emitted when the target application was finished after being successfully + * started. + * Note that this signal is not emitted, for example, when a target + * application without support for KTutorial is closed. */ void finished(); @@ -177,7 +182,7 @@ * Timer to give time to "/ktutorial" object to appear in the service of * the target application. * If the timer ends and the object was not found, the target application - * seems to not to support KTutorial editor. + * seems to not to use KTutorial editor. */ QTimer mKTutorialSupportModuleDiscoveryTimer; @@ -234,15 +239,16 @@ /** * Called when the time to find the "/ktutorial" object expired. - * Signal startFailed(Error), with InvalidApplication, is emitted in that - * case. + * The target application is killed (which causes signal startFailed(Error), + * with InvalidApplication, to be emitted). */ void handleTargetApplicationDoesNotSupportKTutorial(); /** * Called when the process has finished. - * The process, mapper and remote editor support are deleted, and the - * finished() signal is emitted. + * The process, mapper and remote editor support are deleted. + * startFailed(Error) and finished() signals are emitted, depending on the + * case. */ void clean(); Modified: trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp 2011-06-10 22:19:57 UTC (rev 323) +++ trunk/ktutorial/ktutorial-editor/src/view/TargetApplicationView.cpp 2011-06-12 15:29:27 UTC (rev 324) @@ -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 * @@ -84,15 +84,10 @@ //to show the error message. However, once started the signal must be //disconnected to avoid showing several error messages (for example, if the //target application fails after being started several times by this view). - //finished() is also connected, as if the target application is closed - //before it could be checked whether it supports KTutorial or not, only - //finished() signal is emitted. connect(mTargetApplication, SIGNAL(started()), this, SLOT(stopExpectingTheTargetApplicationToStart())); connect(mTargetApplication, SIGNAL(startFailed(TargetApplication::Error)), this, SLOT(showErrorMessage(TargetApplication::Error))); - connect(mTargetApplication, SIGNAL(finished()), - this, SLOT(stopExpectingTheTargetApplicationToStart())); QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); } @@ -129,8 +124,6 @@ this, SLOT(stopExpectingTheTargetApplicationToStart())); disconnect(mTargetApplication, SIGNAL(startFailed(TargetApplication::Error)), this, SLOT(showErrorMessage(TargetApplication::Error))); - disconnect(mTargetApplication, SIGNAL(finished()), - this, SLOT(stopExpectingTheTargetApplicationToStart())); QApplication::restoreOverrideCursor(); } Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp 2011-06-10 22:19:57 UTC (rev 323) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/TargetApplicationTest.cpp 2011-06-12 15:29:27 UTC (rev 324) @@ -406,13 +406,13 @@ TargetApplication targetApplication; targetApplication.setTargetApplicationFilePath(mTargetApplicationStubPath); - QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - QSignalSpy startFailedSpy(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); - SignalWait finishedWait(&targetApplication, SIGNAL(finished())); + SignalWait startFailedWait(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); + QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); targetApplication.start(); @@ -422,7 +422,10 @@ targetApplication.mProcess->kill(); - QVERIFY(finishedWait.waitForCount(1, 1000)); + QVERIFY(startFailedWait.waitForCount(1, 1000)); + QVariant argument = startFailedWait.spy().at(0).at(0); + QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), + TargetApplication::InvalidApplication); QVERIFY(!targetApplication.remoteEditorSupport()); //Keep waiting until the timeout expires to ensure that no other signal is @@ -430,7 +433,8 @@ QTest::qWait(3000); QCOMPARE(startedSpy.count(), 0); - QCOMPARE(startFailedSpy.count(), 0); + QCOMPARE(startFailedWait.spy().count(), 1); + QCOMPARE(finishedSpy.count(), 0); } void TargetApplicationTest:: @@ -439,13 +443,13 @@ targetApplication.setTargetApplicationFilePath( QApplication::applicationDirPath() + "/DummyApplication"); - QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); //TargetApplication::Error must be registered in order to be used with //QSignalSpy qRegisterMetaType<TargetApplication::Error>("TargetApplication::Error"); - QSignalSpy startFailedSpy(&targetApplication, - SIGNAL(startFailed(TargetApplication::Error))); - SignalWait finishedWait(&targetApplication, SIGNAL(finished())); + SignalWait startFailedWait(&targetApplication, + SIGNAL(startFailed(TargetApplication::Error))); + QSignalSpy startedSpy(&targetApplication, SIGNAL(started())); + QSignalSpy finishedSpy(&targetApplication, SIGNAL(finished())); targetApplication.start(); @@ -455,7 +459,10 @@ targetApplication.mProcess->kill(); - QVERIFY(finishedWait.waitForCount(1, 1000)); + QVERIFY(startFailedWait.waitForCount(1, 1000)); + QVariant argument = startFailedWait.spy().at(0).at(0); + QCOMPARE(qvariant_cast<TargetApplication::Error>(argument), + TargetApplication::InvalidApplication); QVERIFY(!targetApplication.remoteEditorSupport()); //Keep waiting until the timeout expires to ensure that no other signal is @@ -463,7 +470,8 @@ QTest::qWait(3000); QCOMPARE(startedSpy.count(), 0); - QCOMPARE(startFailedSpy.count(), 0); + QCOMPARE(startFailedWait.spy().count(), 1); + QCOMPARE(finishedSpy.count(), 0); } QTEST_MAIN(TargetApplicationTest) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-06-13 19:49:27
|
Revision: 325 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=325&view=rev Author: danxuliu Date: 2011-06-13 19:49:21 +0000 (Mon, 13 Jun 2011) Log Message: ----------- Fix missed internationalization in options when exported to Javascript. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2011-06-12 15:29:27 UTC (rev 324) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2011-06-13 19:49:21 UTC (rev 325) @@ -226,19 +226,19 @@ if (reaction->triggerType() == Reaction::OptionSelected && reaction->responseType() == Reaction::NextStep) { - out() << "step.addOption(ktutorial.newOption(\"" - << escape(reaction->optionName()) << "\"), \"" + QString variable = writeOption(reaction->optionName()); + out() << "step.addOption(" << variable << ", \"" << escape(reaction->nextStepId()) << "\");\n"; return; } if (reaction->triggerType() == Reaction::OptionSelected && reaction->responseType() == Reaction::CustomCode) { + QString variable = writeOption(reaction->optionName()); QString functionName = toLowerCamelCase(step->id()) + "Step" + toUpperCamelCase(reaction->optionName()) + "OptionSelected"; - out() << "step.addOption(ktutorial.newOption(\"" - << escape(reaction->optionName()) << "\"), self, \"" + out() << "step.addOption(" << variable << ", self, \"" << functionName << "()\");\n"; addFunction(functionName, reaction->customCode()); return; @@ -262,6 +262,19 @@ addFunction(functionName, reaction->customCode()); } +QString JavascriptExporter::writeOption(const QString& optionName) { + Q_ASSERT(!optionName.isEmpty()); + + QString variable = toLowerCamelCase(optionName) + "Option"; + variable = addVariable(variable); + + out() << variable << " = ktutorial.newOption(t.i18nc(" + << "\"@action Tutorial option\", \"" << escape(optionName) + << "\"));\n"; + + return variable; +} + QString JavascriptExporter::writeWaitFor(const WaitFor* waitFor) { if (qobject_cast<const WaitForComposed*>(waitFor)) { return writeWaitFor(static_cast<const WaitForComposed*>(waitFor)); Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2011-06-12 15:29:27 UTC (rev 324) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2011-06-13 19:49:21 UTC (rev 325) @@ -170,6 +170,15 @@ void writeReaction(const Step* step, const Reaction* reaction); /** + * Writes the code to create and set an option. + * The option name can not be empty. + * + * @param optionName The name of the option. + * @return The name of the variable that holds the option. + */ + QString writeOption(const QString& optionName); + + /** * Writes the code to create and set a WaitFor. * * @param waitFor The WaitFor. Modified: trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2011-06-12 15:29:27 UTC (rev 324) +++ trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2011-06-13 19:49:21 UTC (rev 325) @@ -431,8 +431,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), \ -\"Another step\");\n" +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, \"Another step\");\n" "\n" " The custom setup\n" " code\n" @@ -536,7 +537,9 @@ " step.addWaitFor(waitForTheSignalNameByTheEmitterName, self, \ \"theIdStepWaitForTheSignalNameByTheEmitterNameConditionMet()\");\n" "\n" -" step.addOption(ktutorial.newOption(\"The option name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP @@ -575,8 +578,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), \ -\"Another step\");\n" +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, \"Another step\");\n" "}\n" CONNECT_STEP_SETUP STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; @@ -604,8 +608,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The \\\"option\\\" name\"), \ -\"Another \\\"step\\\"\");\n" +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The \\\"option\\\" name\"));\n" +" step.addOption(theOptionNameOption, \"Another \\\"step\\\"\");\n" "}\n" CONNECT_STEP_SETUP STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; @@ -675,7 +680,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP @@ -709,7 +716,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The \\\"option\\\" name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The \\\"option\\\" name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP @@ -757,7 +766,9 @@ TUTORIAL_EMPTY_INFORMATION_CODE STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_START_CODE "function theIdStepSetup(step) {\n" -" step.addOption(ktutorial.newOption(\"The option name\"), self, \ +" theOptionNameOption = ktutorial.newOption(\ +t.i18nc(\"@action Tutorial option\", \"The option name\"));\n" +" step.addOption(theOptionNameOption, self, \ \"theIdStepTheOptionNameOptionSelected()\");\n" "}\n" CONNECT_STEP_SETUP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-06-17 01:52:05
|
Revision: 328 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=328&view=rev Author: danxuliu Date: 2011-06-17 01:51:56 +0000 (Fri, 17 Jun 2011) Log Message: ----------- Update Spanish translations. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/doc/es/ktutorial-editor-handbook.po trunk/ktutorial/ktutorial-editor/doc/es/new-condition.png trunk/ktutorial/ktutorial-editor/doc/es/set-step-data.png trunk/ktutorial/ktutorial-editor/doc/header.pot trunk/ktutorial/ktutorial-editor/doc/ktutorial-editor-handbook.pot trunk/ktutorial/ktutorial-editor/po/es.po trunk/ktutorial/ktutorial-editor/po/ktutorial-editor.pot Modified: trunk/ktutorial/ktutorial-editor/doc/es/ktutorial-editor-handbook.po =================================================================== --- trunk/ktutorial/ktutorial-editor/doc/es/ktutorial-editor-handbook.po 2011-06-17 01:49:37 UTC (rev 327) +++ trunk/ktutorial/ktutorial-editor/doc/es/ktutorial-editor-handbook.po 2011-06-17 01:51:56 UTC (rev 328) @@ -3,14 +3,14 @@ # Copyright (C) 2010 Daniel Calviño Sánchez # This file is distributed under the same license as the ktutorial-editor handbook. # -# Daniel Calviño Sánchez <dan...@gm...>, 2010. +# Daniel Calviño Sánchez <dan...@gm...>, 2010, 2011. msgid "" msgstr "" "Project-Id-Version: ktutorial-editor handbook\n" "Report-Msgid-Bugs-To: http://sourceforge." "net/tracker/?group_id=301227&atid=1270278\n" -"POT-Creation-Date: 2010-10-29 21:49+0000\n" -"PO-Revision-Date: 2010-10-29 23:50+0200\n" +"POT-Creation-Date: 2011-06-15 15:47+0000\n" +"PO-Revision-Date: 2011-06-15 18:01+0200\n" "Last-Translator: Daniel Calviño Sánchez <dan...@gm...>\n" "Language-Team: Spanish <>\n" "MIME-Version: 1.0\n" @@ -751,9 +751,30 @@ "click de nuevo en el enlace detendrá el remarcado del widget." #. Tag: para -#: using.docbook:116 +#: using.docbook:115 #, no-c-format msgid "" +"To ease all these things, &ktutorial-editor; provides several buttons in the " +"step data dialog that help writing KDE semantic markup tags. These buttons " +"insert the start and end tags for an element as needed, and are enabled or " +"disabled based on the position of the cursor in the text. For example, the " +"button to insert a paragraph tag will be disabled if the cursor is inside a " +"link, but the button to insert a link tag will be enabled if the cursor is " +"inside a paragraph." +msgstr "" +"Para hacer más fácil todo esto, &ktutorial-editor; proporciona varios " +"botones en el diálogo de datos del paso que ayudan a escribir etiquetas de " +"marcado semántico de KDE. Estos botones insertan las etiquetas de apertura y " +"cierre de un elemento según sea necesario, y están habilitados o " +"deshabilitados según la posición del cursor en el texto. Por ejemplo, el " +"botón para insertar una etiqueta de párrafo estará deshabilitado si el " +"cursor está dentro de un enlace, pero el botón para insertar una etiqueta de " +"enlace estará habilitado si el cursor está dentro de un párrafo." + +#. Tag: para +#: using.docbook:117 +#, no-c-format +msgid "" "The step data dialog is also shown when a new step is added. If the dialog " "is accepted, the step is added. If the dialog is cancelled, the step is not " "added." @@ -763,7 +784,7 @@ "el paso no se añade." #. Tag: para -#: using.docbook:117 +#: using.docbook:118 #, no-c-format msgid "" "Also note that, in every tutorial, there must be one step with id " @@ -774,19 +795,19 @@ "empieza el tutorial." #. Tag: screeninfo -#: using.docbook:120 +#: using.docbook:121 #, no-c-format msgid "The dialog to set the id and text of a step" msgstr "El diálogo para establecer el identificador y el texto de un paso" #. Tag: phrase -#: using.docbook:126 +#: using.docbook:127 #, no-c-format msgid "Step data edition dialog" msgstr "Diálogo de edición de los datos de un paso" #. Tag: para -#: using.docbook:131 +#: using.docbook:132 #, no-c-format msgid "" "The setup and tear down code dialogs behave like the tutorial ones. The only " @@ -799,7 +820,7 @@ "otro." #. Tag: para -#: using.docbook:132 +#: using.docbook:133 #, no-c-format msgid "" "Also note that the exported scripted tutorial creates all the reactions in " @@ -810,13 +831,13 @@ "inicialización se añade tras ese código." #. Tag: title -#: using.docbook:136 +#: using.docbook:137 #, no-c-format msgid "Reaction edition" msgstr "Edición de reacciones" #. Tag: para -#: using.docbook:138 +#: using.docbook:139 #, no-c-format msgid "" "The reaction dialog is used to set the trigger and response of a reaction. " @@ -828,7 +849,7 @@ "obligatorias, ya que definen el funcionamiento de la reacción." #. Tag: para -#: using.docbook:139 +#: using.docbook:140 #, no-c-format msgid "" "The trigger can be either an option selected or a condition met, but not " @@ -844,7 +865,7 @@ "cuando se cumpla la condición." #. Tag: para -#: using.docbook:140 +#: using.docbook:141 #, no-c-format msgid "" "Likely, the response can be changing to another step or executing some " @@ -860,25 +881,25 @@ "sólo tienes que establecer el cuerpo." #. Tag: screeninfo -#: using.docbook:143 +#: using.docbook:144 #, no-c-format msgid "The dialog to set the trigger and response of a reaction" msgstr "El diálogo para establecer el activador y la respuesta de una reacción" #. Tag: phrase -#: using.docbook:149 +#: using.docbook:150 #, no-c-format msgid "Set reaction data edition dialog" msgstr "Diálogo de edición para establecer los datos de una reacción" #. Tag: title -#: using.docbook:155 +#: using.docbook:156 #, no-c-format msgid "Condition edition" msgstr "Edición de condiciones" #. Tag: para -#: using.docbook:157 +#: using.docbook:158 #, no-c-format msgid "" "The condition that acts as a trigger of a reaction can be a simple condition " @@ -895,7 +916,7 @@ "primero." #. Tag: para -#: using.docbook:158 +#: using.docbook:159 #, no-c-format msgid "" "Due to this, conditions are represented in a tree, and it also affects how " @@ -905,7 +926,7 @@ "manera en que son editadas." #. Tag: para -#: using.docbook:159 +#: using.docbook:160 #, no-c-format msgid "" "A condition can be added as the root condition when there are no other " @@ -922,33 +943,37 @@ "condición y establecer una nueva." #. Tag: screeninfo -#: using.docbook:162 +#: using.docbook:163 #, no-c-format msgid "The dialog to select the type of the new condition to add" msgstr "El diálogo para seleccionar el tipo de la nueva condición a añadir." #. Tag: phrase -#: using.docbook:168 +#: using.docbook:169 #, no-c-format msgid "New condition dialog" msgstr "Diálogo de nueva condición" #. Tag: para -#: using.docbook:173 +#: using.docbook:174 #, no-c-format msgid "" -"Only simple conditions (waiting for an event, waiting for a signal and " -"waiting for a window to be shown) can be edited, showing specific dialogs " -"for it. Composed conditions only group other conditions, so they don't have " -"properties to be edited." +"Only simple conditions (waiting for an event, waiting for a signal, waiting " +"for a window to be shown and waiting for a property to have certain value) " +"can be edited, showing specific dialogs for it. Composed conditions only " +"group other conditions, so they don't have properties to be edited. The " +"condition to wait for its step to be activated, despite being a simple " +"condition, can not be edited either." msgstr "" -"Sólo las condiciones simples (esperar por un evento, esperar por una señal y " -"esperar a que se muestre una ventana) pueden editarse, lo que muestra " -"diálogos específicos para ello. Las condiciones compuestas sólo agrupan " -"otras condiciones, por lo que no tienen propiedades que editar." +"Sólo las condiciones simples (esperar por un evento, esperar por una señal, " +"esperar a que se muestre una ventana y esperar a que una propiedad tenga " +"cierto valor) pueden editarse, lo que muestra diálogos específicos para " +"ello. Las condiciones compuestas sólo agrupan otras condiciones, por lo que " +"no tienen propiedades que editar. La condición para esperar a que se active " +"su paso, a pesar de ser una condición simple, tampoco puede ser editada." #. Tag: para -#: using.docbook:174 +#: using.docbook:175 #, no-c-format msgid "" "Any condition can be removed from its parent composed condition, or from the " @@ -958,7 +983,7 @@ "contiene, o de la reacción si es la condición raíz." #. Tag: para -#: using.docbook:176 +#: using.docbook:177 #, no-c-format msgid "" "There is a special type of condition that verifies that its negated " @@ -981,13 +1006,13 @@ "éste debe añadirse una reacción que pueda cumplirse si la otra no." #. Tag: title -#: using.docbook:179 +#: using.docbook:180 #, no-c-format msgid "Conditions and modal dialogs" msgstr "Condiciones y diálogos modales" #. Tag: para -#: using.docbook:180 +#: using.docbook:181 #, no-c-format msgid "" "Modal dialogs are those that block the interaction with the windows of the " @@ -1006,7 +1031,7 @@ "documento." #. Tag: para -#: using.docbook:181 +#: using.docbook:182 #, no-c-format msgid "" "Take, for example, an <emphasis>Open file</emphasis> dialog. If the " @@ -1026,7 +1051,7 @@ "<emphasis>Abrir archivo</emphasis>." #. Tag: para -#: using.docbook:182 +#: using.docbook:183 #, no-c-format msgid "" "The condition to wait for windows to be shown supports both windows and " @@ -1040,13 +1065,13 @@ "diálogo modal o un diálogo no modal." #. Tag: title -#: using.docbook:189 +#: using.docbook:190 #, no-c-format msgid "Interacting with the target application" msgstr "Interactuando con la aplicación objetivo" #. Tag: para -#: using.docbook:191 +#: using.docbook:192 #, no-c-format msgid "" "When a tutorial is being designed it is usually necessary to know some " @@ -1062,7 +1087,7 @@ "desarrolladores de la aplicación sepan esas cosas de memoria." #. Tag: para -#: using.docbook:192 +#: using.docbook:193 #, no-c-format msgid "" "To help with this problem &ktutorial-editor; is able to \"talk\" with any " @@ -1078,7 +1103,7 @@ "los objetos a los que puede acceder KTutorial en la aplicación objetivo." #. Tag: para -#: using.docbook:193 +#: using.docbook:194 #, no-c-format msgid "" "Note, however, that the intercommunication system between &ktutorial-editor; " @@ -1095,13 +1120,13 @@ "posiblemente ya sabes qué significa todo esto ;)" #. Tag: title -#: using.docbook:196 +#: using.docbook:197 #, no-c-format msgid "Starting the target application" msgstr "Arrancando la aplicación objetivo" #. Tag: para -#: using.docbook:198 +#: using.docbook:199 #, no-c-format msgid "" "&ktutorial-editor; requires an instance of the target application to be " @@ -1113,7 +1138,7 @@ "haber sido lanzada por el propio &ktutorial-editor;." #. Tag: para -#: using.docbook:199 +#: using.docbook:200 #, no-c-format msgid "" "So, how can the target application be started from &ktutorial-editor;? When " @@ -1130,7 +1155,7 @@ "la aplicación de manera manual." #. Tag: para -#: using.docbook:200 +#: using.docbook:201 #, no-c-format msgid "" "Note that the application list contains all the known KDE applications in " @@ -1144,7 +1169,7 @@ "no es válida." #. Tag: para -#: using.docbook:201 +#: using.docbook:202 #, no-c-format msgid "" "Once a valid target application has been specified it will be used " @@ -1159,13 +1184,13 @@ "aplicación objetivo." #. Tag: title -#: using.docbook:205 +#: using.docbook:206 #, no-c-format msgid "Choosing an object in the target application" msgstr "Escoger un objeto en la aplicación objetivo" #. Tag: para -#: using.docbook:207 +#: using.docbook:208 #, no-c-format msgid "" "When you want to choose an object from the target application a list with " @@ -1181,7 +1206,7 @@ "también muestra la relación padre-hijo entre objetos." #. Tag: para -#: using.docbook:208 +#: using.docbook:209 #, no-c-format msgid "" "The list is updated when there are changes in the target application. For " @@ -1193,7 +1218,7 @@ "diálogo y todos sus hijos se mostrarán en la lista." #. Tag: para -#: using.docbook:209 +#: using.docbook:210 #, no-c-format msgid "" "Usually, the objects used in tutorials are widgets, so when a widget is " @@ -1206,9 +1231,24 @@ "no tienen representación gráfica." #. Tag: para -#: using.docbook:210 +#: using.docbook:211 #, no-c-format msgid "" +"As widgets are the most used objects in tutorials, plain objects can be " +"filtered from the list. In the same way, objects without name can also be " +"filtered. However, some objects may appear in the list even if they should " +"be hidden when they have any descendant that passes the enabled filters." +msgstr "" +"Dado que en los tutoriales los objetos más utilizados son los widgets, los " +"objetos sencillos pueden filtrarse en la lista. Asimismo, también se pueden " +"filtrar los objetos sin nombre. Sin embargo, algunos objetos podrían " +"aparecer en la lista incluso si deberían estar ocultos cuando tienen algún " +"descendiente que sí pasa los filtros activos." + +#. Tag: para +#: using.docbook:212 +#, no-c-format +msgid "" "When the list with the objects is shown, the rest of the &ktutorial-editor; " "windows are hidden. It is made to better view the widgets when they are " "highlighted in the target application. The &ktutorial-editor; windows are " @@ -1221,11 +1261,92 @@ #. Tag: title #: using.docbook:214 #, no-c-format +msgid "Objects with duplicated names" +msgstr "Objetos con nombres duplicados" + +#. Tag: para +#: using.docbook:215 +#, no-c-format +msgid "" +"Usually, the name of an object in the target application will identify that " +"and only that object. However, sometimes there could be two or more objects " +"with the same name. For example, if there are two or more dialogs opened, " +"there will probably be two or more objects named <literal>Ok button</" +"literal>." +msgstr "" +"Generalmente, el nombre de un objeto en la aplicación objetivo identificará " +"a ese objeto y sólo a ese objeto. Sin embargo, en ocasiones podría haber dos " +"o más objetos con el mismo nombre. Por ejemplo, si hay dos o más diálogos " +"abiertos, probablemente haya dos o más objetos llamados <literal>Ok button</" +"literal>." + +#. Tag: para +#: using.docbook:216 +#, no-c-format +msgid "" +"Therefore, when two or more objects have the same name, they can not be " +"identified by their name alone. Instead, their name must be qualified with " +"the name of one or more ancestor objects. For example, " +"<literal>Configuration dialog/Ok button</literal>. When an object is chosen " +"in the list, &ktutorial-editor; takes care of all this and gets a unique " +"name for the object." +msgstr "" +"Por lo tanto, cuando dos o más objetos tienen el mismo nombre no se les " +"puede identificar utilizando únicamente dicho nombre. En cambio, su nombre " +"debe acompañarse con el nombre de uno o más de sus objetos ancestros. Por " +"ejemplo, <literal>Configuration dialog/Ok button</literal>. Cuando se escoge " +"un objeto en la lista, &ktutorial-editor; se encarga de todo esto y escoge " +"un nombre único para el objeto." + +#. Tag: para +#: using.docbook:217 +#, no-c-format +msgid "" +"But note that a name and the object it represents depends on the state of " +"the target application. For example, if there is a dialog named " +"<literal>Configuration dialog</literal> with a button named <literal>Ok " +"button</literal>, its unique name could be just <literal>Ok button</" +"literal>. However, if another dialog named <literal>File information dialog</" +"literal> were opened while the <literal>Configuration dialog</literal> was " +"still opened, and <literal>File information dialog</literal> had a also " +"button called <literal>Ok button</literal>, now the unique name of the first " +"button would be <literal>Configuration dialog/Ok button</literal>. In this " +"situation, <literal>Ok button</literal> would not represent a specific " +"object in the target application." +msgstr "" +"Pero ten en cuenta que el nombre y el objeto al que representa dependen del " +"estado de la aplicación objetivo. Por ejemplo, si hay un diálogo llamado " +"<literal>Configuration dialog</literal> con un botón llamado <literal>Ok " +"button</literal>, su nombre único podría ser simplemente <literal>Ok button</" +"literal>. Sin embargo, si se abriese otro diálogo llamado <literal>File " +"information dialog</literal> cuando el diálogo <literal>Configuration " +"dialog</literal> estuviese abierto, y el diálogo <literal>File information " +"dialog</literal> tuviese también un botón llamado <literal>Ok button</" +"literal>, ahora el nombre único del primer botón sería " +"<literal>Configuration dialog/Ok button</literal>. En esta situación, " +"<literal>Ok button</literal> no representaría a un objeto específico en la " +"aplicación objetivo." + +#. Tag: para +#: using.docbook:218 +#, no-c-format +msgid "" +"All that means that, when choosing an object from the target application, " +"the target application should be in the same state as it would be when " +"following the tutorial and getting to the current step." +msgstr "" +"Todo esto quiere decir que, cuando se seleccione un objeto de la aplicación " +"objetivo, la aplicación objetivo debería estar en el mismo estado en que " +"estará cuando se siga el tutorial y se llegue al paso actual." + +#. Tag: title +#: using.docbook:223 +#, no-c-format msgid "Testing a tutorial in the target application" msgstr "Probar un tutorial en la aplicación objetivo" #. Tag: para -#: using.docbook:216 +#: using.docbook:225 #, no-c-format msgid "" "Designing a tutorial is not a failproof task. Maybe your custom code does " @@ -1240,22 +1361,24 @@ "veces." #. Tag: para -#: using.docbook:217 +#: using.docbook:226 #, no-c-format msgid "" "Exporting the tutorial to the application data directory and then starting " "the target application each time you want to test the tutorial can be very " "tedious. To ease testing the tutorial, &ktutorial-editor; is able to start " -"the tutorial being designed directly in the target application." +"the tutorial being designed directly in the target application. The tutorial " +"can be started from the beginning or from the currently selected step." msgstr "" "Exportar el tutorial al directorio de datos de la aplicación y luego " "arrancar la aplicación objetivo cada vez que quieras probar el tutorial " "puede ser muy tedioso. Para hacer más fácil probar el tutorial, &ktutorial-" "editor; es capaz de empezar el tutorial que se está diseñando directamente " -"en la aplicación objetivo." +"en la aplicación objetivo. El tutorial puede empezarse desde el principio o " +"desde el paso seleccionado actualmente." #. Tag: para -#: using.docbook:218 +#: using.docbook:227 #, no-c-format msgid "" "Note, however, that after closing the tutorial the target application will " @@ -1271,13 +1394,13 @@ "quieres empezarlo desde la aplicación misma." #. Tag: title -#: using.docbook:222 +#: using.docbook:231 #, no-c-format msgid "Other less noticeable features" msgstr "Otras características menos evidentes" #. Tag: para -#: using.docbook:224 +#: using.docbook:233 #, no-c-format msgid "" "Besides those already mentioned, &ktutorial-editor; uses a running target " @@ -1288,7 +1411,7 @@ "igualmente útiles características." #. Tag: para -#: using.docbook:225 +#: using.docbook:234 #, no-c-format msgid "" "The one-line text editors to set the name of an object have text completion, " @@ -1302,22 +1425,39 @@ "el nombre en base a los objetos de la aplicación objetivo." #. Tag: para -#: using.docbook:226 +#: using.docbook:235 #, no-c-format msgid "" "The one-line text editor to set the name of a signal also has text " "completion, so when the object name was set, the text editor will suggest " -"the signal name based on the signals that can be emitted by that object." +"the signal name based on the signals that can be emitted by that object. The " +"same schema is used for the name of properties." msgstr "" "Los editores de texto de una única línea para establecer el nombre de una " "señal también tienen completado de texto, por lo que una vez que se " "establece el nombre del objeto, el editor de texto sugerirá el nombre de la " -"señal en base a las señales que pueden ser emitidas por ese objeto." +"señal en base a las señales que pueden ser emitidas por ese objeto. El " +"nombre de las propiedades sigue este mismo esquema." #. Tag: para -#: using.docbook:227 +#: using.docbook:236 #, no-c-format msgid "" +"The one-line text editors for step ids in the step data and reaction dialogs " +"have text completion too. The first one will suggest the ids not assigned " +"yet (from the <emphasis>change to step</emphasis> field of the reactions), " +"and the second one will suggest the ids already set in the steps." +msgstr "" +"Los editores de texto de una única línea para identificadores de pasos en " +"los diálogos de datos del paso y de reacciones también tienen completado de " +"texto. El primero sugerirá los identificadores que no fueron asignados " +"todavía (del campo <emphasis>cambiar al paso</emphasis> de las reacciones), " +"y el segundo sugerirá los identificadores ya establecidos en los pasos." + +#. Tag: para +#: using.docbook:237 +#, no-c-format +msgid "" "The text completion uses the standard KDE text completion system, so all the " "standard keyboard shortcuts can be used (like <keycombo action=\"simul" "\">&Ctrl;<keycap>T</keycap></keycombo> to show all the available " @@ -1329,25 +1469,25 @@ "todas las propuestas de completado disponibles)." #. Tag: screeninfo -#: using.docbook:230 +#: using.docbook:240 #, no-c-format msgid "An example of text completion for a signal name" msgstr "Un ejemplo de completado de texto para el nombre de una señal" #. Tag: phrase -#: using.docbook:236 +#: using.docbook:246 #, no-c-format msgid "Signal name completion" msgstr "Completado del nombre de una señal" #. Tag: title -#: using.docbook:244 +#: using.docbook:254 #, no-c-format msgid "Saving and loading again the tutorial" msgstr "Guardar y cargar de nuevo el tutorial" #. Tag: para -#: using.docbook:246 +#: using.docbook:256 #, no-c-format msgid "" "&ktutorial-editor; supports saving a tutorial being designed so it can be " @@ -1364,7 +1504,7 @@ "guimenuitem></menuchoice>." #. Tag: para -#: using.docbook:247 +#: using.docbook:257 #, no-c-format msgid "" "Note that tutorials are saved in an XML format specific to &ktutorial-" @@ -1378,7 +1518,7 @@ "\">exportarse</link> para que KTutorial pueda entenderlo." #. Tag: para -#: using.docbook:248 +#: using.docbook:258 #, no-c-format msgid "" "Also note that loading and saving a tutorial does not need to be done from " @@ -1392,7 +1532,7 @@ "(mediante <acronym>FTP</acronym>, <acronym>SSH</acronym>, etc)." #. Tag: para -#: using.docbook:249 +#: using.docbook:259 #, no-c-format msgid "" "When a tutorial is loaded or saved it is added to the recently used file " @@ -1406,13 +1546,13 @@ "una forma rápida de cargar un tutorial usado recientemente de dicha lista." #. Tag: title -#: using.docbook:253 +#: using.docbook:263 #, no-c-format msgid "Exporting the tutorial" msgstr "Exportación del tutorial" #. Tag: para -#: using.docbook:255 +#: using.docbook:265 #, no-c-format msgid "" "Once you have finished designing the tutorial you can export it to a " @@ -1431,7 +1571,7 @@ "\"understanding-ktutorial\"/>." #. Tag: para -#: using.docbook:256 +#: using.docbook:266 #, no-c-format msgid "" "The export dialog also supports exporting to remote directories, although it " @@ -1441,13 +1581,13 @@ "aunque sería muy extraño que necesitases hacer eso." #. Tag: title -#: using.docbook:260 +#: using.docbook:270 #, no-c-format msgid "Command Line Options" msgstr "Opciones de la línea de órdenes" #. Tag: para -#: using.docbook:262 +#: using.docbook:272 #, no-c-format msgid "" "Though &ktutorial-editor; will be usually started from the &kde; program " @@ -1461,7 +1601,7 @@ "disponibles en este caso." #. Tag: para -#: using.docbook:264 +#: using.docbook:274 #, no-c-format msgid "" "Apart from generic &kde; command line options, &ktutorial-editor; optionally " @@ -1471,7 +1611,7 @@ "editor; acepta de manera opcional una URL desde la que cargar un tutorial:" #. Tag: cmdsynopsis -#: using.docbook:265 +#: using.docbook:275 #, no-c-format msgid "" "<command>ktutorial-editor</command> <arg choice=\"opt\" rep=\"norepeat" @@ -1481,7 +1621,7 @@ "\">URL</arg>" #. Tag: para -#: using.docbook:266 +#: using.docbook:276 #, no-c-format msgid "" "The URL does not need to be a local file; remote directories are also " @@ -1491,38 +1631,38 @@ "remotos." #. Tag: title -#: using.docbook:269 +#: using.docbook:279 #, no-c-format msgid "Default &kde; Command Line Options" msgstr "Opciones por defecto de &kde; de la línea de órdenes" #. Tag: para -#: using.docbook:271 +#: using.docbook:281 #, no-c-format msgid "The following command line help options are available:" msgstr "" "Las siguientes opciones de ayuda en la línea de órdenes están disponibles:" #. Tag: command -#: using.docbook:276 +#: using.docbook:286 #, no-c-format msgid "ktutorial-editor <option>--help</option>" msgstr "ktutorial-editor <option>--help</option>" #. Tag: para -#: using.docbook:279 +#: using.docbook:289 #, no-c-format msgid "This lists the most basic options available at the command line." msgstr "Lista las opciones más básicas disponibles en la línea de órdenes." #. Tag: command -#: using.docbook:285 +#: using.docbook:295 #, no-c-format msgid "ktutorial-editor <option>--help-qt</option>" msgstr "ktutorial-editor <option>--help-qt</option>" #. Tag: para -#: using.docbook:288 +#: using.docbook:298 #, no-c-format msgid "" "This lists the options available for changing the way &ktutorial-editor; " @@ -1532,13 +1672,13 @@ "editor; interacciona con &Qt;." #. Tag: command -#: using.docbook:294 +#: using.docbook:304 #, no-c-format msgid "ktutorial-editor <option>--help-kde</option>" msgstr "ktutorial-editor <option>--help-kde</option>" #. Tag: para -#: using.docbook:297 +#: using.docbook:307 #, no-c-format msgid "" "This lists the options available for changing the way &ktutorial-editor; " @@ -1548,37 +1688,37 @@ "editor; interacciona con &kde;." #. Tag: command -#: using.docbook:303 +#: using.docbook:313 #, no-c-format msgid "ktutorial-editor <option>--help-all</option>" msgstr "ktutorial-editor <option>--help-all</option>" #. Tag: para -#: using.docbook:306 +#: using.docbook:316 #, no-c-format msgid "This lists all of the command line options." msgstr "Lista todas las opciones de la línea de órdenes." #. Tag: command -#: using.docbook:312 +#: using.docbook:322 #, no-c-format msgid "ktutorial-editor <option>--author</option>" msgstr "ktutorial-editor <option>--author</option>" #. Tag: para -#: using.docbook:315 +#: using.docbook:325 #, no-c-format msgid "Lists &ktutorial-editor;'s author in the terminal window." msgstr "Lista los autores de &ktutorial-editor; en la terminal." #. Tag: command -#: using.docbook:321 +#: using.docbook:331 #, no-c-format msgid "ktutorial-editor <option>--version</option>" msgstr "ktutorial-editor <option>--version</option>" #. Tag: para -#: using.docbook:324 +#: using.docbook:334 #, no-c-format msgid "" "Lists version information for &Qt;, &kde;, and &ktutorial-editor;. Also " @@ -1589,13 +1729,13 @@ "command>." #. Tag: command -#: using.docbook:330 +#: using.docbook:340 #, no-c-format msgid "ktutorial-editor <option>--license</option>" msgstr "ktutorial-editor <option>--license</option>" #. Tag: para -#: using.docbook:333 +#: using.docbook:343 #, no-c-format msgid "Shows &ktutorial-editor;'s license text in the terminal window." msgstr "Muestra el texto de la licencia de &ktutorial-editor; en la terminal." @@ -1986,14 +2126,34 @@ msgid "Starts the tutorial in the target application." msgstr "Empieza el tutorial en la aplicación objetivo." +#. Tag: menuchoice +#: commands.docbook:343 +#, no-c-format +msgid "" +"<guimenu>Edit</guimenu> <guimenuitem>Test tutorial from current step</" +"guimenuitem>" +msgstr "" +"<guimenu>Editar</guimenu> <guimenuitem>Probar tutorial desde el paso actual<" +"/guimenuitem>" + +#. Tag: action +#: commands.docbook:350 +#, no-c-format +msgid "" +"Starts the tutorial in the target application from the currently selected " +"step." +msgstr "" +"Empieza el tutorial en la aplicación objetivo desde el paso seleccionado " +"actualmente." + #. Tag: title -#: commands.docbook:346 +#: commands.docbook:359 #, no-c-format msgid "The <guimenu>View</guimenu> Menu" msgstr "El menú <guimenu>Ver</guimenu>" #. Tag: menuchoice -#: commands.docbook:351 +#: commands.docbook:364 #, no-c-format msgid "" "<guimenu>View</guimenu> <guimenuitem>Panels</guimenuitem> <guimenuitem>Edit " @@ -2003,7 +2163,7 @@ "<guimenuitem>Editar tutorial</guimenuitem>" #. Tag: action -#: commands.docbook:359 +#: commands.docbook:372 #, no-c-format msgid "Shows or hides the panel with the shorcuts to tutorial edition actions." msgstr "" @@ -2011,7 +2171,7 @@ "del tutorial." #. Tag: menuchoice -#: commands.docbook:365 +#: commands.docbook:378 #, no-c-format msgid "" "<guimenu>View</guimenu> <guimenuitem>Panels</guimenuitem> <guimenuitem>Edit " @@ -2021,7 +2181,7 @@ "<guimenuitem>Editar paso</guimenuitem>" #. Tag: action -#: commands.docbook:373 +#: commands.docbook:386 #, no-c-format msgid "Shows or hides the panel with the shorcuts to step edition actions." msgstr "" @@ -2029,7 +2189,7 @@ "de los pasos." #. Tag: menuchoice -#: commands.docbook:379 +#: commands.docbook:392 #, no-c-format msgid "" "<guimenu>View</guimenu> <guimenuitem>Panels</guimenuitem> <guimenuitem>Edit " @@ -2039,7 +2199,7 @@ "<guimenuitem>Editar reacción</guimenuitem>" #. Tag: action -#: commands.docbook:387 +#: commands.docbook:400 #, no-c-format msgid "Shows or hides the panel with the shorcuts to reaction edition actions." msgstr "" @@ -2047,13 +2207,13 @@ "de las reacciones." #. Tag: title -#: commands.docbook:396 +#: commands.docbook:409 #, no-c-format msgid "The <guimenu>Settings</guimenu> Menu" msgstr "El menú <guimenu>Preferencias</guimenu>" #. Tag: menuchoice -#: commands.docbook:401 +#: commands.docbook:414 #, no-c-format msgid "<guimenu>Settings</guimenu> <guimenuitem>Show Toolbar</guimenuitem>" msgstr "" @@ -2061,13 +2221,13 @@ "herramientas</guimenuitem>" #. Tag: action -#: commands.docbook:408 +#: commands.docbook:421 #, no-c-format msgid "Shows or hides the main toolbar." msgstr "Muestra u oculta la barra de herramientas principal." #. Tag: menuchoice -#: commands.docbook:414 +#: commands.docbook:427 #, no-c-format msgid "<guimenu>Settings</guimenu> <guimenuitem>Show Statusbar</guimenuitem>" msgstr "" @@ -2075,13 +2235,13 @@ "guimenuitem>" #. Tag: action -#: commands.docbook:421 +#: commands.docbook:434 #, no-c-format msgid "Shows or hides the statusbar." msgstr "Muestra u oculta la barra de estado." #. Tag: menuchoice -#: commands.docbook:427 +#: commands.docbook:440 #, no-c-format msgid "" "<guimenu>Settings</guimenu> <guimenuitem>Configure Shortcuts...</guimenuitem>" @@ -2090,13 +2250,13 @@ "rápidos...</guimenuitem>" #. Tag: action -#: commands.docbook:434 +#: commands.docbook:447 #, no-c-format msgid "Opens a configure dialog for binding keys to actions." msgstr "Abre el diálogo de configuración para asociar teclas con acciones." #. Tag: menuchoice -#: commands.docbook:440 +#: commands.docbook:453 #, no-c-format msgid "" "<guimenu>Settings</guimenu> <guimenuitem>Configure Toolbars...</guimenuitem>" @@ -2105,7 +2265,7 @@ "herramientas...</guimenuitem>" #. Tag: action -#: commands.docbook:447 +#: commands.docbook:460 #, no-c-format msgid "" "Opens a configure dialog for selecting the actions to show in the toolbar." @@ -2114,13 +2274,13 @@ "la barra de herramientas." #. Tag: title -#: commands.docbook:456 +#: commands.docbook:469 #, no-c-format msgid "The <guimenu>Help</guimenu> Menu" msgstr "El menú <guimenu>Ayuda</guimenu>" #. Tag: sect2 -#: commands.docbook:456 +#: commands.docbook:469 #, no-c-format msgid "&help.menu.documentation;" msgstr "&help.menu.documentation;" @@ -2252,15 +2412,14 @@ msgid "" "<prompt>$</prompt> <userinput><command>mkdir</command> build && " "<command>cd</command> build</userinput>\n" -" <prompt>$</prompt> <userinput><command>cmake</command> ..</" -"userinput>\n" -" <prompt>$</prompt> <userinput><command>make</command></userinput>" +"<prompt>$</prompt> <userinput><command>cmake</command> ..</userinput>\n" +"<prompt>$</prompt> <userinput><command>make</command></userinput>" msgstr "" "<prompt>$</prompt> <userinput><command>mkdir</command> build && " "<command>cd</command> build</userinput>\n" -" <prompt>$</prompt> <userinput><command>cmake</command> ..</" +"<prompt>$</prompt> <userinput><command>cmake</command> ..</" "userinput>\n" -" <prompt>$</prompt> <userinput><command>make</command></userinput>" +"<prompt>$</prompt> <userinput><command>make</command></userinput>" #. Tag: para #: installation.docbook:39 Modified: trunk/ktutorial/ktutorial-editor/doc/es/new-condition.png =================================================================== (Binary files differ) Modified: trunk/ktutorial/ktutorial-editor/doc/es/set-step-data.png =================================================================== (Binary files differ) Modified: trunk/ktutorial/ktutorial-editor/doc/header.pot =================================================================== --- trunk/ktutorial/ktutorial-editor/doc/header.pot 2011-06-17 01:49:37 UTC (rev 327) +++ trunk/ktutorial/ktutorial-editor/doc/header.pot 2011-06-17 01:51:56 UTC (rev 328) @@ -9,7 +9,7 @@ "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" "group_id=301227&atid=1270278\n" -"POT-Creation-Date: 2010-10-29 21:49+0000\n" +"POT-Creation-Date: 2011-06-15 15:47+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" Modified: trunk/ktutorial/ktutorial-editor/doc/ktutorial-editor-handbook.pot =================================================================== --- trunk/ktutorial/ktutorial-editor/doc/ktutorial-editor-handbook.pot 2011-06-17 01:49:37 UTC (rev 327) +++ trunk/ktutorial/ktutorial-editor/doc/ktutorial-editor-handbook.pot 2011-06-17 01:51:56 UTC (rev 328) @@ -9,7 +9,7 @@ "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" "group_id=301227&atid=1270278\n" -"POT-Creation-Date: 2010-10-29 21:49+0000\n" +"POT-Creation-Date: 2011-06-15 15:47+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" @@ -558,16 +558,29 @@ msgstr "" #. Tag: para -#: using.docbook:116 +#: using.docbook:115 #, no-c-format msgid "" +"To ease all these things, &ktutorial-editor; provides several buttons in the " +"step data dialog that help writing KDE semantic markup tags. These buttons " +"insert the start and end tags for an element as needed, and are enabled or " +"disabled based on the position of the cursor in the text. For example, the " +"button to insert a paragraph tag will be disabled if the cursor is inside a " +"link, but the button to insert a link tag will be enabled if the cursor is " +"inside a paragraph." +msgstr "" + +#. Tag: para +#: using.docbook:117 +#, no-c-format +msgid "" "The step data dialog is also shown when a new step is added. If the dialog " "is accepted, the step is added. If the dialog is cancelled, the step is not " "added." msgstr "" #. Tag: para -#: using.docbook:117 +#: using.docbook:118 #, no-c-format msgid "" "Also note that, in every tutorial, there must be one step with id " @@ -575,19 +588,19 @@ msgstr "" #. Tag: screeninfo -#: using.docbook:120 +#: using.docbook:121 #, no-c-format msgid "The dialog to set the id and text of a step" msgstr "" #. Tag: phrase -#: using.docbook:126 +#: using.docbook:127 #, no-c-format msgid "Step data edition dialog" msgstr "" #. Tag: para -#: using.docbook:131 +#: using.docbook:132 #, no-c-format msgid "" "The setup and tear down code dialogs behave like the tutorial ones. The only " @@ -596,7 +609,7 @@ msgstr "" #. Tag: para -#: using.docbook:132 +#: using.docbook:133 #, no-c-format msgid "" "Also note that the exported scripted tutorial creates all the reactions in " @@ -604,13 +617,13 @@ msgstr "" #. Tag: title -#: using.docbook:136 +#: using.docbook:137 #, no-c-format msgid "Reaction edition" msgstr "" #. Tag: para -#: using.docbook:138 +#: using.docbook:139 #, no-c-format msgid "" "The reaction dialog is used to set the trigger and response of a reaction. " @@ -619,7 +632,7 @@ msgstr "" #. Tag: para -#: using.docbook:139 +#: using.docbook:140 #, no-c-format msgid "" "The trigger can be either an option selected or a condition met, but not " @@ -630,7 +643,7 @@ msgstr "" #. Tag: para -#: using.docbook:140 +#: using.docbook:141 #, no-c-format msgid "" "Likely, the response can be changing to another step or executing some " @@ -641,25 +654,25 @@ msgstr "" #. Tag: screeninfo -#: using.docbook:143 +#: using.docbook:144 #, no-c-format msgid "The dialog to set the trigger and response of a reaction" msgstr "" #. Tag: phrase -#: using.docbook:149 +#: using.docbook:150 #, no-c-format msgid "Set reaction data edition dialog" msgstr "" #. Tag: title -#: using.docbook:155 +#: using.docbook:156 #, no-c-format msgid "Condition edition" msgstr "" #. Tag: para -#: using.docbook:157 +#: using.docbook:158 #, no-c-format msgid "" "The condition that acts as a trigger of a reaction can be a simple condition " @@ -670,7 +683,7 @@ msgstr "" #. Tag: para -#: using.docbook:158 +#: using.docbook:159 #, no-c-format msgid "" "Due to this, conditions are represented in a tree, and it also affects how " @@ -678,7 +691,7 @@ msgstr "" #. Tag: para -#: using.docbook:159 +#: using.docbook:160 #, no-c-format msgid "" "A condition can be added as the root condition when there are no other " @@ -689,29 +702,31 @@ msgstr "" #. Tag: screeninfo -#: using.docbook:162 +#: using.docbook:163 #, no-c-format msgid "The dialog to select the type of the new condition to add" msgstr "" #. Tag: phrase -#: using.docbook:168 +#: using.docbook:169 #, no-c-format msgid "New condition dialog" msgstr "" #. Tag: para -#: using.docbook:173 +#: using.docbook:174 #, no-c-format msgid "" -"Only simple conditions (waiting for an event, waiting for a signal and " -"waiting for a window to be shown) can be edited, showing specific dialogs " -"for it. Composed conditions only group other conditions, so they don't have " -"properties to be edited." +"Only simple conditions (waiting for an event, waiting for a signal, waiting " +"for a window to be shown and waiting for a property to have certain value) " +"can be edited, showing specific dialogs for it. Composed conditions only " +"group other conditions, so they don't have properties to be edited. The " +"condition to wait for its step to be activated, despite being a simple " +"condition, can not be edited either." msgstr "" #. Tag: para -#: using.docbook:174 +#: using.docbook:175 #, no-c-format msgid "" "Any condition can be removed from its parent composed condition, or from the " @@ -719,7 +734,7 @@ msgstr "" #. Tag: para -#: using.docbook:176 +#: using.docbook:177 #, no-c-format msgid "" "There is a special type of condition that verifies that its negated " @@ -733,13 +748,13 @@ msgstr "" #. Tag: title -#: using.docbook:179 +#: using.docbook:180 #, no-c-format msgid "Conditions and modal dialogs" msgstr "" #. Tag: para -#: using.docbook:180 +#: using.docbook:181 #, no-c-format msgid "" "Modal dialogs are those that block the interaction with the windows of the " @@ -751,7 +766,7 @@ msgstr "" #. Tag: para -#: using.docbook:181 +#: using.docbook:182 #, no-c-format msgid "" "Take, for example, an <emphasis>Open file</emphasis> dialog. If the " @@ -764,7 +779,7 @@ msgstr "" #. Tag: para -#: using.docbook:182 +#: using.docbook:183 #, no-c-format msgid "" "The condition to wait for windows to be shown supports both windows and " @@ -774,13 +789,13 @@ msgstr "" #. Tag: title -#: using.docbook:189 +#: using.docbook:190 #, no-c-format msgid "Interacting with the target application" msgstr "" #. Tag: para -#: using.docbook:191 +#: using.docbook:192 #, no-c-format msgid "" "When a tutorial is being designed it is usually necessary to know some " @@ -791,7 +806,7 @@ msgstr "" #. Tag: para -#: using.docbook:192 +#: using.docbook:193 #, no-c-format msgid "" "To help with this problem &ktutorial-editor; is able to \"talk\" with any " @@ -802,7 +817,7 @@ msgstr "" #. Tag: para -#: using.docbook:193 +#: using.docbook:194 #, no-c-format msgid "" "Note, however, that the intercommunication system between &ktutorial-editor; " @@ -813,13 +828,13 @@ msgstr "" #. Tag: title -#: using.docbook:196 +#: using.docbook:197 #, no-c-format msgid "Starting the target application" msgstr "" #. Tag: para -#: using.docbook:198 +#: using.docbook:199 #, no-c-format msgid "" "&ktutorial-editor; requires an instance of the target application to be " @@ -828,7 +843,7 @@ msgstr "" #. Tag: para -#: using.docbook:199 +#: using.docbook:200 #, no-c-format msgid "" "So, how can the target application be started from &ktutorial-editor;? When " @@ -839,7 +854,7 @@ msgstr "" #. Tag: para -#: using.docbook:200 +#: using.docbook:201 #, no-c-format msgid "" "Note that the application list contains all the known KDE applications in " @@ -849,7 +864,7 @@ msgstr "" #. Tag: para -#: using.docbook:201 +#: using.docbook:202 #, no-c-format msgid "" "Once a valid target application has been specified it will be used " @@ -859,13 +874,13 @@ msgstr "" #. Tag: title -#: using.docbook:205 +#: using.docbook:206 #, no-c-format msgid "Choosing an object in the target application" msgstr "" #. Tag: para -#: using.docbook:207 +#: using.docbook:208 #, no-c-format msgid "" "When you want to choose an object from the target application a list with " @@ -876,7 +891,7 @@ msgstr "" #. Tag: para -#: using.docbook:208 +#: using.docbook:209 #, no-c-format msgid "" "The list is updated when there are changes in the target application. For " @@ -885,7 +900,7 @@ msgstr "" #. Tag: para -#: using.docbook:209 +#: using.docbook:210 #, no-c-format msgid "" "Usually, the objects used in tutorials are widgets, so when a widget is " @@ -894,9 +909,19 @@ msgstr "" #. Tag: para -#: using.docbook:210 +#: using.docbook:211 #, no-c-format msgid "" +"As widgets are the most used objects in tutorials, plain objects can be " +"filtered from the list. In the same way, objects without name can also be " +"filtered. However, some objects may appear in the list even if they should " +"be hidden when they have any descendant that passes the enabled filters." +msgstr "" + +#. Tag: para +#: using.docbook:212 +#, no-c-format +msgid "" "When the list with the objects is shown, the rest of the &ktutorial-editor; " "windows are hidden. It is made to better view the widgets when they are " "highlighted in the target application. The &ktutorial-editor; windows are " @@ -906,13 +931,68 @@ #. Tag: title #: using.docbook:214 #, no-c-format -msgid "Testing a tutorial in the target application" +msgid "Objects with duplicated names" msgstr "" #. Tag: para +#: using.docbook:215 +#, no-c-format +msgid "" +"Usually, the name of an object in the target application will identify that " +"and only that object. However, sometimes there could be two or more objects " +"with the same name. For example, if there are two or more dialogs opened, " +"there will probably be two or more objects named <literal>Ok button</" +"literal>." +msgstr "" + +#. Tag: para #: using.docbook:216 #, no-c-format msgid "" +"Therefore, when two or more objects have the same name, they can not be " +"identified by their name alone. Instead, their name must be qualified with " +"the name of one or more ancestor objects. For example, " +"<literal>Configuration dialog/Ok button</literal>. When an object is chosen " +"in the list, &ktutorial-editor; takes care of all this and gets a unique " +"name for the object." +msgstr "" + +#. Tag: para +#: using.docbook:217 +#, no-c-format +msgid "" +"But note that a name and the object it represents depends on the state of " +"the target application. For example, if there is a dialog named " +"<literal>Configuration dialog</literal> with a button named <literal>Ok " +"button</literal>, its unique name could be just <literal>Ok button</" +"literal>. However, if another dialog named <literal>File information dialog</" +"literal> were opened while the <literal>Configuration dialog</literal> was " +"still opened, and <literal>File information dialog</literal> had a also " +"button called <literal>Ok button</literal>, now the unique name of the first " +"button would be <literal>Configuration dialog/Ok button</literal>. In this " +"situation, <literal>Ok button</literal> would not represent a specific " +"object in the target application." +msgstr "" + +#. Tag: para +#: using.docbook:218 +#, no-c-format +msgid "" +"All that means that, when choosing an object from the target application, " +"the target application should be in the same state as it would be when " +"following the tutorial and getting to the current step." +msgstr "" + +#. Tag: title +#: using.docbook:223 +#, no-c-format +msgid "Testing a tutorial in the target application" +msgstr "" + +#. Tag: para +#: using.docbook:225 +#, no-c-format +msgid "" "Designing a tutorial is not a failproof task. Maybe your custom code does " "not work as expected, or you are not waiting for the right signal to be " "emitted, or you forgot some step, or... so the tutorial will have to be " @@ -920,17 +1000,18 @@ msgstr "" #. Tag: para -#: using.docbook:217 +#: using.docbook:226 #, no-c-format msgid "" "Exporting the tutorial to the application data directory and then starting " "the target application each time you want to test the tutorial can be very " "tedious. To ease testing the tutorial, &ktutorial-editor; is able to start " -"the tutorial being designed directly in the target application." +"the tutorial being designed directly in the target application. The tutorial " +"can be started from the beginning or from the currently selected step." msgstr "" #. Tag: para -#: using.docbook:218 +#: using.docbook:227 #, no-c-format msgid "" "Note, however, that after closing the tutorial the target application will " @@ -941,13 +1022,13 @@ msgstr "" #. Tag: title -#: using.docbook:222 +#: using.docbook:231 #, no-c-format msgid "Other less noticeable features" msgstr "" #. Tag: para -#: using.docbook:224 +#: using.docbook:233 #, no-c-format msgid "" "Besides those already mentioned, &ktutorial-editor; uses a running target " @@ -955,7 +1036,7 @@ msgstr "" #. Tag: para -#: using.docbook:225 +#: using.docbook:234 #, no-c-format msgid "" "The one-line text editors to set the name of an object have text completion, " @@ -965,18 +1046,29 @@ msgstr "" #. Tag: para -#: using.docbook:226 +#: using.docbook:235 #, no-c-format msgid "" "The one-line text editor to set the name of a signal also has text " "completion, so when the object name was set, the text editor will suggest " -"the signal name based on the signals that can be emitted by that object." +"the signal name based on the signals that can be emitted by that object. The " +"same schema is used for the name of properties." msgstr "" #. Tag: para -#: using.docbook:227 +#: using.docbook:236 #, no-c-format msgid "" +"The one-line text editors for step ids in the step data and reaction dialogs " +"have text completion too. The first one will suggest the ids not assigned " +"yet (from the <emphasis>change to step</emphasis> field of the reactions), " +"and the second one will suggest the ids already set in the steps." +msgstr "" + +#. Tag: para +#: using.docbook:237 +#, no-c-format +msgid "" "The text completion uses the standard KDE text completion system, so all the " "standard keyboard shortcuts can be used (like <keycombo action=\"simul" "\">&Ctrl;<keycap>T</keycap></keycombo> to show all the available " @@ -984,25 +1076,25 @@ msgstr "" #. Tag: screeninfo -#: using.docbook:230 +#: using.docbook:240 #, no-c-format msgid "An example of text completion for a signal name" msgstr "" #. Tag: phrase -#: using.docbook:236 +#: using.docbook:246 #, no-c-format msgid "Signal name completion" msgstr "" #. Tag: title -#: using.docbook:244 +#: using.docbook:254 #, no-c-format msgid "Saving and loading again the tutorial" msgstr "" #. Tag: para -#: using.docbook:246 +#: using.docbook:256 #, no-c-format msgid "" "&ktutorial-editor; supports saving a tutorial being designed so it can be " @@ -1013,7 +1105,7 @@ msgstr "" #. Tag: para -#: using.docbook:247 +#: using.docbook:257 #, no-c-format msgid "" "Note that tutorials are saved in an XML format specific to &ktutorial-" @@ -1023,7 +1115,7 @@ msgstr "" #. Tag: para -#: using.docbook:248 +#: using.docbook:258 #, no-c-format msgid "" "Also note that loading and saving a tutorial does not need to be done from " @@ -1033,7 +1125,7 @@ msgstr "" #. Tag: para -#: using.docbook:249 +#: using.docbook:259 #, no-c-format msgid "" "When a tutorial is loaded or saved it is added to the recently used file " @@ -1043,13 +1135,13 @@ msgstr "" #. Tag: title -#: using.docbook:253 +#: using.docbook:263 #, no-c-format msgid "Exporting the tutorial" msgstr "" #. Tag: para -#: using.docbook:255 +#: using.docbook:265 #, no-c-format msgid "" "Once you have finished designing the tutorial you can export it to a " @@ -1061,7 +1153,7 @@ msgstr "" #. Tag: para -#: using.docbook:256 +#: using.docbook:266 #, no-c-format msgid "" "The export dialog also supports exporting to remote directories, although it " @@ -1069,13 +1161,13 @@ msgstr "" #. Tag: title -#: using.docbook:260 +#: using.docbook:270 #, no-c-format msgid "Command Line Options" msgstr "" #. Tag: para -#: using.docbook:262 +#: using.docbook:272 #, no-c-format msgid "" "Though &ktutorial-editor; will be usually started from the &kde; program " @@ -1085,7 +1177,7 @@ msgstr "" #. Tag: para -#: using.docbook:264 +#: using.docbook:274 #, no-c-format msgid "" "Apart from generic &kde; command line options, &ktutorial-editor; optionally " @@ -1093,7 +1185,7 @@ msgstr "" #. Tag: cmdsynopsis -#: using.docbook:265 +#: using.docbook:275 #, no-c-format msgid "" "<command>ktutorial-editor</command> <arg choice=\"opt\" rep=\"norepeat" @@ -1101,7 +1193,7 @@ msgstr "" #. Tag: para -#: using.docbook:266 +#: using.docbook:276 #, no-c-format msgid "" "The URL does not need to be a local file; remote directories are also " @@ -1109,37 +1201,37 @@ msgstr "" #. Tag: title -#: using.docbook:269 +#: using.docbook:279 #, no-c-format msgid "Default &kde; Command Line Options" msgstr "" #. Tag: para -#: using.docbook:271 +#: using.docbook:281 #, no-c-format msgid "The following command line help options are available:" msgstr "" #. Tag: command -#: using.docbook:276 +#: using.docbook:286 #, no-c-format msgid "ktutorial-editor <option>--help</option>" msgstr "" #. Tag: para -#: using.docbook:279 +#: using.docbook:289 #, no-c-format msgid "This lists the most basic options available at the command line." msgstr "" #. Tag: command -#: using.docbook:285 +#: using.docbook:295 #, no-c-format msgid "ktutorial-editor <option>--help-qt</option>" msgstr "" #. Tag: para -#: using.docbook:288 +#: using.docbook:298 #, no-c-format msgid "" "This lists the options available for changing the way &ktutorial-editor; " @@ -1147,13 +1239,13 @@ msgstr "" #. Tag: command -#: using.docbook:294 +#: using.docbook:304 #, no-c-format msgid "ktutorial-editor <option>--help-kde</option>" msgstr "" #. Tag: para -#: using.docbook:297 +#: using.docbook:307 #, no-c-format msgid "" "This lists the options available for changing the way &ktutorial-editor; " @@ -1161,37 +1253,37 @@ msgstr "" #. Tag: command -#: using.docbook:303 +#: using.docbook:313 #, no-c-format msgid "ktutorial-editor <option>--help-all</option>" msgstr "" #. Tag: para -#: using.docbook:306 +#: using.docbook:316 #, no-c-format msgid "This lists all of the command line options." msgstr "" #. Tag: command -#: using.docbook:312 +#: using.docbook:322 #, no-c-format msgid "ktutorial-editor <option>--author</option>" msgstr "" #. Tag: para -#: using.docbook:315 +#: using.docbook:325 #, no-c-format msgid "Lists &ktutorial-editor;'s author in the terminal window." msgstr "" #. Tag: command -#: using.docbook:321 +#: using.docbook:331 #, no-c-format msgid "ktutorial-editor <option>--version</option>" msgstr "" #. Tag: para -#: using.docbook:324 +#: using.docbook:334 #, no-c-format msgid "" "Lists version information for &Qt;, &kde;, and &ktutorial-editor;. Also " @@ -1199,13 +1291,13 @@ msgstr "" #. Tag: command -#: using.docbook:330 +#: using.docbook:340 #, no-c-format msgid "ktutorial-editor <option>--license</option>" msgstr "" #. Tag: para -#: using.docbook:333 +#: using.docbook:343 #, no-c-format msgid "Shows &ktutorial-editor;'s license text in the terminal window." msgstr "" @@ -1545,14 +1637,30 @@ msgid "Starts the tutorial in the target application." msgstr "" +#. Tag: menuchoice +#: commands.docbook:343 +#, no-c-format +msgid "" +"<guimenu>Edit</guimenu> <guimenuitem>Test tutorial from current step</" +"guimenuitem>" +msgstr "" + +#. Tag: action +#: commands.docbook:350 +#, no-c-format +msgid "" +"Starts the tutorial in the target application from the currently selected " +"step." +msgstr "" + #. Tag: title -#: commands.docbook:346 +#: commands.docbook:359 #, no-c-format msgid "The <guimenu>View</guimenu> Menu" msgstr "" #. Tag: menuchoice -#: commands.docbook:351 +#: commands.docbook:364 #, no-c-format msgid "" "<guimenu>View</guimenu> <guimenuitem>Panels</guimenuitem> <guimenuitem>Edit " @@ -1560,13 +1668,13 @@ msgstr "" #. Tag: action -#: commands.docbook:359 +#: commands.docbook:372 #, no-c-format msgid "Shows or hides the panel with the shorcuts to tutorial edition actions." msgstr "" #. Tag: menuchoice -#: commands.docbook:365 +#: commands.docbook:378 #, no-c-format msgid "" "<guimenu>View</guimenu> <guimenuitem>Panels</guimenuitem> <guimenuitem>Edit " @@ -1574,13 +1682,13 @@ msgstr "" #. Tag: action -#: commands.docbook:373 +#: commands.docbook:386 #, no-c-format msgid "Shows or hides the panel with the shorcuts to step edition actions." msgstr "" #. Tag: menuchoice -#: commands.docbook:379 +#: commands.docbook:392 #, no-c-format msgid "" "<guimenu>View</guimenu> <guimenuitem>Panels</guimenuitem> <guimenuitem>Edit " @@ -1588,76 +1696,76 @@ msgstr "" #. Tag: action -#: commands.docbook:387 +#: commands.docbook:400 #, no-c-format msgid "Shows or hides the panel with the shorcuts to reaction edition actions." msgstr "" #. Tag: title -#: commands.docbook:396 +#: commands.docbook:409 #, no-c-format msgid "The <guimenu>Settings</guimenu> Menu" msgstr "" #. Tag: menuchoice -#: commands.docbook:401 +#: commands.docbook:414 #, no-c-format msgid "<guimenu>Settings</guimenu> <guimenuitem>Show Toolbar</guimenuitem>" msgstr "" #. Tag: action -#: commands.docbook:408 +#: commands.docbook:421 #, no-c-format msgid "Shows or hides the main toolbar." msgstr "" #. Tag: menuchoice -#: commands.docbook:414 +#: commands.docbook:427 #, no-c-format msgid "<guimenu>Settings</guimenu> <guimenuitem>Show Statusbar</guimenuitem>" msgstr "" #. Tag: action -#: commands.docbook:421 +#: commands.docbook:434 #, no-c-format msgid "Shows or hides the statusbar." msgstr "" #. Tag: menuchoice -#: commands.docbook:427 +#: commands.docbook:440 #, no-c-format msgid "" "<guimenu>Settings</guimenu> <guimenuitem>Configure Shortcuts...</guimenuitem>" msgstr "" #. Tag: action -#: commands.docbook:434 +#: commands.docbook:447 #, no-c-format msgid "Opens a configure dialog for binding keys to actions." msgstr "" #. Tag: menuchoice -#: commands.docbook:440 +#: commands.docbook:453 #, no-c-format msgid "" "<guimenu>Settings</guimenu> <guimenuitem>Configure Toolbars...</guimenuitem>" msgstr "" #. Tag: action -#: commands.docbook:447 +#: commands.docbook:460 #, no-c-format msgid "" "Opens a configure dialog for selecting the actions to show in the toolbar." msgstr "" #. Tag: title -#: commands.docbook:456 +#: commands.docbook:469 #, no-c-format msgid "The <guimenu>Help</guimenu> Menu" msgstr "" #. Tag: sect2 -#: commands.docbook:456 +#: commands.docbook:469 #, no-c-format msgid "&help.menu.documentation;" msgstr "" @@ -1764,9 +1872,8 @@ msgid "" "<prompt>$</prompt> <userinput><command>mkdir</command> build && " "<command>cd</command> build</userinput>\n" -" <prompt>$</prompt> <userinput><command>cmake</command> ..</" -"userinput>\n" -" <prompt>$</prompt> <userinput><command>make</command></userinput>" +"<prompt>$</prompt> <userinput><command>cmake</command> ..</userinput>\n" +"<prompt>$</prompt> <userinput><command>make</command></userinput>" msgstr "" #. Tag: para Modified: trunk/ktutorial/ktutorial-editor/po/es.po =================================================================== --- trunk/ktutorial/ktutorial-editor/po/es.po 2011-06-17 01:49:37 UTC (rev 327) +++ trunk/ktutorial/ktutorial-editor/po/es.po 2011-06-17 01:51:56 UTC (rev 328) @@ -3,14 +3,14 @@ # Copyright (C) 2010 Daniel Calviño Sánchez # This file is distributed under the same license as the ktutorial-editor package. # -# Daniel Calviño Sánchez <dan...@gm...>, 2010. +# Daniel Calviño Sánchez <dan...@gm...>, 2010, 2011. msgid "" msgstr "" "Project-Id-Version: ktutorial-editor\n" "Report-Msgid-Bugs-To: http://sourceforge." "net/tracker/?group_id=301227&atid=1270278\n" -"POT-Creation-Date: 2010-10-29 23:49+0200\n" -"PO-Revision-Date: 2010-10-29 23:49+0200\n" +"POT-Creation-Date: 2011-06-15 15:24+0200\n" +"PO-Revision-Date: 2011-06-15 15:26+0200\n" "Last-Translator: Daniel Calviño Sánchez <dan...@gm...>\n" "Language-Team: Spanish <>\n" "MIME-Version: 1.0\n" @@ -69,12 +69,12 @@ msgid "Set step tear down code" msgstr "Establecer el código de finalización del paso" -#: commands/StepCommands.cpp:141 EditActions.cpp:303 +#: commands/StepCommands.cpp:141 EditActions.cpp:290 msgctxt "@action" msgid "Add reaction" msgstr "Añadir reacción" -#: commands/StepCommands.cpp:186 EditActions.cpp:207 +#: commands/StepCommands.cpp:186 EditActions.cpp:203 msgctxt "@action" msgid "Remove reaction" msgstr "Eliminar reacción" @@ -104,79 +104,79 @@ msgid "Set tutorial tear down code" msgstr "Establecer el código de finalización del tutorial" -#: commands/TutorialCommands.cpp:164 EditActions.cpp:264 +#: commands/TutorialCommands.cpp:164 EditActions.cpp:248 msgctxt "@action" msgid "Add step" msgstr "Añadir paso" -#: commands/TutorialCommands.cpp:209 EditActions.cpp:180 +#: commands/TutorialCommands.cpp:209 EditActions.cpp:176 msgctxt "@action" msgid "Remove step" msgstr "Eliminar paso" -#: EditActions.cpp:111 +#: EditActions.cpp:107 msgctxt "@action" msgid "Set information..." msgstr "Establecer información..." -#: EditActions.cpp:112 +#: EditActions.cpp:108 msgctxt "@info:status" msgid "Set the name and description of the tutorial." msgstr "Establecer el nombre y la descripción del tutorial." -#: EditActions.cpp:120 +#: EditActions.cpp:116 msgctxt "@action" msgid "Set license..." msgstr "Establecer licencia..." -#: EditActions.cpp:121 +#: EditActions.cpp:117 msgctxt "@info:status" msgid "Set the license text of the tutorial." msgstr "Establecer el texto de licencia del tutorial." -#: EditActions.c... [truncated message content] |
From: <dan...@us...> - 2011-07-07 10:31:23
|
Revision: 334 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=334&view=rev Author: danxuliu Date: 2011-07-07 10:31:17 +0000 (Thu, 07 Jul 2011) Log Message: ----------- Set the object name completion as case insensitive. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2011-07-07 02:31:41 UTC (rev 333) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2011-07-07 10:31:17 UTC (rev 334) @@ -123,6 +123,7 @@ KCompletion* completion = new RemoteObjectNameCompletion(mRemoteObjectNameRegister); completion->setOrder(KCompletion::Sorted); + completion->setIgnoreCase(true); ui->objectNameLineEdit->setCompletionObject(completion); ui->objectNameLineEdit->setAutoDeleteCompletionObject(true); Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-07-07 02:31:41 UTC (rev 333) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2011-07-07 10:31:17 UTC (rev 334) @@ -59,6 +59,7 @@ void testSetChosenRemoteObject(); void testSetChosenRemoteObjectWithNameNotUnique(); + void testNameCompletion(); void testDuplicatedNameCompletion(); void testTargetApplicationStartedAfterWidget(); @@ -247,6 +248,35 @@ assertRemoteObjectSignal(remoteObjectChosenSpy, 2, remoteObject); } +void RemoteObjectNameWidgetTest::testNameCompletion() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + //Give the target application time to start + QTest::qWait(1000); + + RemoteObjectNameWidget widget; + + KCompletion* completion = objectNameLineEdit(&widget)->completionObject(); + QCOMPARE(completion->order(), KCompletion::Sorted); + + QStringList completionItems = completion->allMatches("The object name 42"); + QCOMPARE(completionItems.count(), 5); + QCOMPARE(completionItems[0], QString("The object name 42")); + QCOMPARE(completionItems[1], QString("The object name 420")); + QCOMPARE(completionItems[2], QString("The object name 421")); + QCOMPARE(completionItems[3], QString("The object name 422")); + QCOMPARE(completionItems[4], QString("The object name 423")); + + completionItems = completion->allMatches("the Object Name 42"); + QCOMPARE(completionItems.count(), 5); + QCOMPARE(completionItems[0], QString("The object name 42")); + QCOMPARE(completionItems[1], QString("The object name 420")); + QCOMPARE(completionItems[2], QString("The object name 421")); + QCOMPARE(completionItems[3], QString("The object name 422")); + QCOMPARE(completionItems[4], QString("The object name 423")); +} + void RemoteObjectNameWidgetTest::testDuplicatedNameCompletion() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-08-04 15:55:07
|
Revision: 356 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=356&view=rev Author: danxuliu Date: 2012-08-04 15:54:59 +0000 (Sat, 04 Aug 2012) Log Message: ----------- Fix bug where the RemoteObjectNameRegister/Widget "missed" the name of some remote objects. Before, the name of the remote objects was registered when the object was added to its parent in the target application. This could lead to the object being registered before its name was set, so it was registered with an empty name. Now, when the object is added to its parent in the target application it is queued for its name to be registered, and after a little delay (500ms), the register of the name takes place. During that delay the register should not be queried. If during the name update in the register something is done in the RemoteObjectNameWidget which has to query the register, the operation is also queued and executed once the name update has finished. Modified Paths: -------------- 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/view/RemoteObjectNameRegisterTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.cpp 2012-07-11 14:29:47 UTC (rev 355) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.cpp 2012-08-04 15:54:59 UTC (rev 356) @@ -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 * @@ -28,7 +28,8 @@ //public: RemoteObjectNameRegister::RemoteObjectNameRegister(QObject* parent /*= 0*/): - QObject(parent) { + QObject(parent), + mIsBeingUpdated(false) { if (TargetApplication::self()->remoteEditorSupport()) { registerRemoteObjects(); } @@ -107,6 +108,10 @@ return findRemoteObject(name, 0); } +bool RemoteObjectNameRegister::isBeingUpdated() const { + return mIsBeingUpdated; +} + //private: void RemoteObjectNameRegister::registerRemoteObject(RemoteObject* remoteObject, @@ -116,13 +121,10 @@ mRemoteObjectForParent.insert(parent, remoteObject); - QString name = remoteObject->name(); - if (!name.isEmpty()) { - emit nameAdded(name); + mRemoteObjectsPendingNameRegister.append( + QPointer<RemoteObject>(remoteObject)); + QTimer::singleShot(500, this, SLOT(deferredRegisterRemoteObjectName())); - mRemoteObjectForName.insert(name, remoteObject); - } - foreach (RemoteObject* child, remoteObject->children()) { registerRemoteObject(child, remoteObject); } @@ -278,9 +280,21 @@ return false; } +void RemoteObjectNameRegister::startNameUpdate() { + mIsBeingUpdated = true; + emit nameUpdateStarted(); +} + +void RemoteObjectNameRegister::finishNameUpdate() { + mIsBeingUpdated = false; + emit nameUpdateFinished(); +} + //private slots: void RemoteObjectNameRegister::registerRemoteObjects() { + startNameUpdate(); + try { registerRemoteObject(TargetApplication::self()-> remoteEditorSupport()->mainWindow(), 0); @@ -288,7 +302,11 @@ kWarning() << "The remote objects could not be registered to provide " << "name completion (" << e.message() << ")."; } - + + if (mRemoteObjectsPendingNameRegister.isEmpty()) { + finishNameUpdate(); + } + try { RemoteEventSpy* remoteEventSpy = TargetApplication::self()->remoteEditorSupport()->enableEventSpy(); @@ -311,6 +329,10 @@ return; } + if (eventType == "ChildAdded") { + startNameUpdate(); + } + try { QList<RemoteObject*> children = remoteObject->children(); @@ -337,4 +359,39 @@ << "name completion could not be updated (" << e.message() << ")."; } + + if (eventType == "ChildAdded" && + mRemoteObjectsPendingNameRegister.isEmpty()) { + finishNameUpdate(); + } } + +void RemoteObjectNameRegister::deferredRegisterRemoteObjectName() { + QPointer<RemoteObject> remoteObject = + mRemoteObjectsPendingNameRegister.takeFirst(); + if (!remoteObject) { + if (mRemoteObjectsPendingNameRegister.isEmpty()) { + finishNameUpdate(); + } + + return; + } + + QString name; + try { + name = remoteObject->name(); + } catch (DBusException e) { + kWarning() << "There was a problem getting the name of the remote" + << "object (" << e.message() << ")."; + } + + if (!name.isEmpty()) { + emit nameAdded(name); + + mRemoteObjectForName.insert(name, remoteObject); + } + + if (mRemoteObjectsPendingNameRegister.isEmpty()) { + finishNameUpdate(); + } +} Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.h 2012-07-11 14:29:47 UTC (rev 355) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameRegister.h 2012-08-04 15:54:59 UTC (rev 356) @@ -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 * @@ -21,6 +21,7 @@ #include <QMultiHash> #include <QObject> +#include <QPointer> #include "../targetapplication/DBusException.h" @@ -51,6 +52,17 @@ * "File information dialog" had a also button called "Ok button", now the * unique name of the first button would be "Configuration dialog/Ok button". In * this situation, "Ok button" would not represent a specific remote object. + * + * Also note that names are not registered when the objects are created in the + * target application, but a slight delay is introduced instead. This prevents + * registering objects too soon, before their name was even set in the target + * application. While the update in the registered names is taking place the + * methods described above should not be used. When a name update is started, + * the signal nameUpdateStarted() is emitted; when the update is finished, the + * signal nameUpdateFinished() is emitted. It can be checked if the register is + * being updated or not using isBeingUpdated(). The "updating" state is only + * enabled and the signals emitted when new objects are created; if an object is + * deleted there is no delay in the update of the names. */ class RemoteObjectNameRegister: public QObject { Q_OBJECT @@ -58,6 +70,12 @@ /** * Creates a new RemoteObjectNameRegister. + * Note that if the target application is already started when the + * RemoteObjectNameRegister is created the RemoteObjects will be registered + * and the nameUpdateStarted() signal will be emitted, even before being + * able to connect to it. Thus, you may want to check whether the register + * is being updated or not after the constructor to call the slot that will + * be connected with nameUpdateStarted() signal. * * @param parent The parent QObject. */ @@ -125,6 +143,13 @@ */ RemoteObject* findRemoteObject(const QString& name) const; + /** + * Returns whether the names are being registered or not. + * + * @return True if the names are being registered, false otherwise. + */ + bool isBeingUpdated() const; + Q_SIGNALS: /** @@ -141,6 +166,21 @@ */ void nameRemoved(const QString& name); + /** + * Emitted when one or more remote objects are created in the target + * application, and thus queued for their names to be registered. + * Note that this signal can be emitted several times before + * nameUpdateFinished() signal is emitted. + */ + void nameUpdateStarted(); + + /** + * Emitted when there are no more remote objects pending to be registered. + * Note that this signal may be emitted just once after several + * nameUpdateStarted() signals are emitted. + */ + void nameUpdateFinished(); + private: /** @@ -154,8 +194,21 @@ QMultiHash<RemoteObject*, RemoteObject*> mRemoteObjectForParent; /** + * Whether the names are being registered or not. + */ + bool mIsBeingUpdated; + + /** + * The list of RemoteObjects queued to register their name. + * A guarded pointer is needed, as the RemoteObjects may be deleted if the + * target application is closed before finishing the update of the names. + */ + QList< QPointer<RemoteObject> > mRemoteObjectsPendingNameRegister; + + /** * Registers the given RemoteObject and all its children. - * The objects are only registered if they have a name. + * The name itself is not registered yet, but queued to be registered after + * a little time. * * @param remoteObject The RemoteObject to register. * @param parent The parent of the RemoteObject to register. @@ -289,10 +342,24 @@ bool isDescendantOf(RemoteObject* remoteObject, RemoteObject* ancestor) const; + /** + * Sets this RemoteObjectNameRegister as being updated and emits the + * nameUpdateStarted() signal. + */ + void startNameUpdate(); + + /** + * Sets this RemoteObjectNameRegister as not being updated and emits the + * nameUpdateFinished() signal. + */ + void finishNameUpdate(); + private Q_SLOTS: /** * Registers all the remote objects. + * The name update is started (and finished if no names are queued to be + * registered). */ void registerRemoteObjects(); @@ -304,6 +371,8 @@ /** * Updates the registered remote objects if they received a ChildAdded or * ChildRemoved event. + * If the ChildAdded event is received, the name update is started (and + * finished if no names are queued to be registered). * * @param remoteObject The RemoteObject that received the event. * @param eventType The type of the event received. @@ -311,6 +380,14 @@ void updateRemoteObjects(RemoteObject* remoteObject, const QString& eventType); + /** + * Registers, if it is still available, the name of the remote object + * pending since the longest time ago. + * If there are no more names pending to be registered, the name update is + * finished. + */ + void deferredRegisterRemoteObjectName(); + }; #endif Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2012-07-11 14:29:47 UTC (rev 355) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.cpp 2012-08-04 15:54:59 UTC (rev 356) @@ -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 * @@ -24,6 +24,7 @@ #include "RemoteObjectChooser.h" #include "RemoteObjectNameRegister.h" +#include "../targetapplication/RemoteObject.h" #include "../targetapplication/TargetApplication.h" /** @@ -104,10 +105,19 @@ //public: RemoteObjectNameWidget::RemoteObjectNameWidget(QWidget* parent): - QWidget(parent) { + QWidget(parent), + mIsRemoteObjectChosenPending(false), + mIsNameChangedPending(false), + mIsCompletionPending(false), + mIsSubstringCompletionPending(false) { mRemoteObjectNameRegister = new RemoteObjectNameRegister(this); + connect(mRemoteObjectNameRegister, SIGNAL(nameUpdateStarted()), + this, SLOT(startNameUpdate())); + connect(mRemoteObjectNameRegister, SIGNAL(nameUpdateFinished()), + this, SLOT(finishNameUpdate())); + ui = new Ui::RemoteObjectNameWidget(); ui->setupUi(this); @@ -120,6 +130,9 @@ connect(ui->objectNamePushButton, SIGNAL(clicked(bool)), this, SLOT(showRemoteObjectChooser())); + //It will probably be IBeamCursor, but just in case + mObjectNameLineEditCursorShape = ui->objectNameLineEdit->cursor().shape(); + KCompletion* completion = new RemoteObjectNameCompletion(mRemoteObjectNameRegister); completion->setOrder(KCompletion::Sorted); @@ -127,9 +140,10 @@ ui->objectNameLineEdit->setCompletionObject(completion); ui->objectNameLineEdit->setAutoDeleteCompletionObject(true); - foreach (const QString& name, mRemoteObjectNameRegister->names()) { - completion->addItem(name); - } + connect(ui->objectNameLineEdit, SIGNAL(completion(QString)), + this, SLOT(handleCompletion())); + connect(ui->objectNameLineEdit, SIGNAL(substringCompletion(QString)), + this, SLOT(handleSubstringCompletion())); connect(mRemoteObjectNameRegister, SIGNAL(nameAdded(QString)), completion, SLOT(addItem(QString))); @@ -137,6 +151,13 @@ completion, SLOT(removeItem(QString))); connect(TargetApplication::self(), SIGNAL(finished()), completion, SLOT(clear())); + + //If the target application already exists when the register is + //created the nameUpdateStarted is emitted before being able to connect to + //it. + if (mRemoteObjectNameRegister->isBeingUpdated()) { + startNameUpdate(); + } } RemoteObjectNameWidget::~RemoteObjectNameWidget() { @@ -162,6 +183,16 @@ } void RemoteObjectNameWidget::setChosenRemoteObject(RemoteObject* remoteObject) { + if (mRemoteObjectNameRegister->isBeingUpdated()) { + mIsRemoteObjectChosenPending = true; + mPendingRemoteObjectChosen = QPointer<RemoteObject>(remoteObject); + return; + } + + if (!remoteObject) { + return; + } + try { ui->objectNameLineEdit->setText( mRemoteObjectNameRegister->uniqueName(remoteObject)); @@ -175,5 +206,62 @@ } void RemoteObjectNameWidget::handleNameChanged(const QString& name) { + if (mRemoteObjectNameRegister->isBeingUpdated()) { + mIsNameChangedPending = true; + return; + } + emit remoteObjectChosen(mRemoteObjectNameRegister->findRemoteObject(name)); } + +void RemoteObjectNameWidget::handleCompletion() { + if (!mRemoteObjectNameRegister->isBeingUpdated()) { + return; + } + + mIsCompletionPending = true; +} + +void RemoteObjectNameWidget::handleSubstringCompletion() { + if (!mRemoteObjectNameRegister->isBeingUpdated()) { + return; + } + + mIsSubstringCompletionPending = true; +} + +//This method may be called several times before finishNameUpdate() is called, +//so it should not be assumed that the widget will be in a "not updating" state +void RemoteObjectNameWidget::startNameUpdate() { + ui->objectNameLineEdit->setCursor(Qt::BusyCursor); + + ui->objectNameLineEdit->setHandleSignals(false); +} + +void RemoteObjectNameWidget::finishNameUpdate() { + if (mIsRemoteObjectChosenPending) { + mIsRemoteObjectChosenPending = false; + setChosenRemoteObject(mPendingRemoteObjectChosen); + } + + if (mIsNameChangedPending) { + mIsNameChangedPending = false; + handleNameChanged(ui->objectNameLineEdit->text()); + } + + ui->objectNameLineEdit->setHandleSignals(true); + + if (mIsSubstringCompletionPending) { + mIsSubstringCompletionPending = false; + ui->objectNameLineEdit->setCompletedItems( + ui->objectNameLineEdit->completionObject()->substringCompletion( + ui->objectNameLineEdit->text())); + } + + if (mIsCompletionPending) { + mIsCompletionPending = false; + ui->objectNameLineEdit->doCompletion(ui->objectNameLineEdit->text()); + } + + ui->objectNameLineEdit->setCursor(mObjectNameLineEditCursorShape); +} Modified: trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h 2012-07-11 14:29:47 UTC (rev 355) +++ trunk/ktutorial/ktutorial-editor/src/view/RemoteObjectNameWidget.h 2012-08-04 15:54:59 UTC (rev 356) @@ -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 @@ #ifndef REMOTEOBJECTNAMEWIDGET_H #define REMOTEOBJECTNAMEWIDGET_H +#include <QPointer> #include <QWidget> class RemoteObject; @@ -42,6 +43,16 @@ * * When a name is set in the line edit the signal * remoteObjectChosen(RemoteObject*) is emitted. + * + * To provide name completion, name substring completion, setting the name based + * on the RemoteObject chosen or emitting the signal + * remoteObjectChosen(RemoteObject*) based on the current name, the widget uses + * a register with the names of the remote objects. During the updates of this + * register it should not be queried (as the information provided will not be + * accurate), so if any of the aforementioned operations is requested during a + * register update, the operation is queued and executed once the update + * finishes.The cursor shape is changed to busy during register updates to + * reflect this fact. */ class RemoteObjectNameWidget: public QWidget { Q_OBJECT @@ -99,6 +110,43 @@ */ Ui::RemoteObjectNameWidget* ui; + /** + * Whether the remote object was chosen while the register was being updated + * or not. + */ + bool mIsRemoteObjectChosenPending; + + /** + * The last remote object chosen while the register was being updated, if + * any. + * A guarded pointer is needed, as the RemoteObject may be deleted if the + * target application is closed before finishing the update of the names. + */ + QPointer<RemoteObject> mPendingRemoteObjectChosen; + + /** + * Whether the name was set (programatically or by the user) while the + * register was being updated or not. + */ + bool mIsNameChangedPending; + + /** + * Whether the name completion was triggered while the register was being + * updated or not. + */ + bool mIsCompletionPending; + + /** + * Whether the name substring completion was triggered while the register + * was being updated or not. + */ + bool mIsSubstringCompletionPending; + + /** + * The cursor shape used by default by the object name line edit. + */ + Qt::CursorShape mObjectNameLineEditCursorShape; + private Q_SLOTS: /** @@ -108,6 +156,9 @@ /** * Sets the object name based in the chosen remote object. + * 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. * * @param remoteObject The chosen RemoteObject. */ @@ -116,11 +167,38 @@ /** * Emits remoteObjectChosen(RemoteObject*) with the remote object with the * given name. + * If the name register is being updated, nothing will be done, but marking + * handling the name change as a pending operation. * * @param name The name set. */ void handleNameChanged(const QString& name); + /** + * If the name register is being updated, marks the name completion as a + * pending operation. + */ + void handleCompletion(); + + /** + * If the name register is being updated, marks the name substring + * completion as a pending operation. + */ + void handleSubstringCompletion(); + + /** + * Enters the name register update state. + * Changes the cursor to busy and disables the completion. + */ + void startNameUpdate(); + + /** + * Exists the name register update state. + * Executes all the pending operations, enables again the completion and + * restores the cursor. + */ + void finishNameUpdate(); + }; #endif Modified: trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp 2012-07-11 14:29:47 UTC (rev 355) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameRegisterTest.cpp 2012-08-04 15:54:59 UTC (rev 356) @@ -42,6 +42,7 @@ void testTargetApplicationStartedAfterRegister(); void testTargetApplicationStopped(); + void testTargetApplicationStoppedBeforeFinishingNameUpdate(); void testAddingOrRemovingRemoteObjects(); @@ -68,6 +69,10 @@ bool waitForTargetApplicationToStart(int timeout) const; bool waitForTargetApplicationToStop(int timeout) const; + bool waitForNamesToBeRegistered( + const RemoteObjectNameRegister& remoteObjectNameRegister, + int timeout) const; + void assertNames(const QStringList& names) const; }; @@ -95,6 +100,9 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(remoteObjectNameRegister.isBeingUpdated()); + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + assertNames(remoteObjectNameRegister.names()); } @@ -104,12 +112,26 @@ SIGNAL(nameAdded(QString))); QSignalSpy nameRemovedSpy(&remoteObjectNameRegister, SIGNAL(nameRemoved(QString))); + QSignalSpy nameUpdateStartedSpy(&remoteObjectNameRegister, + SIGNAL(nameUpdateStarted())); + QSignalSpy nameUpdateFinishedSpy(&remoteObjectNameRegister, + SIGNAL(nameUpdateFinished())); TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); QVERIFY(waitForTargetApplicationToStart(10000)); + QVERIFY(remoteObjectNameRegister.isBeingUpdated()); + + QCOMPARE(nameUpdateStartedSpy.count(), 1); + QCOMPARE(nameUpdateFinishedSpy.count(), 0); + + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + QCOMPARE(nameUpdateStartedSpy.count(), 1); + QCOMPARE(nameUpdateFinishedSpy.count(), 1); + assertNames(remoteObjectNameRegister.names()); QCOMPARE(nameAddedSpy.count(), 82); QCOMPARE(nameAddedSpy.at(0).at(0).toString(), @@ -139,6 +161,8 @@ QCOMPARE(nameAddedSpy.at(71).at(0).toString(), QString("The object name 803")); QCOMPARE(nameRemovedSpy.count(), 0); + QCOMPARE(nameUpdateStartedSpy.count(), 1); + QCOMPARE(nameUpdateFinishedSpy.count(), 1); } void RemoteObjectNameRegisterTest::testTargetApplicationStopped() { @@ -149,10 +173,16 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + QSignalSpy nameAddedSpy(&remoteObjectNameRegister, SIGNAL(nameAdded(QString))); QSignalSpy nameRemovedSpy(&remoteObjectNameRegister, SIGNAL(nameAdded(QString))); + QSignalSpy nameUpdateStartedSpy(&remoteObjectNameRegister, + SIGNAL(nameUpdateStarted())); + QSignalSpy nameUpdateFinishedSpy(&remoteObjectNameRegister, + SIGNAL(nameUpdateFinished())); TargetApplication::self()->mProcess->kill(); @@ -161,8 +191,42 @@ QVERIFY(remoteObjectNameRegister.names().isEmpty()); QCOMPARE(nameAddedSpy.count(), 0); QCOMPARE(nameRemovedSpy.count(), 0); + QCOMPARE(nameUpdateStartedSpy.count(), 0); + QCOMPARE(nameUpdateFinishedSpy.count(), 0); } +void RemoteObjectNameRegisterTest:: + testTargetApplicationStoppedBeforeFinishingNameUpdate() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameRegister remoteObjectNameRegister; + + QSignalSpy nameUpdateFinishedSpy(&remoteObjectNameRegister, + SIGNAL(nameUpdateFinished())); + + TargetApplication::self()->mProcess->kill(); + + //Process deleteLater events for the RemoteObjects + QApplication::processEvents(QEventLoop::DeferredDeletion); + + //Ensure that there are still names pending to be updated + QVERIFY(remoteObjectNameRegister.isBeingUpdated()); + + QVERIFY(waitForTargetApplicationToStop(10000)); + + //If the pending RemoteObjects are not stored in the + //RemoteObjectNameRegister using a guarded pointer, getting the names to + //register them after the target application was killed would lead to a + //crash + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + + QVERIFY(remoteObjectNameRegister.names().isEmpty()); + QCOMPARE(nameUpdateFinishedSpy.count(), 1); +} + void RemoteObjectNameRegisterTest::testAddingOrRemovingRemoteObjects() { QSKIP("Unfortunately, testing if the signals are emitted when an object is " "added or removed in the target application is too burdensome so the " @@ -177,6 +241,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); @@ -192,6 +258,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); @@ -208,6 +276,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); @@ -225,6 +295,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); @@ -241,6 +313,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + QCOMPARE(remoteObjectNameRegister.findRemoteObject("The object name 108"), (RemoteObject*)0); } @@ -253,6 +327,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); RemoteObject* remoteObject = @@ -270,6 +346,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); RemoteObject* remoteObject = @@ -288,6 +366,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); RemoteObject* remoteObject = @@ -306,6 +386,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); RemoteObject* remoteObject = @@ -324,6 +406,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); RemoteObject* remoteObject = @@ -342,6 +426,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); RemoteObject* remoteObject = mainWindow->children()[7]->children()[0]; @@ -357,6 +443,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + QStringList uniqueNames = remoteObjectNameRegister.uniqueNames("Duplicated object"); @@ -376,6 +464,8 @@ RemoteObjectNameRegister remoteObjectNameRegister; + QVERIFY(waitForNamesToBeRegistered(remoteObjectNameRegister, 10000)); + QStringList uniqueNames = remoteObjectNameRegister.uniqueNames("The object name 423"); @@ -417,6 +507,39 @@ return waitFor(&isTargetApplicationStopped, timeout); } +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 RegisterNotBeingUpdatedCondition { +public: + const RemoteObjectNameRegister* mRemoteObjectNameRegister; + + bool condition() const { + return !mRemoteObjectNameRegister->isBeingUpdated(); + } +}; + +bool RemoteObjectNameRegisterTest::waitForNamesToBeRegistered( + const RemoteObjectNameRegister& remoteObjectNameRegister, + int timeout) const { + RegisterNotBeingUpdatedCondition helper; + helper.mRemoteObjectNameRegister = &remoteObjectNameRegister; + return waitFor(helper, &RegisterNotBeingUpdatedCondition::condition, + 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-07-11 14:29:47 UTC (rev 355) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/RemoteObjectNameWidgetTest.cpp 2012-08-04 15:54:59 UTC (rev 356) @@ -32,6 +32,7 @@ #include <KLineEdit> #include <KProcess> +#include "RemoteObjectNameRegister.h" #include "../targetapplication/RemoteClassStubs.h" #include "../targetapplication/RemoteEditorSupport.h" #include "../targetapplication/RemoteObject.h" @@ -55,12 +56,17 @@ void testSetName(); void testSetNameWithPath(); void testSetNameWithUnknownRemoteObjectName(); + void testSetNameDuringNameRegisterUpdate(); void testSetChosenRemoteObject(); void testSetChosenRemoteObjectWithNameNotUnique(); + void testSetChosenRemoteObjectDuringNameRegisterUpdate(); + void testSetChosenRemoteObjectDuringNameRegisterUpdateKillingApplication(); void testNameCompletion(); void testDuplicatedNameCompletion(); + void testNameCompletionDuringNameRegisterUpdate(); + void testNameSubcompletionDuringNameRegisterUpdate(); void testTargetApplicationStartedAfterWidget(); void testTargetApplicationStopped(); @@ -84,6 +90,9 @@ bool waitForTargetApplicationToStart(int timeout) const; bool waitForTargetApplicationToStop(int timeout) const; + + bool waitForNamesToBeRegistered(const RemoteObjectNameWidget* widget, + int timeout) const; void assertRemoteObjectSignal(const QSignalSpy& spy, int index, const RemoteObject* remoteObject) const; @@ -121,6 +130,12 @@ QWidget parent; RemoteObjectNameWidget* widget = new RemoteObjectNameWidget(&parent); + QCOMPARE(objectNameLineEdit(widget)->cursor().shape(), Qt::BusyCursor); + + QVERIFY(waitForNamesToBeRegistered(widget, 10000)); + + QCOMPARE(objectNameLineEdit(widget)->cursor().shape(), Qt::IBeamCursor); + QCOMPARE(widget->parentWidget(), &parent); QCOMPARE(widget->name(), QString("")); QStringList items = objectNameLineEdit(widget)->completionObject()->items(); @@ -137,6 +152,8 @@ QSignalSpy remoteObjectChosenSpy(&widget, SIGNAL(remoteObjectChosen(RemoteObject*))); + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + widget.setName("The object name 423"); RemoteObject* mainWindow = @@ -158,6 +175,8 @@ QSignalSpy remoteObjectChosenSpy(&widget, SIGNAL(remoteObjectChosen(RemoteObject*))); + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + widget.setName("The object name 7/Duplicated object"); RemoteObject* mainWindow = @@ -179,6 +198,8 @@ QSignalSpy remoteObjectChosenSpy(&widget, SIGNAL(remoteObjectChosen(RemoteObject*))); + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + widget.setName("The object name 108"); QCOMPARE(widget.name(), QString("The object name 108")); @@ -186,6 +207,36 @@ assertRemoteObjectSignal(remoteObjectChosenSpy, 0, 0); } +void RemoteObjectNameWidgetTest::testSetNameDuringNameRegisterUpdate() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameWidget widget; + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + widget.setName("The object name 423"); + + //Ensure that the register is still being updated + QVERIFY(widget.mRemoteObjectNameRegister->isBeingUpdated()); + + //Check that the name is set, but the signal was not emitted yet + QCOMPARE(widget.name(), QString("The object name 423")); + QCOMPARE(remoteObjectChosenSpy.count(), 0); + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + + QCOMPARE(widget.name(), QString("The object name 423")); + QCOMPARE(remoteObjectChosenSpy.count(), 1); + assertRemoteObjectSignal(remoteObjectChosenSpy, 0, + mainWindow->children()[3]); +} + void RemoteObjectNameWidgetTest::testSetChosenRemoteObject() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); @@ -196,6 +247,8 @@ QSignalSpy remoteObjectChosenSpy(&widget, SIGNAL(remoteObjectChosen(RemoteObject*))); + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); RemoteObject* remoteObject = @@ -218,6 +271,8 @@ QSignalSpy remoteObjectChosenSpy(&widget, SIGNAL(remoteObjectChosen(RemoteObject*))); + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + RemoteObject* mainWindow = TargetApplication::self()->remoteEditorSupport()->mainWindow(); @@ -245,6 +300,85 @@ assertRemoteObjectSignal(remoteObjectChosenSpy, 2, remoteObject); } +void RemoteObjectNameWidgetTest:: + testSetChosenRemoteObjectDuringNameRegisterUpdate() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameWidget widget; + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + RemoteObject* remoteObject = + mainWindow->children()[4]->children()[0]->children()[1]; + + widget.setChosenRemoteObject(remoteObject); + + //Ensure that the register is still being updated + QVERIFY(widget.mRemoteObjectNameRegister->isBeingUpdated()); + + //Check that the name is not set and the signal was not emitted yet + QCOMPARE(widget.name(), QString("")); + QCOMPARE(remoteObjectChosenSpy.count(), 0); + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + + QCOMPARE(widget.name(), QString("The object name 501")); + QCOMPARE(remoteObjectChosenSpy.count(), 1); + assertRemoteObjectSignal(remoteObjectChosenSpy, 0, remoteObject); +} + +void RemoteObjectNameWidgetTest:: + testSetChosenRemoteObjectDuringNameRegisterUpdateKillingApplication() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameWidget widget; + widget.setName("An object name"); + + QSignalSpy remoteObjectChosenSpy(&widget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + + RemoteObject* mainWindow = + TargetApplication::self()->remoteEditorSupport()->mainWindow(); + RemoteObject* remoteObject = + mainWindow->children()[4]->children()[0]->children()[1]; + + widget.setChosenRemoteObject(remoteObject); + + //Ensure that the register is still being updated + QVERIFY(widget.mRemoteObjectNameRegister->isBeingUpdated()); + + TargetApplication::self()->mProcess->kill(); + + QVERIFY(waitForTargetApplicationToStop(10000)); + + //Ensure that the register is still being updated + QVERIFY(widget.mRemoteObjectNameRegister->isBeingUpdated()); + + //Check that the name is not set and the signal was not emitted yet + QCOMPARE(widget.name(), QString("An object name")); + QCOMPARE(remoteObjectChosenSpy.count(), 0); + + //If the pending RemoteObject is not stored using a guarded pointer, getting + //its unique name after the target application was killed would lead to a + //crash + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + + //If there is no RemoteObject to be set, nothing is done. However, the + //remoteObjectChosen signal was queued to be emitted when the name was first + //set (as the names were already being uptated), although it should not be + //emitted again when setting the null RemoteObject. + QCOMPARE(widget.name(), QString("An object name")); + QCOMPARE(remoteObjectChosenSpy.count(), 1); +} + void RemoteObjectNameWidgetTest::testNameCompletion() { TargetApplication::self()->setTargetApplicationFilePath(mPath); TargetApplication::self()->start(); @@ -253,6 +387,8 @@ RemoteObjectNameWidget widget; + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + KCompletion* completion = objectNameLineEdit(&widget)->completionObject(); QCOMPARE(completion->order(), KCompletion::Sorted); @@ -280,6 +416,9 @@ QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + KLineEdit* lineEdit = objectNameLineEdit(&widget); lineEdit->setText("Duplicated "); @@ -288,6 +427,8 @@ KCompletionBox* completionBox = lineEdit->completionBox(); QStringList completionItems = completionBox->items(); + QVERIFY(completionBox->isVisible()); + QCOMPARE(completionItems.count(), 4); QCOMPARE(completionItems[0], QString("Duplicated grandparent/Duplicated parent/" @@ -300,11 +441,100 @@ QString("The object name 8/Duplicated object")); } +void RemoteObjectNameWidgetTest::testNameCompletionDuringNameRegisterUpdate() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameWidget widget; + + KLineEdit* lineEdit = objectNameLineEdit(&widget); + lineEdit->setText("Duplicated "); + + QTest::keyClick(lineEdit, Qt::Key_O, Qt::NoModifier); + + KCompletionBox* completionBox = lineEdit->completionBox(); + QStringList completionItems = completionBox->items(); + + //Ensure that the register is still being updated + QVERIFY(widget.mRemoteObjectNameRegister->isBeingUpdated()); + + QVERIFY(!completionBox->isVisible()); + QCOMPARE(completionItems.count(), 0); + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + + completionBox = lineEdit->completionBox(); + completionItems = completionBox->items(); + + QVERIFY(completionBox->isVisible()); + + QCOMPARE(completionItems.count(), 4); + QCOMPARE(completionItems[0], + QString("Duplicated grandparent/Duplicated parent/" + "Duplicated object")); + QCOMPARE(completionItems[1], + QString("The object name 50/Duplicated object")); + QCOMPARE(completionItems[2], + QString("The object name 7/Duplicated object")); + QCOMPARE(completionItems[3], + QString("The object name 8/Duplicated object")); +} + +void RemoteObjectNameWidgetTest:: + testNameSubcompletionDuringNameRegisterUpdate() { + TargetApplication::self()->setTargetApplicationFilePath(mPath); + TargetApplication::self()->start(); + + QVERIFY(waitForTargetApplicationToStart(10000)); + + RemoteObjectNameWidget widget; + + KLineEdit* lineEdit = objectNameLineEdit(&widget); + + //Using the configured KShortcut with QTest::keyClick is too cumbersome, + //so the binding is overriden for this test + lineEdit->setKeyBinding(KCompletionBase::SubstringCompletion, + KShortcut("Ctrl+T")); + QTest::keyClick(lineEdit, Qt::Key_T, Qt::ControlModifier); + + KCompletionBox* completionBox = lineEdit->completionBox(); + QStringList completionItems = completionBox->items(); + + //Ensure that the register is still being updated + QVERIFY(widget.mRemoteObjectNameRegister->isBeingUpdated()); + + QVERIFY(!completionBox->isVisible()); + QCOMPARE(completionItems.count(), 0); + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + + completionBox = lineEdit->completionBox(); + completionItems = completionBox->items(); + + QVERIFY(completionBox->isVisible()); + + QCOMPARE(completionItems.count(), 82); + QVERIFY(completionItems.contains("The object name 42")); + QVERIFY(completionItems.contains("The object name 420")); + QVERIFY(completionItems.contains("The object name 421")); + QVERIFY(completionItems.contains("The object name 422")); + QVERIFY(completionItems.contains("The object name 423")); + QVERIFY(completionItems.contains("Duplicated grandparent/Duplicated parent/" + "Duplicated object")); + QVERIFY(completionItems.contains("The object name 50/Duplicated object")); + QVERIFY(completionItems.contains("The object name 7/Duplicated object")); + QVERIFY(completionItems.contains("The object name 8/Duplicated object")); +} + void RemoteObjectNameWidgetTest::testTargetApplicationStartedAfterWidget() { RemoteObjectNameWidget widget; QSignalSpy remoteObjectChosenSpy(&widget, SIGNAL(remoteObjectChosen(RemoteObject*))); + QCOMPARE(objectNameLineEdit(&widget)->cursor().shape(), Qt::IBeamCursor); + QStringList items = objectNameLineEdit(&widget)->completionObject()-> items(); QCOMPARE(items.count(), 0); @@ -320,6 +550,12 @@ QVERIFY(waitForTargetApplicationToStart(10000)); + QCOMPARE(objectNameLineEdit(&widget)->cursor().shape(), Qt::BusyCursor); + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + + QCOMPARE(objectNameLineEdit(&widget)->cursor().shape(), Qt::IBeamCursor); + items = objectNameLineEdit(&widget)->completionObject()->items(); assertCompletionItems(items); @@ -341,6 +577,9 @@ QVERIFY(waitForTargetApplicationToStart(10000)); RemoteObjectNameWidget widget; + + QVERIFY(waitForNamesToBeRegistered(&widget, 10000)); + QSignalSpy remoteObjectChosenSpy(&widget, SIGNAL(remoteObjectChosen(RemoteObject*))); @@ -452,6 +691,38 @@ return waitFor(&isTargetApplicationStopped, timeout); } +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 RegisterNotBeingUpdatedCondition { +public: + const RemoteObjectNameRegister* mRemoteObjectNameRegister; + + bool condition() const { + return !mRemoteObjectNameRegister->isBeingUpdated(); + } +}; + +bool RemoteObjectNameWidgetTest::waitForNamesToBeRegistered( + const RemoteObjectNameWidget* widget, int timeout) const { + RegisterNotBeingUpdatedCondition helper; + helper.mRemoteObjectNameRegister = widget->mRemoteObjectNameRegister; + return waitFor(helper, &RegisterNotBeingUpdatedCondition::condition, + 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-07-11 14:29:47 UTC (rev 355) +++ trunk/ktutorial/ktutorial-editor/tests/unit/view/WaitForPropertyWidgetTest.cpp 2012-08-04 15:54:59 UTC (rev 356) @@ -18,13 +18,18 @@ #include <QtTest> +#define protected public +#define private public #include "WaitForPropertyWidget.h" +#undef private +#undef protected #include <KLineEdit> #include "../data/WaitForProperty.h" #ifdef QT_QTDBUS_FOUND +#include "RemoteObjectNameWidget.h" #define protected public #define private public #include "../targetapplication/TargetApplication.h" @@ -56,6 +61,9 @@ bool waitForTargetApplicationToStart(int timeout) const; + bool waitForSignalCount(const QSignalSpy* spy, int count, + int timeout) const; + }; void WaitForPropertyWidgetTest::init() { @@ -112,6 +120,11 @@ QCOMPARE(waitFor.value(), QString("The new value")); } +#ifdef QT_QTDBUS_FOUND +//RemoteObject* must be declared as a metatype to be used in qvariant_cast +Q_DECLARE_METATYPE(RemoteObject*); +#endif + void WaitForPropertyWidgetTest::testPropertyNameCompletion() { #ifdef QT_QTDBUS_FOUND TargetApplication::self()->setTargetApplicationFilePath( @@ -123,8 +136,20 @@ WaitForProperty waitFor; WaitForPropertyWidget widget(&waitFor); + //RemoteObject* must be registered in order to be used with QSignalSpy + qRegisterMetaType<RemoteObject*>("RemoteObject*"); + QSignalSpy remoteObjectChosenSpy(widget.mRemoteObjectNameWidget, + SIGNAL(remoteObjectChosen(RemoteObject*))); + objectNameLineEdit(&widget)->setText("The object name 830"); + //Wait until the RemoteObjectNameWidget emits the remoteObjectChosen signal + //(as it can take some time until the names of the remote objects are + //registered), and ensure that the chosen remote object is not null + QVERIFY(waitForSignalCount(&remoteObjectChosenSpy, 1, 10000)); + QVariant argument = remoteObjectChosenSpy.at(0).at(0); + QVERIFY(qvariant_cast<RemoteObject*>(argument)); + KCompletion* completion = propertyNameLineEdit(&widget)->completionObject(); QStringList items = completion->items(); QCOMPARE(items.count(), 6); @@ -180,6 +205,40 @@ return waitFor(&isTargetApplicationStarted, timeout); } +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 WaitForPropertyWidgetTest::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(WaitForPropertyWidgetTest) #include "WaitForPropertyWidgetTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-08-10 11:28:28
|
Revision: 362 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=362&view=rev Author: danxuliu Date: 2012-08-10 11:28:21 +0000 (Fri, 10 Aug 2012) Log Message: ----------- Remove "clear" method, as it is used nowhere. 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 Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.cpp 2012-08-10 11:19:33 UTC (rev 361) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.cpp 2012-08-10 11:28:21 UTC (rev 362) @@ -59,11 +59,3 @@ return remoteClass; } - -void RemoteObjectMapper::clear() { - qDeleteAll(mRemoteObjects); - mRemoteObjects.clear(); - - qDeleteAll(mRemoteClasses); - mRemoteClasses.clear(); -} Modified: trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.h 2012-08-10 11:19:33 UTC (rev 361) +++ trunk/ktutorial/ktutorial-editor/src/targetapplication/RemoteObjectMapper.h 2012-08-10 11:28:21 UTC (rev 362) @@ -32,7 +32,7 @@ * depending on the case. The same behavior is shown for RemoteClasses. * * The RemoteObjectMapper also has ownership of the RemoteObjects and - * RemoteClasses, so they are deleted when the mapper is cleared or destroyed. + * RemoteClasses, so they are deleted when the mapper is destroyed. */ class RemoteObjectMapper { public: @@ -52,8 +52,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 RemoteObject is destroyed when this RemoteObjectMapper is 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. * @@ -64,19 +64,14 @@ /** * Returns the RemoteClass associated with the given class name. - * The RemoteClass is destroyed when this RemoteObjectMapper is cleared or - * destroyed, so consider using QPointer to store it. + * The RemoteClass is destroyed when this RemoteObjectMapper is destroyed, + * so consider using QPointer to store it. * * @param className The name of the remote class. * @return The RemoteClass. */ RemoteClass* remoteClass(const QString& className); - /** - * Destroys all the mapped RemoteObjects and RemoteClasses. - */ - void clear(); - private: /** @@ -85,14 +80,12 @@ QString mService; /** - * All the RemoteObjects already requested since the last time this - * RemoteObjectMapper was cleared. + * All the RemoteObjects already requested. */ QHash<int, RemoteObject*> mRemoteObjects; /** - * All the RemoteClasses already requested since the last time this - * RemoteObjectMapper was cleared. + * All the RemoteClasses already requested. */ QHash<QString, RemoteClass*> mRemoteClasses; Modified: trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectMapperTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectMapperTest.cpp 2012-08-10 11:19:33 UTC (rev 361) +++ trunk/ktutorial/ktutorial-editor/tests/unit/targetapplication/RemoteObjectMapperTest.cpp 2012-08-10 11:28:21 UTC (rev 362) @@ -43,7 +43,6 @@ void testRemoteClassSeveralIds(); void testRemoteClassTwice(); - void testClear(); private: StubObjectRegister* mObjectRegister; @@ -149,23 +148,6 @@ QCOMPARE(remoteClass1->className(), QString("Class")); } -void RemoteObjectMapperTest::testClear() { - RemoteObjectMapper mapper(QDBusConnection::sessionBus().baseService()); - - QPointer<RemoteObject> remoteObject1 = mapper.remoteObject(42); - QPointer<RemoteClass> remoteClass1 = mapper.remoteClass("Class"); - - mapper.clear(); - - RemoteObject* remoteObject2 = mapper.remoteObject(42); - RemoteClass* remoteClass2 = mapper.remoteClass("Class"); - - QVERIFY(!remoteObject1); - QVERIFY(remoteObject2); - QVERIFY(!remoteClass1); - QVERIFY(remoteClass2); -} - QTEST_MAIN(RemoteObjectMapperTest) #include "RemoteObjectMapperTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2012-08-10 18:06:01
|
Revision: 365 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=365&view=rev Author: danxuliu Date: 2012-08-10 18:05:55 +0000 (Fri, 10 Aug 2012) Log Message: ----------- Fix the exported CamelCase variable names when the name of the remote object used in the WaitFor includes ancestor names. Modified Paths: -------------- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2012-08-10 11:40:27 UTC (rev 364) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.cpp 2012-08-10 18:05:55 UTC (rev 365) @@ -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 * @@ -546,7 +546,7 @@ return ""; } - text.remove(QRegExp("[^\\w ]")); + text.replace(QRegExp("[^\\w ]"), " "); QStringList words = text.split(' ', QString::SkipEmptyParts); QString upperCamelCase; Modified: trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h =================================================================== --- trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2012-08-10 11:40:27 UTC (rev 364) +++ trunk/ktutorial/ktutorial-editor/src/serialization/JavascriptExporter.h 2012-08-10 18:05:55 UTC (rev 365) @@ -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 * @@ -328,7 +328,8 @@ /** * Returns the lowerCamelCase version of the given text. * Note that the returned text contains only letters, digits or underscores. - * Any other character is removed. + * Any other character is removed, and the next valid character is upper + * cased. * * @param text The string to get its lowerCamelCase version. * @return The lowerCamelCase version of the text. @@ -338,7 +339,8 @@ /** * Returns the UpperCamelCase version of the given text. * Note that the returned text contains only letters, digits or underscores. - * Any other character is removed. + * Any other character is removed, and the next valid character is upper + * cased. * * @param text The string to get its UpperCamelCase version. * @return The UpperCamelCase version of the text. Modified: trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2012-08-10 11:40:27 UTC (rev 364) +++ trunk/ktutorial/ktutorial-editor/tests/unit/serialization/JavascriptExporterTest.cpp 2012-08-10 18:05:55 UTC (rev 365) @@ -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,23 +82,29 @@ void testReactionOptionCustomCodeWithEscapeSequences(); void testReactionOptionCustomCodeWithoutOptionNameOrCustomCode(); void testReactionConditionNextStep(); + void testReactionConditionNextStepWithAncestorNames(); void testReactionConditionNextStepWithEscapeSequences(); void testReactionConditionNextStepWithoutConditionOrStepId(); void testReactionConditionCustomCode(); + void testReactionConditionCustomCodeWithAncestorNames(); void testReactionConditionCustomCodeWithEscapeSequences(); void testReactionConditionCustomCodeWithoutConditionOrCustomCode(); void testWaitForEvent(); + void testWaitForEventWithAncestorNames(); void testWaitForEventWithEscapeSequences(); void testWaitForEventWithoutReceiverNameOrEventName(); void testWaitForProperty(); + void testWaitForPropertyWithAncestorNames(); void testWaitForPropertyWithEscapeSequences(); void testWaitForPropertyWithoutObjectNameOrPropertyNameOrValue(); void testWaitForSignal(); + void testWaitForSignalWithAncestorNames(); void testWaitForSignalWithEscapeSequences(); void testWaitForSignalWithoutEmitterNameOrSignalName(); void testWaitForStepActivation(); void testWaitForWindow(); + void testWaitForWindowWithAncestorNames(); void testWaitForWindowWithEscapeSequences(); void testWaitForWindowWithoutWindowObjectName(); void testWaitForComposed(); @@ -818,6 +824,44 @@ QCOMPARE(exportedTutorial, expected); } +void JavascriptExporterTest::testReactionConditionNextStepWithAncestorNames() { + Tutorial tutorial; + Step* step = new Step(); + step->setId("The id"); + tutorial.addStep(step); + + WaitForSignal* waitForSignal = new WaitForSignal(); + waitForSignal->setEmitterName("Grandparent/parent/the emitter name"); + waitForSignal->setSignalName("theSignalName(Argument1Type, Argument2Type)"); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForSignal); + 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" +" waitForTheSignalNameByGrandparentParentTheEmitterName = \ +ktutorial.newWaitFor(\"WaitForSignal\");\n" +" waitForTheSignalNameByGrandparentParentTheEmitterName.setSignal(\ +ktutorial.findObject(\"Grandparent/parent/the emitter name\"), \ +\"theSignalName(Argument1Type, Argument2Type)\");\n" +" step.addWaitFor(waitForTheSignalNameByGrandparentParentTheEmitterName, \ +\"Another step\");\n" +"}\n" +CONNECT_STEP_SETUP +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; + + QCOMPARE(exportedTutorial, expected); +} + void JavascriptExporterTest:: testReactionConditionNextStepWithEscapeSequences() { Tutorial tutorial; @@ -947,6 +991,50 @@ } void JavascriptExporterTest:: + testReactionConditionCustomCodeWithAncestorNames() { + Tutorial tutorial; + Step* step = new Step(); + step->setId("The id"); + tutorial.addStep(step); + + WaitForSignal* waitForSignal = new WaitForSignal(); + waitForSignal->setEmitterName("Grandparent/parent/the emitter name"); + waitForSignal->setSignalName("theSignalName(Argument1Type, Argument2Type)"); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForSignal); + reaction->setResponseType(Reaction::CustomCode); + reaction->setCustomCode("The custom\ncode"); + 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" +" waitForTheSignalNameByGrandparentParentTheEmitterName = \ +ktutorial.newWaitFor(\"WaitForSignal\");\n" +" waitForTheSignalNameByGrandparentParentTheEmitterName.setSignal(\ +ktutorial.findObject(\"Grandparent/parent/the emitter name\"), \ +\"theSignalName(Argument1Type, Argument2Type)\");\n" +" step.addWaitFor(waitForTheSignalNameByGrandparentParentTheEmitterName, \ +self, \"theIdStepWaitForTheSignalNameByGrandparentParentTheEmitterNameConditionMet()\");\n" +"}\n" +CONNECT_STEP_SETUP +"function theIdStepWaitForTheSignalNameByGrandparentParentTheEmitterNameConditionMet() {\n" +" The custom\n" +" code\n" +"}\n" +"\n" +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; + + QCOMPARE(exportedTutorial, expected); +} + +void JavascriptExporterTest:: testReactionConditionCustomCodeWithEscapeSequences() { Tutorial tutorial; Step* step = new Step(); @@ -1083,6 +1171,44 @@ QCOMPARE(exportedTutorial, expected); } +void JavascriptExporterTest::testWaitForEventWithAncestorNames() { + Tutorial tutorial; + Step* step = new Step(); + step->setId("The id"); + tutorial.addStep(step); + + WaitForEvent* waitForEvent = new WaitForEvent(); + waitForEvent->setReceiverName("Grandparent/parent/the receiver name"); + waitForEvent->setEventName("TheEventName"); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForEvent); + 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" +" waitForTheEventNameInGrandparentParentTheReceiverName = \ +ktutorial.newWaitFor(\"WaitForEvent\");\n" +" waitForTheEventNameInGrandparentParentTheReceiverName.setEvent(\ +ktutorial.findObject(\"Grandparent/parent/the receiver name\"), \ +\"TheEventName\");\n" +" step.addWaitFor(waitForTheEventNameInGrandparentParentTheReceiverName, \ +\"Another step\");\n" +"}\n" +CONNECT_STEP_SETUP +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; + + QCOMPARE(exportedTutorial, expected); +} + void JavascriptExporterTest::testWaitForEventWithEscapeSequences() { Tutorial tutorial; Step* step = new Step(); @@ -1203,6 +1329,45 @@ QCOMPARE(exportedTutorial, expected); } +void JavascriptExporterTest::testWaitForPropertyWithAncestorNames() { + Tutorial tutorial; + Step* step = new Step(); + step->setId("The id"); + tutorial.addStep(step); + + WaitForProperty* waitForProperty = new WaitForProperty(); + waitForProperty->setObjectName("Grandparent/parent/the object name"); + waitForProperty->setPropertyName("thePropertyName"); + waitForProperty->setValue("TheValue"); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForProperty); + 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" +" waitForThePropertyNameInGrandparentParentTheObjectName = \ +ktutorial.newWaitFor(\"WaitForProperty\");\n" +" waitForThePropertyNameInGrandparentParentTheObjectName.setProperty(\ +ktutorial.findObject(\"Grandparent/parent/the object name\"), \ +\"thePropertyName\", TheValue);\n" +" step.addWaitFor(waitForThePropertyNameInGrandparentParentTheObjectName, \ +\"Another step\");\n" +"}\n" +CONNECT_STEP_SETUP +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; + + QCOMPARE(exportedTutorial, expected); +} + void JavascriptExporterTest::testWaitForPropertyWithEscapeSequences() { Tutorial tutorial; Step* step = new Step(); @@ -1340,6 +1505,44 @@ QCOMPARE(exportedTutorial, expected); } +void JavascriptExporterTest::testWaitForSignalWithAncestorNames() { + Tutorial tutorial; + Step* step = new Step(); + step->setId("The id"); + tutorial.addStep(step); + + WaitForSignal* waitForSignal = new WaitForSignal(); + waitForSignal->setEmitterName("Grandparent/parent/the emitter name"); + waitForSignal->setSignalName("theSignalName(Argument1Type, Argument2Type)"); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForSignal); + 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" +" waitForTheSignalNameByGrandparentParentTheEmitterName = \ +ktutorial.newWaitFor(\"WaitForSignal\");\n" +" waitForTheSignalNameByGrandparentParentTheEmitterName.setSignal(\ +ktutorial.findObject(\"Grandparent/parent/the emitter name\"), \ +\"theSignalName(Argument1Type, Argument2Type)\");\n" +" step.addWaitFor(waitForTheSignalNameByGrandparentParentTheEmitterName, \ +\"Another step\");\n" +"}\n" +CONNECT_STEP_SETUP +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; + + QCOMPARE(exportedTutorial, expected); +} + void JavascriptExporterTest::testWaitForSignalWithEscapeSequences() { Tutorial tutorial; Step* step = new Step(); @@ -1490,6 +1693,43 @@ QCOMPARE(exportedTutorial, expected); } +void JavascriptExporterTest::testWaitForWindowWithAncestorNames() { + Tutorial tutorial; + Step* step = new Step(); + step->setId("The id"); + tutorial.addStep(step); + + WaitForWindow* waitForWindow = new WaitForWindow(); + waitForWindow->setWindowObjectName("Grandparent/parent/" + "the window object name"); + + Reaction* reaction = new Reaction(); + reaction->setTriggerType(Reaction::ConditionMet); + reaction->setWaitFor(waitForWindow); + 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" +" waitForGrandparentParentTheWindowObjectNameToBeShown = \ +ktutorial.newWaitFor(\"WaitForWindow\");\n" +" waitForGrandparentParentTheWindowObjectNameToBeShown.setWindowObjectName(\ +\"Grandparent/parent/the window object name\");\n" +" step.addWaitFor(waitForGrandparentParentTheWindowObjectNameToBeShown, \ +\"Another step\");\n" +"}\n" +CONNECT_STEP_SETUP +STEP_WITH_ID_THE_ID_AND_EMPTY_TEXT_END_CODE; + + QCOMPARE(exportedTutorial, expected); +} + void JavascriptExporterTest::testWaitForWindowWithEscapeSequences() { Tutorial tutorial; Step* step = new Step(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |