|
1 /* |
|
2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: test document_handler_api |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // [INCLUDE FILES] |
|
20 #include <e32svr.h> |
|
21 #include <stifparser.h> |
|
22 #include <stiftestinterface.h> |
|
23 #include <eikproc.h> |
|
24 #include <eikenv.h> |
|
25 #include <f32file.h> |
|
26 #include <apmstd.h> |
|
27 #include <pathinfo.h> |
|
28 #include <documenthandler.h> |
|
29 |
|
30 #include "testsdkdocumenthandler.h" |
|
31 #include "testsdkdocumenthandlerobserver.h" |
|
32 |
|
33 const TInt KLength = 50; |
|
34 _LIT( KNewFile, "\\data\\others\\testdocumenthandlercopy.txt" ); |
|
35 _LIT( KSaveFile, "\\data\\others\\save" ); |
|
36 _LIT8( KType, "text/vnd.test" ); |
|
37 _LIT( KUnnamedFile, "\\data\\others\\Unnamed" ); |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CTestSDKDocumentHandler::Delete |
|
42 // Delete here all resources allocated and opened from test methods. |
|
43 // Called from destructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 void CTestSDKDocumentHandler::Delete() |
|
47 { |
|
48 |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CTestSDKDocumentHandler::RunMethodL |
|
53 // Run specified method. Contains also table of test mothods and their names. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 TInt CTestSDKDocumentHandler::RunMethodL( CStifItemParser& aItem ) |
|
57 { |
|
58 |
|
59 static TStifFunctionInfo const KFunctions[] = |
|
60 { |
|
61 // First string is the function name used in TestScripter script file. |
|
62 // Second is the actual implementation member function. |
|
63 ENTRY( "TestPLNewPL", CTestSDKDocumentHandler::TestDHNewPL ), |
|
64 ENTRY( "TestDHNewPLC", CTestSDKDocumentHandler::TestDHNewPLC ), |
|
65 ENTRY( "TestDHNewL", CTestSDKDocumentHandler::TestDHNewL ), |
|
66 ENTRY( "TestDHNewLC", CTestSDKDocumentHandler::TestDHNewLC ), |
|
67 ENTRY( "TestDHDeconstructorL", CTestSDKDocumentHandler::TestDHDeconstructorL ), |
|
68 ENTRY( "TestDHOpenTempFileL", CTestSDKDocumentHandler::TestDHOpenTempFileL ), |
|
69 ENTRY( "TestDHSaveTempFileL", CTestSDKDocumentHandler::TestDHSaveTempFileL ), |
|
70 ENTRY( "TestDHInParamListL", CTestSDKDocumentHandler::TestDHInParamListL ), |
|
71 ENTRY( "TestDHOutParamListL", CTestSDKDocumentHandler::TestDHOutParamListL ), |
|
72 ENTRY( "TestDHOpenFileRL", CTestSDKDocumentHandler::TestDHOpenFileRL ), |
|
73 ENTRY( "TestDHOpenFileEmbeddedGPL", CTestSDKDocumentHandler::TestDHOpenFileEmbeddedGPL ), |
|
74 ENTRY( "TestDHOpenFileEmbeddedRL", CTestSDKDocumentHandler::TestDHOpenFileEmbeddedRL ), |
|
75 ENTRY( "TestDHOpenFileL", CTestSDKDocumentHandler::TestDHOpenFileL ), |
|
76 ENTRY( "TestDHOpenFileEmbeddedL", CTestSDKDocumentHandler::TestDHOpenFileEmbeddedL ), |
|
77 ENTRY( "TestDHSaveL", CTestSDKDocumentHandler::TestDHSaveL ), |
|
78 ENTRY( "TestDHSaveNL", CTestSDKDocumentHandler::TestDHSaveNL ), |
|
79 ENTRY( "TestDHCopyL", CTestSDKDocumentHandler::TestDHCopyL ), |
|
80 ENTRY( "TestDHCopyRL", CTestSDKDocumentHandler::TestDHCopyRL ), |
|
81 ENTRY( "TestDHMoveL", CTestSDKDocumentHandler::TestDHMoveL ), |
|
82 ENTRY( "TestDHSilentMoveL", CTestSDKDocumentHandler::TestDHSilentMoveL ), |
|
83 ENTRY( "TestDHCanHandleL", CTestSDKDocumentHandler::TestDHCanHandleL ), |
|
84 ENTRY( "TestDHCanOpenL", CTestSDKDocumentHandler::TestDHCanOpenL ), |
|
85 ENTRY( "TestDHCanSaveL", CTestSDKDocumentHandler::TestDHCanSaveL ), |
|
86 ENTRY( "TestDHGetPathL", CTestSDKDocumentHandler::TestDHGetPathL ), |
|
87 ENTRY( "TestDHHandlerAppUidL", CTestSDKDocumentHandler::TestDHHandlerAppUidL ), |
|
88 ENTRY( "TestDHSetExitObserverL", CTestSDKDocumentHandler::TestDHSetExitObserverL ), |
|
89 ENTRY( "TestDHCheckFileNameExtensionL", CTestSDKDocumentHandler::TestDHCheckFileNameExtensionL ), |
|
90 ENTRY( "TestDHCanHandleProgressivelyL", CTestSDKDocumentHandler::TestDHCanHandleProgressivelyL ), |
|
91 ENTRY( "TestDHGetProgressiveDownloadAppUidsL", CTestSDKDocumentHandler::TestDHGetProgressiveDownloadAppUidsL ), |
|
92 |
|
93 |
|
94 // [test cases entries] |
|
95 |
|
96 }; |
|
97 |
|
98 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
99 |
|
100 return RunInternalL( KFunctions, count, aItem ); |
|
101 |
|
102 } |
|
103 |
|
104 // ============================ MEMBER FUNCTIONS =============================== |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CTestSDKDocumentHandler::TestDHNewPL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TInt CTestSDKDocumentHandler::TestDHNewPL( CStifItemParser& /*aItem*/ ) |
|
110 { |
|
111 CEikProcess* process = iEikonEnvPointer->Process(); |
|
112 CleanupStack::PushL( process ); |
|
113 STIF_ASSERT_NOT_NULL( process ); |
|
114 |
|
115 CDocumentHandler* documentHandler = CDocumentHandler::NewL( process ); |
|
116 CleanupStack::PushL( documentHandler ); |
|
117 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
118 |
|
119 CleanupStack::PopAndDestroy( documentHandler ); |
|
120 CleanupStack::Pop( process ); |
|
121 |
|
122 return KErrNone; |
|
123 |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CTestSDKDocumentHandler::TestDHNewPLC |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TInt CTestSDKDocumentHandler::TestDHNewPLC( CStifItemParser& /*aItem*/ ) |
|
131 { |
|
132 CEikProcess* process = iEikonEnvPointer->Process(); |
|
133 CleanupStack::PushL( process ); |
|
134 STIF_ASSERT_NOT_NULL( process ); |
|
135 |
|
136 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( process ); |
|
137 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
138 |
|
139 CleanupStack::PopAndDestroy( documentHandler ); |
|
140 CleanupStack::Pop( process ); |
|
141 |
|
142 return KErrNone; |
|
143 |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CTestSDKDocumentHandler::TestDHNewL |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 TInt CTestSDKDocumentHandler::TestDHNewL( CStifItemParser& /*aItem*/ ) |
|
151 { |
|
152 CDocumentHandler* documentHandler = CDocumentHandler::NewL(); |
|
153 CleanupStack::PushL( documentHandler ); |
|
154 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
155 |
|
156 CleanupStack::PopAndDestroy( documentHandler ); |
|
157 |
|
158 return KErrNone; |
|
159 |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CTestSDKDocumentHandler::TestDHNewLC |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CTestSDKDocumentHandler::TestDHNewLC( CStifItemParser& /*aItem*/ ) |
|
167 { |
|
168 CDocumentHandler* documentHandler = CDocumentHandler::NewLC(); |
|
169 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
170 |
|
171 CleanupStack::PopAndDestroy( documentHandler ); |
|
172 |
|
173 return KErrNone; |
|
174 |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CTestSDKDocumentHandler::TestDHDeconstructorL |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 TInt CTestSDKDocumentHandler::TestDHDeconstructorL( CStifItemParser& /*aItem*/ ) |
|
182 { |
|
183 CDocumentHandler* documentHandler = CDocumentHandler::NewLC(); |
|
184 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
185 |
|
186 CleanupStack::PopAndDestroy( documentHandler ); |
|
187 |
|
188 return KErrNone; |
|
189 |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CTestSDKDocumentHandler::TestDHOpenTempFileL |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 TInt CTestSDKDocumentHandler::TestDHOpenTempFileL( CStifItemParser& /*aItem*/ ) |
|
197 { |
|
198 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
199 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
200 |
|
201 _LIT( KFile, "\\system\\apps\\opentemp.txt" ); |
|
202 |
|
203 RFs& fs = iEikonEnvPointer->FsSession(); |
|
204 |
|
205 RFile file; |
|
206 CleanupClosePushL( file ); |
|
207 STIF_ASSERT_NOT_NULL( &file ); |
|
208 |
|
209 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
210 { |
|
211 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
212 } |
|
213 TInt error = KErrNone; |
|
214 |
|
215 TRAP( error, documentHandler->OpenTempFileL( KFile, file ) ); |
|
216 |
|
217 CleanupStack::PopAndDestroy( &file ); |
|
218 CleanupStack::PopAndDestroy( documentHandler ); |
|
219 |
|
220 return error; |
|
221 |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CTestSDKDocumentHandler::TestDHSaveTempFileL |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 TInt CTestSDKDocumentHandler::TestDHSaveTempFileL( CStifItemParser& /*aItem*/ ) |
|
229 { |
|
230 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
231 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
232 |
|
233 _LIT( KFile, "savetemp.txt" ); |
|
234 _LIT8( KContext, "Content Text" ); |
|
235 TBuf8<KLength> context( KContext ); |
|
236 |
|
237 RFs& fs = iEikonEnvPointer->FsSession(); |
|
238 |
|
239 RFile file; |
|
240 CleanupClosePushL( file ); |
|
241 STIF_ASSERT_NOT_NULL( &file ); |
|
242 |
|
243 TDataType dataType; |
|
244 |
|
245 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
246 { |
|
247 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
248 } |
|
249 TInt error = KErrNone; |
|
250 |
|
251 TRAP( error, documentHandler->SaveTempFileL( context, dataType, KFile, file ) ); |
|
252 |
|
253 CleanupStack::PopAndDestroy( &file ); |
|
254 CleanupStack::PopAndDestroy( documentHandler ); |
|
255 |
|
256 return error; |
|
257 |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CTestSDKDocumentHandler::TestDHInParamListL |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TInt CTestSDKDocumentHandler::TestDHInParamListL( CStifItemParser& /*aItem*/ ) |
|
265 { |
|
266 CDocumentHandler* documentHandler = CDocumentHandler::NewL( iEikonEnvPointer->Process() ); |
|
267 CleanupStack::PushL( documentHandler ); |
|
268 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
269 |
|
270 CAiwGenericParamList& paramlist = documentHandler->InParamListL(); |
|
271 STIF_ASSERT_NOT_NULL( ¶mlist ); |
|
272 |
|
273 CleanupStack::PopAndDestroy( documentHandler ); |
|
274 |
|
275 return KErrNone; |
|
276 |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CTestSDKDocumentHandler::TestDHOutParamListL |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 TInt CTestSDKDocumentHandler::TestDHOutParamListL( CStifItemParser& /*aItem*/ ) |
|
284 { |
|
285 CDocumentHandler* documentHandler = CDocumentHandler::NewL( iEikonEnvPointer->Process() ); |
|
286 CleanupStack::PushL( documentHandler ); |
|
287 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
288 |
|
289 const CAiwGenericParamList* paramlist = documentHandler->OutParamList(); |
|
290 STIF_ASSERT_NULL( paramlist ); |
|
291 |
|
292 CleanupStack::PopAndDestroy( documentHandler ); |
|
293 |
|
294 return KErrNone; |
|
295 |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CTestSDKDocumentHandler::TestDHOpenFileRL |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 TInt CTestSDKDocumentHandler::TestDHOpenFileRL( CStifItemParser& /*aItem*/ ) |
|
303 { |
|
304 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
305 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
306 |
|
307 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
308 _LIT8( KContext, "Content Text" ); |
|
309 TBuf8<KLength> context( KContext ); |
|
310 |
|
311 RFs& fs = iEikonEnvPointer->FsSession(); |
|
312 |
|
313 RFile file; |
|
314 CleanupClosePushL( file ); |
|
315 STIF_ASSERT_NOT_NULL( &file ); |
|
316 |
|
317 TDataType dataType; |
|
318 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
319 { |
|
320 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
321 } |
|
322 |
|
323 file.Write( context ); |
|
324 TInt flag = documentHandler->OpenFileL( file, dataType ); |
|
325 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
326 |
|
327 CleanupStack::PopAndDestroy( &file ); |
|
328 CleanupStack::PopAndDestroy( documentHandler ); |
|
329 |
|
330 return KErrNone; |
|
331 |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CTestSDKDocumentHandler::TestDHOpenFileEmbeddedGPL |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 TInt CTestSDKDocumentHandler::TestDHOpenFileEmbeddedGPL( CStifItemParser& /*aItem*/ ) |
|
339 { |
|
340 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
341 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
342 |
|
343 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
344 _LIT8( KContext, "Content Text" ); |
|
345 TBuf8<KLength> context( KContext ); |
|
346 |
|
347 RFs& fs = iEikonEnvPointer->FsSession(); |
|
348 |
|
349 RFile file; |
|
350 CleanupClosePushL( file ); |
|
351 STIF_ASSERT_NOT_NULL( &file ); |
|
352 |
|
353 TDataType dataType; |
|
354 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
355 { |
|
356 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
357 } |
|
358 |
|
359 CAiwGenericParamList& paramlist = documentHandler->InParamListL(); |
|
360 STIF_ASSERT_NOT_NULL( ¶mlist ); |
|
361 |
|
362 file.Write( context ); |
|
363 TInt flag = documentHandler->OpenFileEmbeddedL( file, dataType, paramlist ); |
|
364 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
365 |
|
366 CleanupStack::PopAndDestroy( &file ); |
|
367 CleanupStack::PopAndDestroy( documentHandler ); |
|
368 |
|
369 return KErrNone; |
|
370 |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CTestSDKDocumentHandler::TestDHOpenFileEmbeddedRL |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 TInt CTestSDKDocumentHandler::TestDHOpenFileEmbeddedRL( CStifItemParser& /*aItem*/ ) |
|
378 { |
|
379 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
380 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
381 |
|
382 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
383 _LIT8( KContext, "Content Text" ); |
|
384 TBuf8<KLength> context( KContext ); |
|
385 |
|
386 RFs& fs = iEikonEnvPointer->FsSession(); |
|
387 |
|
388 RFile file; |
|
389 CleanupClosePushL( file ); |
|
390 STIF_ASSERT_NOT_NULL( &file ); |
|
391 |
|
392 TDataType dataType; |
|
393 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
394 { |
|
395 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
396 } |
|
397 |
|
398 file.Write( context ); |
|
399 TInt flag = documentHandler->OpenFileEmbeddedL( file, dataType ); |
|
400 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
401 |
|
402 CleanupStack::PopAndDestroy( &file ); |
|
403 CleanupStack::PopAndDestroy( documentHandler ); |
|
404 |
|
405 return KErrNone; |
|
406 |
|
407 } |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // CTestSDKDocumentHandler::TestDHOpenFileL |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 TInt CTestSDKDocumentHandler::TestDHOpenFileL( CStifItemParser& /*aItem*/ ) |
|
414 { |
|
415 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
416 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
417 |
|
418 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
419 _LIT8( KContext, "Content Text" ); |
|
420 TBuf8<KLength> context( KContext ); |
|
421 |
|
422 RFs& fs = iEikonEnvPointer->FsSession(); |
|
423 |
|
424 RFile file; |
|
425 CleanupClosePushL( file ); |
|
426 STIF_ASSERT_NOT_NULL( &file ); |
|
427 |
|
428 TDataType dataType; |
|
429 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
430 { |
|
431 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
432 } |
|
433 |
|
434 file.Write( context ); |
|
435 TInt flag = documentHandler->OpenFileL( KFile, dataType ); |
|
436 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
437 |
|
438 CleanupStack::PopAndDestroy( &file ); |
|
439 CleanupStack::PopAndDestroy( documentHandler ); |
|
440 |
|
441 return KErrNone; |
|
442 |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CTestSDKDocumentHandler::TestDHOpenFileEmbeddedL |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 TInt CTestSDKDocumentHandler::TestDHOpenFileEmbeddedL( CStifItemParser& /*aItem*/ ) |
|
450 { |
|
451 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
452 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
453 |
|
454 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
455 _LIT8( KContext, "Content Text" ); |
|
456 TBuf8<KLength> context( KContext ); |
|
457 |
|
458 RFs& fs = iEikonEnvPointer->FsSession(); |
|
459 |
|
460 RFile file; |
|
461 CleanupClosePushL( file ); |
|
462 STIF_ASSERT_NOT_NULL( &file ); |
|
463 |
|
464 TDataType dataType; |
|
465 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
466 { |
|
467 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
468 } |
|
469 |
|
470 file.Write( context ); |
|
471 TInt flag = documentHandler->OpenFileEmbeddedL( KFile, dataType ); |
|
472 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
473 |
|
474 CleanupStack::PopAndDestroy( &file ); |
|
475 CleanupStack::PopAndDestroy( documentHandler ); |
|
476 |
|
477 return KErrNone; |
|
478 |
|
479 } |
|
480 |
|
481 // ----------------------------------------------------------------------------- |
|
482 // CTestSDKDocumentHandler::TestDHSaveL |
|
483 // ----------------------------------------------------------------------------- |
|
484 // |
|
485 TInt CTestSDKDocumentHandler::TestDHSaveL( CStifItemParser& /*aItem*/ ) |
|
486 { |
|
487 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
488 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
489 |
|
490 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
491 _LIT8( KContext, "Content Text" ); |
|
492 TBuf8<KLength> context( KContext ); |
|
493 |
|
494 RFs& fs = iEikonEnvPointer->FsSession(); |
|
495 fs.Delete( KUnnamedFile ); |
|
496 |
|
497 RFile file; |
|
498 CleanupClosePushL( file ); |
|
499 STIF_ASSERT_NOT_NULL( &file ); |
|
500 |
|
501 TDataType dataType( KType ); |
|
502 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
503 { |
|
504 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
505 } |
|
506 |
|
507 file.Write( context ); |
|
508 TInt flag = documentHandler->SaveL( context, dataType, 0 ); |
|
509 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
510 |
|
511 CleanupStack::PopAndDestroy( &file ); |
|
512 CleanupStack::PopAndDestroy( documentHandler ); |
|
513 |
|
514 return KErrNone; |
|
515 |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // CTestSDKDocumentHandler::TestDHSaveNL |
|
520 // ----------------------------------------------------------------------------- |
|
521 // |
|
522 TInt CTestSDKDocumentHandler::TestDHSaveNL( CStifItemParser& /*aItem*/ ) |
|
523 { |
|
524 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
525 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
526 |
|
527 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
528 _LIT8( KContext, "Content Text" ); |
|
529 TBuf8<KLength> context( KContext ); |
|
530 |
|
531 RFs& fs = iEikonEnvPointer->FsSession(); |
|
532 fs.Delete( KSaveFile ); |
|
533 |
|
534 RFile file; |
|
535 CleanupClosePushL( file ); |
|
536 STIF_ASSERT_NOT_NULL( &file ); |
|
537 |
|
538 TDataType dataType( KType ); |
|
539 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
540 { |
|
541 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
542 } |
|
543 |
|
544 file.Write( context ); |
|
545 |
|
546 _LIT( KName, "save" ); |
|
547 TBuf<KLength> name( KName ); |
|
548 |
|
549 TInt flag = documentHandler->SaveL( context, dataType, name, 0 ); |
|
550 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
551 |
|
552 CleanupStack::PopAndDestroy( &file ); |
|
553 CleanupStack::PopAndDestroy( documentHandler ); |
|
554 |
|
555 return KErrNone; |
|
556 |
|
557 } |
|
558 |
|
559 // ----------------------------------------------------------------------------- |
|
560 // CTestSDKDocumentHandler::TestDHCopyL |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 TInt CTestSDKDocumentHandler::TestDHCopyL( CStifItemParser& /*aItem*/ ) |
|
564 { |
|
565 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
566 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
567 |
|
568 _LIT( KFile, "C:\\system\\apps\\testdocumenthandler.txt" ); |
|
569 _LIT( KNewPath, "testdocumenthandlercopy.txt" ); |
|
570 _LIT8( KContext, "Content Text" ); |
|
571 TBuf8<KLength> context( KContext ); |
|
572 |
|
573 RFs& fs = iEikonEnvPointer->FsSession(); |
|
574 fs.Delete( KNewFile ); |
|
575 |
|
576 RFile file; |
|
577 CleanupClosePushL( file ); |
|
578 STIF_ASSERT_NOT_NULL( &file ); |
|
579 |
|
580 TDataType dataType( KType ); |
|
581 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
582 { |
|
583 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
584 } |
|
585 |
|
586 file.Write( context ); |
|
587 |
|
588 _LIT( KName, "save" ); |
|
589 TBuf<KLength> name( KName ); |
|
590 |
|
591 CleanupStack::PopAndDestroy( &file ); |
|
592 |
|
593 TInt flag = documentHandler->CopyL( KFile, KNewPath, dataType, 0 ); |
|
594 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
595 |
|
596 CleanupStack::PopAndDestroy( documentHandler ); |
|
597 |
|
598 return KErrNone; |
|
599 |
|
600 } |
|
601 |
|
602 // ----------------------------------------------------------------------------- |
|
603 // CTestSDKDocumentHandler::TestDHCopyRL |
|
604 // ----------------------------------------------------------------------------- |
|
605 // |
|
606 TInt CTestSDKDocumentHandler::TestDHCopyRL( CStifItemParser& /*aItem*/ ) |
|
607 { |
|
608 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
609 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
610 |
|
611 _LIT( KFile, "C:\\system\\apps\\testdocumenthandler.txt" ); |
|
612 _LIT( KNewPath, "testdocumenthandlercopy.txt" ); |
|
613 _LIT8( KContext, "Content Text" ); |
|
614 TBuf8<KLength> context( KContext ); |
|
615 |
|
616 RFs& fs = iEikonEnvPointer->FsSession(); |
|
617 fs.Delete( KNewFile ); |
|
618 |
|
619 RFile file; |
|
620 CleanupClosePushL( file ); |
|
621 STIF_ASSERT_NOT_NULL( &file ); |
|
622 |
|
623 TDataType dataType( KType ); |
|
624 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
625 { |
|
626 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
627 } |
|
628 |
|
629 file.Write( context ); |
|
630 |
|
631 _LIT( KName, "save" ); |
|
632 TBuf<KLength> name( KName ); |
|
633 |
|
634 TInt flag = documentHandler->CopyL( file, KNewPath, dataType, 0 ); |
|
635 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
636 |
|
637 CleanupStack::PopAndDestroy( &file ); |
|
638 CleanupStack::PopAndDestroy( documentHandler ); |
|
639 |
|
640 return KErrNone; |
|
641 |
|
642 } |
|
643 |
|
644 // ----------------------------------------------------------------------------- |
|
645 // CTestSDKDocumentHandler::TestDHMoveL |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 TInt CTestSDKDocumentHandler::TestDHMoveL( CStifItemParser& /*aItem*/ ) |
|
649 { |
|
650 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
651 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
652 |
|
653 _LIT( KFile, "C:\\system\\apps\\testdocumenthandler.txt" ); |
|
654 _LIT( KNewPath, "testdocumenthandlercopy.txt" ); |
|
655 _LIT8( KContext, "Content Text" ); |
|
656 TBuf8<KLength> context( KContext ); |
|
657 |
|
658 RFs& fs = iEikonEnvPointer->FsSession(); |
|
659 fs.Delete( KNewFile ); |
|
660 |
|
661 RFile file; |
|
662 CleanupClosePushL( file ); |
|
663 STIF_ASSERT_NOT_NULL( &file ); |
|
664 |
|
665 TDataType dataType( KType ); |
|
666 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
667 { |
|
668 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
669 } |
|
670 |
|
671 file.Write( context ); |
|
672 |
|
673 _LIT( KName, "save" ); |
|
674 TBuf<KLength> name( KName ); |
|
675 |
|
676 CleanupStack::PopAndDestroy( &file ); |
|
677 |
|
678 TInt flag = documentHandler->MoveL( KFile, KNewPath, dataType, 0 ); |
|
679 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
680 |
|
681 CleanupStack::PopAndDestroy( documentHandler ); |
|
682 |
|
683 return KErrNone; |
|
684 |
|
685 } |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CTestSDKDocumentHandler::TestDHSilentMoveL |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 TInt CTestSDKDocumentHandler::TestDHSilentMoveL( CStifItemParser& /*aItem*/ ) |
|
692 { |
|
693 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
694 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
695 |
|
696 _LIT( KFile, "C:\\system\\apps\\testdocumenthandler.txt" ); |
|
697 _LIT( KNewPath, "testdocumenthandlercopy.txt" ); |
|
698 _LIT8( KContext, "Content Text" ); |
|
699 TBuf8<KLength> context( KContext ); |
|
700 |
|
701 RFs& fs = iEikonEnvPointer->FsSession(); |
|
702 fs.Delete( KNewFile ); |
|
703 |
|
704 RFile file; |
|
705 CleanupClosePushL( file ); |
|
706 STIF_ASSERT_NOT_NULL( &file ); |
|
707 |
|
708 TDataType dataType( KType ); |
|
709 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
710 { |
|
711 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
712 } |
|
713 |
|
714 file.Write( context ); |
|
715 |
|
716 _LIT( KName, "save" ); |
|
717 TBuf<KLength> name( KName ); |
|
718 |
|
719 CleanupStack::PopAndDestroy( &file ); |
|
720 |
|
721 TInt flag = documentHandler->SilentMoveL( KFile, KNewPath, PathInfo::PhoneMemoryRootPath(), dataType, 0 ); |
|
722 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
723 |
|
724 CleanupStack::PopAndDestroy( documentHandler ); |
|
725 |
|
726 return KErrNone; |
|
727 |
|
728 } |
|
729 |
|
730 // ----------------------------------------------------------------------------- |
|
731 // CTestSDKDocumentHandler::TestDHCanHandleL |
|
732 // ----------------------------------------------------------------------------- |
|
733 // |
|
734 TInt CTestSDKDocumentHandler::TestDHCanHandleL( CStifItemParser& /*aItem*/ ) |
|
735 { |
|
736 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
737 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
738 |
|
739 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
740 _LIT8( KContext, "Content Text" ); |
|
741 TBuf8<KLength> context( KContext ); |
|
742 |
|
743 RFs& fs = iEikonEnvPointer->FsSession(); |
|
744 |
|
745 RFile file; |
|
746 CleanupClosePushL( file ); |
|
747 STIF_ASSERT_NOT_NULL( &file ); |
|
748 |
|
749 TDataType dataType; |
|
750 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
751 { |
|
752 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
753 } |
|
754 |
|
755 file.Write( context ); |
|
756 |
|
757 _LIT( KName, "save" ); |
|
758 TBuf<KLength> name( KName ); |
|
759 |
|
760 TInt flag = documentHandler->OpenFileL( KFile, dataType ); |
|
761 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
762 |
|
763 TInt canhandle = documentHandler->CanHandleL( dataType ); |
|
764 STIF_ASSERT_TRUE( canhandle ); |
|
765 |
|
766 CleanupStack::PopAndDestroy( &file ); |
|
767 CleanupStack::PopAndDestroy( documentHandler ); |
|
768 |
|
769 return KErrNone; |
|
770 |
|
771 } |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CTestSDKDocumentHandler::TestDHCanOpenL |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 TInt CTestSDKDocumentHandler::TestDHCanOpenL( CStifItemParser& /*aItem*/ ) |
|
778 { |
|
779 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
780 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
781 |
|
782 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
783 _LIT8( KContext, "Content Text" ); |
|
784 TBuf8<KLength> context( KContext ); |
|
785 |
|
786 RFs& fs = iEikonEnvPointer->FsSession(); |
|
787 |
|
788 RFile file; |
|
789 CleanupClosePushL( file ); |
|
790 STIF_ASSERT_NOT_NULL( &file ); |
|
791 |
|
792 TDataType dataType; |
|
793 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
794 { |
|
795 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
796 } |
|
797 |
|
798 file.Write( context ); |
|
799 |
|
800 _LIT( KName, "save" ); |
|
801 TBuf<KLength> name( KName ); |
|
802 |
|
803 TInt flag = documentHandler->OpenFileL( KFile, dataType ); |
|
804 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
805 |
|
806 TInt canopen = documentHandler->CanOpenL( dataType ); |
|
807 STIF_ASSERT_TRUE( canopen ); |
|
808 |
|
809 CleanupStack::PopAndDestroy( &file ); |
|
810 CleanupStack::PopAndDestroy( documentHandler ); |
|
811 |
|
812 return KErrNone; |
|
813 |
|
814 } |
|
815 |
|
816 // ----------------------------------------------------------------------------- |
|
817 // CTestSDKDocumentHandler::TestDHCanSaveL |
|
818 // ----------------------------------------------------------------------------- |
|
819 // |
|
820 TInt CTestSDKDocumentHandler::TestDHCanSaveL( CStifItemParser& /*aItem*/ ) |
|
821 { |
|
822 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
823 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
824 |
|
825 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
826 _LIT8( KContext, "Content Text" ); |
|
827 TBuf8<KLength> context( KContext ); |
|
828 |
|
829 RFs& fs = iEikonEnvPointer->FsSession(); |
|
830 |
|
831 RFile file; |
|
832 CleanupClosePushL( file ); |
|
833 STIF_ASSERT_NOT_NULL( &file ); |
|
834 |
|
835 TDataType dataType; |
|
836 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
837 { |
|
838 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
839 } |
|
840 |
|
841 file.Write( context ); |
|
842 |
|
843 _LIT( KName, "save" ); |
|
844 TBuf<KLength> name( KName ); |
|
845 |
|
846 TInt cansave = documentHandler->CanSaveL( dataType ); |
|
847 STIF_ASSERT_TRUE( cansave ); |
|
848 |
|
849 CleanupStack::PopAndDestroy( &file ); |
|
850 CleanupStack::PopAndDestroy( documentHandler ); |
|
851 |
|
852 return KErrNone; |
|
853 |
|
854 } |
|
855 |
|
856 // ----------------------------------------------------------------------------- |
|
857 // CTestSDKDocumentHandler::TestDHGetPathL |
|
858 // ----------------------------------------------------------------------------- |
|
859 // |
|
860 TInt CTestSDKDocumentHandler::TestDHGetPathL( CStifItemParser& /*aItem*/ ) |
|
861 { |
|
862 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
863 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
864 |
|
865 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
866 _LIT8( KContext, "Content Text" ); |
|
867 TBuf8<KLength> context( KContext ); |
|
868 |
|
869 RFs& fs = iEikonEnvPointer->FsSession(); |
|
870 fs.Delete( KSaveFile ); |
|
871 |
|
872 RFile file; |
|
873 CleanupClosePushL( file ); |
|
874 STIF_ASSERT_NOT_NULL( &file ); |
|
875 |
|
876 TDataType dataType( KType ); |
|
877 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
878 { |
|
879 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
880 } |
|
881 |
|
882 file.Write( context ); |
|
883 |
|
884 _LIT( KName, "save" ); |
|
885 TBuf<KLength> name( KName ); |
|
886 |
|
887 TInt flag = documentHandler->SaveL( context, dataType, name, 0 ); |
|
888 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
889 |
|
890 const TInt KPathLength = 50; |
|
891 TBuf<KPathLength> path; |
|
892 TInt getpath = documentHandler->GetPath( path ); |
|
893 STIF_ASSERT_TRUE( getpath == KErrNone ); |
|
894 |
|
895 CleanupStack::PopAndDestroy( &file ); |
|
896 CleanupStack::PopAndDestroy( documentHandler ); |
|
897 |
|
898 return KErrNone; |
|
899 |
|
900 } |
|
901 |
|
902 // ----------------------------------------------------------------------------- |
|
903 // CTestSDKDocumentHandler::TestDHHandlerAppUidL |
|
904 // ----------------------------------------------------------------------------- |
|
905 // |
|
906 TInt CTestSDKDocumentHandler::TestDHHandlerAppUidL( CStifItemParser& /*aItem*/ ) |
|
907 { |
|
908 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
909 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
910 |
|
911 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
912 _LIT8( KContext, "Content Text" ); |
|
913 TBuf8<KLength> context( KContext ); |
|
914 |
|
915 RFs& fs = iEikonEnvPointer->FsSession(); |
|
916 fs.Delete( KUnnamedFile ); |
|
917 |
|
918 RFile file; |
|
919 CleanupClosePushL( file ); |
|
920 STIF_ASSERT_NOT_NULL( &file ); |
|
921 |
|
922 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
923 { |
|
924 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
925 } |
|
926 |
|
927 TDataType dataType( KType ); |
|
928 TInt flag = documentHandler->SaveL( context, dataType, 0 ); |
|
929 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
930 |
|
931 TUid uid; |
|
932 documentHandler->HandlerAppUid( uid ); |
|
933 |
|
934 CleanupStack::PopAndDestroy( &file ); |
|
935 CleanupStack::PopAndDestroy( documentHandler ); |
|
936 |
|
937 return KErrNone; |
|
938 |
|
939 } |
|
940 |
|
941 // ----------------------------------------------------------------------------- |
|
942 // CTestSDKDocumentHandler::TestDHSetExitObserverL |
|
943 // ----------------------------------------------------------------------------- |
|
944 // |
|
945 TInt CTestSDKDocumentHandler::TestDHSetExitObserverL( CStifItemParser& /*aItem*/ ) |
|
946 { |
|
947 CTestSDKDocumentHandlerObserver* observer = new (ELeave) CTestSDKDocumentHandlerObserver; |
|
948 CleanupStack::PushL( observer ); |
|
949 STIF_ASSERT_NOT_NULL( observer ); |
|
950 |
|
951 CDocumentHandler* documentHandler = CDocumentHandler::NewL( iEikonEnvPointer->Process() ); |
|
952 CleanupStack::PushL( documentHandler ); |
|
953 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
954 |
|
955 documentHandler->SetExitObserver( observer ); |
|
956 |
|
957 CleanupStack::PopAndDestroy( documentHandler ); |
|
958 CleanupStack::PopAndDestroy( observer ); |
|
959 |
|
960 return KErrNone; |
|
961 |
|
962 } |
|
963 |
|
964 // ----------------------------------------------------------------------------- |
|
965 // CTestSDKDocumentHandler::TestDHCheckFileNameExtensionL |
|
966 // ----------------------------------------------------------------------------- |
|
967 // |
|
968 TInt CTestSDKDocumentHandler::TestDHCheckFileNameExtensionL( CStifItemParser& /*aItem*/ ) |
|
969 { |
|
970 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
971 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
972 |
|
973 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
974 _LIT8( KContext, "Content Text" ); |
|
975 TBuf8<KLength> context( KContext ); |
|
976 |
|
977 RFs& fs = iEikonEnvPointer->FsSession(); |
|
978 fs.Delete( KUnnamedFile ); |
|
979 |
|
980 RFile file; |
|
981 CleanupClosePushL( file ); |
|
982 STIF_ASSERT_NOT_NULL( &file ); |
|
983 |
|
984 TDataType dataType( KType ); |
|
985 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
986 { |
|
987 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
988 } |
|
989 |
|
990 file.Write( context ); |
|
991 TInt flag = documentHandler->SaveL( context, dataType, 0 ); |
|
992 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
993 |
|
994 TBuf<KLength> filename; |
|
995 documentHandler->CheckFileNameExtension( filename, dataType ); |
|
996 |
|
997 CleanupStack::PopAndDestroy( &file ); |
|
998 CleanupStack::PopAndDestroy( documentHandler ); |
|
999 |
|
1000 return KErrNone; |
|
1001 |
|
1002 } |
|
1003 |
|
1004 // ----------------------------------------------------------------------------- |
|
1005 // CTestSDKDocumentHandler::TestDHCanHandleProgressivelyL |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // |
|
1008 TInt CTestSDKDocumentHandler::TestDHCanHandleProgressivelyL( CStifItemParser& /*aItem*/ ) |
|
1009 { |
|
1010 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
1011 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
1012 |
|
1013 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
1014 _LIT8( KContext, "Content Text" ); |
|
1015 TBuf8<KLength> context( KContext ); |
|
1016 |
|
1017 RFs& fs = iEikonEnvPointer->FsSession(); |
|
1018 fs.Delete( KUnnamedFile ); |
|
1019 |
|
1020 RFile file; |
|
1021 CleanupClosePushL( file ); |
|
1022 STIF_ASSERT_NOT_NULL( &file ); |
|
1023 |
|
1024 TDataType dataType( KType ); |
|
1025 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
1026 { |
|
1027 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
1028 } |
|
1029 |
|
1030 file.Write( context ); |
|
1031 TInt flag = documentHandler->SaveL( context, dataType, 0 ); |
|
1032 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
1033 |
|
1034 TUid uid; |
|
1035 documentHandler->CanHandleProgressivelyL( dataType, uid ); |
|
1036 |
|
1037 CleanupStack::PopAndDestroy( &file ); |
|
1038 CleanupStack::PopAndDestroy( documentHandler ); |
|
1039 |
|
1040 return KErrNone; |
|
1041 |
|
1042 } |
|
1043 |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // CTestSDKDocumentHandler::TestDHGetProgressiveDownloadAppUidsL |
|
1046 // ----------------------------------------------------------------------------- |
|
1047 // |
|
1048 TInt CTestSDKDocumentHandler::TestDHGetProgressiveDownloadAppUidsL( CStifItemParser& /*aItem*/ ) |
|
1049 { |
|
1050 CDocumentHandler* documentHandler = CDocumentHandler::NewLC( iEikonEnvPointer->Process() ); |
|
1051 STIF_ASSERT_NOT_NULL( documentHandler ); |
|
1052 |
|
1053 _LIT( KFile, "\\system\\apps\\testdocumenthandler.txt" ); |
|
1054 _LIT8( KContext, "Content Text" ); |
|
1055 TBuf8<KLength> context( KContext ); |
|
1056 |
|
1057 RFs& fs = iEikonEnvPointer->FsSession(); |
|
1058 fs.Delete( KUnnamedFile ); |
|
1059 |
|
1060 RFile file; |
|
1061 CleanupClosePushL( file ); |
|
1062 STIF_ASSERT_NOT_NULL( &file ); |
|
1063 |
|
1064 TDataType dataType( KType ); |
|
1065 if( file.Open( fs, KFile, EFileWrite | EFileShareAny ) != KErrNone ) |
|
1066 { |
|
1067 file.Create( fs, KFile, EFileWrite | EFileShareAny ); |
|
1068 } |
|
1069 |
|
1070 file.Write( context ); |
|
1071 TInt flag = documentHandler->SaveL( context, dataType, 0 ); |
|
1072 STIF_ASSERT_TRUE( flag == KErrNone ); |
|
1073 |
|
1074 RArray<TInt32> uidList; |
|
1075 CleanupClosePushL( uidList ); |
|
1076 STIF_ASSERT_NOT_NULL( &uidList ); |
|
1077 |
|
1078 TUid uid; |
|
1079 documentHandler->CanHandleProgressivelyL( dataType, uid ); |
|
1080 documentHandler->GetProgressiveDownloadAppUidsL( uidList ); |
|
1081 |
|
1082 CleanupStack::PopAndDestroy( &uidList ); |
|
1083 CleanupStack::PopAndDestroy( &file ); |
|
1084 CleanupStack::PopAndDestroy( documentHandler ); |
|
1085 |
|
1086 return KErrNone; |
|
1087 |
|
1088 } |
|
1089 |
|
1090 // [End of File] |