summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/integration/perffuncsuite/src/concurrenttimeoutlistenerstep.cpp
blob: bc78fbc703a922ae106c8088f0a257cc2e684476 (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
/*
* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* 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 "concurrenttimeoutlistenerstep.h"
#include "performancefunctionalitydefs.h"

_LIT(KRun1,"Open");
_LIT(KRun2,"Update");
_LIT(KRun3,"Read");
_LIT(KRun4,"Delete");
_LIT(KRun5,"Add");

_LIT(KTest1, "Contacts Open timeout test");
_LIT(KTest2, "Contacts Update timeout test");
_LIT(KTest3, "Contacts Read timeout test");
_LIT(KTest4, "Contacts Delete timeout test");
_LIT(KTest5, "Contacts Add/Create timeout test");

const TInt KTimeout = 50000000;//50 seconds timeout
const TInt KOneSecond = 1000000;
const TInt KLocalTimeOut = 10;

_LIT(KDoubleChar,"AA");

	
CConcurrentTimeOutListenerStep::CConcurrentTimeOutListenerStep() : 	CTimeoutBaseStep(KConcurrentTimeoutContacts, KDeviation), 
																	iCid( -1 ),
																	iSharedTime( -1 )
	{
	iConcurrent = ETrue;
	SetTestStepName(KConcurrentTimeOutListenerStep);
	}

/**
runs the next timeout test after receiving message specifying that the relevant
resources have been locked for said amount of time, then sends message back stating that
countdown should take place.
timesout if no messages are received from the notifier
*/
void CConcurrentTimeOutListenerStep::CConcurrentTimeOutListenerMyActive::RunL()
	{
	const TInt KTestCount = iStep->iTests->Count();
	iStep->iEnd.UniversalTime();
	iStep->GetTimerL();
	iStep->GetContactL();
	iStep->GetNextTestL();
	TInt64 alldiff = iStep->iEnd.MicroSecondsFrom( iStep->iTestStart ).Int64();
	if( iStep->iNextTest >= KTestCount )
		{
		CActiveScheduler::Stop();
		iStep->iNextTest = 0;
		}
	else if( alldiff > KTimeout )
		{
		_LIT(KTimedOut,"Listener test %d has timed out");
		iStep->ERR_PRINTF2(KTimedOut, ++iStep->iNextTest);
		iStep->iCid = -1;
		iStep->iSharedTime = -1;
		
		iStep->TEST1( EFalse, ETrue );
		iStep->iNextTest = iStep->iTests->Count();
		Activate();
		}
	else if( iStep->iSharedNext && iStep->iCid > 0 && iStep->iSharedTime > 0)
		{
		iStep->iSharedNext = EFalse;
		iStep->RemoteLockL();
		iStep->TEST1( (iStep->*(*(iStep->iTests))[iStep->iNextTest++] )(), ETrue);
		iStep->iTestStart.UniversalTime();
		Activate();
		}
	else
		{
		Activate();
		}
	}
	
void CConcurrentTimeOutListenerStep::CConcurrentTimeOutListenerMyActive::DoCancel()
	{
	}

TInt CConcurrentTimeOutListenerStep::CConcurrentTimeOutListenerMyActive::RunError(TInt aError)
	{
	_LIT(KActiveError,"CConcurrentTimeOutListenerStep:: Error in doTest runL: %d");
	iStep->ERR_PRINTF2(KActiveError, aError );
	return aError;
	}
/**
activates the active object
*/
void CConcurrentTimeOutListenerStep::CConcurrentTimeOutListenerMyActive::Activate()
	{
	if(!IsActive())
		{	
		TRequestStatus *pS=&iStatus;
		User::RequestComplete(pS,KErrNone);
		SetActive();
		}
	}

CConcurrentTimeOutListenerStep::~CConcurrentTimeOutListenerStep()
	{
	if( iTests )
		{
		iTests->Close();
		CLEAR(iTests);
		}
	CLEAR(iMyActive);
	}
	
void CConcurrentTimeOutListenerStep::PreTestL()
	{
	iMyActive = new (ELeave) CConcurrentTimeOutListenerStep::CConcurrentTimeOutListenerMyActive( this );
	iTests = new(ELeave) RArray< TBool (CConcurrentTimeOutListenerStep::*)() >();
	
	const TDesC &run = ConfigSection();
	
	if( run == KRun1 )
		{
		iTests->AppendL( &CConcurrentTimeOutListenerStep::OpenContactTestL );
		}
	else if( run == KRun2 )
		{
		iTests->AppendL( &CConcurrentTimeOutListenerStep::UpdateContactTestL );
		}
	else if( run == KRun3 )
		{
		iTests->AppendL( &CConcurrentTimeOutListenerStep::ReadContactTestL );
		}
	else if( run == KRun4 )
		{
		iTests->AppendL( &CConcurrentTimeOutListenerStep::DeleteContactTestL );
		}
	else if( run == KRun5 )
		{
		iTests->AppendL( &CConcurrentTimeOutListenerStep::AddContactTestL );
		}
	else
		{
		MissingTestPanic();
		}
	
	}

TVerdict CConcurrentTimeOutListenerStep::doTestStepL()
	{
	__UHEAP_MARK;
	InitializeL();
	_LIT(KDoStepPrint,"CConcurrentTimeOutListenerStep::doTestStepL()");
	INFO_PRINTF1(KDoStepPrint);  //Block start 
	iIterate->Reset();
	
	//RemoteLockL();
	CActiveScheduler::Add(iMyActive);
	iMyActive->Activate();
	iTestStart.UniversalTime();
	CActiveScheduler::Start();
	
	Cleanup();
	__UHEAP_MARKEND;

	return TestStepResult();
	}

/**
get message from notifier specifying epxected timeout
then clear message
*/
void CConcurrentTimeOutListenerStep::GetTimerL()
	{
	if( iSharedTime <= 0)
		{
		iSharedTime = GetSharedIntL(KSharedEvents);
		}
	if( iSharedTime > 0)
		{
		ShareIntL(KSharedEvents, -1);
		}
	}

/**
get message from notifier specifying the locked resource
then clear mesasge
*/	
void CConcurrentTimeOutListenerStep::GetContactL()
	{
	if( iCid <= 0)
		{
		iCid = GetSharedIntL(KSharedContact);
		}
	if( iCid > 0)
		{
		ShareIntL(KSharedContact, -1);
		}
	}

/**
get message from notifier specifying that next test has started
then clear mesasge
*/	
void CConcurrentTimeOutListenerStep::GetNextTestL()
	{
	if( !iSharedNext )
		{
		iSharedNext = SharedCountL(KSharedNextTest) > 0;
		}
	if( iSharedNext )
		{
		SetSharedTextL(KSharedNextTest, KNullDesC, EFalse);
		}
	}
/**
specify that countdown should being on notifier
*/	
void CConcurrentTimeOutListenerStep::RemoteLockL()
	{
	SetSharedTextL(KSharedClients, KDoubleChar, EFalse );
	}
		
TBool CConcurrentTimeOutListenerStep::OpenContactTestL()
	{
	TBool ret = EFalse;
	INFO_PRINTF1(KTest1);
	iTimeOut = ( (KLocalTimeOut + iSharedTime) * KOneSecond );
	ret = CheckTimeOutL(&CConcurrentTimeOutListenerStep::CheckOpenL, iContactsDatabase, iCid, KErrNone, ( iSharedTime * KOneSecond ) );
	return ret;
	}
		
TBool CConcurrentTimeOutListenerStep::UpdateContactTestL()
	{
	TBool ret = EFalse;
	INFO_PRINTF1(KTest2);
	iTimeOut = ( (KLocalTimeOut + iSharedTime) * KOneSecond );
	ret = CheckTimeOutL(&CConcurrentTimeOutListenerStep::CheckUpdateL, iContactsDatabase, iCid, KErrNone, ( iSharedTime * KOneSecond ) );
	return ret;
	}
	
TBool CConcurrentTimeOutListenerStep::ReadContactTestL()
	{
	TBool ret = EFalse;
	INFO_PRINTF1(KTest3);
	iTimeOut = ( (KLocalTimeOut + iSharedTime) * KOneSecond );
	ret = CheckTimeOutL(&CConcurrentTimeOutListenerStep::CheckRead, iContactsDatabase, iCid, KErrNone, 0 );
	return ret;
	}
		
TBool CConcurrentTimeOutListenerStep::DeleteContactTestL()
	{
	TBool ret = EFalse;
	INFO_PRINTF1(KTest4);
	iTimeOut = ( (KLocalTimeOut + iSharedTime) * KOneSecond );
	ret = CheckTimeOutL(&CConcurrentTimeOutListenerStep::CheckDelete, iContactsDatabase, iCid, KErrNone, ( iSharedTime * KOneSecond ) );
	return ret;
	}
		
TBool CConcurrentTimeOutListenerStep::AddContactTestL()
	{
	TBool ret = EFalse;
	INFO_PRINTF1(KTest5);
	iTimeOut = ( (KLocalTimeOut + iSharedTime) * KOneSecond );
	ret = CheckTimeOutL(&CConcurrentTimeOutListenerStep::CheckAddL, iContactsDatabase, iCid, KErrNone, ( iSharedTime * KOneSecond ) );
	return ret;
	}