|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <s32mem.h> |
|
17 #include <e32test.h> |
|
18 #include <vprop.h> |
|
19 #include <versit.h> |
|
20 #include <vcal.h> |
|
21 #include <vcard.h> |
|
22 #include <f32file.h> |
|
23 #include <s32file.h> |
|
24 #include "testdata.h" |
|
25 |
|
26 // Type definitions |
|
27 #define UNUSED_VAR(a) a = a |
|
28 |
|
29 CConsoleBase* console; |
|
30 LOCAL_D RTest test(_L("TEST_SAVELOADBIN")); |
|
31 |
|
32 |
|
33 |
|
34 void doTestL() |
|
35 { |
|
36 console=Console::NewL(_L("TEST_SAVELOADBIN"),TSize(76,18)); |
|
37 CleanupStack::PushL(console); |
|
38 // tests a vcard without agents |
|
39 RDesReadStream input1(vcardbinary); |
|
40 CParserVCard* vcard1 = CParserVCard::NewL(); |
|
41 CleanupStack::PushL(vcard1); |
|
42 vcard1->SetEntityNameL(_L("vcard")); |
|
43 vcard1->InternalizeL(input1); |
|
44 TInt numfiles = vcard1->SaveBinaryValuesToFilesL(0,_L("c:\\")); |
|
45 ASSERT(numfiles == 1); |
|
46 numfiles = vcard1->LoadBinaryValuesFromFilesL(); |
|
47 ASSERT(numfiles == 1); |
|
48 CleanupStack::PopAndDestroy(vcard1); |
|
49 // tests a vcard with agents |
|
50 RDesReadStream input2(vcardagent); |
|
51 CParserVCard* vcard2 = CParserVCard::NewL(); |
|
52 CleanupStack::PushL(vcard2); |
|
53 vcard2->SetEntityNameL(_L("vcard")); |
|
54 vcard2->InternalizeL(input2); |
|
55 RFs fs; |
|
56 fs.Connect(); |
|
57 CleanupClosePushL(fs); |
|
58 // the overloaded member functions that accept a RFs param is used |
|
59 numfiles = vcard2->SaveBinaryValuesToFilesL(0,_L("c:\\"),fs); |
|
60 ASSERT(numfiles == 1); |
|
61 numfiles = vcard2->LoadBinaryValuesFromFilesL(fs); |
|
62 ASSERT(numfiles == 1); |
|
63 CleanupStack::PopAndDestroy(&fs); |
|
64 CleanupStack::PopAndDestroy(vcard2); |
|
65 // tests a vcard with a binary data field that is empty |
|
66 RDesReadStream input3(vcardbinaryempty); |
|
67 CParserVCard* vcard3 = CParserVCard::NewL(); |
|
68 CleanupStack::PushL(vcard3); |
|
69 vcard3->SetEntityNameL(_L("vcard")); |
|
70 vcard3->InternalizeL(input3); |
|
71 fs.Connect(); |
|
72 CleanupClosePushL(fs); |
|
73 numfiles = vcard3->SaveBinaryValuesToFilesL(0,_L("c:\\"),fs); |
|
74 ASSERT(numfiles == 0); |
|
75 numfiles = vcard3->LoadBinaryValuesFromFilesL(fs); |
|
76 ASSERT(numfiles == 0); |
|
77 CleanupStack::PopAndDestroy(&fs); |
|
78 CleanupStack::PopAndDestroy(vcard3); |
|
79 |
|
80 CleanupStack::PopAndDestroy(console); |
|
81 } |
|
82 |
|
83 /** |
|
84 @SYMTestCaseID PIM-TESTSAVELOADBIN-0001 |
|
85 */ |
|
86 TInt E32Main() |
|
87 { |
|
88 __UHEAP_MARK; |
|
89 test.Start(_L("@SYMTestCaseID PIM-TESTSAVELOADBIN-0001 TEST_SAVELOADBIN")); |
|
90 test.Title(); |
|
91 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
92 TRAPD(error,doTestL()); |
|
93 UNUSED_VAR(error); //Used to supress build warnings |
|
94 |
|
95 ASSERT(error == KErrNone); |
|
96 delete cleanup; |
|
97 test.End(); |
|
98 test.Close(); |
|
99 __UHEAP_MARKEND; |
|
100 return (KErrNone); |
|
101 } |