[Ktutorial-commits] SF.net SVN: ktutorial:[365] trunk/ktutorial/ktutorial-editor
Status: Alpha
Brought to you by:
danxuliu
|
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.
|