48
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: - Main test class for Msgnotification -indicator plugin,
|
|
15 |
* -notification dialog plugin
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "testmmsplugin.h"
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
#include "debugtraces.h"
|
|
21 |
#include <QTimer>
|
|
22 |
#include <QSignalSpy>
|
|
23 |
#include "convergedmessage.h"
|
|
24 |
#include "convergedmessageid.h"
|
|
25 |
#include "unieditormmsplugin.h"
|
|
26 |
#include "mmstestbed.h"
|
|
27 |
#include "testmmsplugin.ini"
|
|
28 |
#include <QSignalSpy>
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
//out put directory for test results.
|
|
33 |
QString OUTPUTDIRECTORY = "c:/logs/testmmsplugin";
|
|
34 |
//o/p directory for data to be written on temp file.
|
|
35 |
QString TEMPDIR = "c:/logs/testmmsplugin/testdata";
|
|
36 |
//test result O/P file name.
|
|
37 |
QString RESULTFILE = "c:/logs/testmmsplugin/result_%1.txt";
|
|
38 |
// folder named UID3 of testmmsplugin inside private folder.
|
|
39 |
const QString PRIVATE_DIR("C:/private/E4c5e8b4");
|
|
40 |
|
|
41 |
//factory method to create objects.
|
|
42 |
QObject* getObject(QString className)
|
|
43 |
{
|
|
44 |
if(className == "TestMmsPlugin" )
|
|
45 |
{
|
|
46 |
return new TestMmsPlugin;
|
|
47 |
}
|
|
48 |
else
|
|
49 |
{
|
|
50 |
return 0;
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
//creating o/p directory.
|
|
55 |
void createOutPutDirectory()
|
|
56 |
{
|
|
57 |
QDir dir;
|
|
58 |
//o/p dir
|
|
59 |
dir.mkdir(OUTPUTDIRECTORY);
|
|
60 |
//tmp dir
|
|
61 |
dir.mkdir(TEMPDIR);
|
|
62 |
// dir inside private folder.
|
|
63 |
dir.mkdir(PRIVATE_DIR);
|
|
64 |
}
|
|
65 |
|
|
66 |
//main entry point
|
|
67 |
int main(int argc, char *argv[])
|
|
68 |
{
|
|
69 |
int ret = -1;
|
|
70 |
QCoreApplication app(argc, argv);
|
|
71 |
|
|
72 |
//creating output directory.
|
|
73 |
createOutPutDirectory();
|
|
74 |
|
|
75 |
//the configuration file.
|
|
76 |
QFile data("c:/testmmsplugin.cfg");
|
|
77 |
|
|
78 |
if (data.open(QFile::ReadOnly))
|
|
79 |
{
|
|
80 |
QTextStream in(&data);
|
|
81 |
while(!in.atEnd())
|
|
82 |
{
|
|
83 |
QStringList args;
|
|
84 |
QString appName = argv[0];
|
|
85 |
args << appName;
|
|
86 |
|
|
87 |
QString option = "-o";
|
|
88 |
args << option;
|
|
89 |
|
|
90 |
QString outFile = RESULTFILE;
|
|
91 |
QString name = in.readLine();
|
|
92 |
outFile = outFile.arg(name);
|
|
93 |
args << outFile;
|
|
94 |
|
|
95 |
QObject* tc = getObject(name);
|
|
96 |
|
|
97 |
if(tc)
|
|
98 |
{
|
|
99 |
|
|
100 |
ret = QTest::qExec(tc, args);
|
|
101 |
delete tc;
|
|
102 |
}
|
|
103 |
}
|
|
104 |
}
|
|
105 |
data.close();
|
|
106 |
return ret;
|
|
107 |
}
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
//---------------------------------------------------------------
|
|
114 |
// TestMmsPlugin::initTestCase
|
|
115 |
//---------------------------------------------------------------
|
|
116 |
|
|
117 |
void TestMmsPlugin::initTestCase()
|
|
118 |
{
|
|
119 |
qRegisterMetaType<long int> ("long int");
|
|
120 |
msgPlugin = new UniEditorMmsPlugin();
|
|
121 |
QVERIFY(msgPlugin != 0);
|
|
122 |
mmsId = -1;
|
|
123 |
mmstestbed = new MmsTestBed;
|
|
124 |
QVERIFY(mmstestbed != 0);
|
|
125 |
if(!mmstestbed)
|
|
126 |
{
|
|
127 |
QSKIP("Mmstestbed creation failed", SkipAll);
|
|
128 |
}
|
|
129 |
|
|
130 |
spy_draft = new QSignalSpy(mmstestbed,SIGNAL(entryCreatedInDraft(long int)));
|
|
131 |
spy_outbox = new QSignalSpy(mmstestbed,SIGNAL(entryMovedToOutbox(long int)));
|
|
132 |
spy_sent = new QSignalSpy(mmstestbed,SIGNAL(entryMovedToSent(long int)));
|
|
133 |
|
|
134 |
}
|
|
135 |
|
|
136 |
//---------------------------------------------------------------
|
|
137 |
// TestMmsPlugin::init
|
|
138 |
//---------------------------------------------------------------
|
|
139 |
|
|
140 |
void TestMmsPlugin::init()
|
|
141 |
{
|
|
142 |
}
|
|
143 |
|
|
144 |
//---------------------------------------------------------------
|
|
145 |
// TestMmsPlugin::testSendMMS
|
|
146 |
//---------------------------------------------------------------
|
|
147 |
|
|
148 |
void TestMmsPlugin::testSendMMS()
|
|
149 |
{
|
|
150 |
|
|
151 |
qRegisterMetaType<long int> ("long int");
|
|
152 |
QString service = TEST_SERVICE_NAME_MMS;
|
|
153 |
|
|
154 |
QString subject = TEST_MSG_SUBJECT;
|
|
155 |
qint64 timeStamp = QDateTime::currentDateTime().toTime_t();
|
|
156 |
|
|
157 |
QString sender(TEST_SENDER);
|
|
158 |
ConvergedMessageAddress address(sender);
|
|
159 |
ConvergedMessageAttachmentList attachmentList;
|
|
160 |
|
|
161 |
QString attachment2Path = TEST_ATTACHMENT4;
|
|
162 |
ConvergedMessageAttachment* attachment2 =
|
|
163 |
new ConvergedMessageAttachment(attachment2Path, ConvergedMessageAttachment::EAttachment);
|
|
164 |
|
|
165 |
QString attachmentPath = TEST_ATTACHMENT5;
|
|
166 |
ConvergedMessageAttachment* attachment =
|
|
167 |
new ConvergedMessageAttachment(attachmentPath, ConvergedMessageAttachment::EAttachment);
|
|
168 |
|
|
169 |
attachmentList.append(attachment);
|
|
170 |
attachmentList.append(attachment2);
|
|
171 |
ConvergedMessage msg;
|
|
172 |
msg.setMessageType(ConvergedMessage::Mms);
|
|
173 |
msg.setSubject(subject);
|
|
174 |
msg.setTimeStamp(timeStamp);
|
|
175 |
msg.addToRecipient(address);
|
|
176 |
msg.addAttachments(attachmentList);
|
|
177 |
msg.setPriority(ConvergedMessage::Normal);
|
|
178 |
//Adding alias
|
|
179 |
ConvergedMessageAddress address1;
|
|
180 |
address1.setAlias(QString(TEST_MSG_RECIEPIENT));
|
|
181 |
msg.addToRecipient(address1);
|
|
182 |
|
|
183 |
//Adding CC Address
|
|
184 |
QString ccAddress(TEST_CC);
|
|
185 |
ConvergedMessageAddress ccAdd(ccAddress);
|
|
186 |
msg.addCcRecipient(ccAdd);
|
|
187 |
|
|
188 |
//Adding BCC Address
|
|
189 |
QString bccAddress(TEST_BCC);
|
|
190 |
ConvergedMessageAddress bccAdd(bccAddress);
|
|
191 |
msg.addBccRecipient(bccAdd);
|
|
192 |
|
|
193 |
mmstestbed->cleanAll();
|
|
194 |
mmstestbed->setConnectionLocal(true);
|
|
195 |
long int id = msgPlugin->convertTo(&msg);
|
|
196 |
|
|
197 |
QVERIFY(id != 0);
|
|
198 |
msgPlugin->send(id);
|
|
199 |
QTest::qWait(5000);
|
|
200 |
long int idRec;
|
|
201 |
|
|
202 |
if( 1 == spy_draft->count())
|
|
203 |
{
|
|
204 |
void * temp = const_cast<void*>(spy_draft->at(0).at(0).data());
|
|
205 |
idRec = *reinterpret_cast< long int(*)>(temp);
|
|
206 |
QDEBUG_WRITE("passed: spy_draft.count");
|
|
207 |
}
|
|
208 |
else
|
|
209 |
{
|
|
210 |
QFAIL("testSendReceiveMMS: Failed to create message in Draft");
|
|
211 |
mmstestbed->setConnectionLocal(false);
|
|
212 |
return;
|
|
213 |
}
|
|
214 |
if( 1 == spy_outbox->count())
|
|
215 |
{
|
|
216 |
mmstestbed->fromOutboxToMmsc();
|
|
217 |
QDEBUG_WRITE("passed: spy_outbox.count");
|
|
218 |
}
|
|
219 |
else
|
|
220 |
{
|
|
221 |
QFAIL("testSendReceiveMMS: Failed to move message to Outbox");
|
|
222 |
mmstestbed->setConnectionLocal(false);
|
|
223 |
return;
|
|
224 |
}
|
|
225 |
|
|
226 |
if( 1 == spy_sent->count())
|
|
227 |
{
|
|
228 |
void * temp = const_cast<void*>(spy_sent->at(0).at(0).data());
|
|
229 |
long int sentmsgid = *reinterpret_cast< long int(*)>(temp);
|
|
230 |
QCOMPARE(sentmsgid, idRec);
|
|
231 |
mmstestbed->fromMmscToInbox();
|
|
232 |
QDEBUG_WRITE("passed: spy_sent.count");
|
|
233 |
}
|
|
234 |
else
|
|
235 |
{
|
|
236 |
QFAIL("testSendReceiveMMS: Failed to move message to Sent folder");
|
|
237 |
mmstestbed->setConnectionLocal(false);
|
|
238 |
return;
|
|
239 |
}
|
|
240 |
}
|
|
241 |
|
|
242 |
//---------------------------------------------------------------
|
|
243 |
// TestMmsPlugin::testMmsReceived
|
|
244 |
//---------------------------------------------------------------
|
|
245 |
void TestMmsPlugin::testMmsReceived()
|
|
246 |
{
|
|
247 |
QTest::qWait(5000);
|
|
248 |
}
|
|
249 |
|
|
250 |
//---------------------------------------------------------------
|
|
251 |
// TestMmsPlugin::cleanup
|
|
252 |
//---------------------------------------------------------------
|
|
253 |
void TestMmsPlugin::cleanup()
|
|
254 |
{
|
|
255 |
}
|
|
256 |
|
|
257 |
//---------------------------------------------------------------
|
|
258 |
// TestMmsPlugin::cleanupTestCase
|
|
259 |
//---------------------------------------------------------------
|
|
260 |
void TestMmsPlugin::cleanupTestCase()
|
|
261 |
{
|
|
262 |
delete msgPlugin;
|
|
263 |
delete mmstestbed;
|
|
264 |
}
|
|
265 |
|