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