63
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: UT_AddFavoritiesVisibility class member functions
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// [INCLUDE FILES] - do not remove
|
|
21 |
#include <Stiftestinterface.h>
|
|
22 |
#include "UT_AddFavoritiesVisibility.h"
|
|
23 |
#include <SettingServerClient.h>
|
|
24 |
#include <CVPbkContactTestUtils.h>
|
|
25 |
#include <centralrepository.h>
|
|
26 |
#include "stifunitmacros.h"
|
|
27 |
#include "CPbk2AddFavoritesVisibilityImpl.h"
|
|
28 |
#include "CCallbackTimer.h"
|
|
29 |
|
|
30 |
|
|
31 |
// Logging path
|
|
32 |
_LIT( KUT_AddFavoritiesVisibilityLogPath, "\\logs\\testframework\\UT_AddFavoritiesVisibility\\" );
|
|
33 |
// Log file
|
|
34 |
_LIT( KUT_AddFavoritiesVisibilityLogFile, "UT_AddFavoritiesVisibility.txt" );
|
|
35 |
_LIT( KUT_AddFavoritiesVisibilityLogFileWithTitle, "UT_AddFavoritiesVisibility_[%S].txt" );
|
|
36 |
|
|
37 |
#define GETPTR &
|
|
38 |
#define ENTRY(str1,str2,func1,func2,func3) {(const TText*)(L##str1 L" [" L##str2 L"]"),GETPTR func1,GETPTR func2, GETPTR func3, 0,0,0}
|
|
39 |
#define OOM_ENTRY(str1,str2,func1,func2,func3,a,b,c) {(const TText*)(L##str1 L" [" L##str2 L"]"), GETPTR func1,GETPTR func2, GETPTR func3,a,b,c}
|
|
40 |
|
|
41 |
typedef void (CUT_AddFavoritiesVisibility::* TestFunction)();
|
|
42 |
|
|
43 |
class TCaseInfoInternal
|
|
44 |
{
|
|
45 |
public:
|
|
46 |
const TText* iCaseName;
|
|
47 |
TestFunction iSetup;
|
|
48 |
TestFunction iMethod;
|
|
49 |
TestFunction iTeardown;
|
|
50 |
TBool iIsOOMTest;
|
|
51 |
TInt iFirstMemoryAllocation;
|
|
52 |
TInt iLastMemoryAllocation;
|
|
53 |
TPtrC CaseName() const {return TPtrC(iCaseName);};
|
|
54 |
};
|
|
55 |
|
|
56 |
const TUint32 KPhonebookAddFavoritiesVisibility = 0x00000006;
|
|
57 |
|
|
58 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
59 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
60 |
void CUT_AddFavoritiesVisibility::SetTCPromotionL(TInt aVal)
|
|
61 |
{
|
|
62 |
TInt res = iRepository->Set(KPhonebookAddFavoritiesVisibility, aVal);
|
|
63 |
STIF_ASSERT(res == KErrNone);
|
|
64 |
}
|
|
65 |
|
|
66 |
void CUT_AddFavoritiesVisibility::CmdItemVisibilityChanged( TInt /*aCmdId*/, TBool aVisible )
|
|
67 |
{
|
|
68 |
iCallbackTimer->CallbackReceived(); // fall back to test case
|
|
69 |
|
|
70 |
iCallbackReceived = ETrue;
|
|
71 |
iCallbackRes = aVisible;
|
|
72 |
|
|
73 |
if(iTestLeave)
|
|
74 |
{
|
|
75 |
User::Leave(KErrGeneral); // This is to be trapped by class under test
|
|
76 |
}
|
|
77 |
}
|
|
78 |
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
// CUT_AddFavoritiesVisibility::CUT_AddFavoritiesVisibility
|
|
81 |
// C++ default constructor can NOT contain any code, that
|
|
82 |
// might leave.
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
CUT_AddFavoritiesVisibility::CUT_AddFavoritiesVisibility()
|
|
86 |
{
|
|
87 |
|
|
88 |
}
|
|
89 |
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
// CUT_AddFavoritiesVisibility::ConstructL
|
|
92 |
// Symbian 2nd phase constructor can leave.
|
|
93 |
//
|
|
94 |
// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
|
|
95 |
// with static buffer size parameter (aStaticBufferSize). Otherwise Logger
|
|
96 |
// allocates memory from heap and therefore causes error situations with OOM
|
|
97 |
// testing. For more information about STIF Logger construction, see STIF Users
|
|
98 |
// Guide.
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
void CUT_AddFavoritiesVisibility::ConstructL()
|
|
102 |
{
|
|
103 |
//Read logger settings to check whether test case name is to be
|
|
104 |
//appended to log file name.
|
|
105 |
RSettingServer settingServer;
|
|
106 |
TInt ret = settingServer.Connect();
|
|
107 |
if(ret != KErrNone)
|
|
108 |
{
|
|
109 |
User::Leave(ret);
|
|
110 |
}
|
|
111 |
// Struct to StifLogger settigs.
|
|
112 |
TLoggerSettings loggerSettings;
|
|
113 |
// Parse StifLogger defaults from STIF initialization file.
|
|
114 |
ret = settingServer.GetLoggerSettings(loggerSettings);
|
|
115 |
if(ret != KErrNone)
|
|
116 |
{
|
|
117 |
User::Leave(ret);
|
|
118 |
}
|
|
119 |
// Close Setting server session
|
|
120 |
settingServer.Close();
|
|
121 |
iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
|
|
122 |
|
|
123 |
iStdLog = CStifLogger::NewL( KUT_AddFavoritiesVisibilityLogPath,
|
|
124 |
KUT_AddFavoritiesVisibilityLogFile);
|
|
125 |
iLog = iStdLog;
|
|
126 |
|
|
127 |
// Sample how to use logging
|
|
128 |
_LIT( KLogStart, "UT_AddFavoritiesVisibility logging starts!" );
|
|
129 |
iLog->Log( KLogStart );
|
|
130 |
|
|
131 |
iVersionLogged = EFalse;
|
|
132 |
|
|
133 |
if(!CActiveScheduler::Current())
|
|
134 |
{
|
|
135 |
iAS = new(ELeave) CActiveScheduler;
|
|
136 |
CActiveScheduler::Install(iAS);
|
|
137 |
}
|
|
138 |
|
|
139 |
}
|
|
140 |
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
// CUT_AddFavoritiesVisibility::NewL
|
|
143 |
// Two-phased constructor.
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
CUT_AddFavoritiesVisibility* CUT_AddFavoritiesVisibility::NewL()
|
|
147 |
{
|
|
148 |
CUT_AddFavoritiesVisibility* self = new (ELeave) CUT_AddFavoritiesVisibility;
|
|
149 |
|
|
150 |
CleanupStack::PushL( self );
|
|
151 |
self->ConstructL();
|
|
152 |
CleanupStack::Pop();
|
|
153 |
|
|
154 |
return self;
|
|
155 |
|
|
156 |
}
|
|
157 |
|
|
158 |
// Destructor
|
|
159 |
CUT_AddFavoritiesVisibility::~CUT_AddFavoritiesVisibility()
|
|
160 |
{
|
|
161 |
iLog = NULL;
|
|
162 |
delete iStdLog;
|
|
163 |
iStdLog = NULL;
|
|
164 |
delete iTCLog;
|
|
165 |
iTCLog = NULL;
|
|
166 |
delete iRepository;
|
|
167 |
delete iVisibilityImpl;
|
|
168 |
CActiveScheduler::Install(NULL);
|
|
169 |
delete iAS;
|
|
170 |
}
|
|
171 |
|
|
172 |
// -----------------------------------------------------------------------------
|
|
173 |
// CUT_AddFavoritiesVisibility::InitL
|
|
174 |
// InitL is used to initialize the Test Module.
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
TInt CUT_AddFavoritiesVisibility::InitL(
|
|
178 |
TFileName& /*aIniFile*/,
|
|
179 |
TBool /*aFirstTime*/ )
|
|
180 |
{
|
|
181 |
return KErrNone;
|
|
182 |
|
|
183 |
}
|
|
184 |
|
|
185 |
// -----------------------------------------------------------------------------
|
|
186 |
// CUT_AddFavoritiesVisibility::GetTestCasesL
|
|
187 |
// GetTestCases is used to inquire test cases from the Test Module. Test
|
|
188 |
// cases are stored to array of test cases. The Test Framework will be
|
|
189 |
// the owner of the data in the RPointerArray after GetTestCases return
|
|
190 |
// and it does the memory deallocation.
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
TInt CUT_AddFavoritiesVisibility::GetTestCasesL(
|
|
194 |
const TFileName& /*aConfig*/,
|
|
195 |
RPointerArray<TTestCaseInfo>& aTestCases )
|
|
196 |
{
|
|
197 |
|
|
198 |
// Loop through all test cases and create new
|
|
199 |
// TTestCaseInfo items and append items to aTestCase array
|
|
200 |
for( TInt i = 0; Case(i).iMethod != NULL; i++ )
|
|
201 |
{
|
|
202 |
|
|
203 |
// Allocate new TTestCaseInfo from heap for a testcase definition.
|
|
204 |
TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
|
|
205 |
|
|
206 |
// PushL TTestCaseInfo to CleanupStack.
|
|
207 |
CleanupStack::PushL( newCase );
|
|
208 |
|
|
209 |
// Set number for the testcase.
|
|
210 |
// When the testcase is run, this comes as a parameter to RunTestCaseL.
|
|
211 |
newCase->iCaseNumber = i;
|
|
212 |
|
|
213 |
// Set title for the test case. This is shown in UI to user.
|
|
214 |
newCase->iTitle.Copy( Case(i).CaseName() );
|
|
215 |
|
|
216 |
// Append TTestCaseInfo to the testcase array. After appended
|
|
217 |
// successfully the TTestCaseInfo object is owned (and freed)
|
|
218 |
// by the TestServer.
|
|
219 |
User::LeaveIfError(aTestCases.Append ( newCase ) );
|
|
220 |
|
|
221 |
// Pop TTestCaseInfo from the CleanupStack.
|
|
222 |
CleanupStack::Pop( newCase );
|
|
223 |
|
|
224 |
}
|
|
225 |
|
|
226 |
return KErrNone;
|
|
227 |
|
|
228 |
}
|
|
229 |
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
// CUT_AddFavoritiesVisibility::RunTestCaseL
|
|
232 |
// RunTestCaseL is used to run an individual test case specified
|
|
233 |
// by aTestCase. Test cases that can be run may be requested from
|
|
234 |
// Test Module by GetTestCases method before calling RunTestCase.
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
TInt CUT_AddFavoritiesVisibility::RunTestCaseL(
|
|
238 |
const TInt aCaseNumber,
|
|
239 |
const TFileName& /*aConfig*/,
|
|
240 |
TTestResult& aResult )
|
|
241 |
{
|
|
242 |
iResult = &aResult;
|
|
243 |
if(!iVersionLogged)
|
|
244 |
{
|
|
245 |
SendTestModuleVersion();
|
|
246 |
iVersionLogged = ETrue;
|
|
247 |
}
|
|
248 |
|
|
249 |
// Return value
|
|
250 |
TInt execStatus = KErrNone;
|
|
251 |
|
|
252 |
// Get the pointer to test case function
|
|
253 |
const TCaseInfoInternal& tmp = Case ( aCaseNumber );
|
|
254 |
|
|
255 |
_LIT( KLogStartTC, "Starting testcase [%S]" );
|
|
256 |
TPtrC caseName = tmp.CaseName();
|
|
257 |
iLog->Log( KLogStartTC, &caseName);
|
|
258 |
|
|
259 |
// Check that case number was valid
|
|
260 |
if ( tmp.iMethod != NULL )
|
|
261 |
{
|
|
262 |
//Open new log file with test case title in file name
|
|
263 |
if(iAddTestCaseTitleToLogName)
|
|
264 |
{
|
|
265 |
//Delete test case logger if exists
|
|
266 |
if(iTCLog)
|
|
267 |
{
|
|
268 |
delete iTCLog;
|
|
269 |
iTCLog = NULL;
|
|
270 |
}
|
|
271 |
|
|
272 |
TFileName logFileName;
|
|
273 |
TName title;
|
|
274 |
TestModuleIf().GetTestCaseTitleL(title);
|
|
275 |
|
|
276 |
logFileName.Format(KUT_AddFavoritiesVisibilityLogFileWithTitle, &title);
|
|
277 |
|
|
278 |
iTCLog = CStifLogger::NewL(KUT_AddFavoritiesVisibilityLogPath,
|
|
279 |
logFileName);
|
|
280 |
iLog = iTCLog;
|
|
281 |
}
|
|
282 |
|
|
283 |
|
|
284 |
TInt err = KErrNone;
|
|
285 |
TRAP(err, ( this->*(tmp.iSetup) )());
|
|
286 |
if(err!=KErrNone)
|
|
287 |
{
|
|
288 |
_LIT( KDescription, "Setup failed" );
|
|
289 |
aResult.SetResult( err, KDescription );
|
|
290 |
execStatus = KErrNone;
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
|
294 |
aResult.iResult = KErrNone;
|
|
295 |
TRAP(err, ( this->*(tmp.iMethod) )());
|
|
296 |
if(err==KErrNone)
|
|
297 |
{
|
|
298 |
_LIT( KDescription, "Test passed" );
|
|
299 |
aResult.SetResult( err, KDescription );
|
|
300 |
}
|
|
301 |
else if ( aResult.iResult == KErrNone )
|
|
302 |
{
|
|
303 |
_LIT( KDescription, "Test failed" );
|
|
304 |
aResult.SetResult( err, KDescription );
|
|
305 |
}
|
|
306 |
TRAP(err, ( this->*(tmp.iTeardown) )());
|
|
307 |
if(err!=KErrNone)
|
|
308 |
{
|
|
309 |
_LIT( KDescription, "Teardown failed" );
|
|
310 |
aResult.SetResult( err, KDescription );
|
|
311 |
execStatus = KErrNone;
|
|
312 |
}
|
|
313 |
}
|
|
314 |
}
|
|
315 |
else
|
|
316 |
{
|
|
317 |
// Valid case was not found, return error.
|
|
318 |
execStatus = KErrNotFound;
|
|
319 |
}
|
|
320 |
|
|
321 |
// Return case execution status (not the result of the case execution)
|
|
322 |
return execStatus;
|
|
323 |
|
|
324 |
}
|
|
325 |
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
// CUT_AddFavoritiesVisibility::OOMTestQueryL
|
|
328 |
// Used to check if a particular test case should be run in OOM conditions and
|
|
329 |
// which memory allocations should fail.
|
|
330 |
// -----------------------------------------------------------------------------
|
|
331 |
//
|
|
332 |
TBool CUT_AddFavoritiesVisibility::OOMTestQueryL(
|
|
333 |
const TFileName& /* aTestCaseFile */,
|
|
334 |
const TInt aCaseNumber,
|
|
335 |
TOOMFailureType& /* aFailureType */,
|
|
336 |
TInt& aFirstMemFailure,
|
|
337 |
TInt& aLastMemFailure )
|
|
338 |
{
|
|
339 |
_LIT( KLogOOMTestQueryL, "CUT_AddFavoritiesVisibility::OOMTestQueryL" );
|
|
340 |
iLog->Log( KLogOOMTestQueryL );
|
|
341 |
|
|
342 |
aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
|
|
343 |
aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
|
|
344 |
|
|
345 |
return Case( aCaseNumber ).iIsOOMTest;
|
|
346 |
|
|
347 |
}
|
|
348 |
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
// CUT_AddFavoritiesVisibility::OOMTestInitializeL
|
|
351 |
// Used to perform the test environment setup for a particular OOM test case.
|
|
352 |
// Test Modules may use the initialization file to read parameters for Test
|
|
353 |
// Module initialization but they can also have their own configure file or
|
|
354 |
// some other routine to initialize themselves.
|
|
355 |
//
|
|
356 |
// NOTE: User may add implementation for OOM test environment initialization.
|
|
357 |
// Usually no implementation is required.
|
|
358 |
// -----------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
void CUT_AddFavoritiesVisibility::OOMTestInitializeL(
|
|
361 |
const TFileName& /* aTestCaseFile */,
|
|
362 |
const TInt /* aCaseNumber */ )
|
|
363 |
{
|
|
364 |
}
|
|
365 |
|
|
366 |
// -----------------------------------------------------------------------------
|
|
367 |
// CUT_AddFavoritiesVisibility::OOMHandleWarningL
|
|
368 |
// In some cases the heap memory allocation should be skipped, either due to
|
|
369 |
// problems in the OS code or components used by the code being tested, or even
|
|
370 |
// inside the tested components which are implemented this way on purpose (by
|
|
371 |
// design), so it is important to give the tester a way to bypass allocation
|
|
372 |
// failures.
|
|
373 |
//
|
|
374 |
// NOTE: User may add implementation for OOM test warning handling. Usually no
|
|
375 |
// implementation is required.
|
|
376 |
// -----------------------------------------------------------------------------
|
|
377 |
//
|
|
378 |
void CUT_AddFavoritiesVisibility::OOMHandleWarningL(
|
|
379 |
const TFileName& /* aTestCaseFile */,
|
|
380 |
const TInt /* aCaseNumber */,
|
|
381 |
TInt& /* aFailNextValue */ )
|
|
382 |
{
|
|
383 |
}
|
|
384 |
|
|
385 |
// -----------------------------------------------------------------------------
|
|
386 |
// CUT_AddFavoritiesVisibility::OOMTestFinalizeL
|
|
387 |
// Used to perform the test environment cleanup for a particular OOM test case.
|
|
388 |
//
|
|
389 |
// NOTE: User may add implementation for OOM test environment finalization.
|
|
390 |
// Usually no implementation is required.
|
|
391 |
// -----------------------------------------------------------------------------
|
|
392 |
//
|
|
393 |
void CUT_AddFavoritiesVisibility::OOMTestFinalizeL(
|
|
394 |
const TFileName& /* aTestCaseFile */,
|
|
395 |
const TInt /* aCaseNumber */ )
|
|
396 |
{
|
|
397 |
}
|
|
398 |
|
|
399 |
//-----------------------------------------------------------------------------
|
|
400 |
// CUT_AddFavoritiesVisibility::SendTestModuleVersion
|
|
401 |
// Method used to send version of test module
|
|
402 |
//-----------------------------------------------------------------------------
|
|
403 |
//
|
|
404 |
void CUT_AddFavoritiesVisibility::SendTestModuleVersion()
|
|
405 |
{
|
|
406 |
TVersion moduleVersion;
|
|
407 |
moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
|
|
408 |
moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
|
|
409 |
moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
|
|
410 |
|
|
411 |
TFileName moduleName;
|
|
412 |
moduleName = _L("UT_AddFavoritiesVisibility.dll");
|
|
413 |
|
|
414 |
TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName);
|
|
415 |
}
|
|
416 |
|
|
417 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
418 |
|
|
419 |
// -----------------------------------------------------------------------------
|
|
420 |
// LibEntryL is a polymorphic Dll entry point
|
|
421 |
// Returns: CTestModuleBase*: Pointer to Test Module object
|
|
422 |
// -----------------------------------------------------------------------------
|
|
423 |
//
|
|
424 |
EXPORT_C CTestModuleBase* LibEntryL()
|
|
425 |
{
|
|
426 |
return CUT_AddFavoritiesVisibility::NewL();
|
|
427 |
|
|
428 |
}
|
|
429 |
|
|
430 |
// -----------------------------------------------------------------------------
|
|
431 |
// SetRequirements handles test module parameters(implements evolution
|
|
432 |
// version 1 for test module's heap and stack sizes configuring).
|
|
433 |
// Returns: TInt: Symbian error code.
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/,
|
|
437 |
TUint32& /*aParameterValid*/ )
|
|
438 |
{
|
|
439 |
|
|
440 |
/* --------------------------------- NOTE ---------------------------------
|
|
441 |
USER PANICS occurs in test thread creation when:
|
|
442 |
1) "The panic occurs when the value of the stack size is negative."
|
|
443 |
2) "The panic occurs if the minimum heap size specified is less
|
|
444 |
than KMinHeapSize".
|
|
445 |
KMinHeapSize: "Functions that require a new heap to be allocated will
|
|
446 |
either panic, or will reset the required heap size to this value if
|
|
447 |
a smaller heap size is specified".
|
|
448 |
3) "The panic occurs if the minimum heap size specified is greater than
|
|
449 |
the maximum size to which the heap can grow".
|
|
450 |
Other:
|
|
451 |
1) Make sure that your hardware or Symbian OS is supporting given sizes.
|
|
452 |
e.g. Hardware might support only sizes that are divisible by four.
|
|
453 |
------------------------------- NOTE end ------------------------------- */
|
|
454 |
|
|
455 |
// Normally STIF uses default heap and stack sizes for test thread, see:
|
|
456 |
// KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
|
|
457 |
// If needed heap and stack sizes can be configured here by user. Remove
|
|
458 |
// comments and define sizes.
|
|
459 |
|
|
460 |
/*
|
|
461 |
aParameterValid = KStifTestModuleParameterChanged;
|
|
462 |
|
|
463 |
CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
|
|
464 |
// Stack size
|
|
465 |
param->iTestThreadStackSize= 16384; // 16K stack
|
|
466 |
// Heap sizes
|
|
467 |
param->iTestThreadMinHeap = 4096; // 4K heap min
|
|
468 |
param->iTestThreadMaxHeap = 1048576;// 1M heap max
|
|
469 |
|
|
470 |
aTestModuleParam = param;
|
|
471 |
*/
|
|
472 |
return KErrNone;
|
|
473 |
|
|
474 |
}
|
|
475 |
|
|
476 |
// -----------------------------------------------------------------------------
|
|
477 |
// CUT_AddFavoritiesVisibility::Case
|
|
478 |
// Returns a test case by number.
|
|
479 |
//
|
|
480 |
// This function contains an array of all available test cases
|
|
481 |
// i.e pair of case name and test function. If case specified by parameter
|
|
482 |
// aCaseNumber is found from array, then that item is returned.
|
|
483 |
//
|
|
484 |
// The reason for this rather complicated function is to specify all the
|
|
485 |
// test cases only in one place. It is not necessary to understand how
|
|
486 |
// function pointers to class member functions works when adding new test
|
|
487 |
// cases. See function body for instructions how to add new test case.
|
|
488 |
// -----------------------------------------------------------------------------
|
|
489 |
//
|
|
490 |
const TCaseInfoInternal& CUT_AddFavoritiesVisibility::Case (
|
|
491 |
const TInt aCaseNumber ) const
|
|
492 |
{
|
|
493 |
|
|
494 |
/**
|
|
495 |
* To add new test cases, implement new test case function and add new
|
|
496 |
* line to KCases array specify the name of the case and the function
|
|
497 |
* doing the test case
|
|
498 |
* In practice, do following
|
|
499 |
* 1) Make copy of existing test case function and change its name
|
|
500 |
* and functionality. Note that the function must be added to
|
|
501 |
* UT_AddFavoritiesVisibility.cpp file and to UT_AddFavoritiesVisibility.h
|
|
502 |
* header file.
|
|
503 |
*
|
|
504 |
* 2) Add entry to following KCases array either by using:
|
|
505 |
*
|
|
506 |
* 2.1: FUNCENTRY or ENTRY macro
|
|
507 |
* ENTRY macro takes two parameters: test case name and test case
|
|
508 |
* function name.
|
|
509 |
*
|
|
510 |
* FUNCENTRY macro takes only test case function name as a parameter and
|
|
511 |
* uses that as a test case name and test case function name.
|
|
512 |
*
|
|
513 |
* Or
|
|
514 |
*
|
|
515 |
* 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
|
|
516 |
* only with OOM (Out-Of-Memory) testing!
|
|
517 |
*
|
|
518 |
* OOM_ENTRY macro takes five parameters: test case name, test case
|
|
519 |
* function name, TBool which specifies is method supposed to be run using
|
|
520 |
* OOM conditions, TInt value for first heap memory allocation failure and
|
|
521 |
* TInt value for last heap memory allocation failure.
|
|
522 |
*
|
|
523 |
* OOM_FUNCENTRY macro takes test case function name as a parameter and uses
|
|
524 |
* that as a test case name, TBool which specifies is method supposed to be
|
|
525 |
* run using OOM conditions, TInt value for first heap memory allocation
|
|
526 |
* failure and TInt value for last heap memory allocation failure.
|
|
527 |
*/
|
|
528 |
|
|
529 |
static TCaseInfoInternal const KCases[] =
|
|
530 |
{
|
|
531 |
// [test cases entries] - do not remove
|
|
532 |
|
|
533 |
// NOTE: When compiled to GCCE, there must be Classname::
|
|
534 |
// declaration in front of the method name, e.g.
|
|
535 |
// CUT_AddFavoritiesVisibility::PrintTest. Otherwise the compiler
|
|
536 |
// gives errors.
|
|
537 |
//Removed for raptor build
|
|
538 |
//#include "UT_AddFavoritiesVisibilitytesttable.cpp"
|
|
539 |
|
|
540 |
ENTRY("AlwaysON","CUT_AddFavoritiesVisibility",
|
|
541 |
CUT_AddFavoritiesVisibility::SetupAlwaysON,
|
|
542 |
CUT_AddFavoritiesVisibility::TestAlwaysOnL,
|
|
543 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
544 |
|
|
545 |
ENTRY("AlwaysOFF","CUT_AddFavoritiesVisibility",
|
|
546 |
CUT_AddFavoritiesVisibility::SetupAlwaysOFF,
|
|
547 |
CUT_AddFavoritiesVisibility::TestAlwaysOFFL,
|
|
548 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
549 |
|
|
550 |
ENTRY("FirstTimeUse","CUT_AddFavoritiesVisibility",
|
|
551 |
CUT_AddFavoritiesVisibility::SetupFirstTimeUse,
|
|
552 |
CUT_AddFavoritiesVisibility::TestFirstTimeUseL,
|
|
553 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
554 |
|
|
555 |
ENTRY("TCPromotionMinus1","CUT_AddFavoritiesVisibility",
|
|
556 |
CUT_AddFavoritiesVisibility::SetupTCPromotionMinus1,
|
|
557 |
CUT_AddFavoritiesVisibility::TestAlwaysOFFL,
|
|
558 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
559 |
|
|
560 |
ENTRY("TCPromotionMinus5000","CUT_AddFavoritiesVisibility",
|
|
561 |
CUT_AddFavoritiesVisibility::SetupTCPromotionMinus5000,
|
|
562 |
CUT_AddFavoritiesVisibility::TestAlwaysOFFL,
|
|
563 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
564 |
|
|
565 |
ENTRY("TCPromotion3","CUT_AddFavoritiesVisibility",
|
|
566 |
CUT_AddFavoritiesVisibility::SetupTCPromotion3,
|
|
567 |
CUT_AddFavoritiesVisibility::TestAlwaysOFFL,
|
|
568 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
569 |
|
|
570 |
ENTRY("TCPromotion9999","CUT_AddFavoritiesVisibility",
|
|
571 |
CUT_AddFavoritiesVisibility::SetupTCPromotion9999,
|
|
572 |
CUT_AddFavoritiesVisibility::TestAlwaysOFFL,
|
|
573 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
574 |
|
|
575 |
ENTRY("TestLeaveInClientCallback","CUT_AddFavoritiesVisibility",
|
|
576 |
CUT_AddFavoritiesVisibility::SetupAlwaysON,
|
|
577 |
CUT_AddFavoritiesVisibility::TestLeaveInClientCallbackL,
|
|
578 |
CUT_AddFavoritiesVisibility::Teardown),
|
|
579 |
|
|
580 |
};
|
|
581 |
|
|
582 |
// Verify that case number is valid
|
|
583 |
if( (TUint) aCaseNumber >= sizeof( KCases ) /
|
|
584 |
sizeof( TCaseInfoInternal ) )
|
|
585 |
{
|
|
586 |
// Invalid case, construct empty object
|
|
587 |
static const TCaseInfoInternal nullCase = {NULL, NULL, NULL,NULL,EFalse,0,0};
|
|
588 |
return nullCase;
|
|
589 |
}
|
|
590 |
|
|
591 |
return KCases[ aCaseNumber ];
|
|
592 |
}
|
|
593 |
|
|
594 |
// End of File
|