|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * ?description_line |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "FT_CPosTp668.h" |
|
22 |
|
23 #include <EPos_CPosLmDatabaseManager.h> |
|
24 #include <EPos_CPosLandmarkDatabase.h> |
|
25 #include <EPos_CPosLandmarkCategory.h> |
|
26 #include <EPos_CPosLmCategoryManager.h> |
|
27 |
|
28 // CONSTANTS |
|
29 _LIT(KSetCapPath, "c:\\sys\\bin\\setcap.exe"); |
|
30 // Nr of tests in this TP |
|
31 const TInt KNrOfTests = 12; |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // Destructor |
|
36 CPosTp668::~CPosTp668() |
|
37 { |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CPosTp668::GetName |
|
42 // |
|
43 // (other items were commented in a header). |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 |
|
47 void CPosTp668::GetName(TDes& aName) const |
|
48 { |
|
49 _LIT(KTestName0, "SetCap-TP109"); |
|
50 aName = KTestName0; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CPosTp668::StartL |
|
55 // |
|
56 // (other items were commented in a header). |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 void CPosTp668::StartL() |
|
60 { |
|
61 iLog->Put(_L("StartL")); |
|
62 |
|
63 SetupTestPartL(0); |
|
64 SetupTestPartL(1); |
|
65 SetupTestPartL(2); |
|
66 SetupTestPartL(3); |
|
67 SetupTestPartL(4); |
|
68 SetupTestPartL(5); |
|
69 SetupTestPartL(6); |
|
70 SetupTestPartL(7); |
|
71 SetupTestPartL(8); |
|
72 SetupTestPartL(9); |
|
73 SetupTestPartL(10); |
|
74 SetupTestPartL(11); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------- |
|
78 // CPosTp668::SetupTestPartL |
|
79 // |
|
80 // (other items were commented in a header). |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 void CPosTp668::SetupTestPartL(TInt aIndex) |
|
84 { |
|
85 iLog->Put(_L("StartL(TInt aIndex)")); |
|
86 /* |
|
87 #ifdef __WINS__ |
|
88 _LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!"); |
|
89 LogErrorAndLeave(KNotOnWins); |
|
90 |
|
91 #endif |
|
92 */ |
|
93 TBuf<20> capability; |
|
94 switch (aIndex) |
|
95 { |
|
96 case 0: |
|
97 iLog->Put(_L("Part1")); |
|
98 capability.Zero(); |
|
99 // Set to no capabilites at all |
|
100 capability.Append(_L("0")); |
|
101 break; |
|
102 |
|
103 case 1: |
|
104 iLog->Put(_L("Part2")); |
|
105 // Set to All capabilities of CAP_CLIENT_DLL but ReadUserData |
|
106 capability.Append(_L("37FFE")); |
|
107 break; |
|
108 |
|
109 case 2: |
|
110 iLog->Put(_L("Part3")); |
|
111 // Set to All capabilities of CAP_CLIENT_DLL but WriteUserData |
|
112 capability.Append(_L("2FFFE")); |
|
113 break; |
|
114 |
|
115 case 3: |
|
116 iLog->Put(_L("Part4")); |
|
117 // Set to All capabilities of CAP_CLIENT_DLL but WriteUserData and ReadUserData |
|
118 capability.Append(_L("27FFE")); |
|
119 break; |
|
120 |
|
121 case 4: |
|
122 iLog->Put(_L("Part5")); |
|
123 // Set to all capabilities of CAP_CLIENT_DLL |
|
124 capability.Append(_L("3FFFE")); |
|
125 break; |
|
126 |
|
127 case 5: |
|
128 iLog->Put(_L("Part6")); |
|
129 // Set to Only TCB |
|
130 capability.Append(_L("1")); |
|
131 break; |
|
132 |
|
133 case 6: |
|
134 iLog->Put(_L("Part7")); |
|
135 // Set to All capabilities but CAP_RECOGNIZER_DLL and TCB |
|
136 capability.Append(_L("3FEFE")); |
|
137 break; |
|
138 |
|
139 case 7: |
|
140 iLog->Put(_L("Part8")); |
|
141 // Set to Only CAP_RECOGNIZER_DLL |
|
142 capability.Append(_L("100")); |
|
143 break; |
|
144 |
|
145 case 8: |
|
146 iLog->Put(_L("Part9")); |
|
147 // Set to Only CAP_RECOGNIZER_DLL and ReadUserData |
|
148 capability.Append(_L("8100")); |
|
149 break; |
|
150 |
|
151 case 9: |
|
152 iLog->Put(_L("Part10")); |
|
153 // Set to All capabilities but CAP_SERVER_DLL and TCB |
|
154 capability.Append(_L("ECE")); |
|
155 break; |
|
156 |
|
157 case 10: |
|
158 iLog->Put(_L("Part11")); |
|
159 // Set to CAP_SERVER_DLL |
|
160 capability.Append(_L("3F130")); |
|
161 break; |
|
162 |
|
163 case 11: |
|
164 iLog->Put(_L("Part12")); |
|
165 // Set to CAP_SERVER_DLL and CommDD |
|
166 capability.Append(_L("3F132")); |
|
167 break; |
|
168 |
|
169 default: |
|
170 iLog->Put(_L("Default")); |
|
171 LogErrorAndLeave(_L("We should never come here")); |
|
172 break; |
|
173 } |
|
174 // Only for target, on winscw use bat-script |
|
175 RProcess execlient; |
|
176 RFile file; |
|
177 RFs fileSession; |
|
178 User::LeaveIfError(fileSession.Connect()); |
|
179 CleanupClosePushL(fileSession); |
|
180 CleanupClosePushL(file); |
|
181 CFileMan* fileMan = CFileMan::NewL(fileSession); |
|
182 CleanupStack::PushL(fileMan); |
|
183 |
|
184 TBuf<100> buf; |
|
185 |
|
186 buf.Append(_L("CapabilityTests.exe ")); |
|
187 buf.Append(capability); |
|
188 buf.Append(_L(" CapabilityTests_tmp.exe")); |
|
189 |
|
190 // Make call to SetCap |
|
191 TInt result = execlient.Create(KSetCapPath, |
|
192 buf, |
|
193 TUidType(KNullUid, KNullUid, KNullUid)); |
|
194 User::LeaveIfError(result); |
|
195 execlient.Resume(); //make the execlient visible |
|
196 User::After(800000); //Wait 0.8 s |
|
197 |
|
198 execlient.Close(); //Close handle to exe-client |
|
199 |
|
200 // now move file CapabilityTests_tmp.exe to CapabilityTests.exe |
|
201 TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite); |
|
202 if (err != KErrNone) |
|
203 { |
|
204 iLog->Put(_L("Move problem")); |
|
205 LogErrorAndLeave(_L("Move problem"), err); |
|
206 } |
|
207 |
|
208 CleanupStack::PopAndDestroy(fileMan); //fileMan |
|
209 CleanupStack::PopAndDestroy(&file); //file |
|
210 CleanupStack::PopAndDestroy(&fileSession); //fileSession |
|
211 |
|
212 // Prepare test conditions |
|
213 SetupTestEnvironmentL(); |
|
214 |
|
215 buf.Zero(); |
|
216 buf.Format(_L("SetCap done, Now Execute CapabilityTest TP107, part %d"), aIndex+1); |
|
217 TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse); |
|
218 //if(answer == EUtfwUserAnswerNo) |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // CPosTp668::SetupTestEnvironmentL |
|
223 // |
|
224 // (other items were commented in a header). |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 void CPosTp668::SetupTestEnvironmentL() |
|
228 { |
|
229 iLog->Put(_L("SetupTestEnvironmentL")); |
|
230 |
|
231 // Setup start conditions for compatibility test |
|
232 _LIT(KDefaultDb, "file://c:eposlm.ldb"); |
|
233 |
|
234 CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); |
|
235 CleanupStack::PushL(dbManager); |
|
236 |
|
237 // Remove all landmark databases |
|
238 CDesCArray* uris = dbManager->ListDatabasesL(); |
|
239 CleanupStack::PushL(uris); |
|
240 for (TInt i = 0; i < uris->Count(); i++) |
|
241 { |
|
242 dbManager->DeleteDatabaseL((*uris)[i]); |
|
243 } |
|
244 CleanupStack::PopAndDestroy(uris); |
|
245 |
|
246 // Create and initialize a default database |
|
247 dbManager->CreateDatabaseL(KDefaultDb); |
|
248 dbManager->SetDefaultDatabaseL(KDefaultDb); |
|
249 CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); |
|
250 CleanupStack::PushL(database); |
|
251 ExecuteAndDeleteLD(database->InitializeL()); |
|
252 |
|
253 // Add 5 landmarks - will generate ids 1 - 5 |
|
254 const TInt KFive = 5; |
|
255 for (TInt j = 0; j < KFive; j++) |
|
256 { |
|
257 CPosLandmark* lm = CPosLandmark::NewLC(); |
|
258 lm->SetLandmarkNameL(_L("Landmark")); |
|
259 database->AddLandmarkL(*lm); |
|
260 CleanupStack::PopAndDestroy(lm); |
|
261 } |
|
262 |
|
263 // Add 5 categories |
|
264 CPosLmCategoryManager* catManager = CPosLmCategoryManager::NewL(*database); |
|
265 CleanupStack::PushL(catManager); |
|
266 for (TInt k = 0; k < KFive; k++) |
|
267 { |
|
268 CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
269 TBuf<15> name; |
|
270 name = _L("Category "); |
|
271 name.AppendNum(k); |
|
272 category->SetCategoryNameL(name); |
|
273 catManager->AddCategoryL(*category); |
|
274 CleanupStack::PopAndDestroy(category); |
|
275 } |
|
276 |
|
277 CleanupStack::PopAndDestroy(3, dbManager); |
|
278 } |
|
279 |
|
280 // End of File |