|
1 // Copyright (c) 2003-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 #if !defined(__T_SECONDNAME_H__) |
|
17 #define __T_SECONDNAME_H__ |
|
18 |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <e32def.h> |
|
22 #include <e32test.h> |
|
23 #include <f32file.h> |
|
24 #include <s32file.h> |
|
25 #include <s32mem.h> |
|
26 #include <cntdb.h> |
|
27 #include <cntdef.h> |
|
28 #include <cntitem.h> |
|
29 #include <cntfield.h> |
|
30 #include <cntfldst.h> |
|
31 #include <cntvcard.h> |
|
32 #include <vtoken.h> |
|
33 |
|
34 /** Parameter object to encapsulate test data. */ |
|
35 class TTestData |
|
36 { |
|
37 public: |
|
38 TTestData(const TDesC8& aImportVCard, const TDesC8& aUpdateVCard, |
|
39 const TDesC8& aVersitToken, const TUid aFieldUid, |
|
40 const TDesC& aFieldContent, const TDesC& aUpdatedFieldContent, |
|
41 const TDesC& aImportFilename, const TDesC& aExportFilename); |
|
42 void SetVCardMapping(TUid aVCardMapping); |
|
43 public: |
|
44 const TDesC8& iImportVCard; |
|
45 const TDesC8& iUpdateVCard; |
|
46 const TDesC8& iVersitToken; |
|
47 const TUid iFieldUid; |
|
48 const TDesC& iFieldContent; |
|
49 const TDesC& iUpdatedFieldContent; |
|
50 const TDesC& iImportFilename; |
|
51 const TDesC& iExportFilename; |
|
52 TUid iVCardMapping; |
|
53 }; |
|
54 |
|
55 /** Base class for new contact field vCard tests. */ |
|
56 class CNewFieldTestBase : public CBase |
|
57 { |
|
58 public: |
|
59 ~CNewFieldTestBase(); |
|
60 protected: |
|
61 CParserVCard* CreateVCardLC(const TDesC8& aContents); |
|
62 void WriteVCardL(const TDesC& aFileName, CParserVCard& aVCard); |
|
63 TBool CheckSingleFieldValue(CContactItemFieldSet& aFieldSet, TTestData& aTd, const TDesC& aExpectedValue); |
|
64 TContactItemId CreateContactL(); |
|
65 CParserVCard* ParseVCardLC(const TDesC& aFilename); |
|
66 CArrayPtr<CContactItem>* ImportVCardLC(const TDesC& aFilename, TBool aConnectWhitespaceOption = ETrue); |
|
67 void ExportVCardL(const TDesC& aFilename, CArrayPtr<CContactItem>* aContactArray); |
|
68 protected: |
|
69 void TestImportL(TTestData& aTd); |
|
70 void TestExportL(TTestData& aTd); |
|
71 void TestUpdateL(TTestData& aTd); |
|
72 protected: |
|
73 CNewFieldTestBase(RTest& aTest, RFs& aFs); |
|
74 CNewFieldTestBase(); |
|
75 void BaseConstructL(); |
|
76 protected: |
|
77 CContactDatabase* iDb; |
|
78 RTest& iTest; |
|
79 RFs& iFs; |
|
80 }; |
|
81 |
|
82 /** Tests for second name field (X-EPOCSECONDNAME). */ |
|
83 class CSecondNameTest : public CNewFieldTestBase |
|
84 { |
|
85 public: |
|
86 static CSecondNameTest* NewLC(RTest& aTest, RFs& aFs); |
|
87 void RunTestsL(); |
|
88 ~CSecondNameTest(); |
|
89 private: |
|
90 CSecondNameTest(RTest& aTest, RFs& aFs); |
|
91 void ConstructL(); |
|
92 }; |
|
93 |
|
94 /** Tests for SIP identity field (X-SIP). */ |
|
95 class CSipIdTest : public CNewFieldTestBase |
|
96 { |
|
97 public: |
|
98 static CSipIdTest* NewLC(RTest& aTest, RFs& aFs); |
|
99 void RunTestsL(); |
|
100 ~CSipIdTest(); |
|
101 private: |
|
102 CSipIdTest(RTest& aTest, RFs& aFs); |
|
103 void ConstructL(); |
|
104 void RunTestCaseL(const TDesC8& aImportVCard, const TDesC8& aUpdateVCard, TUid aVCardMapping); |
|
105 }; |
|
106 |
|
107 /** Tests for Wireless Village identity field (X-WV-ID). */ |
|
108 class CWvIdTest : public CNewFieldTestBase |
|
109 { |
|
110 public: |
|
111 static CWvIdTest* NewLC(RTest& aTest, RFs& aFs); |
|
112 void RunTestsL(); |
|
113 ~CWvIdTest(); |
|
114 private: |
|
115 CWvIdTest(RTest& aTest, RFs& aFs); |
|
116 void ConstructL(); |
|
117 }; |
|
118 |
|
119 /** Test for fields limitation at import time - related to defect INC077129 */ |
|
120 class CFieldLimitationTest : public CNewFieldTestBase |
|
121 { |
|
122 public: |
|
123 static CFieldLimitationTest* NewLC(RTest& aTest, RFs& aFs); |
|
124 void RunTestsL(); |
|
125 ~CFieldLimitationTest(); |
|
126 private: |
|
127 CFieldLimitationTest(RTest& aTest, RFs& aFs); |
|
128 void ConstructL(); |
|
129 void RunTestCaseL(const TDesC8& aImportVCard, const TDesC8& aVersitToken, TUid aCardMapping, const TDesC16& aExpectedValue); |
|
130 }; |
|
131 |
|
132 #endif |