|
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: |
|
15 */ |
|
16 #include <QtTest/QtTest> |
|
17 #include <QtDebug> |
|
18 #include <QTimer> |
|
19 #include <QSignalSpy> |
|
20 #include <xqconversions.h> |
|
21 #include <bsp.h> |
|
22 #include <biodb.h> |
|
23 #include <biouids.h> |
|
24 #include <biocmtm.h> |
|
25 #include "convergedmessageaddress.h" |
|
26 |
|
27 #include "testunidatamodelloader.h" |
|
28 #include <unidatamodelloader.h> |
|
29 #include "testunidatamodelloader.ini" |
|
30 #include "unidatamodelplugininterface.h" |
|
31 #include <convergedmessage.h> |
|
32 #include <unieditorplugininterface.h> |
|
33 |
|
34 const TInt KTelephoneNumberMaxLength = 32; |
|
35 |
|
36 // vCalender |
|
37 _LIT(KUnixEpoch, "19700000:000000.000000"); |
|
38 #define KBioUidValue 0x10001262 |
|
39 |
|
40 const TUid KBioUidValueUid = {KBioUidValue}; |
|
41 |
|
42 |
|
43 //--------------------------------------------------------------- |
|
44 //Main entry point |
|
45 //--------------------------------------------------------------- |
|
46 int main(int argc, char *argv[]) |
|
47 { |
|
48 int ret = -1; |
|
49 QCoreApplication app(argc, argv); |
|
50 QObject* tc = new TestUniDataModelLoader(); |
|
51 |
|
52 #ifdef __WINSCW__ |
|
53 char *new_argv[3]; |
|
54 QString str = "C:\\data\\" + QFileInfo(QCoreApplication::applicationFilePath()).baseName() + ".log"; |
|
55 QByteArray bytes = str.toAscii(); |
|
56 char arg1[] = "-o"; |
|
57 new_argv[0] = argv[0]; |
|
58 new_argv[1] = arg1; |
|
59 new_argv[2] = bytes.data(); |
|
60 ret = QTest::qExec(tc, 3, new_argv); |
|
61 #else |
|
62 ret = QTest::qExec(tc, argc, argv); |
|
63 #endif |
|
64 delete tc; |
|
65 return ret; |
|
66 |
|
67 } |
|
68 |
|
69 //--------------------------------------------------------------- |
|
70 // TestUniDataModelLoader::init |
|
71 //--------------------------------------------------------------- |
|
72 void TestUniDataModelLoader::initTestCase() |
|
73 { |
|
74 iObserver = new (ELeave) MsgObserver(); |
|
75 |
|
76 // Create a new messaging server session.. |
|
77 iMSession = CMsvSession::OpenSyncL(*iObserver); |
|
78 |
|
79 iMsvEntry = iMSession->GetEntryL(KMsvRootIndexEntryId); |
|
80 newEntryId = 0; |
|
81 pluginLoader = new UniDataModelLoader(); |
|
82 |
|
83 retTimeStamp = QDateTime::currentDateTime(); |
|
84 int err = iFs.Connect(); |
|
85 QVERIFY(err == 0); |
|
86 iBioDb = CBIODatabase::NewL(iFs); |
|
87 iFs.SetSessionPath(_L("c:\\")); |
|
88 inbox = EFalse; |
|
89 } |
|
90 |
|
91 //--------------------------------------------------------------- |
|
92 // TestUniDataModelLoader::init |
|
93 //--------------------------------------------------------------- |
|
94 void TestUniDataModelLoader::init() |
|
95 { |
|
96 |
|
97 } |
|
98 |
|
99 //--------------------------------------------------------------- |
|
100 // TestUniDataModelLoader::testBioMessage |
|
101 //--------------------------------------------------------------- |
|
102 void TestUniDataModelLoader::testBioMessage() |
|
103 { |
|
104 inbox = ETrue; |
|
105 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::BioMsg); |
|
106 |
|
107 QVERIFY( pluginInterface != NULL ); |
|
108 |
|
109 QString msgType = pluginInterface->messageType(); |
|
110 |
|
111 qDebug() <<"msgType" << msgType; |
|
112 QCOMPARE(msgType, QString("biomessage")); |
|
113 |
|
114 qDebug() <<"UnidataModel Loader for Biomessage Created Successfully"; |
|
115 } |
|
116 |
|
117 //--------------------------------------------------------------- |
|
118 // TestUniDataModelLoader::testMMSMessage |
|
119 //--------------------------------------------------------------- |
|
120 void TestUniDataModelLoader::testMMSMessage() |
|
121 { |
|
122 qRegisterMetaType<long int> ("long int"); |
|
123 QString service = TEST_SERVICE_NAME_MMS; |
|
124 QString subject = TEST_MSG_SUBJECT; |
|
125 qint64 timeStamp = QDateTime::currentDateTime().toTime_t(); |
|
126 |
|
127 QString sender(TEST_SENDER); |
|
128 ConvergedMessageAddress address(sender); |
|
129 ConvergedMessageAttachmentList attachmentList; |
|
130 |
|
131 QString attachment2Path = TEST_ATTACHMENT4; |
|
132 ConvergedMessageAttachment* attachment2 = |
|
133 new ConvergedMessageAttachment(attachment2Path, ConvergedMessageAttachment::EAttachment); |
|
134 |
|
135 QString attachmentPath = TEST_ATTACHMENT5; |
|
136 ConvergedMessageAttachment* attachment = |
|
137 new ConvergedMessageAttachment(attachmentPath, ConvergedMessageAttachment::EAttachment); |
|
138 |
|
139 attachmentList.append(attachment); |
|
140 attachmentList.append(attachment2); |
|
141 ConvergedMessage msg; |
|
142 msg.setMessageType(ConvergedMessage::Mms); |
|
143 msg.setSubject(subject); |
|
144 msg.setTimeStamp(timeStamp); |
|
145 msg.addToRecipient(address); |
|
146 msg.addAttachments(attachmentList); |
|
147 msg.setPriority(ConvergedMessage::Normal); |
|
148 //Adding alias |
|
149 ConvergedMessageAddress address1; |
|
150 address1.setAlias(QString(TEST_MSG_RECIEPIENT)); |
|
151 msg.addToRecipient(address1); |
|
152 |
|
153 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Mms); |
|
154 pluginInterface->setMessageId(newEntryId); |
|
155 |
|
156 QVERIFY( pluginInterface != NULL ); |
|
157 |
|
158 QString msgType = pluginInterface->messageType(); |
|
159 |
|
160 qDebug() <<"msgType" << msgType; |
|
161 QCOMPARE(msgType, QString("mms")); |
|
162 |
|
163 qDebug() <<"UnidataModel Loader for MMS Created Successfully"; |
|
164 } |
|
165 |
|
166 //--------------------------------------------------------------- |
|
167 // TestUniDataModelLoader::testSMSMessage |
|
168 //--------------------------------------------------------------- |
|
169 void TestUniDataModelLoader::testSMSMessage() |
|
170 { |
|
171 qint64 timeStamp = QDateTime::currentDateTime().toTime_t(); |
|
172 QString sender(TEST_SENDER); |
|
173 ConvergedMessageAddress address(sender); |
|
174 ConvergedMessage msg; |
|
175 msg.setMessageType(ConvergedMessage::Sms); |
|
176 msg.setTimeStamp(timeStamp); |
|
177 msg.addToRecipient(address); |
|
178 msg.setBodyText( TEST_MSG_BODY); |
|
179 msg.setPriority(ConvergedMessage::Normal); |
|
180 //Adding alias |
|
181 ConvergedMessageAddress address1; |
|
182 address1.setAlias(QString(TEST_MSG_RECIEPIENT)); |
|
183 msg.addToRecipient(address1); |
|
184 |
|
185 pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Sms); |
|
186 |
|
187 QVERIFY( pluginInterface != NULL ); |
|
188 |
|
189 QString msgType = pluginInterface->messageType(); |
|
190 |
|
191 qDebug() <<"msgType" << msgType; |
|
192 QCOMPARE(msgType, QString("sms")); |
|
193 |
|
194 qDebug() <<"UnidataModel Loader for SMS Created Successfully"; |
|
195 } |
|
196 |
|
197 //--------------------------------------------------------------- |
|
198 // TestUniDataModelLoader::cleanup |
|
199 //--------------------------------------------------------------- |
|
200 void TestUniDataModelLoader::cleanup() |
|
201 { |
|
202 |
|
203 } |
|
204 |
|
205 //--------------------------------------------------------------- |
|
206 // TestUniDataModelLoader::cleanupTestCase |
|
207 //--------------------------------------------------------------- |
|
208 void TestUniDataModelLoader::cleanupTestCase() |
|
209 { |
|
210 delete iMsvEntry; |
|
211 iMsvEntry = NULL; |
|
212 delete iObserver; |
|
213 iObserver = NULL; |
|
214 delete iMSession; |
|
215 iMSession = NULL; |
|
216 delete pluginLoader; |
|
217 } |
|
218 |
|
219 //--------------------------------------------------------------- |
|
220 // TestUniDataModelLoader::HandleSessionEventL |
|
221 //--------------------------------------------------------------- |
|
222 void MsgObserver::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
|
223 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
224 { |
|
225 } |