summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/integration/cntperftest/src/viewdefallfieldstest.cpp
blob: 20d96da056bf17caf6ffd842f592697326ce71b5 (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
/*
* 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: 
*
*/


/**
 @file
 @publishedAll
 @released
*/

#include <e32panic.h>
#include <test/testexecutelog.h>
#include <cntfldst.h>
#include "clientserver.h"
#include "viewdefallfieldstest.h"

_LIT(KTest1,"Testing ...");

const LOCAL_D TInt KFields = 67;
const LOCAL_D TInt KHfields = 3;

//Number of contacts
CViewDefAllFieldsTest::CViewDefAllFieldsTest():CViewDefBase(5)
	{
	// Call base class method to set up the human readable name for logging
	SetTestStepName(SharedConstants::KViewDefAllFieldsTest);
	}

TVerdict CViewDefAllFieldsTest::doTestStepL()
	{
	
	__UHEAP_MARK;

	InitializeL();
	iIterate->Reset();
	INFO_PRINTF1(KTest1);
	FieldCountTestL();
	Cleanup();
	__UHEAP_MARKEND;
	
	return TestStepResult();
	}
/**viewdef tests where contact item is opened/read using empty viewdefs or one containng,
KUidContactFieldMatchAll only*/
void CViewDefAllFieldsTest::FieldCountTestL()
	{		
	iViewII->AddL(KUidContactFieldMatchAll);
	iViewIM->AddL(KUidContactFieldMatchAll);
	iViewMI->AddL(KUidContactFieldMatchAll);
	iViewMM->AddL(KUidContactFieldMatchAll);
	
	//commented out tests that fail
	SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewII,EFalse,EFalse,EFalse),0,0 );
	SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewIM,EFalse,EFalse,ETrue),0,0 );
	//the behaviour of this test is inverted with regards to hidden fields, they are excluded.
	SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewMI,EFalse,ETrue,ETrue),0,0 );
	SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewMM,EFalse,ETrue,ETrue),0,0 );
	//using the default viewdefs used in open and read causes a discrepency
	SINGLECOMPARE( FieldCountCompL(iIterate->NextL(),*iViewAll,ETrue,EFalse,ETrue),0,0 );
	
	iViewII->Reset();
	iViewIM->Reset();
	iViewMI->Reset();
	iViewMM->Reset();
	}
/**opens and read contct aCid using the default viewdefs. 
then it reads and minimally reads aCid using aView, it stores the number relevant fields after
each read/open, then checks that the values match the expected resluts as constrained by aZeroN/H,
aZeroN == all normal fields should be excluded, aZeroH == all hidden fields should be excluded*/
TBool CViewDefAllFieldsTest::FieldCountCompL(	const TContactItemId aCid,
										const CContactItemViewDef &aView, 
										const TBool aDefault, 
										const TBool aZeroN, 
										const TBool aZeroH)
	{
	TBool SingleCheck = EFalse;
	TBool OverallResult = ETrue;
	
	TInt counti = 0;
	TInt countr = 0;
	TInt countrv = 0;
	TInt countrAll = 0;
	TInt countrAllv = 0;
	TInt countrm = 0;
	
	TInt hcounti = 0;
	TInt hcountr = 0;
	TInt hcountrv = 0;
	TInt hcountrm = 0;
	
	OpenL(aCid,aView, ETrue);
	SetContactFieldsL(*iContactItem);
	counti = iFields->Count();
	hcounti = CountHiddenFields(*iFields);
	CommitL();
	
	ReadL(aCid,*iViewAll,EFalse);
	countrv = CountEmpty(*iFields);
	countrAllv = iFields->Count();
	hcountrv = CountHiddenFields(*iFields);
	Close();
	
	ReadL(aCid,aView,aDefault);
	countr = CountEmpty(*iFields);
	countrAll = iFields->Count();
	hcountr = CountHiddenFields(*iFields);
	Close();
	
	ReadMinimalL(aCid, aView, *iDefView, aDefault);
	countrm = iFields->Count();
	hcountrm = CountHiddenFields(*iFields);
	Close();
		
	SingleCheck = INTCOMPARE( countrAllv, ==, counti, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE(hcounti , ==,  hcountrv, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE(countrv , ==,  0, 0, 0 );
	OverallResult = OverallResult && SingleCheck;
	
	SingleCheck = INTCOMPARE( ( countrAll - countr) , ==,  countrm , 0, 0 ); 
	OverallResult = OverallResult && SingleCheck;
	
	
	if(aZeroN)
		{
		SingleCheck = INTCOMPARE( ( countr - hcountr ) , ==,  ( counti - hcounti ) , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		SingleCheck = INTCOMPARE( ( countrm - hcountrm ) , ==,  0 , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		}
	else
		{
		SingleCheck = INTCOMPARE( countr , ==,  0 , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		SingleCheck = INTCOMPARE( (countrm - hcountrm) , ==,  KFields , 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		SingleCheck = INTCOMPARE( (countrm - hcountrm) , ==,  (counti - hcounti), 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		}
		
	if(aZeroH)
		{
		SingleCheck = INTCOMPARE(hcountrm , ==,  0, 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		SingleCheck = SINGLECOMPARE( ( (hcountr == 0) || ( (hcountr == hcountrv) && (countr == countrAll) ) ), 0, 0 );
		OverallResult = OverallResult && SingleCheck;	
		}
	else
		{
		SingleCheck = INTCOMPARE(hcountrm , ==,  KHfields, 0, 0 );
		OverallResult = OverallResult && SingleCheck;
			
		SingleCheck = INTCOMPARE(hcountr , ==,  hcountrm, 0, 0 );
		OverallResult = OverallResult && SingleCheck;
	
		SingleCheck = INTCOMPARE(hcountrm , ==,  hcounti, 0, 0 );
		OverallResult = OverallResult && SingleCheck;	
		}
		
	return OverallResult;
	}