summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/unittest_cntpbapsupport/src/t_cntpbapsupport.cpp
blob: 64ff1adb1cb7ebfb6848f06a15fb00cb74c29a2a (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#include <e32std.h>
#include <e32test.h>
#include <s32file.h>
#include <s32mem.h>
#include <cntdef.h>
#include <cntdb.h>
#include <cntitem.h>
#include <cntfldst.h>
#include <vcard.h>

#include "t_cntpbapsupport.h"
#include "t_testdata.h"
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
#include "cntdb_internal.h"
#endif

_LIT(KTestName,"T_CntPBAPSupport");
// Configure database location
_LIT(KDbFileName,"C:T_CntPBAPSupport.cdb");
//Temporary Export file
_LIT(KTempExportFile,"c:\\TempExport.vcf");

RTest test( KTestName );

/**
Cleanup function
*/
void CleanUpResetAndDestroy(TAny* aArray)
	{
	if (aArray)
		{
		CArrayPtr<CContactItem>* array = (CArrayPtr<CContactItem>*)aArray;
		array->ResetAndDestroy();
		delete array;
		}
	}
	
/**
NewL	
*/
CCntPBAPSupport* CCntPBAPSupport::NewL()
	{
	CCntPBAPSupport* self = new(ELeave) CCntPBAPSupport();
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop();
	return self;
	} 
 
/**
Constructor
*/
CCntPBAPSupport::CCntPBAPSupport()
 	{
 	} 

/**
Destructor:deletes the temporary file created during test execution
*/	
CCntPBAPSupport::~CCntPBAPSupport()
 	{
	if (iSessionConnected)
		{
		iFsSession.Delete(KTempExportFile());
		iFsSession.Close();
		}
	delete iDb;
	TRAP_IGNORE(CContactDatabase::DeleteDatabaseL(KDbFileName));
 	delete iIdArray;
 	} 
 	
/**
ConstructL
*/
void CCntPBAPSupport::ConstructL()
 	{
 	User::LeaveIfError(iFsSession.Connect());
	iSessionConnected = ETrue;
	iDb = CContactDatabase::ReplaceL(KDbFileName);
	iIdArray = CContactIdArray::NewL();
	iAddIntraProperties = EFalse;
 	}
 	
/**
Enables or Disables export of Intra-Contact property 	
*/
void CCntPBAPSupport::SetIntraExport(TBool aState)
	{
	iAddIntraProperties = aState;
	}
	
/**
Creates stream from literal containing vCard and imports contacts.
Ids are stored for exporting the contacts later.
*/	
void CCntPBAPSupport::ImportContactsL(const TDesC8& aVCard)
	{
	RDesReadStream vcard(aVCard);
	CleanupClosePushL(vcard);
	CArrayPtr<CContactItem>* contactItems;
	TBool success = EFalse;
	contactItems = iDb->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl), vcard, success, CContactDatabase::ETTFormat);
	CleanupStack::PushL(TCleanupItem(CleanUpResetAndDestroy,contactItems));
	iIdArray->Reset();
	TContactItemId contactId;
	for(TInt loop = 0;loop < contactItems->Count();++loop)
		{
		contactId = (*contactItems)[loop]->Id();
		iIdArray->AddL(contactId);		
		}
	CleanupStack::PopAndDestroy(contactItems);
	CleanupStack::PopAndDestroy(&vcard);
	}

/**
Calls new contacts Export API to export contacts.
*/
void CCntPBAPSupport::ExportContactsL(TInt64 aFilter, TVCardVersion aVer, TBool aExportTel)
	{
	RFile outfile;
	outfile.Replace(iFsSession, KTempExportFile(), EFileWrite);
	CleanupClosePushL(outfile);
	RFileWriteStream writeStream(outfile);
	CleanupClosePushL(writeStream);
	
	TUid pluginUid;
	if(aVer == EPBAPVCard21 || aVer == EPBAPVCard30)
		{
		pluginUid.iUid = KUidPBAPVCardConvImpl;	
		}
	else
		{
		pluginUid.iUid = KUidVCardConvDefaultImpl;				
		}
	iDb->ExportSelectedContactsL(pluginUid, *iIdArray, writeStream, CContactDatabase::EDefault, aFilter, this, aVer, aExportTel);
	writeStream.CommitL();
	CleanupStack::PopAndDestroy(2);
	}


void CCntPBAPSupport::CompareExportsL(const TDesC8& aExpected)
    {
    
	RFile exportedFile;	
	TInt err = exportedFile.Open(iFsSession, KTempExportFile(), EFileRead);
	if (err != KErrNone)
		{
		ReportFileErrorL(err, KTempExportFile());	
		}
	CleanupClosePushL(exportedFile);
	RFileReadStream stream1(exportedFile);
	CleanupClosePushL(stream1);

	TBuf8<0x80> bufO;
	
	TInt line = 1;
	do {
		TRAP(err, stream1.ReadL(bufO, TChar(0xa)));
		if (err != KErrNone && err != KErrEof)
			{
			User::Leave(err);	
			}
        			
    	_LIT8(KPropREV,"REV:");
    	_LIT8(KPropUID,"UID:");
		TBufC8<4> first4char(bufO.Left(4));
		if(!first4char.Compare(KPropREV()) || !first4char.Compare(KPropUID()))
		    {
		    continue;
		    }
		
        if (KErrNotFound == aExpected.Find(bufO))
        	{
        	TBuf<256> info;
            info.Copy(bufO);
            TRefByValue<const TDesC> format(info);
            test.Printf(format);
            test (EFalse);
        	}
		++line;
		} while (err != KErrEof);
	CleanupStack::PopAndDestroy(2,&exportedFile);
    }

/**
Opens the exported file and compares it with expected vCard file passed as argument.
*/
void CCntPBAPSupport::CompareFilesL(RReadStream& aCompareStream)
	{
	RFile exportedFile;	
	TInt err = exportedFile.Open(iFsSession, KTempExportFile(), EFileRead);
	if (err != KErrNone)
		{
		ReportFileErrorL(err, KTempExportFile());	
		}
	CleanupClosePushL(exportedFile);
	RFileReadStream stream1(exportedFile);
	CleanupClosePushL(stream1);

	TBuf8<0x80> bufO,bufC;
	
	TInt line = 1;
	do {
		TRAP(err, stream1.ReadL(bufO, TChar(0xa)));
		if (err == KErrNone || err == KErrEof)
			{
			TRAP(err, aCompareStream.ReadL(bufC, TChar(0xa)));	
			}
		if (err != KErrNone && err != KErrEof)
			{
			User::Leave(err);	
			}
		test(CompareLines(bufO, bufC));
		++line;
		} while (err != KErrEof);
	CleanupStack::PopAndDestroy(2,&exportedFile);
	}
	
/**
Compares each line, REV and UID are ignored as they can be different
*/
TBool CCntPBAPSupport::CompareLines(const TDesC8& aLine1, const TDesC8& aLine2)
	{
	_LIT8(KPropREV,"REV:");
	_LIT8(KPropUID,"UID:");

	TBool ret =	!aLine1.Compare(aLine2);
	if (!ret)
		{
		TBufC8<4> first4char(aLine1.Left(4));
		if(!first4char.Compare(KPropREV()) || !first4char.Compare(KPropUID()))
			{
			return ETrue;
			}
		}
	return ret;
	}

/**
Reports any errors occured while opening a file.
*/
void CCntPBAPSupport::ReportFileErrorL(TInt aErr, const TDesC& aFileName)
	{
	if (aErr == KErrNotFound)
		{
		_LIT(KMissingFile,"\r\n** FILE NOT FOUND: %S\r\n\r\n");
		test.Printf(KMissingFile, &aFileName);
		}
	else if (aErr == KErrPathNotFound)
		{	//You will get this error if you have not exported the test data files.
		_LIT(KMissingPath,"\r\n** PATH NOT FOUND: %S\r\n\r\n");
		test.Printf(KMissingPath, &aFileName);
		}
	else
		{
		_LIT(KError,"Error %d opening file %S\r\n");
		test.Printf(KError, aErr, &aFileName);
		}
	__DEBUGGER();
	User::Leave(aErr);
	}
	
/**
Add intra contact properties when called by Cntmodel/Cntvcard, clients can use aContactId to 
collect any info about that contact and create a property for export.
All property parameters should be in form of name=value pair if exported as vCard3.0	
*/
void  CCntPBAPSupport::AddIntraContactPropertiesL(const TContactItemId& /*aContactId*/, CArrayPtr<CParserProperty>* aPropertyList)
	{
	_LIT8(KVersitIntraProp,"X-IRMC-CALL-DATETIME");
	_LIT8(KParam,"TYPE");
	_LIT8(KParamVal,"MISSED");

	if(iAddIntraProperties)
		{
	    CArrayPtr<CParserParam>* arrayOfParams = new(ELeave) CArrayPtrFlat<CParserParam>(5);
		CleanupStack::PushL(TCleanupItem(CleanUpResetAndDestroy, arrayOfParams));

		CParserParam* param = CParserParam::NewL(KParam, KParamVal);
		CleanupStack::PushL(param);
		arrayOfParams->AppendL(param);
		CleanupStack::Pop(param);

		TDateTime missedTime(2006,EOctober,10,10,30,0,0);
		TVersitDateTime* dateTime = new(ELeave)TVersitDateTime(missedTime, TVersitDateTime::EIsUTC);
		CleanupStack::PushL(dateTime);
		CParserPropertyValueDateTime* dateTimeValue = new(ELeave) CParserPropertyValueDateTime(dateTime);
		CleanupStack::Pop(dateTime);

		CleanupStack::PushL(dateTimeValue);
		CParserProperty* property = CParserGroupedProperty::NewL(*dateTimeValue, KVersitIntraProp, NULL, arrayOfParams);
		CleanupStack::Pop(dateTimeValue);
		CleanupStack::PushL(property);	
		aPropertyList->AppendL(property);
		CleanupStack::Pop(property);
		CleanupStack::Pop(arrayOfParams);
		}
	}

/**
@SYMPREQ 1375
@SYMTestType UT
@SYMTestPriority Critical
@SYMTestCaseDesc Export all supported fields mentioned in PBAP spec.

@SYMTestActions
1.Import contact item having all supported fields
2.Export contact as vCard2.1, include TEL export, no addition of Intra-Contact properties
3.Export contact as vCard30, include TEL export, no addition of Intra-Contact properties
4.Compare exported file with expected output.

@SYMTestExpectedResults For the above tests:
1.Only supported fields should be exported.
2.Export of CLASS,NICKNAME,CATEGORIES,PRODID,SORT-STRING,AGENT is not supported.
4.Comparison of expected vCard should pass.
5.No leaves or panics should occur

*/
void CCntPBAPSupport::TestExportOfAllSupportedFieldsL()
	{
	ImportContactsL(KAllSupportedFields());
	SetIntraExport(EFalse);
	TInt64 filter = 0; //All supported fields should be exported
	//Test for vCard2.1
	ExportContactsL(filter,EPBAPVCard21,ETrue);
	//RDesReadStream compareStream(KAllExpectedExport21());
	//CleanupClosePushL(compareStream);
	//CompareFilesL(compareStream);
	CompareExportsL(KAllExpectedExport21());
	test.Printf(_L("Expected export of PBAP supported fields for vCard2.1 verified\n"));
	//CleanupStack::PopAndDestroy(&compareStream);
	//Test for vCard3.0
	ExportContactsL(filter,EPBAPVCard30,ETrue);
	CompareExportsL(KAllExpectedExport30());
	//RDesReadStream compareStream2(KAllExpectedExport30());
	//CleanupClosePushL(compareStream2);
	//CompareFilesL(compareStream2);
	test.Printf(_L("Expected export of PBAP supported fields for vCard3.0 verified\n"));
	//CleanupStack::PopAndDestroy(&compareStream2);
	}
	
/**
@SYMPREQ 1375
@SYMTestType UT
@SYMTestPriority Critical
@SYMTestCaseDesc Tests export of the Mandatory properties,populated and empty(N,FN
@SYMTestCaseDesc and TEL).Export of TEL is required by PBAP but client has to specify it explictly.

@SYMTestActions
1.Contact item having all populated supported fields present in database.
2.Export contact as vCard2.1 when filter has not included any of the mandatory properties.
3.Export contact as vCard3.0 when filter has not included any of the mandatory properties.
4.Import vCard which is not having any mandatory properties.
5.Export contact as vCard3.0 when filter has not included any of the mandatory properties.
6.Export contact as vCard2.1 when filter has not included any of the mandatory properties.
7.Export contact when export of TEL has been disabled by providing EFalse to aExportTEL.
8.Compare exported file with expected output.

@SYMTestExpectedResults 
1.Mandatory properties N,TEL should be exported.
2.Mandatory properties N,FN,TEL should be exported..
3.Contact created without mandatory properties.
4.Empty mandatory properties should be exported.
5.Empty mandatory properties should be exported.
6.All mandatory properties except TEL should be exported.
7.Comparison of expected vCard should pass.
8.No leaves or panics should occur

*/
void CCntPBAPSupport::TestMandatoryAndTELPropertiesL()
	{
	SetIntraExport(EFalse);
	//filter needs to be non-Zero,This field is not present, so only mandatory ones shall be exported
	TInt64 filter = EPropertySORTSTRING;
	ExportContactsL(filter,EPBAPVCard21,ETrue);
	CompareExportsL(KMandatoryPopulatedProperties21());
	test.Printf(_L("Expected export of populated mandatory properties for vCard2.1 verified\n"));
	/*
	RDesReadStream compareStream(KMandatoryPopulatedProperties21());
	CleanupClosePushL(compareStream);
	CompareFilesL(compareStream);
	CleanupStack::PopAndDestroy(&compareStream);
	*/
	//Test vCard3.0
	ExportContactsL(filter,EPBAPVCard30,ETrue);
	CompareExportsL(KMandatoryPopulatedProperties30());
	test.Printf(_L("Expected export of populated mandatory properties for vCard3.0 verified\n"));
	/*
	RDesReadStream compareStream2(KMandatoryPopulatedProperties30());
	CleanupClosePushL(compareStream2);
	CompareFilesL(compareStream2);
	test.Printf(_L("Expected export of populated mandatory properties for vCard3.0 verified\n"));
	CleanupStack::PopAndDestroy(&compareStream2);
	*/
	//Empty fields
	ImportContactsL(KvCardWithoutMandatoryProperties());
	ExportContactsL(filter,EPBAPVCard21,ETrue);
	CompareExportsL(KEmptyMandatoryProperties21());
	test.Printf(_L("Expected export of Empty mandatory properties for vCard2.1 verified\n"));
	/*
	RDesReadStream compareStream3(KEmptyMandatoryProperties21());
	CleanupClosePushL(compareStream3);
	CompareFilesL(compareStream3);
	test.Printf(_L("Expected export of Empty mandatory properties for vCard2.1 verified\n"));
	CleanupStack::PopAndDestroy(&compareStream3);
	*/
	//Test vCard3.0
	ExportContactsL(filter,EPBAPVCard30,ETrue);
	CompareExportsL(KEmptyMandatoryProperties30());
	test.Printf(_L("Expected export of Empty mandatory properties for vCard3.0 verified\n"));
	/*
	RDesReadStream compareStream4(KEmptyMandatoryProperties30());
	CleanupClosePushL(compareStream4);
	CompareFilesL(compareStream4);
	test.Printf(_L("Expected export of Empty mandatory properties for vCard3.0 verified\n"));
	CleanupStack::PopAndDestroy(&compareStream4);
	*/
	//Test for export of TEL property
	ExportContactsL(filter,EPBAPVCard30,EFalse);
	CompareExportsL(KTELPropertyDisabled30());
	test.Printf(_L("Disabling of TEL export verified\n"));
	/*
	RDesReadStream compareStream5(KTELPropertyDisabled30());
	CleanupClosePushL(compareStream5);
	CompareFilesL(compareStream5);
	test.Printf(_L("Disabling of TEL export verified\n"));
	CleanupStack::PopAndDestroy(&compareStream5);
	*/
	}

/**
@SYMPREQ 1375
@SYMTestType UT
@SYMTestPriority Critical
@SYMTestCaseDesc Test the functionality of adding intra-contact property by callback function.
This function is called by PBAP export Plug-in during export.

@SYMTestActions
1.Import contact item having all supported fields
2.Prepare filter to enable export of required populated contact fields.
3.Export contact as vCard30 and compare with expected vcard,include TEL export.
4.Add one Intra-contact property when callback function is called.
5.Compare exported file with expected output.

@SYMTestExpectedResults For the above tests:
1.Export should contain mandatory properties + TEL and properties mentioned in filter.
2.Exported vCard should contain Intra-Contact property provided by callback function.
3.Comparison of expected vCard should pass.
4.No leaves or panics should occur
*/
void CCntPBAPSupport::TestIntraContactPropertiesL()
	{
	SetIntraExport(ETrue);
	ImportContactsL(KAllSupportedFields());
	TInt64 filter = EPropertyLABEL;
	filter |= EPropertyTITLE;
	filter |= EPropertyNOTE;
	ExportContactsL(filter, EPBAPVCard30,ETrue);
	CompareExportsL(KIntraContactExport());
	test.Printf(_L("Expected export of IntraContact Property verified\n"));
	/*
	RDesReadStream compareStream(KIntraContactExport());
	CleanupClosePushL(compareStream);
	CompareFilesL(compareStream);
	test.Printf(_L("Expected export of IntraContact Property verified\n"));
	CleanupStack::PopAndDestroy(&compareStream);
	*/
	}
	
/**
@SYMPREQ 1375
@SYMTestType UT
@SYMTestPriority Critical
@SYMTestCaseDesc Export contact item having unnamed parameters as vCard following vCard3.0 specification,
all such parameters should be prefixed with "TYPE=".

@SYMTestActions
1.Import contact item having fields with unnamed parameter values.
2.Create an empty filter.
3.Export contact as vCard30,export of TEL enabled.
4.Compare exported file with expected output.

@SYMTestExpectedResults For the above tests:
1.All supported and populated fields will be exported if empty filter is provided.
2.All unnamed parameters should be prefixed with "TYPE=".
4.Comparison of expected vCard should pass.
5.No leaves or panics should occur
*/
void CCntPBAPSupport::TestTypePrefixingL()
	{
	SetIntraExport(EFalse);
	ImportContactsL(KTestTypePrefix());
	TInt64 filter = 0;
	ExportContactsL(filter, EPBAPVCard30,ETrue);
	CompareExportsL(KExpectedTypePrefix30());
	test.Printf(_L("Type= prefix for vCard3.0 verified\n"));
	/*
	RDesReadStream compareStream(KExpectedTypePrefix30());
	CleanupClosePushL(compareStream);
	CompareFilesL(compareStream);
	test.Printf(_L("Type= prefix for vCard3.0 verified\n"));
	CleanupStack::PopAndDestroy(&compareStream);
	*/
	}

/**
@SYMPREQ 1375
@SYMTestType UT
@SYMTestPriority Critical
@SYMTestCaseDesc Tests if properties mentioned in filter are exported.

@SYMTestActions
1.Import vCard to create contact with populated fields.
2.Create 3 filters, each one enabling export of few fields.
3.Enable export of TEL for last two test.
4.Export contact and compare the expected output.

@SYMTestExpectedResults For the above tests:
1.Resulting vCards should contain only mandatory + populated properties present in the filter.
2.Comparison of expected vCard should pass.
3.No leaves or panics should occur
*/
void CCntPBAPSupport::TestFilterL()
	{
	SetIntraExport(EFalse);
	ImportContactsL(KAllSupportedFields());
	//Try with three filters, each enable export of few fields.	
	//Filter1, export LABEL,TITLE,NOTE,ADR apart from mandatory + TEL
	TInt64 filter = EPropertyLABEL;
	filter |= EPropertyTITLE;
	filter |= EPropertyNOTE;
	filter |= EPropertyADR;
	ExportContactsL(filter, EPBAPVCard30, ETrue);
	CompareExportsL(KExpected1FilteredProp30());
	test.Printf(_L("First Filter for vCard3.0 verified\n"));
	/*
 	RDesReadStream compareStream(KExpected1FilteredProp30());
	CleanupClosePushL(compareStream);
	CompareFilesL(compareStream);
	test.Printf(_L("First Filter for vCard3.0 verified\n"));
	CleanupStack::PopAndDestroy(&compareStream);
	*/
	//Filter2, export EMAIL,ORG,ROLE,URL + mandatory and no TEL.
	filter = 0;
	filter |= EPropertyROLE;
	filter |= EPropertyEMAIL;
	filter |= EPropertyORG;
	filter |= EPropertyURL;
	ExportContactsL(filter, EPBAPVCard30, EFalse);
	CompareExportsL(KExpected2FilteredProp30());
	test.Printf(_L("Second Filter for vCard3.0 without TEL verified\n"));
	/*
 	RDesReadStream compareStream2(KExpected2FilteredProp30());
	CleanupClosePushL(compareStream2);
	CompareFilesL(compareStream2);
	test.Printf(_L("Second Filter for vCard3.0 without TEL verified\n"));
	CleanupStack::PopAndDestroy(&compareStream2);
	*/
	//Filter3, export PHOTO,LOGO,BDAY,MAILER,SOUND,KEY + mandatory and no TEL to 2.1
	filter = 0;
	filter |= EPropertyPHOTO;
	filter |= EPropertyLOGO;
	filter |= EPropertyBDAY;
	filter |= EPropertyMAILER;
	filter |= EPropertySOUND;
	filter |= EPropertyKEY;
	ExportContactsL(filter, EPBAPVCard21, EFalse);
	CompareExportsL(KExpected3FilteredProp21());
	test.Printf(_L("Third Filter on vCard2.1 without TEL verified\n"));
	/*
 	RDesReadStream compareStream3(KExpected3FilteredProp21());
	CleanupClosePushL(compareStream3);
	CompareFilesL(compareStream3);
	test.Printf(_L("Third Filter on vCard2.1 without TEL verified\n"));
	CleanupStack::PopAndDestroy(&compareStream3);
	*/
	}

/**
@SYMPREQ 1375
@SYMTestType UT
@SYMTestPriority Critical
@SYMTestCaseDesc Tests if standard vCard2.1 support has been provided or not.

@SYMTestActions
1.Import vCard to create contact with populated fields.
2.Provide EVCard21 as format of export.
3.Export contact and compare the expected output.

@SYMTestExpectedResults For the above tests:
1.Resulting vCards should contain all populated properties supported by standard vCard2.1 export.
2.Comparison of expected vCard should pass.
3.No leaves or panics should occur
*/
void CCntPBAPSupport::TestVCard21SupportL()
	{
	ImportContactsL(KAllSupportedFields());
	TInt64 filter = 0;
	ExportContactsL(filter, EVCard21, ETrue);
	CompareExportsL(KExpectedStandard21vCard());
	test.Printf(_L("Expected export of standard vCard2.1 verified\n"));
	/*
	RDesReadStream compareStream(KExpectedStandard21vCard());
	CleanupClosePushL(compareStream);
	CompareFilesL(compareStream);
	test.Printf(_L("Expected export of standard vCard2.1 verified\n"));
	CleanupStack::PopAndDestroy(&compareStream);
	*/
	}
/**
Initiates test functions.
*/	
void DoTaskL()
	{	
	CCntPBAPSupport* pbapTest = CCntPBAPSupport::NewL();
	CleanupStack::PushL(pbapTest);
	pbapTest->TestExportOfAllSupportedFieldsL();
	pbapTest->TestMandatoryAndTELPropertiesL();
	pbapTest->TestIntraContactPropertiesL();
	pbapTest->TestTypePrefixingL();
	pbapTest->TestFilterL();
	pbapTest->TestVCard21SupportL();
	CleanupStack::PopAndDestroy(pbapTest);	
	test.End();
	}
	
//
// Main.
//

//@SYMTestCaseID PIM-TCNTPBAPSUPPORT-0001
	
GLDEF_C TInt E32Main()
	{
	__UHEAP_MARK;
	test.Start(_L("@SYMTestCaseID PIM-TCNTPBAPSUPPORT-0001 CntPBAPSupport Test"));

	CActiveScheduler* scheduler = new CActiveScheduler;
	if (scheduler)
		{
		CActiveScheduler::Install(scheduler);
		CTrapCleanup* cleanup = CTrapCleanup::New();
		if (cleanup)
			{
			TRAPD(err,DoTaskL() );
			test(err == KErrNone);
			delete cleanup;
			}
		delete scheduler;
		}
	test.Close();
	__UHEAP_MARKEND;
	return KErrNone;
    }