|
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: provides testing of CPosLmOperation class methods |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <EPos_CPosLandmark.h> |
|
22 #include <EPos_CPosLandmarkDatabase.h> |
|
23 #include <EPos_CPosLmCategoryManager.h> |
|
24 #include <EPos_CPosLandmarkCategory.h> |
|
25 #include <LbsPosition.h> |
|
26 #include "testcposlmoperation.h" |
|
27 |
|
28 // Literals |
|
29 // Test Database URI |
|
30 _LIT( KDBUri, "file://c:eposlmtest.ldb" ); |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CTestPosLmOperation::CTestPosLmOperation |
|
36 // |
|
37 // |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CTestPosLmOperation::CTestPosLmOperation( CStifLogger* aLog ) : |
|
41 CActive(EPriorityStandard), iLog(aLog) |
|
42 { |
|
43 CActiveScheduler::Add(this); |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CTestPosLmOperation::NewL |
|
48 // |
|
49 // |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CTestPosLmOperation* CTestPosLmOperation::NewL( CStifLogger* aLog ) |
|
53 { |
|
54 CTestPosLmOperation* self = new (ELeave) CTestPosLmOperation( aLog ); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CTestPosLmOperation::ConstructL |
|
63 // |
|
64 // |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CTestPosLmOperation::ConstructL() |
|
68 { |
|
69 |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CTestPosLmOperation::~CTestPosLmOperation |
|
74 // |
|
75 // |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CTestPosLmOperation::~CTestPosLmOperation() |
|
79 { |
|
80 |
|
81 Cancel(); |
|
82 |
|
83 if( iOperation ) |
|
84 { |
|
85 delete iOperation; |
|
86 } |
|
87 if( iDatabase ) |
|
88 { |
|
89 delete iDatabase; |
|
90 ReleaseLandmarkResources(); |
|
91 } |
|
92 } |
|
93 |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CTestPosLmOperation::DestructOperation |
|
98 // |
|
99 // |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TInt CTestPosLmOperation::DestructOperationL( CStifItemParser& /*aItem*/ ) |
|
103 { |
|
104 // |
|
105 // Open default database |
|
106 CPosLandmarkDatabase* lmkDatabase = CPosLandmarkDatabase::OpenL( KDBUri ); |
|
107 CleanupStack::PushL( lmkDatabase ); |
|
108 // Call Init to Get one operation object which will initializa the DB |
|
109 CPosLmOperation* operation = lmkDatabase->InitializeL(); |
|
110 CleanupStack::PushL( operation ); |
|
111 // Delete operation object, will invoke the destructor |
|
112 CleanupStack::PopAndDestroy( 2, lmkDatabase ); // operation |
|
113 ReleaseLandmarkResources(); |
|
114 return KErrNone; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CTestPosLmOperation::Execute |
|
119 // |
|
120 // |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TInt CTestPosLmOperation::ExecuteL( CStifItemParser& /*aItem*/ ) |
|
124 { |
|
125 // |
|
126 // Open default database |
|
127 CPosLandmarkDatabase* lmkDatabase = CPosLandmarkDatabase::OpenL( KDBUri ); |
|
128 CleanupStack::PushL( lmkDatabase ); |
|
129 // Init database, Get one operation object |
|
130 CPosLmOperation* operation = lmkDatabase->InitializeL(); |
|
131 CleanupStack::PushL( operation ); |
|
132 // Execute the operation |
|
133 operation->ExecuteL(); |
|
134 // Delete operation object |
|
135 CleanupStack::PopAndDestroy( 2, lmkDatabase ); // operation |
|
136 ReleaseLandmarkResources(); |
|
137 return KErrNone; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CTestPosLmOperation::ExecuteAndDeleteOperation |
|
142 // |
|
143 // |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CTestPosLmOperation::ExecuteAndDeleteOperationL( CStifItemParser& /*aItem*/ ) |
|
147 { |
|
148 // |
|
149 // Open default database |
|
150 CPosLandmarkDatabase* lmkDatabase = CPosLandmarkDatabase::OpenL( KDBUri ); |
|
151 CleanupStack::PushL( lmkDatabase ); |
|
152 // Init database, Get one operation object, execute and delete it |
|
153 ExecuteAndDeleteLD( lmkDatabase->InitializeL() ); |
|
154 // Delete DB |
|
155 CleanupStack::PopAndDestroy( lmkDatabase ); |
|
156 ReleaseLandmarkResources(); |
|
157 return KErrNone; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CTestPosLmOperation::NextStep |
|
162 // |
|
163 // |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CTestPosLmOperation::NextStepL( CStifItemParser& /*aItem*/ ) |
|
167 { |
|
168 // |
|
169 // Open default database |
|
170 iDatabase = CPosLandmarkDatabase::OpenL( KDBUri ); |
|
171 // Init database, Get one operation object |
|
172 iOperation = iDatabase->InitializeL(); |
|
173 // Execute the operation Asynchronously |
|
174 iOperation->NextStep( iStatus, iProgress ); |
|
175 SetActive(); |
|
176 // Wait |
|
177 CActiveScheduler::Start(); |
|
178 return iLastResult; |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CTestPosLmOperation::RunL |
|
183 // |
|
184 // |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CTestPosLmOperation::RunL() |
|
188 { |
|
189 // |
|
190 iLog->Log(_L("RunL Starts...")); |
|
191 if( iStatus == KPosLmOperationNotComplete ) |
|
192 { |
|
193 // |
|
194 iLog->Log(_L("RunL Before Next")); |
|
195 iOperation->NextStep( iStatus, iProgress ); |
|
196 SetActive(); |
|
197 iLog->Log(_L("RunL After Next ")); |
|
198 } |
|
199 else |
|
200 { |
|
201 if( iStatus == KErrNone ) |
|
202 { |
|
203 iLog->Log(_L("NextStep Successful ")); |
|
204 iLastResult = KErrNone; |
|
205 } |
|
206 else |
|
207 { |
|
208 iLog->Log(_L("NextStep failed ")); |
|
209 iLastResult = KErrGeneral; |
|
210 } |
|
211 CActiveScheduler::Stop(); |
|
212 } |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CTestPosLmOperation::DoCancel |
|
217 // |
|
218 // |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CTestPosLmOperation::DoCancel() |
|
222 { |
|
223 |
|
224 } |