22 #include <qtest_kde.h>
25 using namespace MailCommon;
39 void FilterActionPipeThroughTest::testWithNoCommand()
45 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
47 item.setPayload<KMime::Message::Ptr>(msgPtr);
52 QCOMPARE(
context.needsPayloadStore(),
false);
55 void FilterActionPipeThroughTest::testWithInvalidCommandPath()
60 "From: Konqui <konqui@kde.org>\n"
61 "To: Friends <friends@kde.org>\n"
62 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
63 "Subject: Sample message\n"
65 "Content-type: multipart/mixed; boundary=\"simple boundary\"\n"
69 "Content-type: text/plain; charset=us-ascii\n"
71 "This is explicitly typed plain US-ASCII text.\n"
72 "It DOES end with a linebreak.\n"
74 "--simple boundary--\n";
77 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
79 msgPtr->setContent(data);
80 item.setPayload<KMime::Message::Ptr>(msgPtr);
85 QCOMPARE(
context.needsPayloadStore(),
false);
86 QCOMPARE(msgPtr->encodedContent(), data);
89 void FilterActionPipeThroughTest::testCommandWithoutOutput()
95 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
97 item.setPayload<KMime::Message::Ptr>(msgPtr);
102 QCOMPARE(
context.needsPayloadStore(),
false);
105 void FilterActionPipeThroughTest::testWithMailOutput()
113 "From: Konqui <konqui@kde.org>\n"
114 "To: Friends <friends@kde.org>\n"
115 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
116 "Subject: Sample message\n"
117 "MIME-Version: 1.0\n"
118 "Content-type: multipart/mixed;\n"
119 " boundary=\"simple boundary\"\n"
122 "--simple boundary\n"
123 "Content-type: text/plain;\n"
124 " charset=us-ascii\n"
126 "This is explicitly typed plain US-ASCII text.\n"
127 "It DOES end with a linebreak.\n"
129 "--simple boundary--\n";
132 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
134 item.setPayload<KMime::Message::Ptr>(msgPtr);
137 setOutput(&filter, data);
139 QCOMPARE(
context.needsPayloadStore(),
true);
141 QCOMPARE( msgPtr->encodedContent(), expected);
143 QCOMPARE( msgPtr->encodedContent(), expected);
147 void FilterActionPipeThroughTest::testCopyMail()
152 "From: Konqui <konqui@kde.org>\n"
153 "To: Friends <friends@kde.org>\n"
154 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
155 "Subject: Sample message\n"
156 "MIME-Version: 1.0\n"
157 "Content-type: multipart/mixed; boundary=\"simple boundary\"\n"
160 "--simple boundary\n"
161 "Content-type: text/plain; charset=us-ascii\n"
163 "This is explicitly typed plain US-ASCII text.\n"
164 "It DOES end with a linebreak.\n"
166 "--simple boundary--\n";
169 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
171 msgPtr->setContent(data);
172 item.setPayload<KMime::Message::Ptr>(msgPtr);
177 QCOMPARE(
context.needsPayloadStore(),
true);
178 QCOMPARE(msgPtr->encodedContent(), data);
181 void FilterActionPipeThroughTest::testXUidUnchange()
185 "From: Konqui <konqui@kde.org>\n"
186 "To: Friends <friends@kde.org>\n"
187 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
188 "Subject: Sample message\n"
189 "MIME-Version: 1.0\n"
191 "Content-type: multipart/mixed;\n"
192 " boundary=\"simple boundary\"\n"
195 "--simple boundary\n"
196 "Content-type: text/plain;\n"
197 " charset=us-ascii\n"
199 "This is explicitly typed plain US-ASCII text.\n"
200 "It DOES end with a linebreak.\n"
202 "--simple boundary--\n";
205 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
207 msgPtr->setContent(data);
209 item.setPayload<KMime::Message::Ptr>(msgPtr);
214 QCOMPARE(
context.needsPayloadStore(),
true);
218 void FilterActionPipeThroughTest::testXUidRemoved()
226 "From: Konqui <konqui@kde.org>\n"
227 "To: Friends <friends@kde.org>\n"
228 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
229 "Subject: Sample message\n"
230 "MIME-Version: 1.0\n"
232 "Content-type: multipart/mixed;\n"
233 " boundary=\"simple boundary\"\n"
236 "--simple boundary\n"
237 "Content-type: text/plain;\n"
238 " charset=us-ascii\n"
240 "This is explicitly typed plain US-ASCII text.\n"
241 "It DOES end with a linebreak.\n"
243 "--simple boundary--\n";
246 "From: Konqui <konqui@kde.org>\n"
247 "To: Friends <friends@kde.org>\n"
248 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
249 "Subject: Sample message\n"
250 "MIME-Version: 1.0\n"
251 "Content-type: multipart/mixed;\n"
252 " boundary=\"simple boundary\"\n"
255 "--simple boundary\n"
256 "Content-type: text/plain;\n"
257 " charset=us-ascii\n"
259 "This is explicitly typed plain US-ASCII text.\n"
260 "It DOES end with a linebreak.\n"
262 "--simple boundary--\n";
265 "From: Konqui <konqui@kde.org>\n"
266 "To: Friends <friends@kde.org>\n"
267 "Date: Sun, 21 Mar 1993 23:56:48 -0800\n"
268 "Subject: Sample message\n"
269 "MIME-Version: 1.0\n"
270 "Content-Type: multipart/mixed; boundary=\"simple boundary\"\n"
274 "--simple boundary\n"
275 "Content-type: text/plain;\n"
276 " charset=us-ascii\n"
278 "This is explicitly typed plain US-ASCII text.\n"
279 "It DOES end with a linebreak.\n"
281 "--simple boundary--\n"
285 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
287 msgPtr->setContent(data);
289 item.setPayload<KMime::Message::Ptr>(msgPtr);
291 setOutput(&filter, send);
293 QCOMPARE(
context.needsPayloadStore(),
true);
294 QCOMPARE(msgPtr->encodedContent(), output);
297 void FilterActionPipeThroughTest::shouldRequiresPart()
303 void FilterActionPipeThroughTest::testXUidChange()
311 "From: Konqui <konqui@kde.org>\n"
312 "To: Friends <friends@kde.org>\n"
313 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
314 "Subject: Sample message\n"
315 "MIME-Version: 1.0\n"
317 "Content-type: multipart/mixed;\n"
318 " boundary=\"simple boundary\"\n"
321 "--simple boundary\n"
322 "Content-type: text/plain;\n"
323 " charset=us-ascii\n"
325 "This is explicitly typed plain US-ASCII text.\n"
326 "It DOES end with a linebreak.\n"
328 "--simple boundary--\n";
331 "From: Konqui <konqui@kde.org>\n"
332 "To: Friends <friends@kde.org>\n"
333 "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\n"
334 "Subject: Sample message\n"
335 "MIME-Version: 1.0\n"
337 "Content-type: multipart/mixed;\n"
338 " boundary=\"simple boundary\"\n"
341 "--simple boundary\n"
342 "Content-type: text/plain;\n"
343 " charset=us-ascii\n"
345 "This is explicitly typed plain US-ASCII text.\n"
346 "It DOES end with a linebreak.\n"
348 "--simple boundary--\n";
351 "From: Konqui <konqui@kde.org>\n"
352 "To: Friends <friends@kde.org>\n"
353 "Date: Sun, 21 Mar 1993 23:56:48 -0800\n"
354 "Subject: Sample message\n"
355 "MIME-Version: 1.0\n"
356 "Content-Type: multipart/mixed; boundary=\"simple boundary\"\n"
360 "--simple boundary\n"
361 "Content-type: text/plain;\n"
362 " charset=us-ascii\n"
364 "This is explicitly typed plain US-ASCII text.\n"
365 "It DOES end with a linebreak.\n"
367 "--simple boundary--\n"
371 KMime::Message::Ptr msgPtr = KMime::Message::Ptr(
new KMime::Message());
373 msgPtr->setContent(data);
375 item.setPayload<KMime::Message::Ptr>(msgPtr);
377 setOutput(&filter, send);
379 QCOMPARE(
context.needsPayloadStore(),
true);
380 QCOMPARE(msgPtr->encodedContent(), output);
QString fromAscii(const char *str, int size)
Go on with applying filter actions.
FilterActionPipeThroughTest()
virtual SearchRule::RequiredPart requiredPart() const =0
Returns the required part from the item that is needed for the action to operate. ...
Abstract base class for mail filter actions.
A non-critical error occurred.
QByteArray & replace(int pos, int len, const char *after)
virtual ReturnCode process(ItemContext &context, bool applyOnOutbound) const =0
Execute action on given message (inside the item context).
virtual void argsFromString(const QString &argsStr)=0
Read extra arguments from given string.
A helper class for the filtering process.