|
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 <EPos_CPosLandmarkDatabase.h> |
|
21 #include <EPos_CPosLandmarkDatabaseExtended.h> |
|
22 #include <EPos_CPosLMItemIterator.h> |
|
23 #include <e32svr.h> // RDebug |
|
24 #include "FT_CPosTp143.h" |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 |
|
28 // --------------------------------------------------------- |
|
29 // --------------------------------------------------------- |
|
30 // |
|
31 void CPosTp143::StartL() |
|
32 { |
|
33 RemoveDefaultDbL(); |
|
34 RemoveAllLmDatabasesL(); |
|
35 |
|
36 iDatabase = CPosLandmarkDatabase::OpenL(); |
|
37 if (iDatabase->IsInitializingNeeded()) |
|
38 { |
|
39 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
40 } |
|
41 |
|
42 ExecuteAndDeleteLD(iDatabase->CompactL()); |
|
43 AddLandmarksL(); |
|
44 |
|
45 CheckCountersL(); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // --------------------------------------------------------- |
|
50 // |
|
51 void CPosTp143::CloseTest() |
|
52 { |
|
53 iLandmarks.ResetAndDestroy(); |
|
54 iLandmarks.Close(); |
|
55 delete iDatabase; |
|
56 iDatabase = NULL; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 void CPosTp143::AddLandmarksL() |
|
63 { |
|
64 iLog->Log(_L("AddLandmarksL")); |
|
65 _LIT(KLmName, "LmTP143 - %d"); |
|
66 _LIT(KLmDescription, "LmTP143Description - %d"); |
|
67 |
|
68 const TInt KNoLandmarks = 1000; |
|
69 for (TInt i=0; i< KNoLandmarks ; i++) |
|
70 { |
|
71 TBuf<100> lmName; |
|
72 lmName.Format(KLmName,i); |
|
73 TBuf<100> lmDesc; |
|
74 lmDesc.Format(KLmDescription,i); |
|
75 |
|
76 CPosLandmark* landmark = CPosLandmark::NewLC(); |
|
77 landmark->SetLandmarkNameL(lmName); |
|
78 landmark->SetLandmarkDescriptionL(lmDesc); |
|
79 TInt err = KErrLocked; |
|
80 while (err == KErrLocked) |
|
81 { |
|
82 TRAP(err, iDatabase->AddLandmarkL(*landmark)); |
|
83 } |
|
84 |
|
85 iLandmarks.Append(landmark); |
|
86 |
|
87 CleanupStack::Pop(landmark); |
|
88 } |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------- |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 void CPosTp143::CheckCountersL() |
|
95 { |
|
96 iLog->Log(_L("CheckCountersL")); |
|
97 |
|
98 TTime start, end; |
|
99 CPosLandmarkDatabaseExtended* dbExt = CPosLandmarkDatabaseExtended::OpenL(); |
|
100 CleanupStack::PushL(dbExt); |
|
101 |
|
102 iLog->Log(_L("checking LandmarksCount")); |
|
103 start.UniversalTime(); |
|
104 TInt lmCount = dbExt->LandmarksCount(); |
|
105 end.UniversalTime(); |
|
106 TTimeIntervalMicroSeconds interval = end.MicroSecondsFrom( start ); |
|
107 iLog->Log(_L("LandmarksCount done in %ld us"), interval.Int64()); |
|
108 |
|
109 if ( lmCount != iLandmarks.Count() ) |
|
110 { |
|
111 iLog->Log( _L("LandmarksCount wrong result, expected %d, actual %d"), |
|
112 iLandmarks.Count(), lmCount ); |
|
113 User::Leave( KErrGeneral ); |
|
114 } |
|
115 |
|
116 CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL(); |
|
117 CleanupStack::PushL(iter); |
|
118 |
|
119 if ( lmCount != iter->NumOfItemsL() ) |
|
120 { |
|
121 iLog->Log( _L("CategoriesCount wrong result, expected %d, actual %d"), |
|
122 iter->NumOfItemsL(), lmCount ); |
|
123 User::Leave( KErrGeneral ); |
|
124 } |
|
125 |
|
126 CleanupStack::PopAndDestroy( iter ); |
|
127 |
|
128 iLog->Log(_L("checking CategoriesCount")); |
|
129 start.UniversalTime(); |
|
130 TInt catCount = dbExt->CategoriesCount(); |
|
131 end.UniversalTime(); |
|
132 interval = end.MicroSecondsFrom( start ); |
|
133 iLog->Log(_L("CategoriesCount done in %ld us"), interval.Int64()); |
|
134 |
|
135 CPosLmCategoryManager& catman = dbExt->CategoryManager(); |
|
136 |
|
137 CPosLmItemIterator* catIter = catman.CategoryIteratorL(); |
|
138 CleanupStack::PushL(catIter); |
|
139 |
|
140 if ( catCount != catIter->NumOfItemsL() ) |
|
141 { |
|
142 iLog->Log( _L("CategoriesCount wrong result, expected %d, actual %d"), |
|
143 catIter->NumOfItemsL(), catCount ); |
|
144 User::Leave( KErrGeneral ); |
|
145 } |
|
146 |
|
147 CleanupStack::PopAndDestroy( catIter ); |
|
148 CleanupStack::PopAndDestroy( dbExt ); |
|
149 } |
|
150 |