|
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_CPosTp666.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 = 4; |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // Destructor |
|
36 CPosTp666::~CPosTp666() |
|
37 { |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CPosTp666::GetName |
|
42 // |
|
43 // (other items were commented in a header). |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 |
|
47 void CPosTp666::GetName(TDes& aName) const |
|
48 { |
|
49 _LIT(KTestName0, "SetCap-TP107"); |
|
50 aName = KTestName0; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CPosTp666::StartL |
|
55 // |
|
56 // (other items were commented in a header). |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 void CPosTp666::StartL() |
|
60 { |
|
61 iLog->Put(_L("StartL")); |
|
62 |
|
63 SetupTestPartL(0); |
|
64 SetupTestPartL(1); |
|
65 SetupTestPartL(2); |
|
66 SetupTestPartL(3); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CPosTp666::SetupTestPartL |
|
71 // |
|
72 // (other items were commented in a header). |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 void CPosTp666::SetupTestPartL(TInt aIndex) |
|
76 { |
|
77 iLog->Put(_L("StartL(TInt aIndex)")); |
|
78 /* |
|
79 #ifdef __WINS__ |
|
80 _LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!"); |
|
81 LogErrorAndLeave(KNotOnWins); |
|
82 |
|
83 #endif |
|
84 */ |
|
85 TBuf<20> capability; |
|
86 switch (aIndex) |
|
87 { |
|
88 case 0: |
|
89 iLog->Put(_L("Part1")); |
|
90 capability.Zero(); |
|
91 // Set to all cap but readuserdata and writeuserdata |
|
92 capability.Append(_L("27FFF")); |
|
93 break; |
|
94 |
|
95 case 1: |
|
96 iLog->Put(_L("Part2")); |
|
97 // Set to Set to all cap but writeuserdata |
|
98 capability.Append(_L("2FFFF")); |
|
99 break; |
|
100 |
|
101 case 2: |
|
102 iLog->Put(_L("Part3")); |
|
103 // Set to Set to all cap but readuserdata |
|
104 capability.Append(_L("37FFF")); |
|
105 break; |
|
106 |
|
107 case 3: |
|
108 iLog->Put(_L("Part4")); |
|
109 // Set to only readuserdata and writeuserdata |
|
110 capability.Append(_L("18000")); |
|
111 break; |
|
112 |
|
113 default: |
|
114 iLog->Put(_L("Default")); |
|
115 LogErrorAndLeave(_L("We should never come here")); |
|
116 break; |
|
117 } |
|
118 // Only for target, on winscw use bat-script |
|
119 RProcess execlient; |
|
120 RFile file; |
|
121 RFs fileSession; |
|
122 User::LeaveIfError(fileSession.Connect()); |
|
123 CleanupClosePushL(fileSession); |
|
124 CleanupClosePushL(file); |
|
125 CFileMan* fileMan = CFileMan::NewL(fileSession); |
|
126 CleanupStack::PushL(fileMan); |
|
127 |
|
128 TBuf<100> buf; |
|
129 |
|
130 buf.Append(_L("CapabilityTests.exe ")); |
|
131 buf.Append(capability); |
|
132 buf.Append(_L(" CapabilityTests_tmp.exe")); |
|
133 |
|
134 // Make call to SetCap |
|
135 TInt result = execlient.Create(KSetCapPath, |
|
136 //_L("CapabilityTests.exe 3FFFF CapabilityTests_All.exe"), |
|
137 buf, |
|
138 TUidType(KNullUid, KNullUid, KNullUid)); |
|
139 User::LeaveIfError(result); |
|
140 execlient.Resume(); //make the execlient visible |
|
141 User::After(800000); //Wait 0.8 s |
|
142 |
|
143 execlient.Close(); //Close handle to exe-client |
|
144 |
|
145 // now move file CapabilityTests_tmp.exe to CapabilityTests.exe |
|
146 TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite); |
|
147 if (err != KErrNone) |
|
148 { |
|
149 iLog->Put(_L("Move problem")); |
|
150 LogErrorAndLeave(_L("Move problem"), err); |
|
151 } |
|
152 |
|
153 CleanupStack::PopAndDestroy(fileMan); //fileMan |
|
154 CleanupStack::PopAndDestroy(&file); //file |
|
155 CleanupStack::PopAndDestroy(&fileSession); //fileSession |
|
156 |
|
157 // Prepare test conditions |
|
158 SetupTestEnvironmentL(); |
|
159 |
|
160 buf.Zero(); |
|
161 buf.Format(_L("SetCap done, Now Execute CapabilityTest TP107, part %d"), aIndex+1); |
|
162 TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse); |
|
163 //if(answer == EUtfwUserAnswerNo) |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------- |
|
167 // CPosTp666::SetupTestEnvironmentL |
|
168 // |
|
169 // (other items were commented in a header). |
|
170 // --------------------------------------------------------- |
|
171 // |
|
172 void CPosTp666::SetupTestEnvironmentL() |
|
173 { |
|
174 iLog->Put(_L("SetupTestEnvironmentL")); |
|
175 |
|
176 // Setup start conditions for compatibility test |
|
177 _LIT(KDefaultDb, "file://c:eposlm.ldb"); |
|
178 |
|
179 CPosLmDatabaseManager* dbManager = CPosLmDatabaseManager::NewL(); |
|
180 CleanupStack::PushL(dbManager); |
|
181 |
|
182 // Remove all landmark databases |
|
183 CDesCArray* uris = dbManager->ListDatabasesL(); |
|
184 CleanupStack::PushL(uris); |
|
185 for (TInt i = 0; i < uris->Count(); i++) |
|
186 { |
|
187 dbManager->DeleteDatabaseL((*uris)[i]); |
|
188 } |
|
189 CleanupStack::PopAndDestroy(uris); |
|
190 |
|
191 // Create and initialize a default database |
|
192 dbManager->CreateDatabaseL(KDefaultDb); |
|
193 dbManager->SetDefaultDatabaseL(KDefaultDb); |
|
194 CPosLandmarkDatabase* database = CPosLandmarkDatabase::OpenL(); |
|
195 CleanupStack::PushL(database); |
|
196 ExecuteAndDeleteLD(database->InitializeL()); |
|
197 |
|
198 // Add 5 landmarks - will generate ids 1 - 5 |
|
199 const TInt KFive = 5; |
|
200 for (TInt j = 0; j < KFive; j++) |
|
201 { |
|
202 CPosLandmark* lm = CPosLandmark::NewLC(); |
|
203 lm->SetLandmarkNameL(_L("Landmark")); |
|
204 database->AddLandmarkL(*lm); |
|
205 CleanupStack::PopAndDestroy(lm); |
|
206 } |
|
207 |
|
208 // Add 5 categories |
|
209 CPosLmCategoryManager* catManager = CPosLmCategoryManager::NewL(*database); |
|
210 CleanupStack::PushL(catManager); |
|
211 for (TInt k = 0; k < KFive; k++) |
|
212 { |
|
213 CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
214 TBuf<15> name; |
|
215 name = _L("Category "); |
|
216 name.AppendNum(k); |
|
217 category->SetCategoryNameL(name); |
|
218 catManager->AddCategoryL(*category); |
|
219 CleanupStack::PopAndDestroy(category); |
|
220 } |
|
221 |
|
222 CleanupStack::PopAndDestroy(3, dbManager); |
|
223 } |
|
224 |
|
225 // End of File |