33
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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: Tests for domain AIWDialData API.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "AiwDialDataTests.h"
|
|
22 |
|
|
23 |
#include <e32math.h>
|
|
24 |
#include <aiwdialdata.h>
|
|
25 |
#include <aiwdialdataext.h>
|
|
26 |
#include <aiwgenericparam.h>
|
|
27 |
// ============================= LOCAL FUNCTIONS ===============================
|
|
28 |
|
|
29 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
30 |
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
// CAiwDialDataTests::Case
|
|
33 |
// Returns a test case by number.
|
|
34 |
//
|
|
35 |
// This function contains an array of all available test cases
|
|
36 |
// i.e pair of case name and test function. If case specified by parameter
|
|
37 |
// aCaseNumber is found from array, then that item is returned.
|
|
38 |
//
|
|
39 |
// The reason for this rather complicated function is to specify all the
|
|
40 |
// test cases only in one place. It is not necessary to understand how
|
|
41 |
// function pointers to class member functions works when adding new test
|
|
42 |
// cases. See function body for instructions how to add new test case.
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
const TCaseInfo CAiwDialDataTests::Case (
|
|
46 |
const TInt aCaseNumber ) const
|
|
47 |
{
|
|
48 |
|
|
49 |
/**
|
|
50 |
* To add new test cases, implement new test case function and add new
|
|
51 |
* line to KCases array specify the name of the case and the function
|
|
52 |
* doing the test case
|
|
53 |
* In practice, do following
|
|
54 |
* 1) Make copy of existing test case function and change its name
|
|
55 |
* and functionality. Note that the function must be added to
|
|
56 |
* AiwDialDataTests.cpp file and to AiwDialDataTests.h
|
|
57 |
* header file.
|
|
58 |
*
|
|
59 |
* 2) Add entry to following KCases array either by using:
|
|
60 |
*
|
|
61 |
* 2.1: FUNCENTRY or ENTRY macro
|
|
62 |
* ENTRY macro takes two parameters: test case name and test case
|
|
63 |
* function name.
|
|
64 |
*
|
|
65 |
* FUNCENTRY macro takes only test case function name as a parameter and
|
|
66 |
* uses that as a test case name and test case function name.
|
|
67 |
*
|
|
68 |
* Or
|
|
69 |
*
|
|
70 |
* 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
|
|
71 |
* only with OOM (Out-Of-Memory) testing!
|
|
72 |
*
|
|
73 |
* OOM_ENTRY macro takes five parameters: test case name, test case
|
|
74 |
* function name, TBool which specifies is method supposed to be run using
|
|
75 |
* OOM conditions, TInt value for first heap memory allocation failure and
|
|
76 |
* TInt value for last heap memory allocation failure.
|
|
77 |
*
|
|
78 |
* OOM_FUNCENTRY macro takes test case function name as a parameter and uses
|
|
79 |
* that as a test case name, TBool which specifies is method supposed to be
|
|
80 |
* run using OOM conditions, TInt value for first heap memory allocation
|
|
81 |
* failure and TInt value for last heap memory allocation failure.
|
|
82 |
*/
|
|
83 |
|
|
84 |
static TCaseInfoInternal const KCases[] =
|
|
85 |
{
|
|
86 |
// To add new test cases, add new items to this array
|
|
87 |
|
|
88 |
// NOTE: When compiled to GCCE, there must be Classname::
|
|
89 |
// declaration in front of the method name, e.g.
|
|
90 |
// CAiwDialDataTests::PrintTest. Otherwise the compiler
|
|
91 |
// gives errors.
|
|
92 |
|
|
93 |
FUNCENTRY( CAiwDialDataTests::ConstructionTestL ),
|
|
94 |
FUNCENTRY( CAiwDialDataTests::SetAndGetTestL ),
|
|
95 |
FUNCENTRY( CAiwDialDataTests::ExtConstructionTestL ),
|
|
96 |
FUNCENTRY( CAiwDialDataTests::ExtSetAndGetTestL ),
|
|
97 |
// Example how to use OOM functionality
|
|
98 |
//OOM_ENTRY( "Loop test with OOM", CAiwDialDataTests::LoopTest, ETrue, 2, 3),
|
|
99 |
//OOM_FUNCENTRY( CAiwDialDataTests::PrintTest, ETrue, 1, 3 ),
|
|
100 |
};
|
|
101 |
|
|
102 |
// Verify that case number is valid
|
|
103 |
if( (TUint) aCaseNumber >= sizeof( KCases ) /
|
|
104 |
sizeof( TCaseInfoInternal ) )
|
|
105 |
{
|
|
106 |
// Invalid case, construct empty object
|
|
107 |
TCaseInfo null( (const TText*) L"" );
|
|
108 |
null.iMethod = NULL;
|
|
109 |
null.iIsOOMTest = EFalse;
|
|
110 |
null.iFirstMemoryAllocation = 0;
|
|
111 |
null.iLastMemoryAllocation = 0;
|
|
112 |
return null;
|
|
113 |
}
|
|
114 |
|
|
115 |
// Construct TCaseInfo object and return it
|
|
116 |
TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
|
|
117 |
tmp.iMethod = KCases[ aCaseNumber ].iMethod;
|
|
118 |
tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
|
|
119 |
tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
|
|
120 |
tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
|
|
121 |
return tmp;
|
|
122 |
|
|
123 |
}
|
|
124 |
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
// Tests CAiwDialData construction
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
TInt CAiwDialDataTests::ConstructionTestL( TTestResult& /*aResult*/ )
|
|
130 |
{
|
|
131 |
CAiwDialData* dialData = CAiwDialData::NewL();
|
|
132 |
delete dialData;
|
|
133 |
|
|
134 |
dialData = CAiwDialData::NewLC();
|
|
135 |
|
|
136 |
TL( dialData->PhoneNumber() == KNullDesC() );
|
|
137 |
T1L( dialData->CallType(), CAiwDialData::EAIWVoice );
|
|
138 |
T1L( dialData->WindowGroup(), 0 );
|
|
139 |
|
|
140 |
CAiwGenericParamList* list = CAiwGenericParamList::NewLC();
|
|
141 |
dialData->FillInParamListL( *list );
|
|
142 |
|
|
143 |
CleanupStack::PopAndDestroy( 2, dialData );
|
|
144 |
|
|
145 |
return KErrNone;
|
|
146 |
}
|
|
147 |
|
|
148 |
// -----------------------------------------------------------------------------
|
|
149 |
// Tests CAiwDialData setting and getting values.
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
TInt CAiwDialDataTests::SetAndGetTestL( TTestResult& /*aResult*/ )
|
|
153 |
{
|
|
154 |
_LIT( KPhoneNumber, "1234567890");
|
|
155 |
|
|
156 |
CAiwDialData* dialData = CAiwDialData::NewLC();
|
|
157 |
|
|
158 |
dialData->SetPhoneNumberL( KPhoneNumber );
|
|
159 |
dialData->SetCallType( CAiwDialData::EAIWVideo );
|
|
160 |
dialData->SetWindowGroup( 1 );
|
|
161 |
|
|
162 |
TL( dialData->PhoneNumber() == KPhoneNumber() );
|
|
163 |
T1L( dialData->CallType(), CAiwDialData::EAIWVideo );
|
|
164 |
T1L( dialData->WindowGroup(), 1 );
|
|
165 |
|
|
166 |
CAiwGenericParamList* list = CAiwGenericParamList::NewLC();
|
|
167 |
dialData->FillInParamListL( *list );
|
|
168 |
|
|
169 |
CleanupStack::PopAndDestroy( 2, dialData );
|
|
170 |
|
|
171 |
return KErrNone;
|
|
172 |
}
|
|
173 |
|
|
174 |
// -----------------------------------------------------------------------------
|
|
175 |
// Tests CAiwDialDataExt construction
|
|
176 |
// -----------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
TInt CAiwDialDataTests::ExtConstructionTestL( TTestResult& /*aResult*/ )
|
|
179 |
{
|
|
180 |
CAiwDialDataExt* dialData = CAiwDialDataExt::NewL();
|
|
181 |
delete dialData;
|
|
182 |
|
|
183 |
dialData = CAiwDialDataExt::NewLC();
|
|
184 |
|
|
185 |
TL( dialData->PhoneNumber() == KNullDesC() );
|
|
186 |
T1L( dialData->CallType(), CAiwDialData::EAIWVoice );
|
|
187 |
T1L( dialData->WindowGroup(), 0 );
|
|
188 |
TL( !dialData->InitiateCall() );
|
|
189 |
TL( dialData->Name() == KNullDesC() );
|
|
190 |
T1L( dialData->Redial(), AIWDialDataExt::KAIWRedialDefault );
|
|
191 |
TL( dialData->ShowNumber() );
|
|
192 |
TL( dialData->ContactLink() == KNullDesC8() );
|
|
193 |
|
|
194 |
CAiwGenericParamList* list = CAiwGenericParamList::NewLC();
|
|
195 |
dialData->FillInParamListL( *list );
|
|
196 |
|
|
197 |
CleanupStack::PopAndDestroy( 2, dialData );
|
|
198 |
|
|
199 |
return KErrNone;
|
|
200 |
|
|
201 |
}
|
|
202 |
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
// Tests CAiwDialDataExt setting and getting values.
|
|
205 |
// -----------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
TInt CAiwDialDataTests::ExtSetAndGetTestL( TTestResult& /*aResult*/ )
|
|
208 |
{
|
|
209 |
_LIT( KPhoneNumber, "1234567890");
|
|
210 |
_LIT8( KContactLink, "ContactLink");
|
|
211 |
_LIT( KName, "Mr Smith" );
|
|
212 |
|
|
213 |
CAiwDialDataExt* dialData = CAiwDialDataExt::NewLC();
|
|
214 |
|
|
215 |
dialData->SetPhoneNumberL( KPhoneNumber );
|
|
216 |
dialData->SetCallType( CAiwDialData::EAIWVideo );
|
|
217 |
dialData->SetWindowGroup( 1 );
|
|
218 |
dialData->SetInitiateCall( ETrue );
|
|
219 |
dialData->SetNameL( KName );
|
|
220 |
|
|
221 |
dialData->SetRedial( AIWDialDataExt::KAIWRedialOff );
|
|
222 |
dialData->SetShowNumber( EFalse );
|
|
223 |
dialData->SetContactLinkL( KContactLink );
|
|
224 |
|
|
225 |
TL( dialData->PhoneNumber() == KPhoneNumber() );
|
|
226 |
T1L( dialData->CallType(), CAiwDialData::EAIWVideo );
|
|
227 |
T1L( dialData->WindowGroup(), 1 );
|
|
228 |
TL( dialData->InitiateCall() );
|
|
229 |
TL( dialData->Name() == KName() );
|
|
230 |
T1L( dialData->Redial(), AIWDialDataExt::KAIWRedialOff );
|
|
231 |
TL( !dialData->ShowNumber() );
|
|
232 |
TL( dialData->ContactLink() == KContactLink() );
|
|
233 |
|
|
234 |
|
|
235 |
CAiwGenericParamList* list = CAiwGenericParamList::NewLC();
|
|
236 |
dialData->FillInParamListL( *list );
|
|
237 |
|
|
238 |
CleanupStack::PopAndDestroy( 2, dialData );
|
|
239 |
|
|
240 |
return KErrNone;
|
|
241 |
}
|
|
242 |
|
|
243 |
|
|
244 |
// End of File
|