1 /* |
|
2 * Copyright (c) 2002 - 2007 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: imcvuiengine_testsendmessage.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // [INCLUDE FILES] - do not remove |
|
20 #include <e32math.h> |
|
21 #include "imcvuiengine_testsendmessage.h" |
|
22 #include "cimcvengine.h" |
|
23 #include "mimcvenginemessagecontainerinfo.h" |
|
24 #include "mimcvenginemessagecreator.h" |
|
25 #include "cimcvenginemessagehandler.h" |
|
26 #include <ximpbase.h> |
|
27 #include <e32property.h> |
|
28 #include "mimcvenginechatinterface.h" |
|
29 #include "mimcvenginemessageswriteinterface.h" |
|
30 #include "mimcvengineopenchats.h" |
|
31 |
|
32 #include "cimcvenginemessagehandler.h" |
|
33 #include <avabilitytext.h> |
|
34 |
|
35 #include <spentry.h> |
|
36 #include <spsettings.h> |
|
37 #include <spproperty.h> |
|
38 #include "s_cch.h" |
|
39 #include "cimcvenginefactory.h" |
|
40 #include "mimcvenginefactory.h" |
|
41 #include "cimcvenginemessagecreator.h" |
|
42 #include "mimcvenginemessagecreator.h" |
|
43 |
|
44 _LIT(KOwnUser,"testlm123@gmail.com"); |
|
45 _LIT8(KBrandId,"YAHOO"); |
|
46 |
|
47 const TInt KProtocolUid = 0x20007B6D; |
|
48 const TUid KIMPropertyUid = { 0x0D334E82 }; |
|
49 |
|
50 const TUint KIMConnectedKey = 0x00000001; |
|
51 const TUint KIMServiceIdKey = 0x00000002; |
|
52 const TUint KIMServiceProtocolUidKey = 0x00000003; |
|
53 const TUint KIMOwnUserIdKey = 0x00000004; |
|
54 |
|
55 _LIT(KRecipientID,"testui123@gmail.com"); |
|
56 _LIT(KRecipientID2,"testlm123@gmail.com"); |
|
57 |
|
58 _LIT(KInvalidRecipientID,"abcsddd@gmail.com"); |
|
59 |
|
60 // meco service uid |
|
61 #define KMECOIMPLEMENTATIONUID 0x20012423 |
|
62 |
|
63 |
|
64 //const TInt ProcessInterval = 2000000; //2 seconds |
|
65 |
|
66 // -------------------------------------------------------------------------- |
|
67 // CIMCVUiEngine_TestSendMessage::CIMCVUiEngine_TestSendMessage |
|
68 // -------------------------------------------------------------------------- |
|
69 // |
|
70 CIMCVUiEngine_TestSendMessage::CIMCVUiEngine_TestSendMessage() |
|
71 { |
|
72 |
|
73 } |
|
74 |
|
75 |
|
76 // CIMCommands_TestLogin::~CIMCommands_TestLogin |
|
77 // -------------------------------------------------------------------------- |
|
78 // |
|
79 CIMCVUiEngine_TestSendMessage::~CIMCVUiEngine_TestSendMessage() |
|
80 { |
|
81 delete iSettings; |
|
82 CIMCVEngineFactory::Release(); |
|
83 } |
|
84 |
|
85 |
|
86 // -------------------------------------------------------------------------- |
|
87 // CIMCommands_TestLogin::NewL |
|
88 // -------------------------------------------------------------------------- |
|
89 // |
|
90 CIMCVUiEngine_TestSendMessage* CIMCVUiEngine_TestSendMessage::NewL() |
|
91 { |
|
92 CIMCVUiEngine_TestSendMessage* self = new(ELeave) CIMCVUiEngine_TestSendMessage(); |
|
93 CleanupStack::PushL(self); |
|
94 self->ConstructL(); |
|
95 CleanupStack::Pop(self); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // Cimcvuiengine_test::ConstructL |
|
101 // Simple printing to UI test. |
|
102 // ----------------------------------------------------------------------------- |
|
103 void CIMCVUiEngine_TestSendMessage::ConstructL() |
|
104 { |
|
105 // define the property for upper layer to use serivceid , |
|
106 // servicesetting id and loggedin user id |
|
107 // servicesetting id and loggedin user id |
|
108 |
|
109 CreateSpEntryL(KTestServiceId); |
|
110 ReadServiceDetalsL(); |
|
111 |
|
112 |
|
113 TInt err = RProperty::Define(KIMPropertyUid, KIMServiceIdKey, RProperty::EInt, |
|
114 ECapabilityReadUserData ,ECapabilityWriteUserData); |
|
115 //User::LeaveIfError(err); |
|
116 |
|
117 |
|
118 err = RProperty::Define(KIMPropertyUid, KIMServiceProtocolUidKey, RProperty::EInt, |
|
119 ECapabilityReadUserData ,ECapabilityWriteUserData ); |
|
120 //User::LeaveIfError(err); |
|
121 |
|
122 err = RProperty::Define(KIMPropertyUid, KIMConnectedKey, RProperty::EInt, |
|
123 ECapabilityReadUserData ,ECapabilityWriteUserData ); |
|
124 //User::LeaveIfError(err); |
|
125 |
|
126 // write into defined property for upper layer to use serivceid , |
|
127 |
|
128 RProperty::Set( KIMPropertyUid, KIMServiceIdKey, KTestServiceId ); |
|
129 RProperty::Set( KIMPropertyUid, KIMServiceProtocolUidKey, KProtocolUid ); |
|
130 RProperty::Set( KIMPropertyUid, KIMConnectedKey, ETrue ); |
|
131 |
|
132 iEngineFactory = CIMCVEngineFactory::InstanceL(); |
|
133 |
|
134 iEngine = &iEngineFactory->GetServiceEngineL( KTestServiceId ); |
|
135 |
|
136 // for send operation |
|
137 iEngine->MessageHandler().SetObserver(this); |
|
138 |
|
139 //iEngine->CCHHandler().EnableService(); |
|
140 } |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CIMCVUiEngine_TestSendMessage::ReadServiceDetalsL |
|
143 // Simple printing to UI test. |
|
144 // ----------------------------------------------------------------------------- |
|
145 void CIMCVUiEngine_TestSendMessage::ReadServiceDetalsL() |
|
146 { |
|
147 iSettings = CSPSettings::NewL(); // CCH Login |
|
148 iServiceId = KErrNotFound; |
|
149 ///////////////////////Get Service Id//////////////// |
|
150 RArray<TServiceId> services; |
|
151 CleanupClosePushL( services ); |
|
152 iSettings->FindServiceIdsL( services ); |
|
153 const TInt serviceCount = services.Count(); |
|
154 for ( TInt i( 0 ); i < serviceCount; i++ ) |
|
155 { |
|
156 TInt refContactUid = KErrNotFound; |
|
157 CSPProperty* property = CSPProperty::NewLC(); |
|
158 iSettings->FindPropertyL( services[i],EPropertyContactViewPluginId,*property ); |
|
159 if ( property ) |
|
160 { |
|
161 property->GetValue( refContactUid ); |
|
162 } |
|
163 CleanupStack::PopAndDestroy( property ); |
|
164 if ( (TUid::Uid( refContactUid ) == TUid::Uid( KMECOIMPLEMENTATIONUID )) |
|
165 || (TUid::Uid( refContactUid ) == TUid::Uid( 0x20007B6D ) )) |
|
166 { |
|
167 iServiceId = services[i]; |
|
168 break; |
|
169 } |
|
170 } |
|
171 CleanupStack::PopAndDestroy( &services ); |
|
172 |
|
173 } |
|
174 |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CIMCVUiEngine_TestSendMessage::CreateConnectionL |
|
178 // Simple printing to UI test. |
|
179 // ----------------------------------------------------------------------------- |
|
180 void CIMCVUiEngine_TestSendMessage::CreateConnectionL() |
|
181 { |
|
182 // TODO : allready loggedin in local mode enable when login to n/w |
|
183 //if(!iEngine->IsLoggedIn() ) |
|
184 // { |
|
185 // iEngine->CreateContextL(); |
|
186 // } |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CIMCVUiEngine_TestSendMessage::ReleaseConnectionL |
|
191 // Simple printing to UI test. |
|
192 // ----------------------------------------------------------------------------- |
|
193 void CIMCVUiEngine_TestSendMessage::ReleaseConnectionL() |
|
194 { |
|
195 if(iEngine->IsLoggedIn() ) |
|
196 { |
|
197 iEngine->ReleaseConnectionL(); |
|
198 } |
|
199 // iEngine->DeleteContextL(); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // Cimcvuiengine_test::SendTextMessageL |
|
204 // Simple printing to UI test. |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TInt CIMCVUiEngine_TestSendMessage::SendTextMessageL() |
|
208 { |
|
209 _LIT(KSomeStr,"hello"); //String to be sent |
|
210 |
|
211 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
212 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
213 |
|
214 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
215 |
|
216 if ( !iWait.IsStarted() ) |
|
217 { |
|
218 iWait.Start(); |
|
219 } |
|
220 |
|
221 MIMCVEngineMessageCreator::SMessageData data = |
|
222 { |
|
223 KMessageDataVersion, |
|
224 KOwnUser, |
|
225 KRecipientID, |
|
226 KSomeStr, |
|
227 MIMCVEngineMessage::EContentText, |
|
228 MIMCVEngineMessage::EMessageSent |
|
229 }; |
|
230 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
231 write.AppendL(message ); |
|
232 iEngine->MessageHandler().SendMessageL( *message ); |
|
233 |
|
234 if ( !iWait.IsStarted() ) |
|
235 { |
|
236 iWait.Start(); |
|
237 } |
|
238 |
|
239 return iResult; |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // Cimcvuiengine_test::SendNullMessageL |
|
244 // Simple printing to UI test. |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 TInt CIMCVUiEngine_TestSendMessage::SendNullMessageL() |
|
248 { |
|
249 _LIT(KSomeStr,""); //String to be sent |
|
250 |
|
251 |
|
252 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
253 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID); |
|
254 |
|
255 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
256 |
|
257 if ( !iWait.IsStarted() ) |
|
258 { |
|
259 iWait.Start(); |
|
260 } |
|
261 |
|
262 MIMCVEngineMessageCreator::SMessageData data = |
|
263 { |
|
264 KMessageDataVersion, |
|
265 KOwnUser, |
|
266 KRecipientID, |
|
267 KSomeStr, |
|
268 MIMCVEngineMessage::EContentText, |
|
269 MIMCVEngineMessage::EMessageSent |
|
270 }; |
|
271 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
272 write.AppendL(message ); |
|
273 iEngine->MessageHandler().SendMessageL( *message ); |
|
274 |
|
275 if ( !iWait.IsStarted() ) |
|
276 { |
|
277 iWait.Start(); |
|
278 } |
|
279 |
|
280 return iResult; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // Cimcvuiengine_test::StartNewConvesationL |
|
285 // Simple printing to UI test. |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 TInt CIMCVUiEngine_TestSendMessage::StartNewConvesationL() |
|
289 { |
|
290 |
|
291 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
292 if ( !iWait.IsStarted() ) |
|
293 { |
|
294 iWait.Start(); |
|
295 } |
|
296 return iResult; |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // Cimcvuiengine_test::CloseConvesationL |
|
301 // Simple printing to UI test. |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 TInt CIMCVUiEngine_TestSendMessage::CloseConvesationL() |
|
305 { |
|
306 |
|
307 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
308 if ( !iWait.IsStarted() ) |
|
309 { |
|
310 iWait.Start(); |
|
311 } |
|
312 iEngine->MessageHandler().CloseConversationL( KRecipientID ); |
|
313 |
|
314 return iResult; |
|
315 } |
|
316 // ----------------------------------------------------------------------------- |
|
317 // Cimcvuiengine_test::SendSplCharMessageL |
|
318 // Simple printing to UI test. |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 TInt CIMCVUiEngine_TestSendMessage::SendSplCharMessageL() |
|
322 { |
|
323 _LIT(KSomeSplStr,"@&!`$?#"); //String to be sent |
|
324 |
|
325 |
|
326 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
327 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
328 |
|
329 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
330 |
|
331 if ( !iWait.IsStarted() ) |
|
332 { |
|
333 iWait.Start(); |
|
334 } |
|
335 |
|
336 MIMCVEngineMessageCreator::SMessageData data = |
|
337 { |
|
338 KMessageDataVersion, |
|
339 KOwnUser, |
|
340 KRecipientID, |
|
341 KSomeSplStr, |
|
342 MIMCVEngineMessage::EContentText, |
|
343 MIMCVEngineMessage::EMessageSent |
|
344 }; |
|
345 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
346 |
|
347 write.AppendL(message ); |
|
348 |
|
349 iEngine->MessageHandler().SendMessageL( *message ); |
|
350 |
|
351 if ( !iWait.IsStarted() ) |
|
352 { |
|
353 iWait.Start(); |
|
354 } |
|
355 |
|
356 return iResult; |
|
357 } |
|
358 // ----------------------------------------------------------------------------- |
|
359 // Cimcvuiengine_test::SendCosMessageL |
|
360 // Simple printing to UI test. |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 TInt CIMCVUiEngine_TestSendMessage::SendCosMessageL() |
|
364 { |
|
365 _LIT(KSomeSplStr,"asdscmdsdsvndv dsvndsfnv dfkdsfkd vkdsfvkdsj dsfdsjfkdsjf dsfjkdsjfkds dskfjdskfjdsk dfjkdsjfds dsfkdsjfkds dsfkdmfkds safdsajhf asfsajfnha adsfjndajsnhfd dsafnajdsfnh adsfjdajf ajfajfnhj fajadsjfa asasjfjafja afnajf asjfjdsaf"); //String to be sent |
|
366 |
|
367 |
|
368 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
369 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
370 |
|
371 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
372 |
|
373 if ( !iWait.IsStarted() ) |
|
374 { |
|
375 iWait.Start(); |
|
376 } |
|
377 |
|
378 MIMCVEngineMessageCreator::SMessageData data = |
|
379 { |
|
380 KMessageDataVersion, |
|
381 KOwnUser, |
|
382 KRecipientID, |
|
383 KSomeSplStr, |
|
384 MIMCVEngineMessage::EContentText, |
|
385 MIMCVEngineMessage::EMessageSent |
|
386 }; |
|
387 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
388 |
|
389 write.AppendL(message ); |
|
390 |
|
391 iEngine->MessageHandler().SendMessageL( *message ); |
|
392 |
|
393 if ( !iWait.IsStarted() ) |
|
394 { |
|
395 iWait.Start(); |
|
396 } |
|
397 |
|
398 return iResult; |
|
399 } |
|
400 // ----------------------------------------------------------------------------- |
|
401 // Cimcvuiengine_test::DeactivateConvesationL |
|
402 // Simple printing to UI test. |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 TInt CIMCVUiEngine_TestSendMessage::DeactivateConvesationL() |
|
406 { |
|
407 |
|
408 |
|
409 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
410 |
|
411 if ( !iWait.IsStarted() ) |
|
412 { |
|
413 iWait.Start(); |
|
414 } |
|
415 iEngine->MessageHandler().DeactivateConversationL(); |
|
416 |
|
417 return iResult; |
|
418 } |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // Cimcvuiengine_test::SendToInvaliedRecipientL |
|
422 // Simple printing to UI test. |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 TInt CIMCVUiEngine_TestSendMessage::SendToInvaliedRecipientL() |
|
426 { |
|
427 _LIT(KSomeSplStr,"Invalied Recipient"); //String to be sent |
|
428 |
|
429 |
|
430 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
431 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
432 |
|
433 iEngine->MessageHandler().StartNewConversationL( KInvalidRecipientID ); |
|
434 |
|
435 if ( !iWait.IsStarted() ) |
|
436 { |
|
437 iWait.Start(); |
|
438 } |
|
439 |
|
440 MIMCVEngineMessageCreator::SMessageData data = |
|
441 { |
|
442 KMessageDataVersion, |
|
443 KOwnUser, |
|
444 KInvalidRecipientID, |
|
445 KSomeSplStr, |
|
446 MIMCVEngineMessage::EContentText, |
|
447 MIMCVEngineMessage::EMessageSent |
|
448 }; |
|
449 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
450 |
|
451 write.AppendL(message ); |
|
452 |
|
453 iEngine->MessageHandler().SendMessageL( *message ); |
|
454 |
|
455 if ( !iWait.IsStarted() ) |
|
456 { |
|
457 iWait.Start(); |
|
458 } |
|
459 if(iResult == KErrArgument ) |
|
460 { |
|
461 iResult = KErrNone; |
|
462 } |
|
463 return iResult; |
|
464 } |
|
465 // ----------------------------------------------------------------------------- |
|
466 // Cimcvuiengine_test::TestRecievedMessageL |
|
467 // Simple printing to UI test. |
|
468 // ----------------------------------------------------------------------------- |
|
469 // |
|
470 TInt CIMCVUiEngine_TestSendMessage::TestMultipleSendMessageL() |
|
471 { |
|
472 _LIT(KSomeSplStr1,"this is recieved message 1"); //String to be sent |
|
473 _LIT(KSomeSplStr2,"this is recieved message 2"); //String to be sent |
|
474 _LIT(KSomeSplStr3,"this is recieved message 3"); //String to be sent |
|
475 |
|
476 |
|
477 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
478 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
479 |
|
480 |
|
481 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
482 |
|
483 if ( !iWait.IsStarted() ) |
|
484 { |
|
485 iWait.Start(); |
|
486 } |
|
487 |
|
488 MIMCVEngineMessageCreator::SMessageData data1 = |
|
489 { |
|
490 KMessageDataVersion, |
|
491 KOwnUser, |
|
492 KRecipientID, |
|
493 KSomeSplStr1, |
|
494 MIMCVEngineMessage::EContentText, |
|
495 MIMCVEngineMessage::EMessageSent |
|
496 }; |
|
497 MIMCVEngineMessage* message1 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data1 ); |
|
498 write.AppendL(message1); |
|
499 iEngine->MessageHandler().SendMessageL( *message1 ); |
|
500 |
|
501 if ( !iWait.IsStarted() ) |
|
502 { |
|
503 iWait.Start(); |
|
504 } |
|
505 |
|
506 MIMCVEngineMessageCreator::SMessageData data2 = |
|
507 { |
|
508 KMessageDataVersion, |
|
509 KOwnUser, |
|
510 KRecipientID, |
|
511 KSomeSplStr2, |
|
512 MIMCVEngineMessage::EContentText, |
|
513 MIMCVEngineMessage::EMessageSent |
|
514 }; |
|
515 MIMCVEngineMessage* message2 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data2 ); |
|
516 write.AppendL(message2); |
|
517 iEngine->MessageHandler().SendMessageL( *message2 ); |
|
518 |
|
519 if ( !iWait.IsStarted() ) |
|
520 { |
|
521 iWait.Start(); |
|
522 } |
|
523 |
|
524 MIMCVEngineMessageCreator::SMessageData data3 = |
|
525 { |
|
526 KMessageDataVersion, |
|
527 KOwnUser, |
|
528 KInvalidRecipientID, |
|
529 KSomeSplStr3, |
|
530 MIMCVEngineMessage::EContentText, |
|
531 MIMCVEngineMessage::EMessageSent |
|
532 }; |
|
533 MIMCVEngineMessage* message3 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data3 ); |
|
534 write.AppendL(message3); |
|
535 iEngine->MessageHandler().SendMessageL( *message3 ); |
|
536 |
|
537 if ( !iWait.IsStarted() ) |
|
538 { |
|
539 iWait.Start(); |
|
540 } |
|
541 |
|
542 return iResult; |
|
543 } |
|
544 // ----------------------------------------------------------------------------- |
|
545 // Cimcvuiengine_test::TestSendRecieveMsgL |
|
546 // Simple printing to UI test. |
|
547 // ----------------------------------------------------------------------------- |
|
548 // |
|
549 TInt CIMCVUiEngine_TestSendMessage::TestSendRecieveMsgL() |
|
550 { |
|
551 |
|
552 _LIT(KSomeSplStr1,"this is send recieved message 1"); //String to be sent |
|
553 _LIT(KSomeSplStr2,"this is send recieved message 2"); //String to be sent |
|
554 |
|
555 |
|
556 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
557 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
558 |
|
559 |
|
560 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
561 |
|
562 if ( !iWait.IsStarted() ) |
|
563 { |
|
564 iWait.Start(); |
|
565 } |
|
566 |
|
567 MIMCVEngineMessageCreator::SMessageData data1 = |
|
568 { |
|
569 KMessageDataVersion, |
|
570 KOwnUser, |
|
571 KRecipientID, |
|
572 KSomeSplStr1, |
|
573 MIMCVEngineMessage::EContentText, |
|
574 MIMCVEngineMessage::EMessageSent |
|
575 }; |
|
576 MIMCVEngineMessage* message1 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data1 ); |
|
577 write.AppendL(message1 ); |
|
578 iEngine->MessageHandler().SendMessageL( *message1 ); |
|
579 |
|
580 if ( !iWait.IsStarted() ) |
|
581 { |
|
582 iWait.Start(); |
|
583 } |
|
584 |
|
585 MIMCVEngineMessageCreator::SMessageData data2 = |
|
586 { |
|
587 KMessageDataVersion, |
|
588 KOwnUser, |
|
589 KRecipientID, |
|
590 KSomeSplStr2, |
|
591 MIMCVEngineMessage::EContentText, |
|
592 MIMCVEngineMessage::EMessageSent |
|
593 }; |
|
594 MIMCVEngineMessage* message2 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data2 ); |
|
595 |
|
596 write.AppendL(message2 ); |
|
597 iEngine->MessageHandler().SendMessageL( *message2 ); |
|
598 |
|
599 if ( !iWait.IsStarted() ) |
|
600 { |
|
601 iWait.Start(); |
|
602 } |
|
603 |
|
604 iEngine->MessageHandler().DeactivateConversationL(); |
|
605 |
|
606 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
607 |
|
608 if ( !iWait.IsStarted() ) |
|
609 { |
|
610 iWait.Start(); |
|
611 } |
|
612 |
|
613 return iResult; |
|
614 } |
|
615 // ----------------------------------------------------------------------------- |
|
616 // Cimcvuiengine_test::TestSendFetchSendMsgL |
|
617 // Simple printing to UI test. |
|
618 // ----------------------------------------------------------------------------- |
|
619 // |
|
620 TInt CIMCVUiEngine_TestSendMessage::TestSendFetchSendMsgL() |
|
621 { |
|
622 _LIT(KSomeSplStr1,"this is send recieved message 1"); //String to be sent |
|
623 _LIT(KSomeSplStr2,"this is send recieved message 2"); //String to be sent |
|
624 _LIT(KSomeSplStr3,"this is send recieved message 3 after fetched im from cache"); //String to be sent |
|
625 |
|
626 |
|
627 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
628 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
629 |
|
630 |
|
631 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
632 |
|
633 if ( !iWait.IsStarted() ) |
|
634 { |
|
635 iWait.Start(); |
|
636 } |
|
637 |
|
638 MIMCVEngineMessageCreator::SMessageData data1 = |
|
639 { |
|
640 KMessageDataVersion, |
|
641 KOwnUser, |
|
642 KRecipientID, |
|
643 KSomeSplStr1, |
|
644 MIMCVEngineMessage::EContentText, |
|
645 MIMCVEngineMessage::EMessageSent |
|
646 }; |
|
647 MIMCVEngineMessage* message1 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data1 ); |
|
648 write.AppendL(message1); |
|
649 iEngine->MessageHandler().SendMessageL( *message1 ); |
|
650 |
|
651 if ( !iWait.IsStarted() ) |
|
652 { |
|
653 iWait.Start(); |
|
654 } |
|
655 |
|
656 MIMCVEngineMessageCreator::SMessageData data2 = |
|
657 { |
|
658 KMessageDataVersion, |
|
659 KOwnUser, |
|
660 KRecipientID, |
|
661 KSomeSplStr2, |
|
662 MIMCVEngineMessage::EContentText, |
|
663 MIMCVEngineMessage::EMessageSent |
|
664 }; |
|
665 MIMCVEngineMessage* message2 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data2 ); |
|
666 write.AppendL(message2); |
|
667 iEngine->MessageHandler().SendMessageL( *message2 ); |
|
668 |
|
669 if ( !iWait.IsStarted() ) |
|
670 { |
|
671 iWait.Start(); |
|
672 } |
|
673 |
|
674 iEngine->MessageHandler().DeactivateConversationL(); |
|
675 |
|
676 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
677 |
|
678 if ( !iWait.IsStarted() ) |
|
679 { |
|
680 iWait.Start(); |
|
681 } |
|
682 |
|
683 MIMCVEngineMessageCreator::SMessageData data3 = |
|
684 { |
|
685 KMessageDataVersion, |
|
686 KOwnUser, |
|
687 KRecipientID, |
|
688 KSomeSplStr3, |
|
689 MIMCVEngineMessage::EContentText, |
|
690 MIMCVEngineMessage::EMessageSent |
|
691 }; |
|
692 MIMCVEngineMessage* message3 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data3 ); |
|
693 write.AppendL(message3); |
|
694 iEngine->MessageHandler().SendMessageL( *message3 ); |
|
695 |
|
696 if ( !iWait.IsStarted() ) |
|
697 { |
|
698 iWait.Start(); |
|
699 } |
|
700 return iResult; |
|
701 } |
|
702 |
|
703 // ----------------------------------------------------------------------------- |
|
704 // Cimcvuiengine_test::PrintTest |
|
705 // Simple printing to UI test. |
|
706 // ----------------------------------------------------------------------------- |
|
707 // |
|
708 TInt CIMCVUiEngine_TestSendMessage::GetResult() const |
|
709 { |
|
710 return iResult; |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // Cimcvuiengine_test::HandleOperationCompletdL |
|
715 // Simple printing to UI test. |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 void CIMCVUiEngine_TestSendMessage::HandleOperationCompletdL( TInt aserviceId, MIMCVEngineMessage::TMessagerType aType , TInt aResult ) |
|
719 { |
|
720 iResult = aResult; |
|
721 if ( iWait.IsStarted() ) |
|
722 { |
|
723 iWait.AsyncStop(); |
|
724 } |
|
725 } |
|
726 // ----------------------------------------------------------------------------- |
|
727 // Cimcvuiengine_test::TestConnectionTerminationL |
|
728 // Simple printing to UI test. |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 TInt CIMCVUiEngine_TestSendMessage::TestConnectionTerminationL() |
|
732 { |
|
733 return KErrNone; |
|
734 } |
|
735 |
|
736 // ----------------------------------------------------------------------------- |
|
737 // CIMCVUiEngine_TestSendMessage::HandleConnectionTerminatedL |
|
738 // Simple printing to UI test. |
|
739 // ----------------------------------------------------------------------------- |
|
740 // |
|
741 void CIMCVUiEngine_TestSendMessage::HandleConnectionEventL(TInt aServiceId, TIMCVConnectionState aState, TInt aReason ) |
|
742 { |
|
743 iResult = aReason; |
|
744 if ( iWait.IsStarted() ) |
|
745 { |
|
746 iWait.AsyncStop(); |
|
747 } |
|
748 } |
|
749 |
|
750 // ----------------------------------------------------------------------------- |
|
751 // Cimcvuiengine_test::TestLoginStateL |
|
752 // Example test method function.TestLoginStateL |
|
753 // (other items were commented in a header). |
|
754 // ----------------------------------------------------------------------------- |
|
755 // |
|
756 TInt CIMCVUiEngine_TestSendMessage::TestLoginStateL() |
|
757 { |
|
758 |
|
759 if(iEngine->IsLoggedIn() ) |
|
760 { |
|
761 return KErrNone; |
|
762 } |
|
763 return KErrServerTerminated ; |
|
764 } |
|
765 |
|
766 // ----------------------------------------------------------------------------- |
|
767 // CIMCVUiEngine_TestSendMessage::TestLoginUserIdL |
|
768 // Example test method function. |
|
769 // (other items were commented in a header). |
|
770 // ----------------------------------------------------------------------------- |
|
771 // |
|
772 TInt CIMCVUiEngine_TestSendMessage::TestLoginUserIdL() |
|
773 { |
|
774 |
|
775 TPtrC userId = iEngine->GetLoggedInUserId(); |
|
776 |
|
777 if(! userId.Compare(KOwnUser ) ) |
|
778 { |
|
779 return KErrNone; |
|
780 } |
|
781 return KErrArgument ; |
|
782 } |
|
783 // ----------------------------------------------------------------------------- |
|
784 // CIMCVUiEngine_TestSendMessage::TestGetBrandIdL |
|
785 // Example test method function. |
|
786 // (other items were commented in a header). |
|
787 // ----------------------------------------------------------------------------- |
|
788 // |
|
789 TInt CIMCVUiEngine_TestSendMessage::TestGetBrandIdL() |
|
790 { |
|
791 TPtrC8 BrandId = iEngine->GetBrandId(); |
|
792 |
|
793 if( BrandId.Length() ) |
|
794 { |
|
795 return KErrNone; |
|
796 } |
|
797 return KErrArgument ; |
|
798 } |
|
799 // ----------------------------------------------------------------------------- |
|
800 // CIMCVUiEngine_TestSendMessage::TestGetLanguageIdL |
|
801 // Example test method function. |
|
802 // (other items were commented in a header). |
|
803 // ----------------------------------------------------------------------------- |
|
804 // |
|
805 TInt CIMCVUiEngine_TestSendMessage::TestGetLanguageIdL() |
|
806 { |
|
807 TInt languageId = iEngine->GetLanguageId(); |
|
808 |
|
809 if(KErrNone != languageId ) |
|
810 { |
|
811 return KErrNone; |
|
812 } |
|
813 return KErrArgument ; |
|
814 } |
|
815 // ----------------------------------------------------------------------------- |
|
816 // CIMCVUiEngine_TestSendMessage::TestChatInterfaceL |
|
817 // Example test method function. |
|
818 // (other items were commented in a header). |
|
819 // ----------------------------------------------------------------------------- |
|
820 // |
|
821 TInt CIMCVUiEngine_TestSendMessage::TestChatInterfaceL() |
|
822 { |
|
823 |
|
824 |
|
825 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
826 |
|
827 MIMCVEngineMessageReadInterface& read = chat.MessageReadInterfaceL(1, KRecipientID) ; |
|
828 read.Lock(ETrue); // to make sure ,valid ref |
|
829 |
|
830 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
831 write.Time();// to make sure ,valid ref |
|
832 |
|
833 return KErrNone; |
|
834 |
|
835 } |
|
836 |
|
837 // ----------------------------------------------------------------------------- |
|
838 // CIMCVUiEngine_TestSendMessage::TestMessageCoundL |
|
839 // Example test method function. |
|
840 // (other items were commented in a header). |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 TInt CIMCVUiEngine_TestSendMessage::TestMessageCoundL() |
|
844 { |
|
845 _LIT(KSomeStr,"hello"); //String to be sent |
|
846 |
|
847 |
|
848 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
849 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
850 |
|
851 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
852 |
|
853 |
|
854 |
|
855 if ( !iWait.IsStarted() ) |
|
856 { |
|
857 iWait.Start(); |
|
858 } |
|
859 |
|
860 MIMCVEngineMessageCreator::SMessageData data = |
|
861 { |
|
862 KMessageDataVersion, |
|
863 KOwnUser, |
|
864 KRecipientID, |
|
865 KSomeStr, |
|
866 MIMCVEngineMessage::EContentText, |
|
867 MIMCVEngineMessage::EMessageSent |
|
868 }; |
|
869 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
870 |
|
871 write.AppendL(message ); |
|
872 |
|
873 iEngine->MessageHandler().SendMessageL( *message ); |
|
874 |
|
875 if ( !iWait.IsStarted() ) |
|
876 { |
|
877 iWait.Start(); |
|
878 } |
|
879 |
|
880 MIMCVEngineMessageReadInterface& read = chat.MessageReadInterfaceL(1, KRecipientID) ; |
|
881 |
|
882 // in case of send this must be zero , except unread |
|
883 // this is the ReadOffset not the actaul message count |
|
884 TInt count = read.MessageCount(); |
|
885 |
|
886 if(count == 0 ) |
|
887 { |
|
888 return KErrNone; |
|
889 } |
|
890 |
|
891 return KErrNotFound; |
|
892 } |
|
893 |
|
894 // ----------------------------------------------------------------------------- |
|
895 // CIMCVUiEngine_TestSendMessage::TestMessageUnreadCoundL |
|
896 // Example test method function. |
|
897 // (other items were commented in a header). |
|
898 // ----------------------------------------------------------------------------- |
|
899 // |
|
900 TInt CIMCVUiEngine_TestSendMessage::TestMessageUnreadCoundL() |
|
901 { |
|
902 _LIT(KSomeStr,"hello"); //String to be sent |
|
903 |
|
904 |
|
905 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
906 |
|
907 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
908 |
|
909 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
910 |
|
911 if ( !iWait.IsStarted() ) |
|
912 { |
|
913 iWait.Start(); |
|
914 } |
|
915 |
|
916 MIMCVEngineMessageCreator::SMessageData data = |
|
917 { |
|
918 KMessageDataVersion, |
|
919 KOwnUser, |
|
920 KRecipientID, |
|
921 KSomeStr, |
|
922 MIMCVEngineMessage::EContentText, |
|
923 MIMCVEngineMessage::EMessageReceived |
|
924 }; |
|
925 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
926 |
|
927 write.AppendL(message ); |
|
928 |
|
929 iEngine->MessageHandler().SendMessageL( *message ); |
|
930 |
|
931 if ( !iWait.IsStarted() ) |
|
932 { |
|
933 iWait.Start(); |
|
934 } |
|
935 |
|
936 MIMCVEngineMessageReadInterface& read = chat.MessageReadInterfaceL(1, KRecipientID) ; |
|
937 |
|
938 TInt count = read.UnreadCount(MIMCVEngineMessageReadInterface::EUnreadAll); |
|
939 |
|
940 if(count == 1) |
|
941 { |
|
942 return KErrNone; |
|
943 } |
|
944 |
|
945 return KErrNotFound; |
|
946 |
|
947 } |
|
948 // ----------------------------------------------------------------------------- |
|
949 // CIMCVUiEngine_TestSendMessage::DeleteContextL |
|
950 // Example test method function. |
|
951 // (other items were commented in a header). |
|
952 // ----------------------------------------------------------------------------- |
|
953 // |
|
954 TInt CIMCVUiEngine_TestSendMessage::DeleteContextL() |
|
955 { |
|
956 //by default engine's context needs to be binded |
|
957 iEngine->CreateContextL() ; |
|
958 |
|
959 TRAPD(err, iEngine->DeleteContextL() ); |
|
960 |
|
961 return err; |
|
962 } |
|
963 |
|
964 // ----------------------------------------------------------------------------- |
|
965 // CIMCVUiEngine_TestSendMessage::CreateContextL |
|
966 // Example test method function. |
|
967 // (other items were commented in a header). |
|
968 // ----------------------------------------------------------------------------- |
|
969 // |
|
970 TInt CIMCVUiEngine_TestSendMessage::CreateContextL() |
|
971 { |
|
972 // by default presence must be EOffline |
|
973 TRAPD(err, iEngine->CreateContextL() ); |
|
974 |
|
975 return err; |
|
976 } |
|
977 |
|
978 // ----------------------------------------------------------------------------- |
|
979 // CIMCVUiEngine_TestSendMessage::TestSubscribePresenceL |
|
980 // Example test method function. |
|
981 // (other items were commented in a header). |
|
982 // ----------------------------------------------------------------------------- |
|
983 // |
|
984 TInt CIMCVUiEngine_TestSendMessage::TestSubscribePresenceL() |
|
985 { |
|
986 TRAPD(err, iEngine->MessageHandler().SubscribePresenceL(KRecipientID) ); |
|
987 return err; |
|
988 } |
|
989 |
|
990 // ----------------------------------------------------------------------------- |
|
991 // CIMCVUiEngine_TestSendMessage::TestGetPresenceStatusL |
|
992 // Example test method function. |
|
993 // (other items were commented in a header). |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 TInt CIMCVUiEngine_TestSendMessage::TestGetPresenceStatusL() |
|
997 { |
|
998 |
|
999 // by default presence must be EOffline |
|
1000 TIMCVOnlineStatus status = iEngine->MessageHandler().GetPresenceStatus(); |
|
1001 if(status == EOffline ) |
|
1002 { |
|
1003 return KErrNone; |
|
1004 } |
|
1005 |
|
1006 return KErrArgument; |
|
1007 |
|
1008 } |
|
1009 |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // CIMCVUiEngine_TestSendMessage::TestAppendInfoMessageL |
|
1012 // Example test method function. |
|
1013 // (other items were commented in a header). |
|
1014 // ----------------------------------------------------------------------------- |
|
1015 // |
|
1016 TInt CIMCVUiEngine_TestSendMessage::TestAppendInfoMessageL() |
|
1017 { |
|
1018 _LIT(KSomeStr,"hello this is information message "); //String to be sent |
|
1019 |
|
1020 |
|
1021 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
1022 |
|
1023 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
1024 |
|
1025 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
1026 |
|
1027 if ( !iWait.IsStarted() ) |
|
1028 { |
|
1029 iWait.Start(); |
|
1030 } |
|
1031 |
|
1032 MIMCVEngineMessageCreator::SMessageData data = |
|
1033 { |
|
1034 KMessageDataVersion, |
|
1035 KOwnUser, |
|
1036 KRecipientID, |
|
1037 KSomeStr, |
|
1038 MIMCVEngineMessage::EContentText, |
|
1039 MIMCVEngineMessage::EMessageOther |
|
1040 }; |
|
1041 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
1042 |
|
1043 write.AppendL(message ); |
|
1044 |
|
1045 TRAPD(err, iEngine->MessageHandler().AppendToCacheL(KRecipientID, message->Text() ) ); |
|
1046 |
|
1047 return err; |
|
1048 } |
|
1049 // ----------------------------------------------------------------------------- |
|
1050 // CIMCVUiEngine_TestSendMessage::HandlePresenceChangedL |
|
1051 // Example test method function. |
|
1052 // (other items were commented in a header). |
|
1053 // ----------------------------------------------------------------------------- |
|
1054 // |
|
1055 void CIMCVUiEngine_TestSendMessage::HandlePresenceChangedL(TInt aServiceId, const TDesC& /*aBuddyId*/ ) |
|
1056 { |
|
1057 // do nothings |
|
1058 } |
|
1059 |
|
1060 |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // CIMCVUiEngine_TestSendMessage::TestCCHHandlerL |
|
1063 // Example test method function. |
|
1064 // (other items were commented in a header). |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // |
|
1067 TInt CIMCVUiEngine_TestSendMessage::TestCCHHandlerL() |
|
1068 { |
|
1069 TInt error = KErrNone; |
|
1070 |
|
1071 MIMCVEngineCchHandler& cchHandler = iEngine->CCHHandler(); |
|
1072 |
|
1073 if ( cchHandler.IsServiceLoggedIn() ) |
|
1074 { |
|
1075 error = KErrArgument ; |
|
1076 } |
|
1077 HBufC* user = cchHandler.GetUserIdL(); |
|
1078 |
|
1079 if( user ) |
|
1080 { |
|
1081 delete user; |
|
1082 error = KErrNone ; |
|
1083 } |
|
1084 else |
|
1085 { |
|
1086 error = KErrArgument ; |
|
1087 } |
|
1088 return error; |
|
1089 } |
|
1090 |
|
1091 // ----------------------------------------------------------------------------- |
|
1092 // CIMCVUiEngine_TestSendMessage::ReadyForShutdownTestL |
|
1093 // Example test method function. |
|
1094 // (other items were commented in a header). |
|
1095 // ----------------------------------------------------------------------------- |
|
1096 // |
|
1097 TInt CIMCVUiEngine_TestSendMessage::ReadyForShutdownTestL() |
|
1098 { |
|
1099 if( !iEngine->ReadyForShutdown() ) |
|
1100 { |
|
1101 // loggedin |
|
1102 return KErrNone; |
|
1103 } |
|
1104 return KErrArgument; |
|
1105 } |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // CIMCVUiEngine_TestSendMessage::ServiceNameTestL |
|
1108 // Example test method function. |
|
1109 // (other items were commented in a header). |
|
1110 // ----------------------------------------------------------------------------- |
|
1111 // |
|
1112 TInt CIMCVUiEngine_TestSendMessage::ServiceNameTestL() |
|
1113 { |
|
1114 if (iEngine->ServiceName().Length() ) |
|
1115 { |
|
1116 return KErrNone ; |
|
1117 } |
|
1118 return KErrArgument; |
|
1119 } |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // CIMCVUiEngine_TestSendMessage::OpenChatsTestL |
|
1122 // Example test method function. |
|
1123 // (other items were commented in a header). |
|
1124 // ----------------------------------------------------------------------------- |
|
1125 // |
|
1126 TInt CIMCVUiEngine_TestSendMessage::OpenChatsTestL() |
|
1127 { |
|
1128 if ( &iEngine->OpenChats() ) |
|
1129 { |
|
1130 MIMCVEngineOpenChats& openchat = iEngine->OpenChats() ; |
|
1131 if( !openchat.Count()) |
|
1132 { |
|
1133 return KErrNone ; |
|
1134 } |
|
1135 } |
|
1136 return KErrArgument; |
|
1137 } |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // CIMCVUiEngine_TestSendMessage::GetServiceIdTestL |
|
1140 // Example test method function. |
|
1141 // (other items were commented in a header). |
|
1142 // ----------------------------------------------------------------------------- |
|
1143 // |
|
1144 TInt CIMCVUiEngine_TestSendMessage::GetServiceIdTestL() |
|
1145 { |
|
1146 if ( iEngine->GetServiceId() > 0 ) |
|
1147 { |
|
1148 return KErrNone ; |
|
1149 } |
|
1150 return KErrArgument; |
|
1151 } |
|
1152 |
|
1153 |
|
1154 |
|
1155 // ----------------------------------------------------------------------------- |
|
1156 // CIMCVUiEngine_TestSendMessage::TestClosAllContainerL |
|
1157 // Example test method function. |
|
1158 // (other items were commented in a header). |
|
1159 // ----------------------------------------------------------------------------- |
|
1160 // |
|
1161 TInt CIMCVUiEngine_TestSendMessage::TestClosAllContainerL() |
|
1162 { |
|
1163 _LIT(KSomeStr,"hello"); //String to be sent |
|
1164 |
|
1165 |
|
1166 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
1167 |
|
1168 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
1169 |
|
1170 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
1171 |
|
1172 if ( !iWait.IsStarted() ) |
|
1173 { |
|
1174 iWait.Start(); |
|
1175 } |
|
1176 |
|
1177 MIMCVEngineMessageCreator::SMessageData data = |
|
1178 { |
|
1179 KMessageDataVersion, |
|
1180 KOwnUser, |
|
1181 KRecipientID, |
|
1182 KSomeStr, |
|
1183 MIMCVEngineMessage::EContentText, |
|
1184 MIMCVEngineMessage::EMessageReceived |
|
1185 }; |
|
1186 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
1187 |
|
1188 write.AppendL(message ); |
|
1189 |
|
1190 iEngine->MessageHandler().SendMessageL( *message ); |
|
1191 |
|
1192 if ( !iWait.IsStarted() ) |
|
1193 { |
|
1194 iWait.Start(); |
|
1195 } |
|
1196 |
|
1197 if( chat.ChatCount() ) |
|
1198 { |
|
1199 chat.CloseAllContainers(); |
|
1200 |
|
1201 } |
|
1202 if( !chat.ChatCount() ) |
|
1203 { |
|
1204 return KErrNone; |
|
1205 |
|
1206 } |
|
1207 |
|
1208 return KErrArgument; |
|
1209 |
|
1210 |
|
1211 } |
|
1212 |
|
1213 |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // CIMCVUiEngine_TestSendMessage::TestDeleteChatL |
|
1216 // Example test method function. |
|
1217 // (other items were commented in a header). |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 // |
|
1220 TInt CIMCVUiEngine_TestSendMessage::TestDeleteChatL() |
|
1221 { |
|
1222 _LIT(KSomeStr,"hello"); //String to be sent |
|
1223 |
|
1224 |
|
1225 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
1226 |
|
1227 iEngine->MessageHandler().StartNewConversationL( KRecipientID ); |
|
1228 |
|
1229 MIMCVEngineMessageWriteInterface& write = chat.MessageWriteInterfaceL(1, KRecipientID ); |
|
1230 |
|
1231 if ( !iWait.IsStarted() ) |
|
1232 { |
|
1233 iWait.Start(); |
|
1234 } |
|
1235 |
|
1236 MIMCVEngineMessageCreator::SMessageData data = |
|
1237 { |
|
1238 KMessageDataVersion, |
|
1239 KOwnUser, |
|
1240 KRecipientID, |
|
1241 KSomeStr, |
|
1242 MIMCVEngineMessage::EContentText, |
|
1243 MIMCVEngineMessage::EMessageReceived |
|
1244 }; |
|
1245 MIMCVEngineMessage* message = iEngine->MessageHandler().MessageCreator().CreateMessageL( data ); |
|
1246 |
|
1247 write.AppendL(message ); |
|
1248 |
|
1249 iEngine->MessageHandler().SendMessageL( *message ); |
|
1250 |
|
1251 if ( !iWait.IsStarted() ) |
|
1252 { |
|
1253 iWait.Start(); |
|
1254 } |
|
1255 |
|
1256 MIMCVEngineMessageWriteInterface& write2 = chat.MessageWriteInterfaceL(1, KRecipientID2 ); |
|
1257 |
|
1258 iEngine->MessageHandler().StartNewConversationL( KRecipientID2 ); |
|
1259 |
|
1260 if ( !iWait.IsStarted() ) |
|
1261 { |
|
1262 iWait.Start(); |
|
1263 } |
|
1264 |
|
1265 MIMCVEngineMessageCreator::SMessageData data1 = |
|
1266 { |
|
1267 KMessageDataVersion, |
|
1268 KOwnUser, |
|
1269 KRecipientID2, |
|
1270 KSomeStr, |
|
1271 MIMCVEngineMessage::EContentText, |
|
1272 MIMCVEngineMessage::EMessageReceived |
|
1273 }; |
|
1274 MIMCVEngineMessage* message1 = iEngine->MessageHandler().MessageCreator().CreateMessageL( data1 ); |
|
1275 |
|
1276 write2.AppendL(message1 ); |
|
1277 |
|
1278 iEngine->MessageHandler().SendMessageL( *message1 ); |
|
1279 |
|
1280 if ( !iWait.IsStarted() ) |
|
1281 { |
|
1282 iWait.Start(); |
|
1283 } |
|
1284 |
|
1285 if( chat.ChatCount() == 2 ) |
|
1286 { |
|
1287 chat.DeleteChatL( 1, KRecipientID2 ); |
|
1288 } |
|
1289 if( chat.ChatCount() == 1) |
|
1290 { |
|
1291 return KErrNone; |
|
1292 |
|
1293 } |
|
1294 |
|
1295 return KErrArgument; |
|
1296 |
|
1297 |
|
1298 } |
|
1299 // ----------------------------------------------------------------------------- |
|
1300 // CIMCVUiEngine_TestSendMessage::TestEditorMessageL |
|
1301 // Example test method function. |
|
1302 // (other items were commented in a header). |
|
1303 // ----------------------------------------------------------------------------- |
|
1304 // |
|
1305 TInt CIMCVUiEngine_TestSendMessage::TestEditorMessageL() |
|
1306 { |
|
1307 |
|
1308 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
1309 |
|
1310 MIMCVEngineMessageReadInterface& read = chat.MessageReadInterfaceL(1, KRecipientID) ; |
|
1311 read.Lock(ETrue); // to make sure ,valid ref |
|
1312 read.StoreEditerMessageL(_L("Test Message")); |
|
1313 TBuf<15> receiveData; |
|
1314 receiveData = read.GetEditerMessage(); |
|
1315 |
|
1316 if(0 == receiveData.Compare(_L("Test Message"))) |
|
1317 return KErrNone; |
|
1318 |
|
1319 return KErrArgument; |
|
1320 } |
|
1321 |
|
1322 // ----------------------------------------------------------------------------- |
|
1323 // CIMCVUiEngine_TestSendMessage::TestEditorMessageL |
|
1324 // Example test method function. |
|
1325 // (other items were commented in a header). |
|
1326 // ----------------------------------------------------------------------------- |
|
1327 // |
|
1328 TInt CIMCVUiEngine_TestSendMessage::TestConvertPresCacheEnum() |
|
1329 { |
|
1330 TInt err; |
|
1331 MIMCVEngineMessageUtils* aMessageUtils = NULL; |
|
1332 MIMCVEngineChatInterface& chat = iEngine->ChatInterface(); |
|
1333 MIMCVEngineMessageCreator* messageCreator = CIMCVEngineMessageCreator::NewL(); |
|
1334 CIMCVEngineMessageHandler* handler = CIMCVEngineMessageHandler::NewL( chat, *messageCreator, NULL, 1 ,KNullDesC); |
|
1335 MPresenceBuddyInfo2::TAvailabilityValues value = MPresenceBuddyInfo2::EUnknownAvailability; |
|
1336 TIMCVOnlineStatus status; |
|
1337 |
|
1338 // the ConvertPresenceCacheEnums does not have the support for block and pending, |
|
1339 // hence should be added in the new test cases. |
|
1340 |
|
1341 /*TBuf<50> buf1(KBlockedState); |
|
1342 TPtrC Ptr1 (buf1); |
|
1343 TIMCVOnlineStatus status = handler->ConvertPresenceCacheEnums(value, Ptr1); |
|
1344 if(EUnknown != status) |
|
1345 { |
|
1346 return KErrNotFound; |
|
1347 } |
|
1348 */ |
|
1349 value = MPresenceBuddyInfo2::EUnknownAvailability; |
|
1350 TBuf<50> buf2(KInvisibleState); |
|
1351 TPtrC Ptr2 (buf2); |
|
1352 status = handler->ConvertPresenceCacheEnums(value, Ptr2); |
|
1353 if(EInvisible != status) |
|
1354 { |
|
1355 return KErrNotFound; |
|
1356 } |
|
1357 |
|
1358 value = MPresenceBuddyInfo2::EBusy; |
|
1359 TBuf<50> buf3(KAwayState); |
|
1360 TPtrC Ptr3 (buf3); |
|
1361 status = handler->ConvertPresenceCacheEnums(value, Ptr3); |
|
1362 if(EAway != status) |
|
1363 { |
|
1364 return KErrNotFound; |
|
1365 } |
|
1366 |
|
1367 value = MPresenceBuddyInfo2::EBusy; |
|
1368 TBuf<50> buf4(KOnPhoneState); |
|
1369 TPtrC Ptr4 (buf4); |
|
1370 status = handler->ConvertPresenceCacheEnums(value, Ptr4); |
|
1371 if(EOnPhone != status) |
|
1372 { |
|
1373 return KErrNotFound; |
|
1374 } |
|
1375 |
|
1376 value = MPresenceBuddyInfo2::EBusy; |
|
1377 TBuf<50> buf5(KDndState); |
|
1378 TPtrC Ptr5 (buf5); |
|
1379 status = handler->ConvertPresenceCacheEnums(value, Ptr5); |
|
1380 if(EDoNotDisturb != status) |
|
1381 { |
|
1382 return KErrNotFound; |
|
1383 } |
|
1384 |
|
1385 /*value = MPresenceBuddyInfo2::EUnknownAvailability; |
|
1386 TBuf<50> buf6(KPendingRequestState); |
|
1387 TPtrC Ptr6 (buf6); |
|
1388 status = handler->ConvertPresenceCacheEnums(value, Ptr6); |
|
1389 if(EUnknown != status) |
|
1390 { |
|
1391 return KErrNotFound; |
|
1392 } |
|
1393 */ |
|
1394 value = MPresenceBuddyInfo2::EAvailable; |
|
1395 _LIT(KAnyMsg,"Any msg"); |
|
1396 TBuf<50> buf7(KAnyMsg); |
|
1397 TPtrC Ptr7 (buf7); |
|
1398 status = handler->ConvertPresenceCacheEnums(value, Ptr7); |
|
1399 if(EOnline != status) |
|
1400 { |
|
1401 return KErrNotFound; |
|
1402 } |
|
1403 |
|
1404 value = MPresenceBuddyInfo2::ENotAvailable; |
|
1405 status = handler->ConvertPresenceCacheEnums(value, Ptr7); |
|
1406 if(EOffline != status) |
|
1407 { |
|
1408 return KErrNotFound; |
|
1409 } |
|
1410 |
|
1411 value = MPresenceBuddyInfo2::EUnknownAvailability; |
|
1412 status = handler->ConvertPresenceCacheEnums(value, Ptr7); |
|
1413 if(EUnknown != status) |
|
1414 { |
|
1415 return KErrNotFound; |
|
1416 } |
|
1417 |
|
1418 return KErrNone; |
|
1419 } |
|
1420 |
|
1421 |
|
1422 // end of file |
|
1423 |
|