summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/macros/tests/xmlhandlertests2.h
blob: d8f92aafd0f2a200793705f9c07d03c32817fb58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
 * This file is part of the KDE project
 * copyright (C) 2006 by Bernd Steindorff ([email protected])
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 * You should have received a copy of the GNU Library General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 ***************************************************************************/

#ifndef KOMACROTEST_XMLHandlerTests2_H
#define KOMACROTEST_XMLHandlerTests2_H

#include <kunittest/tester.h>
#include "../lib/macro.h"

namespace KoMacroTest {

	/**
	* The common testsuite used to test common @a KoMacro
	* functionality.
	*/
	class XMLHandlerTests2 : public KUnitTest::SlotTester
	{
			Q_OBJECT
  TQ_OBJECT
		public:

			/**
			* Constructor.
			*/
			XMLHandlerTests2();

			/**
			* Destructor.
			*/
			virtual ~XMLHandlerTests2();

		public slots:

			/**
			* This slot got called by KUnitTest before testing
			* starts.
			*/
			void setUp();

			/**
			* This slot got called by KUnitTest after all tests
			* are done.
			*/
			void tearDown();

			/**
			* Test the @a KoMacro::XMLHandler parseXML()-function.
			*/
			void testParseAndToXML();

		private:
			/// @internal d-pointer class.
			class Private;
			/// @internal d-pointer instance.
			Private* const d;

			typedef TQMap<TQString,KoMacro::Variable>::size_type sizetypemap;
			typedef TQValueList<KSharedPtr<KoMacro::MacroItem > >::size_type sizetypelist;

			/** 
			* Compares a XML-Element with a Macro. Call sub-asserts.
			* @p macro The parsen @a Macro.
			* @p domelement 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 TQMap of Bools for comparing each @a Variable .
			*/
/*			void assertMacroContentEqToXML(const KSharedPtr<KoMacro::Macro> macro,
				const TQDomElement& elem,
				const bool isitemsempty,
				const bool isactionset,
				const TQMap<TQString, bool> isvariableok);

			// Prints a TQMap of Variables to kdDebug().
			void printMvariables(const TQMap<TQString, KSharedPtr<KoMacro::Variable > > mvariables, const TQString s);
*/
			/** 
			* Sub-methods of testParseXML() and testToXML().
			* Test the correct parsing of a @a TQDomElement into a @a Macro
			* respectively expected failure of parsing. Then transform it
			* back and compare it.
			*/
			// 1.Test - Correct DomElement.
			void testCorrectDomElement();
			// 2.Test - XML-document with bad root element.
			void testBadRoot();
			// 3.Test - XML-document with a missing Variable.
			void testMissingVariable();
			// 4.Test - One more Variable in XML-Document.
			void testMoreVariables();
			// 5.Test - XML-document with wrong macro-xmlversion.
			void testWrongVersion();
			// 6.Test - XML-document if it has a wrong structure like
			// wrong parathesis	or missing end tag.
			void testWrongXMLStruct();
			// 7.Test-XML-document with maximum field-size.
			void testMaxNum();
			// 8.Test-XML-document with maximum+1 field-size.
			void testMaxNum2();
			// 9.Test-XML-document with minimum field-size.
			void testMinNum();
			// 10.Test-XML-document with minimum-1 field-size.
			void testMinNum2();
			// 11.Test - With a to big number.
			void testBigNumber();
			// 12.Test - With two MacroItems.
			void testTwoMacroItems();


			bool assertActionsEqual(KSharedPtr<KoMacro::Action> action,
				KSharedPtr<KoMacro::Action> action2);

			bool assertVariablesEqual(KSharedPtr<KoMacro::Variable> var,
				KSharedPtr<KoMacro::Variable> var2);
	};
}

#endif