|
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_CPosTp34.h" |
|
23 #include <f32file.h> |
|
24 |
|
25 //#include "FT_CSearchResult.h" |
|
26 //#include "FT_CActiveSearch.h" |
|
27 #include <EPos_CPosLandmarkDatabase.h> |
|
28 #include <EPos_CPosLandmarkSearch.h> |
|
29 #include <EPos_CPosLMItemIterator.h> |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // --------------------------------------------------------- |
|
36 // CPosTp34::GetName |
|
37 // |
|
38 // (other items were commented in a header). |
|
39 // --------------------------------------------------------- |
|
40 // |
|
41 void CPosTp34::GetName(TDes& aName) const |
|
42 { |
|
43 _LIT(KTestName, "TP34 - Multiple async operations"); |
|
44 aName = KTestName; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------- |
|
48 // CPosTp34::CloseTest |
|
49 // |
|
50 // (other items were commented in a header). |
|
51 // --------------------------------------------------------- |
|
52 // |
|
53 void CPosTp34::CloseTest() |
|
54 { |
|
55 delete iDatabase; |
|
56 iDatabase = NULL; |
|
57 delete iLandmarkSearch; |
|
58 iLandmarkSearch = NULL; |
|
59 |
|
60 iSearchResults.ResetAndDestroy(); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CPosTp34::StartL |
|
65 // |
|
66 // (other items were commented in a header). |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 void CPosTp34::StartL() |
|
70 { |
|
71 _LIT(KInUseErr, "search is already running, StartLandmarksSearch should leave with error code KErrInUse"); |
|
72 iDatabase = UseGeneratedDbFileL(); |
|
73 |
|
74 if (iDatabase->IsInitializingNeeded()) |
|
75 { |
|
76 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
77 } |
|
78 |
|
79 iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); |
|
80 |
|
81 CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog);//1 |
|
82 CleanupStack::PushL(activeLmOperation); |
|
83 |
|
84 AppendSearchResultsL(); |
|
85 |
|
86 const TInt KSearchResultIndex1=1; |
|
87 const TInt KSearchResultIndex2=10; |
|
88 |
|
89 CPosLmTextCriteria* textCriteria1 = CPosLmTextCriteria::NewLC(); //2 |
|
90 textCriteria1->SetTextL(iSearchResults[KSearchResultIndex1]->TextCriteria()); |
|
91 textCriteria1->SetAttributesToSearch(iSearchResults[KSearchResultIndex1]->Attributes()); |
|
92 |
|
93 CPosLmTextCriteria* textCriteria2 = CPosLmTextCriteria::NewLC(); //3 |
|
94 textCriteria2->SetTextL(iSearchResults[KSearchResultIndex2]->TextCriteria()); |
|
95 textCriteria2->SetAttributesToSearch(iSearchResults[KSearchResultIndex2]->Attributes()); |
|
96 |
|
97 iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria1); |
|
98 activeLmOperation->Start(iOperation); |
|
99 |
|
100 TRAPD(err, iLandmarkSearch->StartLandmarkSearchL(*textCriteria2)); |
|
101 AssertTrueSecL(err == KErrInUse, KInUseErr); |
|
102 |
|
103 CActiveLmOperation* activeLmOperation2 = new(ELeave) CActiveLmOperation(iLog); |
|
104 CleanupStack::PushL(activeLmOperation2); //4 |
|
105 |
|
106 /// |
|
107 CPosLandmarkSearch* landmarkSearch2 = CPosLandmarkSearch::NewL(*iDatabase); |
|
108 CleanupStack::PushL(landmarkSearch2); //5 |
|
109 |
|
110 CPosLmOperation* lmo = landmarkSearch2->StartLandmarkSearchL(*textCriteria2); |
|
111 CleanupStack::PushL(lmo); //6 |
|
112 |
|
113 activeLmOperation2->Start(lmo); |
|
114 |
|
115 CActiveScheduler::Start(); |
|
116 |
|
117 CActiveScheduler::Start(); |
|
118 |
|
119 activeLmOperation->CheckOperationL(); |
|
120 delete iOperation; |
|
121 iOperation = NULL; |
|
122 |
|
123 activeLmOperation2->CheckOperationL(); |
|
124 |
|
125 CheckSearchResultL(*iSearchResults[KSearchResultIndex1], *iLandmarkSearch, *textCriteria1); |
|
126 |
|
127 CheckSearchResultL(*iSearchResults[KSearchResultIndex2], *landmarkSearch2, *textCriteria2); |
|
128 |
|
129 //CleanupStack::PopAndDestroy(5, activeSearch); |
|
130 CleanupStack::PopAndDestroy(6, activeLmOperation); |
|
131 |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CPosTp34::CheckSearchResultL |
|
136 // |
|
137 // (other items were commented in a header). |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 void CPosTp34::CheckSearchResultL(CSearchResult& aSearchResult, |
|
141 CPosLandmarkSearch& aLandmarkSearch, |
|
142 CPosLmTextCriteria& aTextCriteria) |
|
143 { |
|
144 _LIT(KNotFoundErr, "Id %d not found in parsed Lm search results when the search is performed syncronously"); |
|
145 _LIT(KNumOfMatchesErr, "No. of matches is incorrect when the search is performed"); |
|
146 if ((TUint)(aSearchResult.SearchResult()).Count() != aLandmarkSearch.NumOfMatches()) |
|
147 { |
|
148 _LIT(KExpected, "Expected no. of matches: %d"); |
|
149 _LIT(KReturned, "Returned no. of matches: %d"); |
|
150 TBuf<100> info; |
|
151 info.Format(KExpected, (aSearchResult.SearchResult()).Count()); |
|
152 iLog->Put(info); |
|
153 info.Format(KReturned, aLandmarkSearch.NumOfMatches()); |
|
154 iLog->Put(info); |
|
155 iLog->Put(_L("Search criteria: ")); |
|
156 iLog->Put(aTextCriteria.Text()); |
|
157 LogErrorAndLeave(KNumOfMatchesErr); |
|
158 } |
|
159 CPosLmItemIterator* iter = aLandmarkSearch.MatchIteratorL(); |
|
160 CleanupStack::PushL(iter); |
|
161 |
|
162 TPosLmItemId id = iter->NextL(); |
|
163 while (id != KPosLmNullItemId) |
|
164 { |
|
165 AssertTrueSecL(aSearchResult.FindSearchResult(id), KNotFoundErr, id); |
|
166 id = iter->NextL(); |
|
167 } |
|
168 |
|
169 CleanupStack::PopAndDestroy(iter); |
|
170 |
|
171 } |
|
172 |
|
173 // End of File |