|
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 // INCLUDES |
|
21 |
|
22 #include "FT_CPosTp15.h" |
|
23 #include <EPos_CPosLandmarkDatabase.h> |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 |
|
27 // --------------------------------------------------------- |
|
28 // CPosTp15::GetName |
|
29 // |
|
30 // (other items were commented in a header). |
|
31 // --------------------------------------------------------- |
|
32 // |
|
33 void CPosTp15::GetName(TDes& aName) const |
|
34 { |
|
35 _LIT(KTestName, "TP15 - Database initialization - Created"); |
|
36 aName = KTestName; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // CPosTp13::StartL |
|
41 // |
|
42 // (other items were commented in a header). |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 void CPosTp15::StartL() |
|
46 { |
|
47 TestInitializeDatabaseL(ETrue); |
|
48 |
|
49 TestInitializeDatabaseL(); |
|
50 |
|
51 TestInitializeWithUserWaitForL(); |
|
52 |
|
53 TestInitializeDatabaseAndCancelL(); |
|
54 |
|
55 // Cancel proceeds even if the client cancels it so added User::After just to make sure it's done when the test case completes |
|
56 User::After(2000000); |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // CPosTp15::TestInitializeDatabaseL |
|
61 // |
|
62 // (other items were commented in a header). |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 void CPosTp15::TestInitializeDatabaseL(const TBool aSyncronously) |
|
66 { |
|
67 _LIT(KAccessErr, "Access method is not returning KErrPosLmNotInitialized when expected"); |
|
68 _LIT(KInitializedErr, "Method InitializedNeeded is not returning ETrue when expected"); |
|
69 _LIT(KAccessAfterInitErr, "Access method leaves with %d after initialized"); |
|
70 |
|
71 TRAPD(err, RemoveDefaultDbL()); |
|
72 while (err == KErrInUse) |
|
73 { |
|
74 User::After(1000); |
|
75 TRAP(err, RemoveDefaultDbL()); |
|
76 } |
|
77 User::LeaveIfError(err); |
|
78 |
|
79 |
|
80 CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); |
|
81 CleanupStack::PushL(lmd); |
|
82 |
|
83 CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); |
|
84 CleanupStack::PushL(cm); |
|
85 |
|
86 TPosLmGlobalCategory globalCategory = 1; |
|
87 TRAP(err, cm->GetGlobalCategoryL(globalCategory)); |
|
88 AssertTrueSecL(err == KErrPosLmNotInitialized, KAccessErr); |
|
89 |
|
90 AssertTrueSecL(lmd->IsInitializingNeeded(), KInitializedErr); |
|
91 |
|
92 if (aSyncronously) |
|
93 { |
|
94 ExecuteAndDeleteLD(lmd->InitializeL()); |
|
95 } |
|
96 else |
|
97 { |
|
98 RunAsyncOperationLD(lmd->InitializeL()); |
|
99 } |
|
100 |
|
101 |
|
102 TRAP(err, cm->GetGlobalCategoryL(globalCategory)); |
|
103 AssertTrueSecL(err == KErrNone, KAccessAfterInitErr, err); |
|
104 |
|
105 CleanupStack::PopAndDestroy(2, lmd); |
|
106 |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CPosTp15::TestInitializeDatabaseL |
|
112 // |
|
113 // (other items were commented in a header). |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 void CPosTp15::TestInitializeWithUserWaitForL() |
|
117 { |
|
118 // ESLI-64VGXW |
|
119 _LIT(KInitializedErr, "Method InitializedNeeded is not returning ETrue when expected"); |
|
120 |
|
121 TRAPD(err, RemoveDefaultDbL()); |
|
122 while (err == KErrInUse) |
|
123 { |
|
124 User::After(1000); |
|
125 TRAP(err, RemoveDefaultDbL()); |
|
126 } |
|
127 User::LeaveIfError(err); |
|
128 |
|
129 CPosLandmarkDatabase* lmd = CPosLandmarkDatabase::OpenL(); |
|
130 CleanupStack::PushL(lmd); |
|
131 |
|
132 AssertTrueSecL(lmd->IsInitializingNeeded(), KInitializedErr); |
|
133 |
|
134 CPosLmOperation* op = lmd->InitializeL(); |
|
135 CleanupStack::PushL(op); |
|
136 |
|
137 RunAsyncOperationByWaitForReqL(op); |
|
138 |
|
139 CleanupStack::PopAndDestroy(2, lmd); |
|
140 |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CPosTp15::TestInitializeDatabaseL |
|
145 // |
|
146 // (other items were commented in a header). |
|
147 // --------------------------------------------------------- |
|
148 // |
|
149 void CPosTp15::TestInitializeDatabaseAndCancelL() |
|
150 { |
|
151 iLog->Put(_L("TestInitializeDatabaseAndCancelL")); |
|
152 _LIT(KAccessCancelErr, "Access method is not returning KErrPosLmNotInitialized after cancel"); |
|
153 |
|
154 CPosLandmarkDatabase* lmd = NULL; |
|
155 TReal32 progress(0); |
|
156 while (progress < 1.0) |
|
157 { |
|
158 RemoveDefaultDbL(); |
|
159 lmd = CPosLandmarkDatabase::OpenL(); |
|
160 CleanupStack::PushL(lmd); |
|
161 |
|
162 RunAsyncOperationAndCancelInCallbackLD(lmd->InitializeL(), progress); |
|
163 progress = progress + 0.09; |
|
164 |
|
165 CleanupStack::PopAndDestroy(lmd); |
|
166 } |
|
167 |
|
168 lmd = CPosLandmarkDatabase::OpenL(); |
|
169 CleanupStack::PushL(lmd); |
|
170 CPosLmCategoryManager* cm = CPosLmCategoryManager::NewL(*lmd); |
|
171 CleanupStack::PushL(cm); |
|
172 |
|
173 TPosLmGlobalCategory globalCategory = 1; |
|
174 TRAPD(err, cm->GetGlobalCategoryL(globalCategory)); |
|
175 |
|
176 // KErrNone means that the initialization already has completed which is OK |
|
177 if (err == KErrNone) |
|
178 { |
|
179 iLog->Put(_L("Err. code returned is KErrNone->initialization has already completed")); |
|
180 } |
|
181 else |
|
182 { |
|
183 AssertTrueSecL(err == KErrPosLmNotInitialized, KAccessCancelErr, err); |
|
184 } |
|
185 |
|
186 CleanupStack::PopAndDestroy(2, lmd); |
|
187 iLog->Put(_L("TestInitializeDatabaseAndCancelL Done")); |
|
188 } |
|
189 |
|
190 // End of File |