|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Test wrapper to Application Architecture Server. |
|
15 // Tests Application information, Data recognition and application |
|
16 // launching capabilities of the application architecture server.\n |
|
17 // |
|
18 // t_serv3step.cpp |
|
19 // |
|
20 |
|
21 /** |
|
22 @file t_serv3step.cpp |
|
23 @internalComponent - Internal Symbian test code |
|
24 */ |
|
25 |
|
26 #include <f32file.h> |
|
27 #include <fbs.h> |
|
28 #include <apaid.h> |
|
29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
30 #include <apaidpartner.h> |
|
31 #include <apgicnflpartner.h> |
|
32 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
33 #include <apgaplst.h> |
|
34 #include <apaflrec.h> |
|
35 #include "testableapalssession.h" |
|
36 #include <apacmdln.h> |
|
37 #include <apfrec.h> |
|
38 #include <datastor.h> |
|
39 #include <apgicnfl.h> |
|
40 #include <apasvst.h> |
|
41 #include "tstapp.h" |
|
42 // |
|
43 #include <e32test.h> |
|
44 #include "T_Serv3Step.h" |
|
45 |
|
46 #include <coemain.h> |
|
47 #include <eikenv.h> |
|
48 #include "TAppEmbedUids.h" |
|
49 #include "appfwk_test_utils.h" |
|
50 |
|
51 |
|
52 //Literals for directory and file naming |
|
53 _LIT(KMimeDir,"c:\\system\\data\\Mimepath\\"); |
|
54 _LIT(KMimeFile,"c:\\system\\data\\Mimepath\\mime_content"); |
|
55 _LIT(KEmptyDir,"c:\\system\\data\\Testpath\\Empty\\"); |
|
56 _LIT8(KTextContent, "Never hit your mother with a shovel.\ |
|
57 It leaves a dark impression on her mind."); |
|
58 _LIT(KSuffixText, ".txt"); |
|
59 _LIT(KSuffixHtml, ".html"); |
|
60 _LIT8(KHtmlContent, "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0\ |
|
61 Transitional//EN'><HTML><HEAD><TITLE>SYMBIAN Centre\ |
|
62 - 5 Day Forecast for London, United Kingdom</TITLE>\ |
|
63 <META http-equiv=Content-Type content=text/html;\ |
|
64 charset=iso-8859-1><META content='Symbian Five Day Forecast'\ |
|
65 name=type><META content='The Symbian five day forecast'\ |
|
66 name=description>"); |
|
67 _LIT(KSuffixUnknown, ".canyoutell"); |
|
68 |
|
69 const TInt KFixedNumWidth = 3; |
|
70 |
|
71 CT_Serv3Step::~CT_Serv3Step() |
|
72 /** |
|
73 * Destructor |
|
74 */ |
|
75 { |
|
76 delete iActiveScheduler; |
|
77 } |
|
78 |
|
79 CT_Serv3Step::CT_Serv3Step() |
|
80 /** |
|
81 * Constructor |
|
82 */ |
|
83 { |
|
84 // Call base class method to set up the human readable name for logging |
|
85 SetTestStepName(KT_Serv3Step); |
|
86 } |
|
87 |
|
88 /** |
|
89 @SYMTestCaseID T_Serv3Step_DoSyncRecognizerTest1L |
|
90 |
|
91 @SYMPREQ 699 |
|
92 |
|
93 @SYMREQ 3897 |
|
94 |
|
95 @SYMTestCaseDesc Test PREQ699.1.0 Validate Synchronous RecognizeFilesL function and CDataRecognitionResultArray\n |
|
96 |
|
97 @SYMTestPriority High |
|
98 |
|
99 @SYMTestStatus Implemented |
|
100 |
|
101 @SYMTestActions. Calls RecognizeFilesL() with a folder containing two files of zero and one byte sizes. Validates |
|
102 the returned number of files and file types. Tests CDataRecognitionResultArray by using the object. |
|
103 API Calls:\n |
|
104 RApaLsSession::RecognizeFilesL(const TDesC& aPath, CDataRecognitionResultArray& aResult);\n |
|
105 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
106 CDataRecognitionResultArray::Count() const;\n |
|
107 CDataRecognitionResultArray::const TFileName& Path() const\n |
|
108 CDataRecognitionResultArray::GetDataRecognitionResultL(TDataRecognitionResult& aResult, const TUint aIndex) const;\n |
|
109 CDataRecognitionResultArray::GetFileNameL(TFileName& aFileName, const TUint aIndex) const\n |
|
110 |
|
111 @SYMTestExpectedResults KErrNone and CDataRecognitionResultArray returned containing two entries, of MIME type "text/plain" \n |
|
112 |
|
113 */ |
|
114 void CT_Serv3Step::DoSyncFolderRecognizerTest1L(RApaLsSession& aLs) |
|
115 { |
|
116 //Synchronous Folder File Recognition Test Group 1 |
|
117 |
|
118 _LIT(KStandardDir,"z:\\system\\data\\Testpath\\"); |
|
119 |
|
120 // Copy App files around and delete them to check whether |
|
121 // the app list updates and stores the cache correctly. |
|
122 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
123 CleanupStack::PushL(result); |
|
124 |
|
125 INFO_PRINTF1(_L("Synchronous Folder File Recognition Test PREQ699.1.0")); |
|
126 TInt ret=aLs.RecognizeFilesL(KStandardDir,*result); |
|
127 TEST(ret==KErrNone); |
|
128 User::LeaveIfError(ret); |
|
129 |
|
130 // Test the CDataRecognitionResultArray object |
|
131 TFileName path = result->Path(); //test: CDataRecognitionResultArray::Path() |
|
132 TFullName standardDir(KStandardDir); |
|
133 //Test the path created is correct |
|
134 TEST(path==standardDir); |
|
135 |
|
136 TUint count = result->Count(); //test: CDataRecognitionResultArray::Count() |
|
137 TEST(count==2); //two files in directory |
|
138 |
|
139 //get each result from the test directory. Check the MIME values against their known types |
|
140 for(TUint i=0; i<count;i++) |
|
141 { |
|
142 //test: CDataRecognitionResultArray::GetDataRecognitionResultL |
|
143 TDataRecognitionResult res; |
|
144 result->GetDataRecognitionResultL(res, i); |
|
145 //test: correct MIME type is returned - "text/plain" |
|
146 TEST(res.iDataType.Des8().Compare(TDataType(_L8("text/plain")).Des8()) == 0); |
|
147 |
|
148 //test: CDataRecognitionResultArray::GetFileNameL |
|
149 TFileName fileName; |
|
150 result->GetFileNameL(fileName, i); |
|
151 TEST(fileName.Compare( (i==0 ? _L("file1.txt") : _L("file2.txt")) ) == 0); |
|
152 } |
|
153 |
|
154 // Cleanup |
|
155 CleanupStack::PopAndDestroy(result);//result |
|
156 } |
|
157 |
|
158 /** |
|
159 @SYMTestCaseID T_Serv3Step_DoSyncRecognizerTest2L |
|
160 |
|
161 @SYMPREQ 699 |
|
162 |
|
163 @SYMREQ 3899 |
|
164 |
|
165 @SYMTestCaseDesc Test PREQ699.2.0 and PREQ699.2.1 Validate Synchronous RecognizeFilesL function for error handling.\n |
|
166 |
|
167 @SYMTestStatus Implemented |
|
168 |
|
169 @SYMTestPriority High |
|
170 |
|
171 @SYMTestActions. Test 2.0 Calls RecognizeFilesL() (without a data filter then with a data filter) using an unknown folder path. |
|
172 Checks returned value is KErrPathNotFound. |
|
173 Test 2.1 Calls RecognizeFilesL() (without a data filter then with a data filter) using an empty folder path. |
|
174 Checks returned value is KErrNone and that returned array is empty. |
|
175 |
|
176 API Calls:\n |
|
177 RApaLsSession::RecognizeFilesL(const TDesC& aPath, CDataRecognitionResultArray& aResult);\n |
|
178 RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult);\n |
|
179 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
180 CDataRecognitionResultArray::Count() const;\n |
|
181 |
|
182 @SYMTestExpectedResults Test 2.0 returned value is KErrPathNotFound.\n |
|
183 Test 2.1 returned value is KErrNone and that returned array is empty.\n |
|
184 */ |
|
185 void CT_Serv3Step::DoSyncFolderRecognizerTest2L(RApaLsSession& aLs) |
|
186 { |
|
187 TBufC<50> emptyDir(KEmptyDir); |
|
188 TPtr ptrEmptyDir(emptyDir.Des()); |
|
189 |
|
190 //Synchronous Folder File Recognition Test Group |
|
191 |
|
192 //************** |
|
193 // Test Case 2.0 - Test Recognizer for incorrect folder path.Test both versions of synchronous RecognizeFiles |
|
194 //************** |
|
195 INFO_PRINTF1(_L("Synchronous Folder File Recognition Test PREQ699.2.0")); |
|
196 _LIT(KNotKnownDir,"z:\\system\\data\\Testpath\\NotKnown\\"); |
|
197 |
|
198 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
199 CleanupStack::PushL(result1); |
|
200 |
|
201 TInt ret=aLs.RecognizeFilesL(KNotKnownDir,*result1); |
|
202 TEST(ret==KErrPathNotFound); |
|
203 |
|
204 ret=aLs.RecognizeFilesL(KNotKnownDir,_L8("text/plain"),*result1); |
|
205 TEST(ret==KErrPathNotFound); |
|
206 |
|
207 // Cleanup |
|
208 CleanupStack::PopAndDestroy(result1);//result1 |
|
209 |
|
210 // Create a directory with no files |
|
211 RSmlTestUtils utils; |
|
212 CleanupClosePushL(utils); |
|
213 |
|
214 CreateDirL(&utils, ptrEmptyDir); |
|
215 |
|
216 //************** |
|
217 // Test Case 2.1 -Test Recognizer for empty folder. Test both versions of synchronous RecognizeFiles |
|
218 //************** |
|
219 INFO_PRINTF1(_L("Synchronous Folder File Recognition Test PREQ699.2.1")); |
|
220 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
221 CleanupStack::PushL(result2); |
|
222 |
|
223 ret=aLs.RecognizeFilesL(KEmptyDir,*result2); |
|
224 TEST(ret==KErrNone); |
|
225 |
|
226 TUint count = result2->Count(); |
|
227 TEST(count==0); |
|
228 |
|
229 INFO_PRINTF1(_L("Test empty folder for filter version parameter")); |
|
230 ret=aLs.RecognizeFilesL(KEmptyDir,_L8("text/plain"),*result2); |
|
231 TEST(ret==KErrNone); |
|
232 |
|
233 count = result2->Count(); |
|
234 TEST(count==0); |
|
235 |
|
236 //Delete empty directory |
|
237 DeleteDirL(&utils, ptrEmptyDir); |
|
238 |
|
239 // Cleanup |
|
240 CleanupStack::PopAndDestroy(result2);//result2 |
|
241 CleanupStack::PopAndDestroy(&utils);//utils |
|
242 } |
|
243 |
|
244 /** |
|
245 @SYMTestCaseID T_Serv3Step_DoSyncRecognizerTest3L |
|
246 |
|
247 @SYMPREQ 699 |
|
248 |
|
249 @SYMREQ 3899 |
|
250 |
|
251 @SYMTestCaseDesc Validate Synchronous RecognizeFilesL data filter function using various filters.\n |
|
252 Test 3.0 Validate Synchronous RecognizeFilesL data filter function and CDataRecognitionResultArray\n |
|
253 Test 3.1 Validate Synchronous RecognizeFilesL functions with wildcard/MIME type validity.\n |
|
254 Test 3.2 Validate Synchronous RecognizeFilesL functions with irregular strings.\n |
|
255 |
|
256 @SYMTestPriority High |
|
257 |
|
258 @SYMTestStatus Implemented |
|
259 |
|
260 @SYMTestActions. Call RecognizeFilesL with three different data filters: i) standard= "text/plain"; ii) wildcard: "text*"; iii) non-valid \n |
|
261 For each call, check the results are correct: number of files identified and the MIME types. |
|
262 |
|
263 API Calls:\n |
|
264 RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult);\n |
|
265 CDataRecognitionResultArray::CDataRecognitionResultArray();\n |
|
266 CDataRecognitionResultArray::Count() const;\n |
|
267 CDataRecognitionResultArray::const TFileName& Path() const\n |
|
268 CDataRecognitionResultArray::GetDataRecognitionResultL(TDataRecognitionResult& aResult, const TUint aIndex) const;\n |
|
269 CDataRecognitionResultArray::GetFileNameL(TFileName& aFileName, const TUint aIndex) const\n |
|
270 |
|
271 @SYMTestExpectedResults\n |
|
272 Test 3.0 KErrNone and CDataRecognitionResultArray returned containing four entries, of MIME type "text/plain" \n |
|
273 Test 3.1 KErrNone and CDataRecognitionResultArray returned containing four entries, of MIME type "text/plain" \n |
|
274 Test 3.2 KErrNone and CDataRecognitionResultArray returned containing zero entries\n |
|
275 |
|
276 */ |
|
277 void CT_Serv3Step::DoSyncFolderRecognizerTest3L(RApaLsSession& aLs) |
|
278 { |
|
279 |
|
280 //************** |
|
281 // Test Case 3.0 - Test Recognizer filter version with datatype filter type validity. |
|
282 // Also test CDataRecognitionResultArray::GetDataRecognitionResultL(); |
|
283 // CDataRecognitionResultArray:: |
|
284 //*************** |
|
285 //Synchronous Folder File Recognition Test Group 3; |
|
286 _LIT(KFilterTestDir,"z:\\system\\data\\Testpath\\FilterTests\\"); |
|
287 |
|
288 CDataRecognitionResultArray* result3 = new(ELeave) CDataRecognitionResultArray(); |
|
289 CleanupStack::PushL(result3); |
|
290 |
|
291 INFO_PRINTF1(_L("Synchronous Folder File Recognition Test PREQ699.3.0")); |
|
292 TInt ret=aLs.RecognizeFilesL(KFilterTestDir,_L8("text/plain"),*result3); |
|
293 TEST(ret==KErrNone); |
|
294 TUint count = result3->Count(); |
|
295 TEST(count==4); |
|
296 |
|
297 //get each result from the test directory. Check the MIME values against known types |
|
298 for(TUint i=0; i<count;i++) |
|
299 { |
|
300 TDataRecognitionResult res; |
|
301 result3->GetDataRecognitionResultL(res, i); //the result |
|
302 TFileName fileName; |
|
303 result3->GetFileNameL(fileName, i); //the file we are looking at |
|
304 |
|
305 //test for correct MIME type result |
|
306 TEST(res.iDataType.Des8().Compare(TDataType(_L8("text/plain")).Des8())==0);//report an error if not text/plain |
|
307 } |
|
308 |
|
309 // Cleanup |
|
310 CleanupStack::PopAndDestroy(result3);//result |
|
311 |
|
312 //***************** |
|
313 // Test Case 3.1 - Test Recognizer filter version for wildcard/MIME type validity. |
|
314 // Also test CDataRecognitionResultArray |
|
315 //********* |
|
316 INFO_PRINTF1(_L("Synchronous Folder File Recognition Test PREQ699.3.1")); |
|
317 CDataRecognitionResultArray* result4 = new(ELeave) CDataRecognitionResultArray(); |
|
318 CleanupStack::PushL(result4); |
|
319 ret=aLs.RecognizeFilesL(KFilterTestDir,_L8("text*"),*result4); |
|
320 TEST(ret==KErrNone); |
|
321 count = result3->Count(); |
|
322 TEST(count==4); |
|
323 |
|
324 //get each result from the test directory. Check the MIME values against some known types |
|
325 for(TUint j=0; j<count;j++) |
|
326 { |
|
327 TDataRecognitionResult res; |
|
328 result4->GetDataRecognitionResultL(res, j); //the result |
|
329 TFileName fileName; |
|
330 result4->GetFileNameL(fileName, j); //the file we are looking at |
|
331 |
|
332 //test for correct MIME type result |
|
333 TEST(res.iDataType.Des8().Compare(TDataType(_L8("text/plain")).Des8())==0);//report an error if not text |
|
334 } |
|
335 |
|
336 // Cleanup |
|
337 CleanupStack::PopAndDestroy(result4);//result |
|
338 |
|
339 //***************** |
|
340 // Test Case 3.2 -Test Recognizer filter version for with irregular strings. |
|
341 //********* |
|
342 INFO_PRINTF1(_L("Synchronous Folder File Recognition Test PREQ699.3.2")); |
|
343 CDataRecognitionResultArray* result5 = new(ELeave) CDataRecognitionResultArray(); |
|
344 CleanupStack::PushL(result5); |
|
345 ret=aLs.RecognizeFilesL(KFilterTestDir,_L8("&*/?|=+-"),*result5); |
|
346 TEST(ret==KErrNone); |
|
347 count = result5->Count(); |
|
348 TEST(count==0); |
|
349 |
|
350 ret=aLs.RecognizeFilesL(KFilterTestDir,_L8("'/"),*result5); |
|
351 TEST(ret==KErrNone); |
|
352 count = result5->Count(); |
|
353 TEST(count==0); |
|
354 |
|
355 // Cleanup |
|
356 CleanupStack::PopAndDestroy(result5);//result |
|
357 } |
|
358 |
|
359 /** |
|
360 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest1L |
|
361 |
|
362 @SYMPREQ 699 |
|
363 |
|
364 @SYMREQ Non-Specific |
|
365 |
|
366 @SYMTestCaseDesc Test PREQ699.4.0 Validate Asynchronous RecognizeFilesL (non-filtered) function and CDataRecognitionResultArray\n |
|
367 |
|
368 @SYMTestPriority High |
|
369 |
|
370 @SYMTestStatus Implemented |
|
371 |
|
372 @SYMTestActions. Calls RecognizeFilesL() with a folder containing two files of zero and one byte sizes. Uses a Test Active Object |
|
373 within the request. Validates the returned number of files and file types. Tests CDataRecognitionResultArray by using the object.\n |
|
374 |
|
375 API Calls:\n |
|
376 RApaLsSession::RecognizeFilesL(const TDesC& aPath, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus);\n |
|
377 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
378 CDataRecognitionResultArray::Count() const;\n |
|
379 CDataRecognitionResultArray::const TFileName& Path() const\n |
|
380 CDataRecognitionResultArray::GetDataRecognitionResultL(TDataRecognitionResult& aResult, const TUint aIndex) const;\n |
|
381 CDataRecognitionResultArray::GetFileNameL(TFileName& aFileName, const TUint aIndex) const\n |
|
382 |
|
383 @SYMTestExpectedResults status= KErrNone and CDataRecognitionResultArray returned containing two entries, of MIME type "text/plain" \n |
|
384 |
|
385 */ |
|
386 void CT_Serv3Step::DoAsyncFolderRecognizerTest1L(RApaLsSession& aLs) |
|
387 { |
|
388 |
|
389 //Asynchronous folder file recognition Test Group 4 |
|
390 |
|
391 //Setup Active Object |
|
392 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
393 CleanupStack::PushL(active); |
|
394 |
|
395 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
396 CleanupStack::PushL(result); |
|
397 |
|
398 //Check results and Stop AS |
|
399 _LIT(KStandardDir,"z:\\system\\data\\Testpath\\"); |
|
400 |
|
401 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.4.0")); |
|
402 aLs.RecognizeFilesL(KStandardDir,*result,active->iStatus); |
|
403 active->StartL();//set active |
|
404 CActiveScheduler::Start(); |
|
405 |
|
406 TEST(active->iStatus==KErrNone); |
|
407 if (active->iStatus==KErrNone) |
|
408 { |
|
409 TUint count = result->Count(); |
|
410 |
|
411 TEST(count==2); //two files in directory |
|
412 |
|
413 //get each result from the test directory. Check the MIME values against some known types |
|
414 for(TUint i=0; i<count;i++) |
|
415 { |
|
416 TDataRecognitionResult res; |
|
417 result->GetDataRecognitionResultL(res, i); // the result |
|
418 //test MIME type result = "text/plain" |
|
419 TEST(res.iDataType.Des8().Compare(TDataType(_L8("text/plain")).Des8())==0); |
|
420 |
|
421 TFileName fileName; |
|
422 result->GetFileNameL(fileName, i); //the file we are looking at |
|
423 TEST(fileName.Compare( (i==0 ? _L("file1.txt") : _L("file2.txt")) ) == 0); |
|
424 } |
|
425 } |
|
426 |
|
427 // Cleanup |
|
428 CleanupStack::PopAndDestroy(result);//result |
|
429 CleanupStack::PopAndDestroy(active);//active |
|
430 } |
|
431 |
|
432 /** |
|
433 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest2L |
|
434 |
|
435 @SYMPREQ 699 |
|
436 |
|
437 @SYMREQ 3899 |
|
438 |
|
439 @SYMTestCaseDesc Test PREQ699.5.0 Validate Asynchronous RecognizeFilesL (filtered) function and CDataRecognitionResultArray\n |
|
440 |
|
441 @SYMTestPriority High |
|
442 |
|
443 @SYMTestStatus Implemented |
|
444 |
|
445 @SYMTestActions. Call RecognizeFilesL() with a Data Type Filter (aDataType ="Text/Plain") and a Test Active Object. |
|
446 Test that the number and data type of files returned is correct. |
|
447 Tests CDataRecognitionResultArray by using the object.\n |
|
448 |
|
449 API Calls:\n |
|
450 RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus);\n |
|
451 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
452 CDataRecognitionResultArray::Count() const;\n |
|
453 CDataRecognitionResultArray::GetDataRecognitionResultL(TDataRecognitionResult& aResult, const TUint aIndex) const;\n |
|
454 CDataRecognitionResultArray::GetFileNameL(TFileName& aFileName, const TUint aIndex) const\n |
|
455 |
|
456 @SYMTestExpectedResults status= KErrNone and CDataRecognitionResultArray returned containing four entries, of MIME type "text/plain" \n |
|
457 |
|
458 |
|
459 */ |
|
460 void CT_Serv3Step::DoAsyncFolderRecognizerTest2L(RApaLsSession& aLs) |
|
461 { |
|
462 |
|
463 //Asynchronous folder file recognition Test Group 5 |
|
464 |
|
465 //Setup Active Object |
|
466 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
467 CleanupStack::PushL(active); |
|
468 |
|
469 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
470 CleanupStack::PushL(result); |
|
471 |
|
472 _LIT(KFilterDir,"z:\\system\\data\\Testpath\\FilterTests\\"); |
|
473 |
|
474 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.5.0")); |
|
475 //Test RecognizeFilesL with a MIME type filter "text/plain" |
|
476 aLs.RecognizeFilesL(KFilterDir,_L8("text/plain"), *result,active->iStatus); |
|
477 |
|
478 active->StartL();//set active |
|
479 CActiveScheduler::Start(); |
|
480 |
|
481 TEST(active->iStatus==KErrNone); |
|
482 if (active->iStatus==KErrNone) |
|
483 { |
|
484 TUint count = result->Count(); |
|
485 |
|
486 TEST(count==4); //four files in directory |
|
487 |
|
488 //get each result from the test directory. Check the MIME values against some known types |
|
489 for(TUint i=0; i<count;i++) |
|
490 { |
|
491 TDataRecognitionResult res; |
|
492 result->GetDataRecognitionResultL(res, i); // the result |
|
493 TFileName fileName; |
|
494 result->GetFileNameL(fileName, i); // the file we are looking at |
|
495 |
|
496 //test MIME type result = "text/plain" |
|
497 TEST(res.iDataType.Des8().Compare(TDataType(_L8("text/plain")).Des8())==0); |
|
498 } |
|
499 } |
|
500 |
|
501 // Cleanup |
|
502 CleanupStack::PopAndDestroy(result);//result |
|
503 CleanupStack::PopAndDestroy(active);//active |
|
504 } |
|
505 |
|
506 /** |
|
507 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest3L |
|
508 |
|
509 @SYMPREQ 699 |
|
510 |
|
511 @SYMREQ 3899 |
|
512 |
|
513 @SYMTestCaseDesc Test PREQ699.6.0 Validate Asynchronous RecognizeFilesL function (with data filter and wildcard) \n |
|
514 |
|
515 @SYMTestPriority High |
|
516 |
|
517 @SYMTestStatus Implemented |
|
518 |
|
519 @SYMTestActions. Call RecognizeFilesL() with a Data Type Filter and wildcard (aDataType ="Text/ *") and a Test Active Object. |
|
520 Test that the number and data type of files returned is correct. |
|
521 Tests CDataRecognitionResultArray by using the object.\n |
|
522 |
|
523 API Calls:\n |
|
524 RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus);\n |
|
525 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
526 CDataRecognitionResultArray::Count() const;\n |
|
527 CDataRecognitionResultArray::GetDataRecognitionResultL(TDataRecognitionResult& aResult, const TUint aIndex) const;\n |
|
528 CDataRecognitionResultArray::GetFileNameL(TFileName& aFileName, const TUint aIndex) const\n |
|
529 |
|
530 @SYMTestExpectedResults status= KErrNone and CDataRecognitionResultArray returned containing four entries, of MIME type "text/plain" \n |
|
531 |
|
532 |
|
533 */ |
|
534 void CT_Serv3Step::DoAsyncFolderRecognizerTest3L(RApaLsSession& aLs) |
|
535 { |
|
536 |
|
537 // Asynchronous folder file recognition Test Group 6 |
|
538 |
|
539 //Setup Active Object |
|
540 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
541 CleanupStack::PushL(active); |
|
542 |
|
543 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
544 CleanupStack::PushL(result); |
|
545 |
|
546 _LIT(KFilterDir,"z:\\system\\data\\Testpath\\FilterTests\\"); |
|
547 |
|
548 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.6.0")); |
|
549 aLs.RecognizeFilesL(KFilterDir,_L8("text*"), *result,active->iStatus); |
|
550 |
|
551 active->StartL();//set active |
|
552 CActiveScheduler::Start(); |
|
553 |
|
554 TEST(active->iStatus==KErrNone);//Test no error returned |
|
555 if (active->iStatus==KErrNone) |
|
556 { |
|
557 TUint count = result->Count(); |
|
558 |
|
559 TEST(count==4); //four files in directory |
|
560 |
|
561 //get each result from the test directory. Check the MIME values against some known types |
|
562 for(TUint i=0; i<count;i++) |
|
563 { |
|
564 TDataRecognitionResult res; |
|
565 result->GetDataRecognitionResultL(res, i); // the result |
|
566 TFileName fileName; |
|
567 result->GetFileNameL(fileName, i); //the file we are looking at |
|
568 |
|
569 //test MIME type result="text/plain" |
|
570 TEST(res.iDataType.Des8().Compare(TDataType(_L8("text/plain")).Des8())==0); |
|
571 } |
|
572 } |
|
573 |
|
574 // Cleanup |
|
575 CleanupStack::PopAndDestroy(result);//result |
|
576 CleanupStack::PopAndDestroy(active);//active |
|
577 } |
|
578 |
|
579 /** |
|
580 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest4L |
|
581 |
|
582 @SYMPREQ 699 |
|
583 |
|
584 @SYMREQ 3899 |
|
585 |
|
586 @SYMTestCaseDesc Test PREQ699.7.0 Validate Asynchronous RecognizeFilesL function (with unknown and irregular data filters). |
|
587 |
|
588 @SYMTestPriority High |
|
589 |
|
590 @SYMTestStatus Implemented |
|
591 |
|
592 @SYMTestActions. Call RecognizeFilesL() with Data Type Filters of an irregular nature and a Test Active Object. |
|
593 Test that no files are returned and status= KErrNone.\n |
|
594 |
|
595 API Calls:\n |
|
596 RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus);\n |
|
597 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
598 CDataRecognitionResultArray::Count() const;\n |
|
599 |
|
600 @SYMTestExpectedResults status= KErrNone and CDataRecognitionResultArray returned containing zero entries \n |
|
601 |
|
602 */ |
|
603 void CT_Serv3Step::DoAsyncFolderRecognizerTest4L(RApaLsSession& aLs) |
|
604 { |
|
605 |
|
606 //Asynchronous folder file recognition Test Group 7 |
|
607 |
|
608 //Setup Active Object |
|
609 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
610 CleanupStack::PushL(active); |
|
611 |
|
612 INFO_PRINTF1(_L("Testing Recognition of folder filtered with irregular strings")); |
|
613 |
|
614 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
615 CleanupStack::PushL(result); |
|
616 |
|
617 _LIT(KFilterDir,"z:\\system\\data\\Testpath\\FilterTests\\"); |
|
618 |
|
619 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.7.0")); |
|
620 aLs.RecognizeFilesL(KFilterDir,_L8("&* /?|=+-"),*result, active->iStatus); |
|
621 |
|
622 active->StartL();//set active |
|
623 CActiveScheduler::Start(); |
|
624 |
|
625 TEST(active->iStatus==KErrNone); |
|
626 if (active->iStatus==KErrNone) |
|
627 { |
|
628 TUint count = result->Count(); |
|
629 TEST(count==0); //no files should be found |
|
630 } |
|
631 |
|
632 // Cleanup |
|
633 CleanupStack::PopAndDestroy(result);//result |
|
634 CleanupStack::PopAndDestroy(active);//active |
|
635 |
|
636 } |
|
637 /** |
|
638 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest5L |
|
639 |
|
640 @SYMPREQ 699 |
|
641 |
|
642 @SYMREQ Non-Specific |
|
643 |
|
644 @SYMTestCaseDesc Test PREQ699.8.0 Validate Asynchronous RecognizeFilesL function with large directory to test Cache upperlimit. \n |
|
645 |
|
646 @SYMTestPriority High |
|
647 |
|
648 @SYMTestStatus Implemented |
|
649 |
|
650 @SYMTestActions. Call RecognizeFilesL() with a folder containing a large number of files and a Test Active Object. |
|
651 Test that the number of files returned is correct. |
|
652 Tests CDataRecognitionResultArray by using the object.\n |
|
653 |
|
654 API Calls:\n |
|
655 RApaLsSession::RecognizeFilesL(const TDesC& aPath, const TDesC8& aDataType, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus);\n |
|
656 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
657 CDataRecognitionResultArray::Count() const;\n |
|
658 |
|
659 @SYMTestExpectedResults status= KErrNone and CDataRecognitionResultArray returned containing 550 entries. \n |
|
660 |
|
661 */ |
|
662 |
|
663 void CT_Serv3Step::DoAsyncFolderRecognizerTest5L(RApaLsSession& aLs) |
|
664 { |
|
665 _LIT(KLargeDir,"c:\\system\\data\\Testpath\\largeDir\\"); |
|
666 _LIT(KLargeDirRoot, "c:\\system\\data\\Testpath\\largeDir\\focus"); |
|
667 |
|
668 TBufC<50> bigDir(KLargeDir); |
|
669 TPtr ptrBigDir (bigDir.Des()); |
|
670 TBufC<50> bigDirRoot(KLargeDirRoot); |
|
671 TPtr ptrBigDirRoot (bigDirRoot.Des()); |
|
672 |
|
673 // Asynchronous folder file recognition Test Group 8 |
|
674 |
|
675 //Setup Active Object |
|
676 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
677 CleanupStack::PushL(active); |
|
678 |
|
679 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
680 CleanupStack::PushL(result); |
|
681 |
|
682 //File server and utils |
|
683 RFs theFS; |
|
684 theFS.Connect(); |
|
685 RFile file; |
|
686 |
|
687 RSmlTestUtils utils; |
|
688 CleanupClosePushL(utils); |
|
689 |
|
690 CreateDirL(&utils, ptrBigDir); |
|
691 |
|
692 CreateFilesL(theFS, file, ptrBigDirRoot, (TDesC&)KSuffixText, 550, KTextContent, 0); |
|
693 |
|
694 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.8.0")); |
|
695 //Check results and Stop AS |
|
696 aLs.RecognizeFilesL(KLargeDir,*result,active->iStatus); |
|
697 |
|
698 active->StartL();//set active |
|
699 CActiveScheduler::Start(); |
|
700 |
|
701 TEST(active->iStatus==KErrNone); |
|
702 if (active->iStatus==KErrNone) |
|
703 { |
|
704 TUint count = result->Count(); |
|
705 TEST(count==550); //550 files in directory - 500 files is thought to be cache capacity |
|
706 } |
|
707 |
|
708 DeleteFilesL(&utils, ptrBigDirRoot, (TDesC&)KSuffixText, 550); |
|
709 |
|
710 DeleteDirL(&utils, ptrBigDir); |
|
711 |
|
712 // Cleanup |
|
713 CleanupStack::PopAndDestroy(&utils);//utils |
|
714 CleanupStack::PopAndDestroy(result);//result |
|
715 CleanupStack::PopAndDestroy(active);//active |
|
716 } |
|
717 |
|
718 /** |
|
719 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest6L |
|
720 |
|
721 @SYMPREQ 699 |
|
722 |
|
723 @SYMREQ 3898 3899 |
|
724 |
|
725 @SYMTestCaseDesc Test PREQ699.9.0, PREQ699.9.1, PREQ699.9.2 Validates cache functionality with changed file mime type |
|
726 |
|
727 @SYMTestPriority High |
|
728 |
|
729 @SYMTestStatus Implemented |
|
730 |
|
731 @SYMTestActions Recognize a directory with a filter and then change the mime type of one file. |
|
732 Recognize the directory with a filter again and ensure that the file type change has been registered. |
|
733 |
|
734 API Calls:\n |
|
735 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
736 const TDesC8& aDataType, |
|
737 CDataRecognitionResultArray& aResult, |
|
738 TRequestStatus& aStatus); |
|
739 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
740 CDataRecognitionResultArray::Count() const; |
|
741 |
|
742 @SYMTestExpectedResults\n |
|
743 status = KErrNone for file creation |
|
744 9.0 count = 1 CDataRecognitionResultArray::Count returns one entry of MIME type "text/plain" |
|
745 status = KErrNone for file content changed to html |
|
746 9.1 count = 0 CDataRecognitionResultArray::Count returns no entries of MIME type "text/plain" |
|
747 9.2 count = 0 CDataRecognitionResultArray::Count returns no entries of MIME type "text/plain" |
|
748 |
|
749 */ |
|
750 void CT_Serv3Step::DoAsyncFolderRecognizerTest6L(RApaLsSession& aLs) |
|
751 { |
|
752 |
|
753 TBufC<50> mimeDir(KMimeDir); |
|
754 TPtr ptrMimeDir(mimeDir.Des()); |
|
755 |
|
756 TBufC<50> mimeFile(KMimeFile); |
|
757 TPtr ptrMimeFile(mimeFile.Des()); |
|
758 |
|
759 //Setup Active Object |
|
760 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
761 CleanupStack::PushL(active); |
|
762 |
|
763 //Asynchronous folder file recognition Test Group 9 |
|
764 |
|
765 //Declare result arrays for storing seperate recognition results |
|
766 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
767 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
768 CDataRecognitionResultArray* result3 = new(ELeave) CDataRecognitionResultArray(); |
|
769 |
|
770 CleanupStack::PushL(result1); |
|
771 CleanupStack::PushL(result2); |
|
772 CleanupStack::PushL(result3); |
|
773 |
|
774 //File server and utils |
|
775 RFs theFS; |
|
776 theFS.Connect(); |
|
777 RFile file; |
|
778 |
|
779 RSmlTestUtils utils; |
|
780 CleanupClosePushL(utils); |
|
781 |
|
782 //Create directory for test files |
|
783 CreateDirL(&utils, ptrMimeDir); |
|
784 |
|
785 //Timestamp details for files |
|
786 TTime time; |
|
787 time.UniversalTime(); |
|
788 |
|
789 TTime aLaterTime(time); |
|
790 TTimeIntervalMinutes aInterval(1); |
|
791 |
|
792 aLaterTime+=(aInterval); |
|
793 |
|
794 // Create file mime_content000.txt containing text |
|
795 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixText, 1, KTextContent, time); |
|
796 |
|
797 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.9.0")); |
|
798 //Test RecognizeFilesL with a MIME type filter "text/plain" |
|
799 aLs.RecognizeFilesL(KMimeDir,_L8("text/plain"), *result1 ,active->iStatus); |
|
800 |
|
801 active->StartL();//set active |
|
802 CActiveScheduler::Start(); |
|
803 |
|
804 TEST(active->iStatus==KErrNone); |
|
805 if (active->iStatus==KErrNone) |
|
806 { |
|
807 TUint count = result1->Count(); |
|
808 TEST(count==1); |
|
809 } |
|
810 |
|
811 //Change file content to html |
|
812 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixText, 1, KHtmlContent, aLaterTime); |
|
813 |
|
814 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.9.1")); |
|
815 //Test RecognizeFilesL with a MIME type filter "text/plain" |
|
816 aLs.RecognizeFilesL(KMimeDir,_L8("text/plain"), *result2 ,active->iStatus); |
|
817 |
|
818 active->StartL();//set active |
|
819 CActiveScheduler::Start(); |
|
820 |
|
821 TEST(active->iStatus==KErrNone); |
|
822 if (active->iStatus==KErrNone) |
|
823 { |
|
824 TUint count = result2->Count(); |
|
825 TEST(count==0); |
|
826 } |
|
827 |
|
828 |
|
829 //Delete file and recognise again |
|
830 DeleteFilesL(&utils, ptrMimeFile, (TDesC&)KSuffixText, 1); |
|
831 |
|
832 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.9.2")); |
|
833 aLs.RecognizeFilesL(KMimeDir, *result3,active->iStatus); |
|
834 |
|
835 active->StartL();//set active |
|
836 CActiveScheduler::Start(); |
|
837 |
|
838 TEST(active->iStatus==KErrNone); |
|
839 if (active->iStatus==KErrNone) |
|
840 { |
|
841 TUint count = result3->Count(); |
|
842 TEST(count==0); |
|
843 } |
|
844 |
|
845 |
|
846 //Remove test directory |
|
847 DeleteDirL(&utils, ptrMimeDir); |
|
848 |
|
849 // Cleanup |
|
850 CleanupStack::PopAndDestroy(&utils); //utils |
|
851 CleanupStack::PopAndDestroy(result3);//result1 |
|
852 CleanupStack::PopAndDestroy(result2);//result2 |
|
853 CleanupStack::PopAndDestroy(result1);//result3 |
|
854 CleanupStack::PopAndDestroy(active); //active |
|
855 |
|
856 } |
|
857 |
|
858 /** |
|
859 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest7L |
|
860 |
|
861 @SYMPREQ 699 |
|
862 |
|
863 @SYMREQ 3898 3899 |
|
864 |
|
865 @SYMTestCaseDesc Test PREQ699.10.0 Validates cache functionality with changed mime type and filter (1) |
|
866 |
|
867 @SYMTestPriority High |
|
868 |
|
869 @SYMTestStatus Implemented |
|
870 |
|
871 @SYMTestActions Recognize a directory with a filter. Change the mime type of one file in the |
|
872 directory such that it is now described by the filter. Recognize the |
|
873 directory again with the same filter and ensure that the file type change has |
|
874 been registered. |
|
875 |
|
876 API Calls:\n |
|
877 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
878 const TDesC8& aDataType, |
|
879 CDataRecognitionResultArray& aResult, |
|
880 TRequestStatus& aStatus); |
|
881 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
882 CDataRecognitionResultArray::Count() const; |
|
883 |
|
884 @SYMTestExpectedResults\n |
|
885 status = KErrNone for file creation |
|
886 count = 3 CDataRecognitionResultArray::Count returns three entries of MIME type "text/html" |
|
887 status = KErrNone for file content changed to html |
|
888 count = 4 CDataRecognitionResultArray::Count returns four entries of MIME type "text/html" |
|
889 */ |
|
890 void CT_Serv3Step::DoAsyncFolderRecognizerTest7L(RApaLsSession& aLs) |
|
891 { |
|
892 TBufC<50> mimeDir(KMimeDir); |
|
893 TPtr ptrMimeDir (mimeDir.Des()); |
|
894 |
|
895 TBufC<50> mimeFile(KMimeFile); |
|
896 TPtr ptrMimeFile(mimeFile.Des()); |
|
897 |
|
898 //Asynchronous folder file recognition Test Group 10 |
|
899 |
|
900 //Setup Active Object |
|
901 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
902 CleanupStack::PushL(active); |
|
903 |
|
904 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
905 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
906 CleanupStack::PushL(result1); |
|
907 CleanupStack::PushL(result2); |
|
908 |
|
909 |
|
910 RFs theFS; |
|
911 theFS.Connect(); |
|
912 RFile file; |
|
913 |
|
914 RSmlTestUtils utils; |
|
915 CleanupClosePushL(utils); |
|
916 |
|
917 //Create directory for test files |
|
918 CreateDirL(&utils, ptrMimeDir); |
|
919 |
|
920 //Timestamp details for files |
|
921 TTime time; |
|
922 time.UniversalTime(); |
|
923 |
|
924 TTime aLaterTime(time); |
|
925 TTimeIntervalMinutes aInterval(1); |
|
926 aLaterTime+=(aInterval); |
|
927 |
|
928 // Create files mime_content000.canyoutell - mime_content003.canyoutell |
|
929 // 000 with text content and 001-003 with html content |
|
930 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 4, KHtmlContent, time); |
|
931 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KTextContent, time); |
|
932 |
|
933 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.10.0")); |
|
934 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
935 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result1 ,active->iStatus); |
|
936 |
|
937 active->StartL();//set active |
|
938 CActiveScheduler::Start(); |
|
939 |
|
940 TEST(active->iStatus==KErrNone); |
|
941 if (active->iStatus==KErrNone) |
|
942 { |
|
943 TUint count = result1->Count(); |
|
944 TEST(count == 3); |
|
945 } |
|
946 |
|
947 |
|
948 //Change file content to html and update the timestamp |
|
949 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KHtmlContent, aLaterTime); |
|
950 |
|
951 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
952 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result2 ,active->iStatus); |
|
953 |
|
954 active->StartL();//set active |
|
955 CActiveScheduler::Start(); |
|
956 |
|
957 TEST(active->iStatus==KErrNone); |
|
958 if (active->iStatus==KErrNone) |
|
959 { |
|
960 TUint count = result2->Count(); |
|
961 TEST(count == 4); |
|
962 } |
|
963 |
|
964 |
|
965 DeleteFilesL(&utils, ptrMimeFile, (TDesC&)KSuffixUnknown, 4); |
|
966 |
|
967 //Remove test directory |
|
968 DeleteDirL(&utils, ptrMimeDir); |
|
969 |
|
970 // Cleanup |
|
971 CleanupStack::PopAndDestroy(&utils);//utils |
|
972 CleanupStack::PopAndDestroy(result2);//result1 |
|
973 CleanupStack::PopAndDestroy(result1);//result2 |
|
974 CleanupStack::PopAndDestroy(active);//active |
|
975 |
|
976 } |
|
977 |
|
978 /** |
|
979 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest8L |
|
980 |
|
981 @SYMPREQ 699 |
|
982 |
|
983 @SYMREQ 3898 3899 |
|
984 |
|
985 @SYMTestCaseDesc Test PREQ699.11.0 Validates cache functionality with changed file mime type and filter (2) |
|
986 |
|
987 @SYMTestPriority High |
|
988 |
|
989 @SYMTestStatus Implemented |
|
990 |
|
991 @SYMTestActions Recognize a directory with a filter. Change the mime type of one file in the |
|
992 directory such that it is now not described by the filter. Recognize the |
|
993 directory again with the same filter and ensure that the file type change has |
|
994 been registered. |
|
995 |
|
996 API Calls:\n |
|
997 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
998 const TDesC8& aDataType, |
|
999 CDataRecognitionResultArray& aResult, |
|
1000 TRequestStatus& aStatus); |
|
1001 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
1002 CDataRecognitionResultArray::Count() const; |
|
1003 |
|
1004 @SYMTestExpectedResults\n |
|
1005 status = KErrNone for file creation |
|
1006 count = 4 CDataRecognitionResultArray::Count returns four entries of MIME type "text/html" |
|
1007 status = KErrNone for file content changed to html |
|
1008 count = 3 CDataRecognitionResultArray::Count returns three entries of MIME type "text/html" |
|
1009 */ |
|
1010 void CT_Serv3Step::DoAsyncFolderRecognizerTest8L(RApaLsSession& aLs) |
|
1011 { |
|
1012 TBufC<50> mimeDir(KMimeDir); |
|
1013 TPtr ptrMimeDir (mimeDir.Des()); |
|
1014 |
|
1015 TBufC<50> mimeFile(KMimeFile); |
|
1016 TPtr ptrMimeFile(mimeFile.Des()); |
|
1017 |
|
1018 //Asynchronous folder file recognition Test Group 11 |
|
1019 |
|
1020 //Setup Active Object |
|
1021 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
1022 CleanupStack::PushL(active); |
|
1023 |
|
1024 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
1025 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
1026 CleanupStack::PushL(result1); |
|
1027 CleanupStack::PushL(result2); |
|
1028 |
|
1029 |
|
1030 RFs theFS; |
|
1031 theFS.Connect(); |
|
1032 RFile file; |
|
1033 |
|
1034 RSmlTestUtils utils; |
|
1035 CleanupClosePushL(utils); |
|
1036 |
|
1037 //Create directory for test files |
|
1038 CreateDirL(&utils, ptrMimeDir); |
|
1039 |
|
1040 //Timestamp details for files |
|
1041 TTime time; |
|
1042 time.UniversalTime(); |
|
1043 |
|
1044 TTime aLaterTime(time); |
|
1045 TTimeIntervalMinutes aInterval(1); |
|
1046 aLaterTime+=(aInterval); |
|
1047 |
|
1048 // Create files mime_content000.canyoutell - mime_content003.canyoutell with html content |
|
1049 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 4, KHtmlContent, time); |
|
1050 |
|
1051 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1052 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result1 ,active->iStatus); |
|
1053 |
|
1054 active->StartL();//set active |
|
1055 CActiveScheduler::Start(); |
|
1056 |
|
1057 TEST(active->iStatus==KErrNone); |
|
1058 if (active->iStatus==KErrNone) |
|
1059 { |
|
1060 TUint count = result1->Count(); |
|
1061 TEST(count == 4); |
|
1062 } |
|
1063 |
|
1064 |
|
1065 //Change file content to text |
|
1066 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KTextContent, aLaterTime); |
|
1067 |
|
1068 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.11.0")); |
|
1069 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1070 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result2 ,active->iStatus); |
|
1071 |
|
1072 active->StartL();//set active |
|
1073 CActiveScheduler::Start(); |
|
1074 |
|
1075 TEST(active->iStatus==KErrNone); |
|
1076 if (active->iStatus==KErrNone) |
|
1077 { |
|
1078 TUint count = result2->Count(); |
|
1079 TEST(count == 3); |
|
1080 } |
|
1081 |
|
1082 DeleteFilesL(&utils, ptrMimeFile, (TDesC&)KSuffixUnknown, 4); |
|
1083 |
|
1084 //Remove test directory |
|
1085 DeleteDirL(&utils, ptrMimeDir); |
|
1086 |
|
1087 // Cleanup |
|
1088 CleanupStack::PopAndDestroy(&utils);//utils |
|
1089 CleanupStack::PopAndDestroy(result2);//result1 |
|
1090 CleanupStack::PopAndDestroy(result1);//result2 |
|
1091 CleanupStack::PopAndDestroy(active);//active |
|
1092 |
|
1093 } |
|
1094 |
|
1095 /** |
|
1096 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest9L |
|
1097 |
|
1098 @SYMPREQ 699 |
|
1099 |
|
1100 @SYMREQ 3898 3899 |
|
1101 |
|
1102 @SYMTestCaseDesc Test PREQ699.12.0 Validates cache functionality with older timestamp(1) |
|
1103 |
|
1104 @SYMTestPriority High |
|
1105 |
|
1106 @SYMTestStatus Implemented |
|
1107 |
|
1108 @SYMTestActions Recognize a directory. Change the timestamp on one file to be older and alter |
|
1109 the mime type. Repeat the directory recognition and ensure that the mime type |
|
1110 has been updated.. |
|
1111 |
|
1112 API Calls:\n |
|
1113 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
1114 const TDesC8& aDataType, |
|
1115 CDataRecognitionResultArray& aResult, |
|
1116 TRequestStatus& aStatus); |
|
1117 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
1118 CDataRecognitionResultArray::Count() const; |
|
1119 |
|
1120 @SYMTestExpectedResults\n |
|
1121 status = KErrNone for html file creation |
|
1122 count = 1 CDataRecognitionResultArray::Count returns one entry of MIME type "text/html" |
|
1123 status = KErrNone for file content changed to text |
|
1124 count = 0 CDataRecognitionResultArray::Count returns zero entries of MIME type "text/html" |
|
1125 */ |
|
1126 void CT_Serv3Step::DoAsyncFolderRecognizerTest9L(RApaLsSession& aLs) |
|
1127 { |
|
1128 TBufC<50> mimeDir(KMimeDir); |
|
1129 TPtr ptrMimeDir (mimeDir.Des()); |
|
1130 |
|
1131 TBufC<50> mimeFile(KMimeFile); |
|
1132 TPtr ptrMimeFile(mimeFile.Des()); |
|
1133 |
|
1134 //Asynchronous folder file recognition Test Group 12 |
|
1135 |
|
1136 //Setup Active Object |
|
1137 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
1138 CleanupStack::PushL(active); |
|
1139 |
|
1140 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
1141 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
1142 CleanupStack::PushL(result1); |
|
1143 CleanupStack::PushL(result2); |
|
1144 |
|
1145 RFs theFS; |
|
1146 theFS.Connect(); |
|
1147 RFile file; |
|
1148 |
|
1149 RSmlTestUtils utils; |
|
1150 CleanupClosePushL(utils); |
|
1151 |
|
1152 //Create directory for test files |
|
1153 CreateDirL(&utils, ptrMimeDir); |
|
1154 |
|
1155 //Timestamp details for files |
|
1156 TTime time; |
|
1157 time.UniversalTime(); |
|
1158 |
|
1159 TTime aLaterTime(time); |
|
1160 TTimeIntervalMinutes aInterval(1); |
|
1161 aLaterTime+=(aInterval); |
|
1162 |
|
1163 //Set the directory timestamp to be 'new' |
|
1164 theFS.SetModified(ptrMimeDir, aLaterTime); |
|
1165 |
|
1166 // Create file mime_content000.canyoutell with html content and 'new' time |
|
1167 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KHtmlContent, aLaterTime); |
|
1168 |
|
1169 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1170 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result1 ,active->iStatus); |
|
1171 active->StartL();//set active |
|
1172 CActiveScheduler::Start(); |
|
1173 |
|
1174 TEST(active->iStatus==KErrNone); |
|
1175 if (active->iStatus==KErrNone) |
|
1176 { |
|
1177 TUint count = result1->Count(); |
|
1178 TEST(count == 1); |
|
1179 } |
|
1180 |
|
1181 |
|
1182 //Change file content to text and set the timestamp to 'old' |
|
1183 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KTextContent, time); |
|
1184 |
|
1185 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.12.0")); |
|
1186 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1187 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result2 ,active->iStatus); |
|
1188 |
|
1189 active->StartL();//set active |
|
1190 CActiveScheduler::Start(); |
|
1191 |
|
1192 TEST(active->iStatus==KErrNone); |
|
1193 if (active->iStatus==KErrNone) |
|
1194 { |
|
1195 TUint count = result2->Count(); |
|
1196 TEST(count == 0); |
|
1197 } |
|
1198 |
|
1199 //Delete file |
|
1200 utils.DeleteFileL(_L("c:\\system\\data\\Mimepath\\mime_content000.canyoutell")); |
|
1201 |
|
1202 //Remove test directory |
|
1203 DeleteDirL(&utils, ptrMimeDir); |
|
1204 |
|
1205 // Cleanup |
|
1206 CleanupStack::PopAndDestroy(&utils);//utils |
|
1207 CleanupStack::PopAndDestroy(result2);//result1 |
|
1208 CleanupStack::PopAndDestroy(result1);//result2 |
|
1209 CleanupStack::PopAndDestroy(active);//active |
|
1210 |
|
1211 } |
|
1212 |
|
1213 /** |
|
1214 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest10L |
|
1215 |
|
1216 @SYMPREQ 699 |
|
1217 |
|
1218 @SYMREQ 3898 3899 |
|
1219 |
|
1220 @SYMTestCaseDesc Test PREQ699.13.0 Validates cache functionality with older timestamp. |
|
1221 |
|
1222 @SYMTestPriority High |
|
1223 |
|
1224 @SYMTestStatus Implemented |
|
1225 |
|
1226 @SYMTestActions Recognize a directory. Change the timestamp on one file to be older and alter |
|
1227 the mime type. Change the timestamp on the directory to be newer. Repeat the |
|
1228 directory recognition and ensure that the mime type has been updated.. |
|
1229 |
|
1230 API Calls:\n |
|
1231 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
1232 const TDesC8& aDataType, |
|
1233 CDataRecognitionResultArray& aResult, |
|
1234 TRequestStatus& aStatus); |
|
1235 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
1236 CDataRecognitionResultArray::Count() const; |
|
1237 |
|
1238 @SYMTestExpectedResults\n |
|
1239 status = KErrNone for html file creation |
|
1240 count = 1 CDataRecognitionResultArray::Count returns one entry of MIME type "text/html" |
|
1241 status = KErrNone for file content changed to text |
|
1242 count = 0 CDataRecognitionResultArray::Count returns zero entries of MIME type "text/html" |
|
1243 */ |
|
1244 void CT_Serv3Step::DoAsyncFolderRecognizerTest10L(RApaLsSession& aLs) |
|
1245 { |
|
1246 TBufC<50> mimeDir(KMimeDir); |
|
1247 TPtr ptrMimeDir (mimeDir.Des()); |
|
1248 |
|
1249 TBufC<50> mimeFile(KMimeFile); |
|
1250 TPtr ptrMimeFile(mimeFile.Des()); |
|
1251 |
|
1252 //Asynchronous folder file recognition Test Group 13 |
|
1253 |
|
1254 //Setup Active Object |
|
1255 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
1256 CleanupStack::PushL(active); |
|
1257 |
|
1258 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
1259 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
1260 CleanupStack::PushL(result1); |
|
1261 CleanupStack::PushL(result2); |
|
1262 |
|
1263 RFs theFS; |
|
1264 theFS.Connect(); |
|
1265 RFile file; |
|
1266 |
|
1267 RSmlTestUtils utils; |
|
1268 CleanupClosePushL(utils); |
|
1269 |
|
1270 //Create directory for test files |
|
1271 CreateDirL(&utils, ptrMimeDir); |
|
1272 |
|
1273 //Timestamp details for files |
|
1274 TTime time; |
|
1275 time.UniversalTime(); |
|
1276 |
|
1277 TTime aLaterTime(time); |
|
1278 TTimeIntervalMinutes aInterval(1); |
|
1279 aLaterTime+=(aInterval); |
|
1280 |
|
1281 //Set the directory timestamp to be 'old' |
|
1282 theFS.SetModified(ptrMimeDir, time); |
|
1283 |
|
1284 // Create file mime_content000.canyoutell with html content and 'old' time |
|
1285 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KHtmlContent, time); |
|
1286 |
|
1287 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1288 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result1 ,active->iStatus); |
|
1289 |
|
1290 active->StartL();//set active |
|
1291 CActiveScheduler::Start(); |
|
1292 |
|
1293 TEST(active->iStatus==KErrNone); |
|
1294 if (active->iStatus==KErrNone) |
|
1295 { |
|
1296 TUint count = result1->Count(); |
|
1297 TEST(count == 1); |
|
1298 } |
|
1299 |
|
1300 |
|
1301 //Change file content to text and set the timestamp to 'new' |
|
1302 //Change dir timestamp to 'old' |
|
1303 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KTextContent, aLaterTime); |
|
1304 |
|
1305 //Set the directory timestamp to be 'new' |
|
1306 theFS.SetModified(ptrMimeDir, aLaterTime); |
|
1307 |
|
1308 |
|
1309 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.13.0")); |
|
1310 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1311 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result2 ,active->iStatus); |
|
1312 |
|
1313 active->StartL();//set active |
|
1314 CActiveScheduler::Start(); |
|
1315 |
|
1316 TEST(active->iStatus==KErrNone); |
|
1317 if (active->iStatus==KErrNone) |
|
1318 { |
|
1319 TUint count = result2->Count(); |
|
1320 TEST(count == 0); |
|
1321 } |
|
1322 |
|
1323 //Delete file |
|
1324 utils.DeleteFileL(_L("c:\\system\\data\\Mimepath\\mime_content000.canyoutell")); |
|
1325 |
|
1326 //Remove test directory |
|
1327 DeleteDirL(&utils, ptrMimeDir); |
|
1328 |
|
1329 // Cleanup |
|
1330 CleanupStack::PopAndDestroy(&utils);//utils |
|
1331 CleanupStack::PopAndDestroy(result2);//result1 |
|
1332 CleanupStack::PopAndDestroy(result1);//result2 |
|
1333 CleanupStack::PopAndDestroy(active);//active |
|
1334 |
|
1335 } |
|
1336 |
|
1337 /** |
|
1338 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest11L |
|
1339 |
|
1340 @SYMPREQ 699 |
|
1341 |
|
1342 @SYMREQ 3989 3899 |
|
1343 |
|
1344 @SYMTestCaseDesc Test PREQ699.14.0 Validates cache functionality with substituted directory |
|
1345 |
|
1346 @SYMTestPriority High |
|
1347 |
|
1348 @SYMTestStatus Implemented |
|
1349 |
|
1350 @SYMTestActions Recognize a directory. Substitute a directory of the same name with |
|
1351 different contents and repeat the recognition. Ensure that the file |
|
1352 contents are correctly listed. |
|
1353 |
|
1354 API Calls:\n |
|
1355 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
1356 const TDesC8& aDataType, |
|
1357 CDataRecognitionResultArray& aResult, |
|
1358 TRequestStatus& aStatus); |
|
1359 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
1360 CDataRecognitionResultArray::Count() const; |
|
1361 |
|
1362 @SYMTestExpectedResults\n |
|
1363 status = KErrNone for file creation |
|
1364 count = 4 CDataRecognitionResultArray::Count returns four entries of MIME type "text/html" |
|
1365 status = KErrNone for file content changed to text |
|
1366 count = 2 CDataRecognitionResultArray::Count returns two entries of MIME type "text/html" |
|
1367 */ |
|
1368 void CT_Serv3Step::DoAsyncFolderRecognizerTest11L(RApaLsSession& aLs) |
|
1369 { |
|
1370 _LIT(KMimeDir1,"c:\\system\\data\\Mimepath1\\"); |
|
1371 _LIT(KMimeDir2,"c:\\system\\data\\Mimepath2\\"); |
|
1372 |
|
1373 _LIT(KMimeDir1Html,"c:\\system\\data\\Mimepath1\\dir1_html"); |
|
1374 _LIT(KMimeDir1Text,"c:\\system\\data\\Mimepath1\\dir1_text"); |
|
1375 _LIT(KMimeDir2Html,"c:\\system\\data\\Mimepath2\\dir2_html"); |
|
1376 _LIT(KMimeDir2Text,"c:\\system\\data\\Mimepath2\\dir2_text"); |
|
1377 |
|
1378 //After directory renaming |
|
1379 _LIT(KRenameHtml,"c:\\system\\data\\Mimepath1\\dir2_html"); |
|
1380 _LIT(KRenameText,"c:\\system\\data\\Mimepath1\\dir2_text"); |
|
1381 |
|
1382 TBufC<50> mimeDir1(KMimeDir1); |
|
1383 TPtr ptrMimeDir1 (mimeDir1.Des()); |
|
1384 |
|
1385 TBufC<50> mimeDir2(KMimeDir2); |
|
1386 TPtr ptrMimeDir2 (mimeDir2.Des()); |
|
1387 |
|
1388 TBufC<50> mimeDir1Html(KMimeDir1Html); |
|
1389 TPtr ptrFile1x4(mimeDir1Html.Des()); |
|
1390 |
|
1391 TBufC<50> mimeDir1Text(KMimeDir1Text); |
|
1392 TPtr ptrFile1x2(mimeDir1Text.Des()); |
|
1393 |
|
1394 TBufC<50> mimeDir2Html(KMimeDir2Html); |
|
1395 TPtr ptrFile2x2(mimeDir2Html.Des()); |
|
1396 |
|
1397 TBufC<50> mimeDir2Text(KMimeDir2Text); |
|
1398 TPtr ptrFile2x4(mimeDir2Text.Des()); |
|
1399 |
|
1400 TBufC<50> renameText(KRenameText); |
|
1401 TPtr ptrRenameText(renameText.Des()); |
|
1402 |
|
1403 TBufC<50> renameHtml(KRenameHtml); |
|
1404 TPtr ptrRenameHtml(renameHtml.Des()); |
|
1405 |
|
1406 //"Asynchronous folder file recognition Test Group 14 |
|
1407 |
|
1408 //Setup Active Object |
|
1409 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
1410 CleanupStack::PushL(active); |
|
1411 |
|
1412 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
1413 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
1414 CleanupStack::PushL(result1); |
|
1415 CleanupStack::PushL(result2); |
|
1416 |
|
1417 RFs theFS; |
|
1418 theFS.Connect(); |
|
1419 RFile file; |
|
1420 |
|
1421 RSmlTestUtils utils; |
|
1422 CleanupClosePushL(utils); |
|
1423 |
|
1424 //Create directories for test files |
|
1425 CreateDirL(&utils, ptrMimeDir1); |
|
1426 CreateDirL(&utils, ptrMimeDir2); |
|
1427 |
|
1428 //Timestamp details for files |
|
1429 TTime time; |
|
1430 time.UniversalTime(); |
|
1431 |
|
1432 TTime aLaterTime(time); |
|
1433 TTimeIntervalMinutes aInterval(1); |
|
1434 aLaterTime+=(aInterval); |
|
1435 |
|
1436 // Fill the first directory with files |
|
1437 // Create files dir1_html000.html - dir1_html003.html with html content |
|
1438 // Create files dir1_text000.txt - dir1_text001.txt with text content |
|
1439 CreateFilesL(theFS, file, ptrFile1x4, (TDesC&)KSuffixHtml, 4, KHtmlContent, time); |
|
1440 CreateFilesL(theFS, file, ptrFile1x2, (TDesC&)KSuffixText, 2, KTextContent, time); |
|
1441 |
|
1442 // Fill the second directory with files |
|
1443 // Create files dir2_text000.txt - dir2_text003.txt with text content |
|
1444 // Create files dir2_html001.html - dir2_html002.html with html content |
|
1445 CreateFilesL(theFS, file, ptrFile2x4, (TDesC&)KSuffixText, 4, KTextContent, time); |
|
1446 CreateFilesL(theFS, file, ptrFile2x2, (TDesC&)KSuffixHtml, 2, KHtmlContent, time); |
|
1447 |
|
1448 //Test RecognizeFilesL on first directory with a MIME type filter "text/html" |
|
1449 aLs.RecognizeFilesL(KMimeDir1,_L8("text/html"), *result1 ,active->iStatus); |
|
1450 |
|
1451 active->StartL();//set active |
|
1452 CActiveScheduler::Start(); |
|
1453 |
|
1454 TEST(active->iStatus==KErrNone); |
|
1455 if (active->iStatus==KErrNone) |
|
1456 { |
|
1457 TUint count = result1->Count(); |
|
1458 TEST(count == 4); |
|
1459 } |
|
1460 |
|
1461 |
|
1462 //Delete first directory (KMimeDir1) and rename second directory to be the |
|
1463 //first (KMimeDir2 -> KMimeDir1) |
|
1464 DeleteFilesL(&utils, ptrFile1x4, (TDesC&)KSuffixHtml, 4); |
|
1465 DeleteFilesL(&utils, ptrFile1x2, (TDesC&)KSuffixText, 2); |
|
1466 DeleteDirL(&utils, ptrMimeDir1); |
|
1467 utils.RenameDirectoryL(mimeDir2, mimeDir1); |
|
1468 |
|
1469 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.14.0")); |
|
1470 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1471 aLs.RecognizeFilesL(KMimeDir1,_L8("text/html"), *result2 ,active->iStatus); |
|
1472 |
|
1473 active->StartL();//set active |
|
1474 CActiveScheduler::Start(); |
|
1475 |
|
1476 TEST(active->iStatus==KErrNone); |
|
1477 if (active->iStatus==KErrNone) |
|
1478 { |
|
1479 TUint count = result2->Count(); |
|
1480 TEST(count == 2); |
|
1481 } |
|
1482 |
|
1483 //Bin out all the remaining created files |
|
1484 DeleteFilesL(&utils, ptrRenameText, (TDesC&)KSuffixText, 4); |
|
1485 DeleteFilesL(&utils, ptrRenameHtml, (TDesC&)KSuffixHtml, 2); |
|
1486 |
|
1487 //Remove test directory |
|
1488 DeleteDirL(&utils, ptrMimeDir1); |
|
1489 |
|
1490 // Cleanup |
|
1491 CleanupStack::PopAndDestroy(4, active); // utils, result2, result1, active |
|
1492 |
|
1493 } |
|
1494 |
|
1495 /** |
|
1496 @SYMTestCaseID T_Serv3Step_DoSyncRecognizerTest4L |
|
1497 |
|
1498 @SYMPREQ 699 |
|
1499 |
|
1500 @SYMREQ 3898 |
|
1501 |
|
1502 @SYMTestCaseDesc Test PREQ699.15.0, PREQ699.15.1 Validates cache performance with a typical directory |
|
1503 |
|
1504 @SYMTestPriority High |
|
1505 |
|
1506 @SYMTestStatus Implemented |
|
1507 |
|
1508 @SYMTestActions 1st Recognition - Recognize a directory that has significant file content |
|
1509 with the cache enabled and log the time taken. |
|
1510 15.0 Repeat the recognition on the directory, it should be faster than |
|
1511 the first recognition. |
|
1512 15.1 Alter a number of files and repeat, again logging the time. The time |
|
1513 taken should be faster than the 1st recognition, but slower than test 15.0 |
|
1514 |
|
1515 |
|
1516 API Calls:\n |
|
1517 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
1518 const TDesC8& aDataType, |
|
1519 CDataRecognitionResultArray& aResult, |
|
1520 TRequestStatus& aStatus); |
|
1521 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
1522 CDataRecognitionResultArray::Count() const; |
|
1523 |
|
1524 @SYMTestExpectedResults\n |
|
1525 status = KErrNone for file creation |
|
1526 15.0 Time taken faster than 1st recognition |
|
1527 15.1 Time taken faster than 1st recognition, but slower than 15.0 |
|
1528 */ |
|
1529 void CT_Serv3Step::DoSyncFolderRecognizerTest4L(RApaLsSession& aLs) |
|
1530 { |
|
1531 //Synchronous folder file recognition Test Group 15 |
|
1532 _LIT(KTestAppSource, "Z:\\System\\data\\" ); |
|
1533 _LIT(KTestAppDest, "C:\\System\\data\\TestPath\\" ); |
|
1534 _LIT(KEmpty, ""); |
|
1535 |
|
1536 _LIT(KTestWaitingForApplistUpdate,"\nWaiting %d microseconds for applist to be updated"); |
|
1537 const TInt KApplistUpdateTime = 8000000; |
|
1538 |
|
1539 TBufC<128> fileDir(KEmpty); |
|
1540 TPtr ptrFileDir(fileDir.Des()); |
|
1541 |
|
1542 CDataRecognitionResultArray* result1 = new(ELeave) CDataRecognitionResultArray(); |
|
1543 CDataRecognitionResultArray* result2 = new(ELeave) CDataRecognitionResultArray(); |
|
1544 CDataRecognitionResultArray* result3 = new(ELeave) CDataRecognitionResultArray(); |
|
1545 |
|
1546 CleanupStack::PushL(result1); |
|
1547 CleanupStack::PushL(result2); |
|
1548 CleanupStack::PushL(result3); |
|
1549 |
|
1550 RFs theFS; |
|
1551 theFS.Connect(); |
|
1552 RFile file; |
|
1553 |
|
1554 // Remove Test app from the file system |
|
1555 CFileMan* fileManager = CFileMan::NewL (theFS); |
|
1556 |
|
1557 INFO_PRINTF1(_L("Copying the app to C")); |
|
1558 TEST(KErrNone == fileManager->Copy (KTestAppSource, KTestAppDest, CFileMan::EOverWrite )); |
|
1559 |
|
1560 INFO_PRINTF2(KTestWaitingForApplistUpdate, KApplistUpdateTime); |
|
1561 User::After(KApplistUpdateTime); |
|
1562 |
|
1563 TTime time; |
|
1564 TTime timeLater; |
|
1565 |
|
1566 //1st recognition |
|
1567 time.HomeTime(); |
|
1568 TInt ret=aLs.RecognizeFilesL(KTestAppDest,*result1); |
|
1569 timeLater.HomeTime(); |
|
1570 TEST(ret==KErrNone); |
|
1571 User::LeaveIfError(ret); |
|
1572 |
|
1573 TTimeIntervalMicroSeconds delayNoCache = timeLater.MicroSecondsFrom(time); |
|
1574 |
|
1575 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.15.0")); |
|
1576 time.HomeTime(); |
|
1577 ret=aLs.RecognizeFilesL(KTestAppDest,*result2); |
|
1578 timeLater.HomeTime(); |
|
1579 TEST(ret==KErrNone); |
|
1580 User::LeaveIfError(ret); |
|
1581 |
|
1582 TTimeIntervalMicroSeconds delayCache = timeLater.MicroSecondsFrom(time); |
|
1583 |
|
1584 //Modify the timestamps on a few files |
|
1585 TInt count = result1->Count(); |
|
1586 for(TInt i=1; i < (count/2); i++) |
|
1587 { |
|
1588 TDataRecognitionResult res; |
|
1589 result1->GetDataRecognitionResultL(res, i); |
|
1590 TFileName fileName; |
|
1591 result1->GetFileNameL(fileName, i); |
|
1592 |
|
1593 ptrFileDir.Copy(KTestAppDest); |
|
1594 ptrFileDir.Append(fileName); |
|
1595 |
|
1596 time.HomeTime(); |
|
1597 theFS.SetModified(ptrFileDir, time); |
|
1598 } |
|
1599 |
|
1600 INFO_PRINTF2(KTestWaitingForApplistUpdate, KApplistUpdateTime); |
|
1601 User::After(KApplistUpdateTime); |
|
1602 |
|
1603 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.15.1")); |
|
1604 time.HomeTime(); |
|
1605 ret=aLs.RecognizeFilesL(KTestAppDest,*result3); |
|
1606 timeLater.HomeTime(); |
|
1607 TEST(ret==KErrNone); |
|
1608 User::LeaveIfError(ret); |
|
1609 |
|
1610 TTimeIntervalMicroSeconds delayCache2 = timeLater.MicroSecondsFrom(time); |
|
1611 #ifndef __WINS__ |
|
1612 // On Emulator, these time related checks cannot always be ensured. |
|
1613 TEST(delayCache2 > delayCache); |
|
1614 TEST(delayCache2 < delayNoCache); |
|
1615 #endif |
|
1616 |
|
1617 // Cleanup |
|
1618 delete fileManager; |
|
1619 CleanupStack::PopAndDestroy(3, result1); // result3, result2, result1 |
|
1620 } |
|
1621 |
|
1622 /** |
|
1623 @SYMTestCaseID T_Serv3Step_DoAsyncRecognizerTest13L |
|
1624 |
|
1625 @SYMPREQ 699 |
|
1626 |
|
1627 @SYMREQ 3899 |
|
1628 |
|
1629 @SYMTestCaseDesc Test PREQ699.17.0 Validates performance of recognition. |
|
1630 |
|
1631 @SYMTestPriority High |
|
1632 |
|
1633 @SYMTestStatus Not Implemented |
|
1634 |
|
1635 @SYMTestActions Call RecognizeFilesL() without a filter on a directory |
|
1636 containing a text file named text.canyoutell |
|
1637 |
|
1638 API Calls:\n |
|
1639 RApaLsSession::RecognizeFilesL(const TDesC& aPath, |
|
1640 const TDesC8& aDataType, |
|
1641 CDataRecognitionResultArray& aResult, |
|
1642 TRequestStatus& aStatus); |
|
1643 CDataRecognitionResultArray::CDataRecognitionResultArray(); |
|
1644 CDataRecognitionResultArray::Count() const; |
|
1645 |
|
1646 @SYMTestExpectedResults\n |
|
1647 status = KErrNone for file creation |
|
1648 count = 1 returned |
|
1649 */ |
|
1650 void CT_Serv3Step::DoAsyncFolderRecognizerTest13L(RApaLsSession& aLs) |
|
1651 { |
|
1652 //Asynchronous folder file recognition Test Group 17 |
|
1653 TBufC<50> mimeDir(KMimeDir); |
|
1654 TPtr ptrMimeDir (mimeDir.Des()); |
|
1655 |
|
1656 TBufC<350> mimeFile(KMimeFile); |
|
1657 TPtr ptrMimeFile(mimeFile.Des()); |
|
1658 |
|
1659 //Setup Active Object |
|
1660 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
1661 CleanupStack::PushL(active); |
|
1662 |
|
1663 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
1664 CleanupStack::PushL(result); |
|
1665 |
|
1666 RFs theFS; |
|
1667 theFS.Connect(); |
|
1668 RFile file; |
|
1669 |
|
1670 RSmlTestUtils utils; |
|
1671 CleanupClosePushL(utils); |
|
1672 |
|
1673 //Create directory for test files |
|
1674 CreateDirL(&utils, ptrMimeDir); |
|
1675 |
|
1676 //Timestamp details for files |
|
1677 TTime time; |
|
1678 time.UniversalTime(); |
|
1679 |
|
1680 // Create file mime_content000.canyoutell with text content |
|
1681 CreateFilesL(theFS, file, ptrMimeFile, (TDesC&)KSuffixUnknown, 1, KHtmlContent, time); |
|
1682 |
|
1683 INFO_PRINTF1(_L("Asynchronous folder file Recognition Test PREQ699.17.0")); |
|
1684 //Test RecognizeFilesL with a MIME type filter "text/html" |
|
1685 aLs.RecognizeFilesL(KMimeDir,_L8("text/html"), *result ,active->iStatus); |
|
1686 |
|
1687 active->StartL();//set active |
|
1688 CActiveScheduler::Start(); |
|
1689 |
|
1690 TEST(active->iStatus==KErrNone); |
|
1691 if (active->iStatus==KErrNone) |
|
1692 { |
|
1693 TUint count = result->Count(); |
|
1694 TEST(count == 1); |
|
1695 } |
|
1696 |
|
1697 DeleteFilesL(&utils, ptrMimeFile, (TDesC&)KSuffixUnknown, 1); |
|
1698 |
|
1699 //Remove test directory |
|
1700 DeleteDirL(&utils, ptrMimeDir); |
|
1701 |
|
1702 // Cleanup |
|
1703 CleanupStack::PopAndDestroy(&utils);//utils |
|
1704 CleanupStack::PopAndDestroy(result);//result2 |
|
1705 CleanupStack::PopAndDestroy(active);//active |
|
1706 |
|
1707 } |
|
1708 /* |
|
1709 |
|
1710 @SYMTestCaseID APPFWK-APPARC-0098 |
|
1711 |
|
1712 @SYMDEF INC125788 |
|
1713 |
|
1714 @SYMTestCaseDesc The test verify that RApaLsSession::CancelRecognizeFiles() complete TRequestStatus with KErrCancel |
|
1715 that was passed to RApaLsSession::RecognizeFilesL() when cancelling the outstanding async recognition request. |
|
1716 |
|
1717 @SYMTestPriority High |
|
1718 |
|
1719 @SYMTestStatus Implemented |
|
1720 |
|
1721 @SYMTestActions |
|
1722 1.RApaLsSession::RecognizeFilesL(const TDesC& aPath, CDataRecognitionResultArray& aResult, TRequestStatus& aStatus) |
|
1723 is called to get data (MIME) types for files in a specified directory. |
|
1724 2.Outstanding async recognition request is cancelled using RApaLsSession::CancelRecognizeFiles(). |
|
1725 |
|
1726 @SYMTestExpectedResults |
|
1727 RApaLsSession::CancelRecognizeFiles() complete the TRequestStatus with KErrCancel. |
|
1728 |
|
1729 */ |
|
1730 void CT_Serv3Step::DoAsyncFolderRecognizerTest14L(RApaLsSession& aLs) |
|
1731 { |
|
1732 //Setup Active Object |
|
1733 CActiveTest2* active = new(ELeave) CActiveTest2(); |
|
1734 CleanupStack::PushL(active); |
|
1735 |
|
1736 CDataRecognitionResultArray* result = new(ELeave) CDataRecognitionResultArray(); |
|
1737 CleanupStack::PushL(result); |
|
1738 |
|
1739 //Check results and Stop AS |
|
1740 _LIT(KStandardDir,"z:\\system\\data\\Testpath\\"); |
|
1741 |
|
1742 INFO_PRINTF1(_L("Asynchronous RecognizeFilesL Test")); |
|
1743 aLs.RecognizeFilesL(KStandardDir,*result,active->iStatus); |
|
1744 active->StartL();//set active |
|
1745 TEST(active->iStatus==KRequestPending); |
|
1746 INFO_PRINTF2(_L("RecognizeFilesL: iStatus = %d\n"), active->iStatus.Int()); |
|
1747 |
|
1748 aLs.CancelRecognizeFiles(); |
|
1749 TEST(active->iStatus==KErrCancel); |
|
1750 INFO_PRINTF2(_L("CancelRecognizeFiles: iStatus = %d\n"), active->iStatus.Int()); |
|
1751 CActiveScheduler::Start(); |
|
1752 |
|
1753 // Cleanup |
|
1754 CleanupStack::PopAndDestroy(result);//result |
|
1755 CleanupStack::PopAndDestroy(active);//active |
|
1756 } |
|
1757 /** |
|
1758 * Auxiliary Fn for the entire Test Step |
|
1759 * |
|
1760 * This method initiates all the tests. |
|
1761 * |
|
1762 */ |
|
1763 TInt CT_Serv3Step::DoServComTestL() |
|
1764 { |
|
1765 INFO_PRINTF1(_L("Testing Server Com")); |
|
1766 |
|
1767 RFs theServFs; |
|
1768 TInt ret = theServFs.Connect(); |
|
1769 TEST(ret==KErrNone); |
|
1770 CleanupClosePushL(theServFs); |
|
1771 |
|
1772 |
|
1773 RTestableApaLsSession ls; |
|
1774 ret = ls.Connect(); |
|
1775 TEST(ret==KErrNone); |
|
1776 CleanupClosePushL(ls); |
|
1777 |
|
1778 //wait for CExtrasAppKeyLayout to open up a RApaLsSession so it doesn't mess with our result |
|
1779 //unsure why it affects this test but not the others |
|
1780 User::After(10000000); |
|
1781 |
|
1782 HEAP_TEST_LS_SESSION(ls, 0, 0, DoSyncFolderRecognizerTest1L(ls), ls.FlushRecognitionCache() ); |
|
1783 HEAP_TEST_LS_SESSION(ls, 0, 0, DoSyncFolderRecognizerTest2L(ls), ls.FlushRecognitionCache() ); |
|
1784 HEAP_TEST_LS_SESSION(ls, 0, 0, DoSyncFolderRecognizerTest3L(ls), ls.FlushRecognitionCache() ); |
|
1785 |
|
1786 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest1L(ls), ls.FlushRecognitionCache() ); |
|
1787 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest2L(ls), ls.FlushRecognitionCache() ); |
|
1788 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest3L(ls), ls.FlushRecognitionCache() ); |
|
1789 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest4L(ls), ls.FlushRecognitionCache() ); |
|
1790 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest5L(ls), ls.FlushRecognitionCache() ); |
|
1791 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest6L(ls), ls.FlushRecognitionCache() ); |
|
1792 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest7L(ls), ls.FlushRecognitionCache() ); |
|
1793 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest8L(ls), ls.FlushRecognitionCache() ); |
|
1794 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest9L(ls), ls.FlushRecognitionCache() ); |
|
1795 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest10L(ls), ls.FlushRecognitionCache() ); |
|
1796 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest11L(ls), ls.FlushRecognitionCache() ); |
|
1797 HEAP_TEST_LS_SESSION(ls, 0, 0, DoSyncFolderRecognizerTest4L(ls), ls.FlushRecognitionCache() ); |
|
1798 HEAP_TEST_LS_SESSION(ls, 0, 0, DoAsyncFolderRecognizerTest13L(ls), ls.FlushRecognitionCache() ); |
|
1799 //DONT_CHECK Skips the heap check at server side. This heap imbalance occurs randomly in server side |
|
1800 // while canceling the outstanding async request. |
|
1801 HEAP_TEST_LS_SESSION(ls, 0, DONT_CHECK, DoAsyncFolderRecognizerTest14L(ls), ls.FlushRecognitionCache() ); |
|
1802 CleanupStack::PopAndDestroy(&ls); |
|
1803 |
|
1804 // close the server session and we have done some type store reloading |
|
1805 CleanupStack::PopAndDestroy(&theServFs); |
|
1806 |
|
1807 return KErrNone; |
|
1808 } |
|
1809 |
|
1810 |
|
1811 |
|
1812 TVerdict CT_Serv3Step::doTestStepPreambleL() |
|
1813 /** |
|
1814 * @return - TVerdict code |
|
1815 * Override of base class virtual |
|
1816 */ |
|
1817 { |
|
1818 SetTestStepResult(EPass); |
|
1819 return TestStepResult(); |
|
1820 } |
|
1821 |
|
1822 TVerdict CT_Serv3Step::doTestStepPostambleL() |
|
1823 /** |
|
1824 * @return - TVerdict code |
|
1825 * Override of base class virtual |
|
1826 */ |
|
1827 { |
|
1828 return TestStepResult(); |
|
1829 } |
|
1830 |
|
1831 void CT_Serv3Step::CreateDirL(RSmlTestUtils* aPtrUtils, TPtr aDirName) |
|
1832 { |
|
1833 User::LeaveIfError(aPtrUtils->Connect()); |
|
1834 aPtrUtils->CreateDirectoryL(aDirName); |
|
1835 |
|
1836 //Delay required to prevent armv5 failure |
|
1837 const TInt KApplistUpdateTime = 800000; |
|
1838 User::After(KApplistUpdateTime); |
|
1839 } |
|
1840 |
|
1841 void CT_Serv3Step::CreateFilesL(RFs& aFS, RFile& aFile, TPtr aFileRoot, TDesC& aSuffix, TInt aFileNumber, const TDesC8& aFileContent, TTime aTime = 0) |
|
1842 { |
|
1843 if(aTime == 0) |
|
1844 { |
|
1845 aTime.UniversalTime(); |
|
1846 } |
|
1847 |
|
1848 for(TInt counter=0; counter<aFileNumber; counter++) |
|
1849 { |
|
1850 aFileRoot.AppendNumFixedWidth(counter, EDecimal, KFixedNumWidth); |
|
1851 aFileRoot.Append(aSuffix); |
|
1852 |
|
1853 //Creates a file if does not already exist. If file exists, |
|
1854 //content is overwritten |
|
1855 TEST(KErrNone == aFile.Replace(aFS, aFileRoot, EFileWrite)); |
|
1856 |
|
1857 TEST(KErrNone == aFile.Write(aFileContent)); |
|
1858 TEST(KErrNone == aFile.SetModified(aTime)); |
|
1859 TEST(KErrNone == aFile.Flush()); |
|
1860 aFile.Close(); |
|
1861 |
|
1862 TInt Length = aFileRoot.Length(); |
|
1863 TInt DeleteLength = aSuffix.Length() + KFixedNumWidth; |
|
1864 aFileRoot.Delete( (Length - DeleteLength) , DeleteLength); |
|
1865 } |
|
1866 |
|
1867 //Delay required to prevent armv5 failure |
|
1868 const TInt KApplistUpdateTime = 800000; |
|
1869 User::After(KApplistUpdateTime); |
|
1870 } |
|
1871 |
|
1872 void CT_Serv3Step::DeleteDirL(RSmlTestUtils* aPtrUtils, TPtr aDirName) |
|
1873 { |
|
1874 aPtrUtils->DeleteDirectoryL(aDirName); |
|
1875 } |
|
1876 |
|
1877 void CT_Serv3Step::DeleteFilesL(RSmlTestUtils* aPtrUtils, TPtr aDirName, TDesC& aSuffix, TInt aFileNumber) |
|
1878 { |
|
1879 for(TInt counter=0; counter<aFileNumber; counter++) |
|
1880 { |
|
1881 aDirName.AppendNumFixedWidth(counter, EDecimal, KFixedNumWidth); |
|
1882 aDirName.Append(aSuffix); |
|
1883 aPtrUtils->DeleteFileL(aDirName); |
|
1884 TInt Length = aDirName.Length(); |
|
1885 TInt DeleteLength = aSuffix.Length() + KFixedNumWidth; |
|
1886 aDirName.Delete( (Length - DeleteLength) , DeleteLength); |
|
1887 } |
|
1888 } |
|
1889 |
|
1890 TVerdict CT_Serv3Step::doTestStepL() |
|
1891 /** |
|
1892 * Override of base class virtual. |
|
1893 * @return - TVerdict code |
|
1894 */ |
|
1895 { |
|
1896 //Set up active scheduler |
|
1897 iActiveScheduler= new(ELeave) CActiveScheduler; |
|
1898 CActiveScheduler::Install(iActiveScheduler); |
|
1899 |
|
1900 FbsStartup(); |
|
1901 TInt ret = RFbsSession::Connect(); |
|
1902 TEST(ret==KErrNone); |
|
1903 |
|
1904 // run the testcode (inside an alloc heaven harness) |
|
1905 INFO_PRINTF1(_L("About to start tests:")); |
|
1906 TRAP(ret,DoServComTestL()); |
|
1907 INFO_PRINTF2(_L(" DoServComTestL completes with %d"), ret); |
|
1908 TEST(ret==KErrNone); |
|
1909 |
|
1910 INFO_PRINTF1(_L("Test Completed!")); |
|
1911 return TestStepResult(); |
|
1912 |
|
1913 } |
|
1914 |
|
1915 |
|
1916 /** |
|
1917 * |
|
1918 * Methods for Active Object Test |
|
1919 * |
|
1920 * Used in for Asynchronous Data Recognizer tests |
|
1921 * |
|
1922 */ |
|
1923 |
|
1924 CActiveTest2::CActiveTest2() |
|
1925 :CActive(0) |
|
1926 { |
|
1927 CActiveScheduler::Add(this); |
|
1928 } |
|
1929 |
|
1930 CActiveTest2::~CActiveTest2() |
|
1931 { |
|
1932 Cancel(); |
|
1933 } |
|
1934 |
|
1935 void CActiveTest2::DoCancel() |
|
1936 { |
|
1937 TRequestStatus* s=&iStatus; |
|
1938 User::RequestComplete(s, KErrNone); |
|
1939 } |
|
1940 |
|
1941 void CActiveTest2::StartL() |
|
1942 { |
|
1943 SetActive(); |
|
1944 } |
|
1945 |
|
1946 void CActiveTest2::RunL() |
|
1947 { |
|
1948 //Stop AS |
|
1949 CActiveScheduler::Stop(); |
|
1950 } |
|
1951 |