|
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 #include "FT_CPosTp141.h" |
|
22 #include <EPos_CPosLandmarkDatabase.h> |
|
23 #include <EPos_CPosLandmarkSearch.h> |
|
24 #include <EPos_CPosLmTextCriteria.h> |
|
25 #include <EPos_CPosLMItemIterator.h> |
|
26 #include <EPos_CPosLmDisplayData.h> |
|
27 #include <EPos_CPosLmDisplayItem.h> |
|
28 #include <EPos_TPosLMSortPref.h> |
|
29 #include "FT_CSearchResult.h" |
|
30 |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 |
|
34 |
|
35 // --------------------------------------------------------- |
|
36 // CPosTp141::CloseTest |
|
37 // |
|
38 // (other items were commented in a header). |
|
39 // --------------------------------------------------------- |
|
40 // |
|
41 void CPosTp141::CloseTest() |
|
42 { |
|
43 |
|
44 delete iDatabase; |
|
45 iDatabase = NULL; |
|
46 |
|
47 delete iLandmarkSearch; |
|
48 iLandmarkSearch = NULL; |
|
49 |
|
50 iSearchResults.ResetAndDestroy(); |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CPosTp141::StartL |
|
55 // |
|
56 // (other items were commented in a header). |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 void CPosTp141::StartL() |
|
60 { |
|
61 _LIT(KEmptyTextCriteriaErr, "An empty string as text criteria should not be allowed"); |
|
62 _LIT(KLandMarkattrErr, "Landmark attribute set -> AttributesToSearch should return ELandmarkName |EDescription "); |
|
63 iDatabase = UseGeneratedDbFileL(); |
|
64 |
|
65 if (iDatabase->IsInitializingNeeded()) |
|
66 { |
|
67 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
68 } |
|
69 |
|
70 iLandmarkSearch = CPosLandmarkSearch::NewL(*iDatabase); |
|
71 |
|
72 TestInvalidPositionFieldsL(); |
|
73 |
|
74 // Check iterator before search has started (in multidb search all iterators are empty thus NOT NULL) |
|
75 CPosLmItemIterator* iter = iLandmarkSearch->MatchIteratorL(); |
|
76 if (iter) |
|
77 { |
|
78 CleanupStack::PushL(iter); |
|
79 AssertTrueSecL(iter->NumOfItemsL() == 0, _L("Iterator should be empty")); |
|
80 CleanupStack::PopAndDestroy(iter); |
|
81 } |
|
82 else |
|
83 { |
|
84 |
|
85 iLog->Log(_L("Iterator should NOT be NULL")); |
|
86 User::Leave(-1); |
|
87 } |
|
88 |
|
89 TUint attr = CPosLandmark::ELandmarkName | CPosLandmark::EDescription; |
|
90 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
91 textCriteria->SetAttributesToSearch(attr); |
|
92 AssertTrueSecL(textCriteria->AttributesToSearch() == CPosLandmark::EDescription | CPosLandmark::ELandmarkName, KLandMarkattrErr); |
|
93 |
|
94 textCriteria->SetTextL(_L("")); |
|
95 |
|
96 TRAPD(err, iLandmarkSearch->StartLandmarkSearchL(*textCriteria)); |
|
97 AssertTrueSecL(err == KErrArgument, KEmptyTextCriteriaErr); |
|
98 |
|
99 |
|
100 CleanupStack::PopAndDestroy(textCriteria); |
|
101 |
|
102 } |
|
103 |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CPosTp141::TestInvalidPositionFieldsL |
|
107 // |
|
108 // (other items were commented in a header). |
|
109 // --------------------------------------------------------- |
|
110 // |
|
111 void CPosTp141::TestInvalidPositionFieldsL() |
|
112 { |
|
113 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
114 RArray<TUint> arr; |
|
115 CleanupClosePushL(arr); |
|
116 textCriteria->GetPositionFieldsToSearchL(arr); |
|
117 textCriteria->SetTextL(_L("*")); |
|
118 textCriteria->SetPositionFieldsToSearchL(arr); |
|
119 |
|
120 // Search with empty positionfields list, should find all landmarks |
|
121 iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria); |
|
122 ExecuteAndDeleteLD(iOperation); |
|
123 TInt nr = iLandmarkSearch->NumOfMatches(); |
|
124 TBuf<100> buf; |
|
125 buf.Format(_L("Found %d nr of matches when searching in empty position fields list"), nr); |
|
126 iLog->Log(buf); |
|
127 |
|
128 |
|
129 |
|
130 User::LeaveIfError(arr.Append(1)); |
|
131 User::LeaveIfError(arr.Append(2)); |
|
132 User::LeaveIfError(arr.Append(3)); |
|
133 |
|
134 textCriteria->SetPositionFieldsToSearchL(arr); |
|
135 textCriteria->GetPositionFieldsToSearchL(arr); |
|
136 TBuf<100> buf1; |
|
137 for(TInt i=0;i< arr.Count();i++) |
|
138 { |
|
139 buf1.Format(_L(" %d position fields--%d- "),i, arr[i]); |
|
140 iLog->Log(buf1); |
|
141 } |
|
142 |
|
143 |
|
144 //Clears the position fields list used in a search |
|
145 textCriteria->ClearPositionFieldsToSearch(); |
|
146 textCriteria->GetPositionFieldsToSearchL(arr); |
|
147 if(arr.Count()==0) |
|
148 { |
|
149 iLog->Log(_L("ClearPositionFieldsToSearch()-Cleared the position fields list used in a search.")); |
|
150 } |
|
151 |
|
152 |
|
153 |
|
154 iLog->Log(_L("Sets the position fields list used in a search")); |
|
155 User::LeaveIfError(arr.Append(0)); |
|
156 User::LeaveIfError(arr.Append(50)); |
|
157 User::LeaveIfError(arr.Append(500)); |
|
158 |
|
159 textCriteria->SetPositionFieldsToSearchL(arr); |
|
160 textCriteria->GetPositionFieldsToSearchL(arr); |
|
161 TBuf<100> buf2; |
|
162 for(TInt i=0;i< arr.Count();i++) |
|
163 { |
|
164 buf2.Format(_L(" %d position fields--%d- "),i, arr[i]); |
|
165 iLog->Log(buf2); |
|
166 } |
|
167 |
|
168 |
|
169 // Search with invalid positionfields list, should NOT find any landmarks |
|
170 iOperation = iLandmarkSearch->StartLandmarkSearchL(*textCriteria); |
|
171 ExecuteAndDeleteLD(iOperation); |
|
172 nr = iLandmarkSearch->NumOfMatches(); |
|
173 |
|
174 buf.Format(_L("Found %d nr of matches when searching in invalid position fields"), nr); |
|
175 iLog->Log(buf); |
|
176 |
|
177 AssertTrueSecL(nr == 0, _L("We should not find any matches")); |
|
178 textCriteria->ClearPositionFieldsToSearch(); |
|
179 CleanupStack::PopAndDestroy(&arr); |
|
180 CleanupStack::PopAndDestroy(textCriteria); |
|
181 } |
|
182 |
|
183 // End of File |