diff options
Diffstat (limited to 'kexi/plugins/macros/tests/xmlhandlertests.cpp')
-rw-r--r-- | kexi/plugins/macros/tests/xmlhandlertests.cpp | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/kexi/plugins/macros/tests/xmlhandlertests.cpp b/kexi/plugins/macros/tests/xmlhandlertests.cpp index 9a0ebcb1..a08ff33d 100644 --- a/kexi/plugins/macros/tests/xmlhandlertests.cpp +++ b/kexi/plugins/macros/tests/xmlhandlertests.cpp @@ -29,7 +29,7 @@ #include <ostream> #include <cfloat> -#include <qdom.h> +#include <tqdom.h> #include <kdebug.h> #include <kunittest/runner.h> @@ -58,7 +58,7 @@ namespace KoMacroTest { /** * An @a TestObject instance used internaly to test - * handling and communication with from QObject + * handling and communication with from TQObject * inheritated instances. */ KSharedPtr<KoMacro::Action> testaction; @@ -144,11 +144,11 @@ void XMLHandlerTests::testCorrectDomElement() { // Local Init KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; // Part 1: From XML to a Macro. // Test-XML-document with normal allocated variables. - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -159,12 +159,12 @@ void XMLHandlerTests::testCorrectDomElement() "</macro>"); // Set the XML-document with the above string. doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); // Is our XML parseable by calling parseXML()? KOMACROTEST_ASSERT(macro->parseXML(elem),true); // Is the parsen content in the Macro correct ? - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; @@ -172,12 +172,12 @@ void XMLHandlerTests::testCorrectDomElement() assertMacroContentEqToXML(macro,elem,false,true,isvariableok); // Transform back by calling toXML(). - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); // Test the Compare-method when a Variable will change, it must fail. macro->items().first()->variable("teststring")->setVariant("bla"); - isvariableok.replace("teststring",false); + isvariableok.tqreplace("teststring",false); assertMacroContentEqToXML(macro,elem,false,true,isvariableok); } @@ -185,9 +185,9 @@ void XMLHandlerTests::testCorrectDomElement() void XMLHandlerTests::testBadRoot() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<maro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -197,23 +197,23 @@ void XMLHandlerTests::testBadRoot() "</item>" "</maro>"); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_XASSERT(macro->parseXML(elem),true); //no assertMacroContentEqToXML(), because parsing failed. - assertMacroContentEqToXML(macro,elem,true,false,QMap<QString,bool>()); + assertMacroContentEqToXML(macro,elem,true,false,TQMap<TQString,bool>()); - const QDomElement elem2 = macro->toXML(); - assertMacroContentEqToXML(macro,elem2,true,false,QMap<QString,bool>()); + const TQDomElement elem2 = macro->toXML(); + assertMacroContentEqToXML(macro,elem2,true,false,TQMap<TQString,bool>()); } // 3.Test - XML-document with a missing Variable. void XMLHandlerTests::testMissingVariable() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -222,16 +222,16 @@ void XMLHandlerTests::testMissingVariable() "</item>" "</macro>"); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testdouble"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } @@ -239,9 +239,9 @@ void XMLHandlerTests::testMissingVariable() void XMLHandlerTests::testMoreVariables() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -252,10 +252,10 @@ void XMLHandlerTests::testMoreVariables() "</item>" "</macro>"); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; @@ -263,7 +263,7 @@ void XMLHandlerTests::testMoreVariables() isvariableok["testbla"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } @@ -271,9 +271,9 @@ void XMLHandlerTests::testMoreVariables() void XMLHandlerTests::testWrongVersion() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"2\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -283,14 +283,14 @@ void XMLHandlerTests::testWrongVersion() "</item>" "</macro>"); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_XASSERT(macro->parseXML(elem),true); //no assertMacroContentEqToXML(), because parsing failed. - assertMacroContentEqToXML(macro,elem,true,false,QMap<QString,bool>()); + assertMacroContentEqToXML(macro,elem,true,false,TQMap<TQString,bool>()); - const QDomElement elem2 = macro->toXML(); - assertMacroContentEqToXML(macro,elem2,true,false,QMap<QString,bool>()); + const TQDomElement elem2 = macro->toXML(); + assertMacroContentEqToXML(macro,elem2,true,false,TQMap<TQString,bool>()); } // 6.Test - XML-document if it has a wrong structure like wrong parathesis @@ -298,9 +298,9 @@ void XMLHandlerTests::testWrongVersion() void XMLHandlerTests::testWrongXMLStruct() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "macro xmlversion=\"1\">>" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -308,23 +308,23 @@ void XMLHandlerTests::testWrongXMLStruct() "</item>" "</macro>"); KOMACROTEST_XASSERT(doomdocument.setContent(xml),true); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_XASSERT(macro->parseXML(elem),true); //no assertMacroContentEqToXML(), because parsing failed. - assertMacroContentEqToXML(macro,elem,true,false,QMap<QString,bool>()); + assertMacroContentEqToXML(macro,elem,true,false,TQMap<TQString,bool>()); - const QDomElement elem2 = macro->toXML(); - assertMacroContentEqToXML(macro,elem2,true,false,QMap<QString,bool>()); + const TQDomElement elem2 = macro->toXML(); + assertMacroContentEqToXML(macro,elem2,true,false,TQMap<TQString,bool>()); } // 7.Test-XML-document with maximum field-size. void XMLHandlerTests::testMaxNum() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -332,19 +332,19 @@ void XMLHandlerTests::testMaxNum() "<variable name=\"testbool\" >true</variable>" "<variable name=\"testdouble\" > %2 </variable>" "</item>" - "</macro>").arg(INT_MAX).arg(DBL_MAX); + "</macro>").tqarg(INT_MAX).tqarg(DBL_MAX); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; isvariableok["testdouble"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - QDomElement elem2 = macro->toXML(); + TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } @@ -352,9 +352,9 @@ void XMLHandlerTests::testMaxNum() void XMLHandlerTests::testMaxNum2() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -362,19 +362,19 @@ void XMLHandlerTests::testMaxNum2() "<variable name=\"testbool\" >true</variable>" "<variable name=\"testdouble\" > %2 </variable>" "</item>" - "</macro>").arg(INT_MAX+1).arg(DBL_MAX+1); + "</macro>").tqarg(INT_MAX+1).tqarg(DBL_MAX+1); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; isvariableok["testdouble"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } @@ -382,9 +382,9 @@ void XMLHandlerTests::testMaxNum2() void XMLHandlerTests::testMinNum() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -392,19 +392,19 @@ void XMLHandlerTests::testMinNum() "<variable name=\"testbool\" >true</variable>" "<variable name=\"testdouble\" > %2 </variable>" "</item>" - "</macro>").arg(INT_MIN).arg(DBL_MIN); + "</macro>").tqarg(INT_MIN).tqarg(DBL_MIN); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; isvariableok["testdouble"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } @@ -412,9 +412,9 @@ void XMLHandlerTests::testMinNum() void XMLHandlerTests::testMinNum2() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -422,19 +422,19 @@ void XMLHandlerTests::testMinNum2() "<variable name=\"testbool\" >true</variable>" "<variable name=\"testdouble\" > %2 </variable>" "</item>" - "</macro>").arg(INT_MIN-1).arg(DBL_MIN-1); + "</macro>").tqarg(INT_MIN-1).tqarg(DBL_MIN-1); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; isvariableok["testdouble"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } @@ -442,9 +442,9 @@ void XMLHandlerTests::testMinNum2() void XMLHandlerTests::testBigNumber() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -452,19 +452,19 @@ void XMLHandlerTests::testBigNumber() "<variable name=\"testbool\" >true</variable>" "<variable name=\"testdouble\" > %1 </variable>" "</item>" - "</macro>").arg(DBL_MAX+1); + "</macro>").tqarg(DBL_MAX+1); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; isvariableok["testdouble"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } @@ -472,9 +472,9 @@ void XMLHandlerTests::testBigNumber() void XMLHandlerTests::testTwoMacroItems() { KSharedPtr<KoMacro::Macro> macro = KoMacro::Manager::self()->createMacro("testMacro"); - QDomDocument doomdocument; + TQDomDocument doomdocument; - const QString xml = QString("<!DOCTYPE macros>" + const TQString xml = TQString("<!DOCTYPE macros>" "<macro xmlversion=\"1\">" "<item action=\"testaction\" >" "<variable name=\"teststring\" >test_string</variable>" @@ -492,17 +492,17 @@ void XMLHandlerTests::testTwoMacroItems() "</item>" "</macro>"); doomdocument.setContent(xml); - const QDomElement elem = doomdocument.documentElement(); + const TQDomElement elem = doomdocument.documentElement(); KOMACROTEST_ASSERT(macro->parseXML(elem),true); - QMap<QString,bool> isvariableok; + TQMap<TQString,bool> isvariableok; isvariableok["teststring"] = true; isvariableok["testint"] = true; isvariableok["testbool"] = true; isvariableok["testdouble"] = true; assertMacroContentEqToXML(macro,elem,false,true,isvariableok); - const QDomElement elem2 = macro->toXML(); + const TQDomElement elem2 = macro->toXML(); assertMacroContentEqToXML(macro,elem2,false,true,isvariableok); } /*************************************************************************** @@ -512,20 +512,20 @@ void XMLHandlerTests::testTwoMacroItems() /** * Compares a XML-Element with a Macro. Call sub-asserts. * @p macro The parsen @a Macro. -* @p elem The given @a QDomElement which is parsen. +* @p elem The given @a TQDomElement which is parsen. * @p isitemsempty Bool for expectation of an empty @a MacroItem -List. * @p isactionset Bool for expectation that the @a Action -names are equal. -* @p isvariableok QMap of Bools for comparing each @a Variable . +* @p isvariableok TQMap of Bools for comparing each @a Variable . */ void XMLHandlerTests::assertMacroContentEqToXML(const KSharedPtr<KoMacro::Macro> macro, - const QDomElement& elem, + const TQDomElement& elem, const bool isitemsempty, const bool isactionset, - const QMap<QString, bool> isvariableok) + const TQMap<TQString, bool> isvariableok) { // Make an Iterator over the MacroItems of the Macro. - const QValueList<KSharedPtr<KoMacro::MacroItem > > macroitems = macro->items(); - QValueList<KSharedPtr<KoMacro::MacroItem > >::ConstIterator + const TQValueList<KSharedPtr<KoMacro::MacroItem > > macroitems = macro->items(); + TQValueList<KSharedPtr<KoMacro::MacroItem > >::ConstIterator mit(macroitems.constBegin()), end(macroitems.constEnd()); //1.comparison - Is the MacroItem-list empty? @@ -541,12 +541,12 @@ void XMLHandlerTests::assertMacroContentEqToXML(const KSharedPtr<KoMacro::Macro> } // Got to the first item-elements of the elem (there is only one in the tests). - QDomNode itemnode = elem.firstChild(); + TQDomNode itemnode = elem.firstChild(); // Iterate over the MacroItems and item-elements. while(mit != end && ! itemnode.isNull()) { const KSharedPtr<KoMacro::MacroItem> macroitem = *mit; - const QDomElement itemelem = itemnode.toElement(); + const TQDomElement itemelem = itemnode.toElement(); //2.comparison - Is the Action-name equal? { @@ -563,25 +563,25 @@ void XMLHandlerTests::assertMacroContentEqToXML(const KSharedPtr<KoMacro::Macro> } // Go down to MacroItem->Variable and item->variable and compare them. - QMap<QString, KSharedPtr<KoMacro::Variable > > mvariables = macroitem->variables(); - QDomNode varnode = itemelem.firstChild(); + TQMap<TQString, KSharedPtr<KoMacro::Variable > > mvariables = macroitem->variables(); + TQDomNode varnode = itemelem.firstChild(); while ( ! varnode.isNull()) { - const QDomElement varelem = varnode.toElement(); - const KSharedPtr<KoMacro::Variable> varitem = mvariables.find(varelem.attribute("name")).data(); + const TQDomElement varelem = varnode.toElement(); + const KSharedPtr<KoMacro::Variable> varitem = mvariables.tqfind(varelem.attribute("name")).data(); //3.comparison - Is the content of the Variable // in the MacroItem and and item equal? { - const bool var = *isvariableok.find(varelem.attribute("name")); + const bool var = *isvariableok.tqfind(varelem.attribute("name")); if( ! var ) { - KOMACROTEST_XASSERT(varitem->variant() == QVariant(varelem.text()), !var); + KOMACROTEST_XASSERT(varitem->variant() == TQVariant(varelem.text()), !var); kdDebug() << "The content of the Variable: " << varitem->name() << " is not equal." << varitem->variant() << "!=" << varelem.text() << endl; } else { - KOMACROTEST_ASSERT(varitem->variant() == QVariant(varelem.text()), var); + KOMACROTEST_ASSERT(varitem->variant() == TQVariant(varelem.text()), var); } } @@ -604,11 +604,11 @@ void XMLHandlerTests::assertMacroContentEqToXML(const KSharedPtr<KoMacro::Macro> } } -// Prints a QMap of Variables to kdDebug(). -void XMLHandlerTests::printMvariables(const QMap<QString, KSharedPtr<KoMacro::Variable > > mvariables, const QString s) +// Prints a TQMap of Variables to kdDebug(). +void XMLHandlerTests::printMvariables(const TQMap<TQString, KSharedPtr<KoMacro::Variable > > mvariables, const TQString s) { - //QValueList<QString>::ConstIterator kit (keys.constBegin()), end(keys.constEnd()); - QMap<QString, KSharedPtr<KoMacro::Variable > >::ConstIterator mvit (mvariables.constBegin()), end(mvariables.constEnd()); + //TQValueList<TQString>::ConstIterator kit (keys.constBegin()), end(keys.constEnd()); + TQMap<TQString, KSharedPtr<KoMacro::Variable > >::ConstIterator mvit (mvariables.constBegin()), end(mvariables.constEnd()); while(mvit != end){ const KoMacro::Variable * v = *mvit; kdDebug() << s << ": " << v->name() << endl; |