|
1 // Copyright (c) 2006-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 /** |
|
17 @file |
|
18 @publishedAll |
|
19 @released |
|
20 */ |
|
21 |
|
22 #include <e32panic.h> |
|
23 #include <test/testexecutelog.h> |
|
24 #include <cntfldst.h> |
|
25 #include "ClientServer.h" |
|
26 #include "ViewDefAllFieldsTest.h" |
|
27 |
|
28 _LIT(KTest1,"Testing ..."); |
|
29 |
|
30 const LOCAL_D TInt KFields = 67; |
|
31 const LOCAL_D TInt KHfields = 3; |
|
32 |
|
33 //Number of contacts |
|
34 CViewDefAllFieldsTest::CViewDefAllFieldsTest():CViewDefBase(5) |
|
35 { |
|
36 // Call base class method to set up the human readable name for logging |
|
37 SetTestStepName(SharedConstants::KViewDefAllFieldsTest); |
|
38 } |
|
39 |
|
40 TVerdict CViewDefAllFieldsTest::doTestStepL() |
|
41 { |
|
42 |
|
43 __UHEAP_MARK; |
|
44 |
|
45 InitializeL(); |
|
46 iIterate->Reset(); |
|
47 INFO_PRINTF1(KTest1); |
|
48 FieldCountTestL(); |
|
49 Cleanup(); |
|
50 __UHEAP_MARKEND; |
|
51 |
|
52 return TestStepResult(); |
|
53 } |
|
54 /**viewdef tests where contact item is opened/read using empty viewdefs or one containng, |
|
55 KUidContactFieldMatchAll only*/ |
|
56 void CViewDefAllFieldsTest::FieldCountTestL() |
|
57 { |
|
58 iViewII->AddL(KUidContactFieldMatchAll); |
|
59 iViewIM->AddL(KUidContactFieldMatchAll); |
|
60 iViewMI->AddL(KUidContactFieldMatchAll); |
|
61 iViewMM->AddL(KUidContactFieldMatchAll); |
|
62 |
|
63 //commented out tests that fail |
|
64 SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewII,EFalse,EFalse,EFalse),0,0 ); |
|
65 SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewIM,EFalse,EFalse,ETrue),0,0 ); |
|
66 //the behaviour of this test is inverted with regards to hidden fields, they are excluded. |
|
67 SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewMI,EFalse,ETrue,ETrue),0,0 ); |
|
68 SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewMM,EFalse,ETrue,ETrue),0,0 ); |
|
69 //using the default viewdefs used in open and read causes a discrepency |
|
70 SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewAll,ETrue,EFalse,ETrue),0,0 ); |
|
71 |
|
72 iViewII->Reset(); |
|
73 iViewIM->Reset(); |
|
74 iViewMI->Reset(); |
|
75 iViewMM->Reset(); |
|
76 } |
|
77 /**opens and read contct aCid using the default viewdefs. |
|
78 then it reads and minimally reads aCid using aView, it stores the number relevant fields after |
|
79 each read/open, then checks that the values match the expected resluts as constrained by aZeroN/H, |
|
80 aZeroN == all normal fields should be excluded, aZeroH == all hidden fields should be excluded*/ |
|
81 TBool CViewDefAllFieldsTest::FieldCountCompL( const TContactItemId aCid, |
|
82 const CContactItemViewDef &aView, |
|
83 const TBool aDefault, |
|
84 const TBool aZeroN, |
|
85 const TBool aZeroH) |
|
86 { |
|
87 TBool SingleCheck = EFalse; |
|
88 TBool OverallResult = ETrue; |
|
89 |
|
90 TInt counti = 0; |
|
91 TInt countr = 0; |
|
92 TInt countrv = 0; |
|
93 TInt countrAll = 0; |
|
94 TInt countrAllv = 0; |
|
95 TInt countrm = 0; |
|
96 |
|
97 TInt hcounti = 0; |
|
98 TInt hcountr = 0; |
|
99 TInt hcountrv = 0; |
|
100 TInt hcountrm = 0; |
|
101 |
|
102 OpenL(aCid,aView, ETrue); |
|
103 SetContactFieldsL(*iContactItem); |
|
104 counti = iFields->Count(); |
|
105 hcounti = CountHiddenFields(*iFields); |
|
106 CommitL(); |
|
107 |
|
108 ReadL(aCid,*iViewAll,EFalse); |
|
109 countrv = CountEmpty(*iFields); |
|
110 countrAllv = iFields->Count(); |
|
111 hcountrv = CountHiddenFields(*iFields); |
|
112 Close(); |
|
113 |
|
114 ReadL(aCid,aView,aDefault); |
|
115 countr = CountEmpty(*iFields); |
|
116 countrAll = iFields->Count(); |
|
117 hcountr = CountHiddenFields(*iFields); |
|
118 Close(); |
|
119 |
|
120 ReadMinimalL(aCid, aView, *iDefView, aDefault); |
|
121 countrm = iFields->Count(); |
|
122 hcountrm = CountHiddenFields(*iFields); |
|
123 Close(); |
|
124 |
|
125 SingleCheck = INTCOMPARE( countrAllv, ==, counti, 0, 0 ); |
|
126 OverallResult = OverallResult && SingleCheck; |
|
127 |
|
128 SingleCheck = INTCOMPARE(hcounti , ==, hcountrv, 0, 0 ); |
|
129 OverallResult = OverallResult && SingleCheck; |
|
130 |
|
131 SingleCheck = INTCOMPARE(countrv , ==, 0, 0, 0 ); |
|
132 OverallResult = OverallResult && SingleCheck; |
|
133 |
|
134 SingleCheck = INTCOMPARE( ( countrAll - countr) , ==, countrm , 0, 0 ); |
|
135 OverallResult = OverallResult && SingleCheck; |
|
136 |
|
137 |
|
138 if(aZeroN) |
|
139 { |
|
140 SingleCheck = INTCOMPARE( ( countr - hcountr ) , ==, ( counti - hcounti ) , 0, 0 ); |
|
141 OverallResult = OverallResult && SingleCheck; |
|
142 |
|
143 SingleCheck = INTCOMPARE( ( countrm - hcountrm ) , ==, 0 , 0, 0 ); |
|
144 OverallResult = OverallResult && SingleCheck; |
|
145 |
|
146 } |
|
147 else |
|
148 { |
|
149 SingleCheck = INTCOMPARE( countr , ==, 0 , 0, 0 ); |
|
150 OverallResult = OverallResult && SingleCheck; |
|
151 |
|
152 SingleCheck = INTCOMPARE( (countrm - hcountrm) , ==, KFields , 0, 0 ); |
|
153 OverallResult = OverallResult && SingleCheck; |
|
154 |
|
155 SingleCheck = INTCOMPARE( (countrm - hcountrm) , ==, (counti - hcounti), 0, 0 ); |
|
156 OverallResult = OverallResult && SingleCheck; |
|
157 |
|
158 } |
|
159 |
|
160 if(aZeroH) |
|
161 { |
|
162 SingleCheck = INTCOMPARE(hcountrm , ==, 0, 0, 0 ); |
|
163 OverallResult = OverallResult && SingleCheck; |
|
164 |
|
165 SingleCheck = SINGLECOMPARE( ( (hcountr == 0) || ( (hcountr == hcountrv) && (countr == countrAll) ) ), 0, 0 ); |
|
166 OverallResult = OverallResult && SingleCheck; |
|
167 } |
|
168 else |
|
169 { |
|
170 SingleCheck = INTCOMPARE(hcountrm , ==, KHfields, 0, 0 ); |
|
171 OverallResult = OverallResult && SingleCheck; |
|
172 |
|
173 SingleCheck = INTCOMPARE(hcountr , ==, hcountrm, 0, 0 ); |
|
174 OverallResult = OverallResult && SingleCheck; |
|
175 |
|
176 SingleCheck = INTCOMPARE(hcountrm , ==, hcounti, 0, 0 ); |
|
177 OverallResult = OverallResult && SingleCheck; |
|
178 } |
|
179 |
|
180 return OverallResult; |
|
181 } |
|
182 |