|
1 /* |
|
2 * Copyright (c) 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: Implementation of the MT_MProEngProfileNameArray test class. |
|
15 * |
|
16 */ |
|
17 |
|
18 //////////////////////////////////////////////////////////////////////// |
|
19 // MT_MProEngProfileNameArray.cpp |
|
20 // |
|
21 |
|
22 // CLASS HEADER |
|
23 #include "MT_MProEngProfileNameArray.h" |
|
24 |
|
25 // EXTERNAL INCLUDES |
|
26 #include <EUnitMacros.h> |
|
27 #include <MProEngProfileNameArray.h> |
|
28 #include <MProEngProfile.h> |
|
29 #include <MProEngEngine.h> |
|
30 #include "MProfileEngineExtended.h" |
|
31 #include "MProfile.h" |
|
32 #include "MProfileName.h" |
|
33 #include "MProfilesNamesArray.h" |
|
34 #include "MProfileExtended.h" |
|
35 #include <ProEngFactory.h> |
|
36 #include <Profile.hrh> |
|
37 |
|
38 // INTERNAL INCLUDES |
|
39 #include "T_ProfileTestTools.h" |
|
40 |
|
41 MT_MProEngProfileNameArray* MT_MProEngProfileNameArray::NewL() |
|
42 { |
|
43 MT_MProEngProfileNameArray* self = MT_MProEngProfileNameArray::NewLC(); |
|
44 CleanupStack::Pop(); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 MT_MProEngProfileNameArray* MT_MProEngProfileNameArray::NewLC() |
|
50 { |
|
51 MT_MProEngProfileNameArray* self = new( ELeave ) MT_MProEngProfileNameArray(); |
|
52 CleanupStack::PushL( self ); |
|
53 |
|
54 self->ConstructL(); |
|
55 |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 MT_MProEngProfileNameArray::~MT_MProEngProfileNameArray() |
|
61 { |
|
62 if( iInternalEngine ) |
|
63 { |
|
64 iInternalEngine->Release(); |
|
65 iInternalEngine = NULL; |
|
66 } |
|
67 if( iEngine ) |
|
68 { |
|
69 iEngine->Release(); |
|
70 iEngine = NULL; |
|
71 } |
|
72 } |
|
73 |
|
74 |
|
75 MT_MProEngProfileNameArray::MT_MProEngProfileNameArray() |
|
76 { |
|
77 } |
|
78 |
|
79 void MT_MProEngProfileNameArray::ConstructL() |
|
80 { |
|
81 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
82 // It generates the test case table. |
|
83 CEUnitTestSuiteClass::ConstructL(); |
|
84 iInternalEngine = CreateProfileEngineExtendedL(); |
|
85 iEngine = ProEngFactory::NewEngineL(); |
|
86 } |
|
87 |
|
88 |
|
89 void MT_MProEngProfileNameArray::SetupL() |
|
90 { |
|
91 iArray = iEngine->ProfileNameArrayLC(); |
|
92 CleanupStack::Pop(); // iArray |
|
93 iInternalArray = iInternalEngine->ProfilesNamesArrayLC(); |
|
94 CleanupStack::Pop(); // iInternalArray |
|
95 } |
|
96 |
|
97 void MT_MProEngProfileNameArray::SetupDynamicProfilesL() |
|
98 { |
|
99 MProfileExtended* internalProfile( iInternalEngine->CreateProfileL() ); |
|
100 if( internalProfile ) |
|
101 { |
|
102 iProfileId = ( internalProfile->ProfileName().Id() ); |
|
103 internalProfile->Release(); |
|
104 } |
|
105 SetupL(); |
|
106 } |
|
107 |
|
108 void MT_MProEngProfileNameArray::Teardown() |
|
109 { |
|
110 delete iArray; |
|
111 delete iInternalArray; |
|
112 } |
|
113 |
|
114 void MT_MProEngProfileNameArray::TeardownDynamicProfiles() |
|
115 { |
|
116 Teardown(); |
|
117 TRAP_IGNORE( iInternalEngine->DeleteProfileL( iProfileId ) ); |
|
118 } |
|
119 |
|
120 |
|
121 void MT_MProEngProfileNameArray::ProfileIdTestL() |
|
122 { |
|
123 TInt count( iArray->MdcaCount() ); |
|
124 TInt internalCount( iInternalArray->MdcaCount() ); |
|
125 EUNIT_ASSERT( count == internalCount ); |
|
126 for( TInt i( 0 ); i<internalCount; ++i ) |
|
127 { |
|
128 TInt id1( iArray->ProfileId(i) ); |
|
129 TInt id2( iInternalArray->ProfileName(i)->Id() ); |
|
130 EUNIT_ASSERT( id1 == id2 ); |
|
131 } |
|
132 } |
|
133 |
|
134 |
|
135 void MT_MProEngProfileNameArray::FindByIdTestL() |
|
136 { |
|
137 TInt lastId( EProfilePagerId + 1 ); |
|
138 #ifdef __OFFLINE_MODE |
|
139 lastId = EProfileOffLineId + 1; |
|
140 #endif // __OFFLINE_MODE |
|
141 #ifdef __DRIVE_MODE |
|
142 lastId = EProfileDriveId + 1; |
|
143 #endif // __DRIVE_MODE |
|
144 // i<=lastId: tests also the first id which isn't found |
|
145 for( TInt i( 0 ); i<=lastId; ++i ) |
|
146 { |
|
147 EUNIT_ASSERT( iArray->FindById(i) == iInternalArray->FindById(i) ); |
|
148 } |
|
149 } |
|
150 |
|
151 |
|
152 void MT_MProEngProfileNameArray::FindByNameTestL() |
|
153 { |
|
154 EUNIT_ASSERT( iArray->FindByName(KProfileGeneralName) == |
|
155 iInternalArray->FindByName(KProfileGeneralName) ); |
|
156 EUNIT_ASSERT( iArray->FindByName(KProfileSilentName) == |
|
157 iInternalArray->FindByName(KProfileSilentName) ); |
|
158 EUNIT_ASSERT( iArray->FindByName(KProfileMeetingName) == |
|
159 iInternalArray->FindByName(KProfileMeetingName) ); |
|
160 EUNIT_ASSERT( iArray->FindByName(KProfileOutdoorName) == |
|
161 iInternalArray->FindByName(KProfileOutdoorName) ); |
|
162 EUNIT_ASSERT( iArray->FindByName(KProfilePagerName) == |
|
163 iInternalArray->FindByName(KProfilePagerName) ); |
|
164 #ifdef __OFFLINE_MODE |
|
165 EUNIT_ASSERT( iArray->FindByName(KProfileOfflineName) == |
|
166 iInternalArray->FindByName(KProfileOfflineName) ); |
|
167 #endif |
|
168 #ifdef __DRIVE_MODE |
|
169 EUNIT_ASSERT( iArray->FindByName(KProfileDriveName) == |
|
170 iInternalArray->FindByName(KProfileDriveName) ); |
|
171 #endif |
|
172 EUNIT_ASSERT( iArray->FindByName(KProfileInvalidName) == |
|
173 iInternalArray->FindByName(KProfileInvalidName) ); |
|
174 } |
|
175 |
|
176 void MT_MProEngProfileNameArray::FindByIdDynamicProfileTestL() |
|
177 { |
|
178 EUNIT_ASSERT( iArray->FindById( iProfileId ) == |
|
179 iInternalArray->FindById( iProfileId ) ); |
|
180 } |
|
181 |
|
182 void MT_MProEngProfileNameArray::FindByNameDynamicProfileTestL() |
|
183 { |
|
184 EUNIT_ASSERT( iArray->FindByName(KProfileDynamicName) == |
|
185 iInternalArray->FindByName(KProfileDynamicName) ); |
|
186 } |
|
187 |
|
188 EUNIT_BEGIN_TEST_TABLE( |
|
189 MT_MProEngProfileNameArray, |
|
190 "Profile Name Array Wrapper Test cases.", |
|
191 "MODULE" ) |
|
192 |
|
193 EUNIT_TEST( |
|
194 "Get Profile Id by index test", |
|
195 "MProEngProfileNameArray", |
|
196 "ProfileId", |
|
197 "FUNCTIONALITY", |
|
198 SetupL, |
|
199 ProfileIdTestL, |
|
200 Teardown) |
|
201 |
|
202 EUNIT_TEST( |
|
203 "Find index by Profile ID test", |
|
204 "MProEngProfileNameArray", |
|
205 "FindById", |
|
206 "FUNCTIONALITY", |
|
207 SetupL, |
|
208 FindByIdTestL, |
|
209 Teardown) |
|
210 |
|
211 EUNIT_TEST( |
|
212 "Find index by Profile name test", |
|
213 "MProEngProfileNameArray", |
|
214 "FindByName", |
|
215 "FUNCTIONALITY", |
|
216 SetupL, |
|
217 FindByNameTestL, |
|
218 Teardown) |
|
219 |
|
220 EUNIT_TEST( |
|
221 "Find index by Dynamic Profile ID test", |
|
222 "MProEngProfileNameArray", |
|
223 "FindById", |
|
224 "FUNCTIONALITY", |
|
225 SetupDynamicProfilesL, |
|
226 FindByIdDynamicProfileTestL, |
|
227 TeardownDynamicProfiles) |
|
228 |
|
229 EUNIT_TEST( |
|
230 "Find index by Dynamic Profile name test", |
|
231 "MProEngProfileNameArray", |
|
232 "FindByName", |
|
233 "FUNCTIONALITY", |
|
234 SetupDynamicProfilesL, |
|
235 FindByNameDynamicProfileTestL, |
|
236 TeardownDynamicProfiles) |
|
237 |
|
238 EUNIT_END_TEST_TABLE |
|
239 |