1 /* |
|
2 * Copyright (c) 2005-2006 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: Source file for EUnit test app for MountMan API |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "T_RSFW_TA_Basic.h" |
|
21 |
|
22 // INCLUDES |
|
23 #include <EUnitMacros.h> |
|
24 #include <rsfwmountentry.h> |
|
25 #include <rsfwmountentryitem.h> |
|
26 #include <f32file.h> |
|
27 #include <badesca.h> |
|
28 #include <ecom.h> |
|
29 #include "rsfwcontrol.h" |
|
30 #include <s32file.h> |
|
31 |
|
32 // CONSTRUCTION |
|
33 T_MountMan* T_MountMan::NewL() |
|
34 { |
|
35 T_MountMan* self = T_MountMan::NewLC(); |
|
36 CleanupStack::Pop(); |
|
37 |
|
38 return self; |
|
39 } |
|
40 |
|
41 T_MountMan* T_MountMan::NewLC() |
|
42 { |
|
43 T_MountMan* self = new( ELeave ) T_MountMan(); |
|
44 CleanupStack::PushL( self ); |
|
45 |
|
46 self->ConstructL(); |
|
47 |
|
48 return self; |
|
49 } |
|
50 |
|
51 // Destructor (virtual by CBase) |
|
52 T_MountMan::~T_MountMan() |
|
53 { |
|
54 iFs.Close(); |
|
55 REComSession::FinalClose(); |
|
56 } |
|
57 |
|
58 // Default constructor |
|
59 T_MountMan::T_MountMan() |
|
60 { |
|
61 } |
|
62 |
|
63 // Second phase construct |
|
64 void T_MountMan::ConstructL() |
|
65 { |
|
66 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
67 // It generates the test case table. |
|
68 CEUnitTestSuiteClass::ConstructL(); |
|
69 |
|
70 iFs.Connect(); |
|
71 } |
|
72 |
|
73 // METHODS |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // T_MountMan::SetupL |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 void T_MountMan::SetupL( ) |
|
80 { |
|
81 iMountMan = CRsfwMountMan::NewL(0,NULL); |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // T_MountMan::Teardown |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 void T_MountMan::Teardown( ) |
|
89 { |
|
90 delete iMountMan; |
|
91 iMountMan = NULL; |
|
92 } |
|
93 |
|
94 /////////////////////////////////////////////////////////////////////////////// |
|
95 ////// CRsfwMountEntry /////////////////////////////////////////////////////// |
|
96 /////////////////////////////////////////////////////////////////////////////// |
|
97 |
|
98 |
|
99 // ---------------------------------------------------------------------------- |
|
100 // T_MountMan::TestSetMountEntryL |
|
101 // Tests that it is not possible to create an entry with too long attributes |
|
102 // ---------------------------------------------------------------------------- |
|
103 // |
|
104 void T_MountMan::TestSetMountEntryL( ) |
|
105 { |
|
106 TInt err; |
|
107 CRsfwMountEntry* mountEntry; |
|
108 mountEntry = CRsfwMountEntry::NewLC(); |
|
109 |
|
110 // too long friendly name |
|
111 TBuf<KMaxMountNameLength+1> longName; |
|
112 longName.FillZ(longName.MaxLength()); |
|
113 TRAP(err, mountEntry->SetItemL(EMountEntryItemName, longName)); |
|
114 EUNIT_ASSERT(err == KErrArgument); |
|
115 |
|
116 // too long URI |
|
117 TBuf<KMaxMountUriLength+1> longUri; |
|
118 longUri.FillZ(longUri.MaxLength()); |
|
119 TRAP(err, mountEntry->SetItemL(EMountEntryItemUri, longUri)); |
|
120 EUNIT_ASSERT(err == KErrArgument); |
|
121 |
|
122 // too long username |
|
123 TBuf<KMaxMountUserNameLength+1> longUserName; |
|
124 longUserName.FillZ(longUserName.MaxLength()); |
|
125 TRAP(err, mountEntry->SetItemL(EMountEntryItemUserName, longUserName)); |
|
126 EUNIT_ASSERT(err == KErrArgument); |
|
127 |
|
128 // too long password |
|
129 TBuf<KMaxMountPasswordLength+1> longPassword; |
|
130 longPassword.FillZ(longPassword.MaxLength()); |
|
131 TRAP(err, mountEntry->SetItemL(EMountEntryItemPassword, longPassword)); |
|
132 EUNIT_ASSERT(err == KErrArgument); |
|
133 |
|
134 // too long IAP |
|
135 TBuf<KMaxMountConfItemLength+1> longIap; |
|
136 longIap.FillZ(longIap.MaxLength()); |
|
137 TRAP(err, mountEntry->SetItemL(EMountEntryItemIap, longIap)); |
|
138 EUNIT_ASSERT(err == KErrArgument); |
|
139 |
|
140 CleanupStack::PopAndDestroy(mountEntry); |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // T_MountMan::TestSetItemL |
|
145 // Tests CRsfwMountEntry::SetItemL(TInt aIndex, const TDesC8& aValue); |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void T_MountMan::TestSetItemL( ) |
|
149 { |
|
150 TInt err; |
|
151 CRsfwMountEntry* mountEntry; |
|
152 mountEntry = CRsfwMountEntry::NewLC(); |
|
153 |
|
154 // set entry items one by one |
|
155 TRAP(err, mountEntry->SetItemL(EMountEntryItemName, _L8("name"))); |
|
156 EUNIT_ASSERT(err == KErrNone); |
|
157 TRAP(err, mountEntry->SetItemL(EMountEntryItemUri, _L8("http://url"))); |
|
158 EUNIT_ASSERT(err == KErrNone); |
|
159 TRAP(err, mountEntry->SetItemL(EMountEntryItemUserName, _L8("username"))); |
|
160 EUNIT_ASSERT(err == KErrNone); |
|
161 TRAP(err, mountEntry->SetItemL(EMountEntryItemPassword, _L8("password"))); |
|
162 EUNIT_ASSERT(err == KErrNone); |
|
163 TRAP(err, mountEntry->SetItemL(EMountEntryItemIap, _L8("iap"))); |
|
164 EUNIT_ASSERT(err == KErrNone); |
|
165 |
|
166 // check the values |
|
167 const HBufC* item = mountEntry->Item(EMountEntryItemName); |
|
168 EUNIT_ASSERT((*item).Compare(_L("name")) == KErrNone); |
|
169 item = mountEntry->Item(EMountEntryItemUri); |
|
170 EUNIT_ASSERT((*item).Compare(_L("http://url")) == KErrNone); |
|
171 item = mountEntry->Item(EMountEntryItemUserName); |
|
172 EUNIT_ASSERT((*item).Compare(_L("username")) == KErrNone); |
|
173 item = mountEntry->Item(EMountEntryItemPassword); |
|
174 EUNIT_ASSERT((*item).Compare(_L("password")) == KErrNone); |
|
175 item = mountEntry->Item(EMountEntryItemIap); |
|
176 EUNIT_ASSERT((*item).Compare(_L("iap")) == KErrNone); |
|
177 |
|
178 CleanupStack::PopAndDestroy(mountEntry); |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------------------------- |
|
182 // T_MountMan::TestSetItemL |
|
183 // Tests CRsfwMountEntry::SetItemL(TInt aIndex, const TDesC& aValue); |
|
184 // ---------------------------------------------------------------------------- |
|
185 // |
|
186 void T_MountMan::TestSetItem2L( ) |
|
187 { |
|
188 TInt err; |
|
189 CRsfwMountEntry* mountEntry; |
|
190 mountEntry = CRsfwMountEntry::NewLC(); |
|
191 |
|
192 // set entry items one by one |
|
193 TRAP(err, mountEntry->SetItemL(EMountEntryItemName, _L("name"))); |
|
194 EUNIT_ASSERT(err == KErrNone); |
|
195 TRAP(err, mountEntry->SetItemL(EMountEntryItemUri, _L("http://url"))); |
|
196 EUNIT_ASSERT(err == KErrNone); |
|
197 TRAP(err, mountEntry->SetItemL(EMountEntryItemUserName, _L("username"))); |
|
198 EUNIT_ASSERT(err == KErrNone); |
|
199 TRAP(err, mountEntry->SetItemL(EMountEntryItemPassword, _L("password"))); |
|
200 EUNIT_ASSERT(err == KErrNone); |
|
201 TRAP(err, mountEntry->SetItemL(EMountEntryItemIap, _L("iap"))); |
|
202 EUNIT_ASSERT(err == KErrNone); |
|
203 |
|
204 // check the values |
|
205 const HBufC* item = mountEntry->Item(EMountEntryItemName); |
|
206 EUNIT_ASSERT((*item).Compare(_L("name")) == KErrNone); |
|
207 item = mountEntry->Item(EMountEntryItemUri); |
|
208 EUNIT_ASSERT((*item).Compare(_L("http://url")) == KErrNone); |
|
209 item = mountEntry->Item(EMountEntryItemUserName); |
|
210 EUNIT_ASSERT((*item).Compare(_L("username")) == KErrNone); |
|
211 item = mountEntry->Item(EMountEntryItemPassword); |
|
212 EUNIT_ASSERT((*item).Compare(_L("password")) == KErrNone); |
|
213 item = mountEntry->Item(EMountEntryItemIap); |
|
214 EUNIT_ASSERT((*item).Compare(_L("iap")) == KErrNone); |
|
215 |
|
216 CleanupStack::PopAndDestroy(mountEntry); |
|
217 } |
|
218 |
|
219 // ---------------------------------------------------------------------------- |
|
220 // T_MountMan::TestClearL |
|
221 // Tests CRsfwMountEntry::Clear |
|
222 // ---------------------------------------------------------------------------- |
|
223 // |
|
224 void T_MountMan::TestClearL( ) |
|
225 { |
|
226 TInt err; |
|
227 CRsfwMountEntry* mountEntry; |
|
228 mountEntry = CRsfwMountEntry::NewL(); |
|
229 CleanupStack::PushL(mountEntry); |
|
230 |
|
231 // set entry items one by one |
|
232 TRAP(err, mountEntry->SetItemL(EMountEntryItemName, _L("name"))); |
|
233 EUNIT_ASSERT(err == KErrNone); |
|
234 TRAP(err, mountEntry->SetItemL(EMountEntryItemUri, _L("http://url"))); |
|
235 EUNIT_ASSERT(err == KErrNone); |
|
236 TRAP(err, mountEntry->SetItemL(EMountEntryItemUserName, _L("username"))); |
|
237 EUNIT_ASSERT(err == KErrNone); |
|
238 TRAP(err, mountEntry->SetItemL(EMountEntryItemPassword, _L("password"))); |
|
239 EUNIT_ASSERT(err == KErrNone); |
|
240 TRAP(err, mountEntry->SetItemL(EMountEntryItemIap, _L("iap"))); |
|
241 EUNIT_ASSERT(err == KErrNone); |
|
242 |
|
243 // clear the values |
|
244 mountEntry->Clear(); |
|
245 |
|
246 // check whether the values are NULL |
|
247 const HBufC* item = mountEntry->Item(EMountEntryItemName); |
|
248 EUNIT_ASSERT(item == NULL); |
|
249 item = mountEntry->Item(EMountEntryItemUri); |
|
250 EUNIT_ASSERT(item == NULL); |
|
251 item = mountEntry->Item(EMountEntryItemUserName); |
|
252 EUNIT_ASSERT(item == NULL); |
|
253 item = mountEntry->Item(EMountEntryItemPassword); |
|
254 EUNIT_ASSERT(item == NULL); |
|
255 item = mountEntry->Item(EMountEntryItemIap); |
|
256 EUNIT_ASSERT(item == NULL); |
|
257 |
|
258 CleanupStack::PopAndDestroy(mountEntry); |
|
259 } |
|
260 |
|
261 // ---------------------------------------------------------------------------- |
|
262 // T_MountMan::TestCloneL |
|
263 // Tests CRsfwMountEntry::Clone |
|
264 // ---------------------------------------------------------------------------- |
|
265 // |
|
266 void T_MountMan::TestCloneL( ) |
|
267 { |
|
268 TInt err; |
|
269 CRsfwMountEntry* mountEntry; |
|
270 mountEntry = CRsfwMountEntry::NewL(); |
|
271 CleanupStack::PushL(mountEntry); |
|
272 |
|
273 // set entry items one by one |
|
274 TRAP(err, mountEntry->SetItemL(EMountEntryItemName, _L("name"))); |
|
275 EUNIT_ASSERT(err == KErrNone); |
|
276 TRAP(err, mountEntry->SetItemL(EMountEntryItemUri, _L("http://url"))); |
|
277 EUNIT_ASSERT(err == KErrNone); |
|
278 TRAP(err, mountEntry->SetItemL(EMountEntryItemUserName, _L("username"))); |
|
279 EUNIT_ASSERT(err == KErrNone); |
|
280 TRAP(err, mountEntry->SetItemL(EMountEntryItemPassword, _L("password"))); |
|
281 EUNIT_ASSERT(err == KErrNone); |
|
282 TRAP(err, mountEntry->SetItemL(EMountEntryItemIap, _L("iap"))); |
|
283 EUNIT_ASSERT(err == KErrNone); |
|
284 |
|
285 // clone the entry |
|
286 CRsfwMountEntry* clonedEntry = mountEntry->CloneL(); |
|
287 CleanupStack::PushL(clonedEntry); |
|
288 |
|
289 // check the values in cloned entry |
|
290 const HBufC* item = clonedEntry->Item(EMountEntryItemName); |
|
291 EUNIT_ASSERT((*item).Compare(_L("name")) == KErrNone); |
|
292 item = clonedEntry->Item(EMountEntryItemUri); |
|
293 EUNIT_ASSERT((*item).Compare(_L("http://url")) == KErrNone); |
|
294 item = clonedEntry->Item(EMountEntryItemUserName); |
|
295 EUNIT_ASSERT((*item).Compare(_L("username")) == KErrNone); |
|
296 item = clonedEntry->Item(EMountEntryItemPassword); |
|
297 EUNIT_ASSERT((*item).Compare(_L("password")) == KErrNone); |
|
298 item = clonedEntry->Item(EMountEntryItemIap); |
|
299 EUNIT_ASSERT((*item).Compare(_L("iap")) == KErrNone); |
|
300 |
|
301 CleanupStack::PopAndDestroy(clonedEntry); |
|
302 CleanupStack::PopAndDestroy(mountEntry); |
|
303 } |
|
304 |
|
305 // ---------------------------------------------------------------------------- |
|
306 // T_MountMan::TestAddMountEntryL |
|
307 // Tests that it is possible to add 9 mount entries, but not more |
|
308 // ---------------------------------------------------------------------------- |
|
309 // |
|
310 void T_MountMan::TestAddMountEntryL( ) |
|
311 { |
|
312 // be sure no mount entries are in CenRep |
|
313 ClearAllMountsL(); |
|
314 |
|
315 TInt err; |
|
316 err = AddMountEntryL(0, |
|
317 _L("drivename0"), |
|
318 DriveToChar(EDriveK), |
|
319 _L("http://url0.com"), |
|
320 _L("userName0"), |
|
321 _L("password0"), |
|
322 _L("iap0")); |
|
323 EUNIT_ASSERT(err == KErrNone); |
|
324 err = AddMountEntryL(1, |
|
325 _L("drivename1"), |
|
326 DriveToChar(EDriveL), |
|
327 _L("http://url1.com"), |
|
328 _L("userName1"), |
|
329 _L("password1"), |
|
330 _L("iap1")); |
|
331 EUNIT_ASSERT(err == KErrNone); |
|
332 err = AddMountEntryL(2, |
|
333 _L("drivename2"), |
|
334 DriveToChar(EDriveM), |
|
335 _L("http://url2.com"), |
|
336 _L("userName2"), |
|
337 _L("password2"), |
|
338 _L("iap2")); |
|
339 EUNIT_ASSERT(err == KErrNone); |
|
340 err = AddMountEntryL(3, |
|
341 _L("drivename3"), |
|
342 DriveToChar(EDriveN), |
|
343 _L("http://url3.com"), |
|
344 _L("userName3"), |
|
345 _L("password3"), |
|
346 _L("iap3")); |
|
347 EUNIT_ASSERT(err == KErrNone); |
|
348 err = AddMountEntryL(4, |
|
349 _L("drivename4"), |
|
350 DriveToChar(EDriveO), |
|
351 _L("http://url4.com"), |
|
352 _L("userName4"), |
|
353 _L("password4"), |
|
354 _L("iap4")); |
|
355 EUNIT_ASSERT(err == KErrNone); |
|
356 err = AddMountEntryL(5, |
|
357 _L("drivename5"), |
|
358 DriveToChar(EDriveP), |
|
359 _L("http://url5.com"), |
|
360 _L("userName5"), |
|
361 _L("password5"), |
|
362 _L("iap5")); |
|
363 EUNIT_ASSERT(err == KErrNone); |
|
364 err = AddMountEntryL(6, |
|
365 _L("drivename6"), |
|
366 DriveToChar(EDriveQ), |
|
367 _L("http://url6.com"), |
|
368 _L("userName6"), |
|
369 _L("password6"), |
|
370 _L("iap6")); |
|
371 EUNIT_ASSERT(err == KErrNone); |
|
372 err = AddMountEntryL(7, |
|
373 _L("drivename7"), |
|
374 DriveToChar(EDriveR), |
|
375 _L("http://url7.com"), |
|
376 _L("userName7"), |
|
377 _L("password7"), |
|
378 _L("iap7")); |
|
379 EUNIT_ASSERT(err == KErrNone); |
|
380 err = AddMountEntryL(8, |
|
381 _L("drivename8"), |
|
382 DriveToChar(EDriveS), |
|
383 _L("http://url8.com"), |
|
384 _L("userName8"), |
|
385 _L("password8"), |
|
386 _L("iap8")); |
|
387 EUNIT_ASSERT(err == KErrNone); |
|
388 // 10th drive should not pass! |
|
389 err = AddMountEntryL(9, |
|
390 _L("drivename9"), |
|
391 DriveToChar(EDriveT), |
|
392 _L("http://url9.com"), |
|
393 _L("userName9"), |
|
394 _L("password9"), |
|
395 _L("iap9")); |
|
396 EUNIT_ASSERT(err == KErrInUse); |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // T_MountMan::TestAddMountEntry2L |
|
401 // Tests that it is not possible to add two entries with the same name |
|
402 // ---------------------------------------------------------------------------- |
|
403 // |
|
404 void T_MountMan::TestAddMountEntry2L( ) |
|
405 { |
|
406 // be sure no mount entries are in CenRep |
|
407 ClearAllMountsL(); |
|
408 |
|
409 TInt err; |
|
410 err = AddMountEntryL(0, |
|
411 _L("thesamename"), |
|
412 DriveToChar(EDriveK), |
|
413 _L("http://url0.com"), |
|
414 _L("userName0"), |
|
415 _L("password0"), |
|
416 _L("iap0")); |
|
417 EUNIT_ASSERT(err == KErrNone); |
|
418 err = AddMountEntryL(1, |
|
419 _L("thesamename"), |
|
420 DriveToChar(EDriveL), |
|
421 _L("http://url1.com"), |
|
422 _L("userName1"), |
|
423 _L("password1"), |
|
424 _L("iap1")); |
|
425 EUNIT_ASSERT(err == KErrInUse); |
|
426 } |
|
427 |
|
428 // ---------------------------------------------------------------------------- |
|
429 // T_MountMan::TestAddMountEntry3L |
|
430 // Tests that it is not possible to add two entries with the same drive letter |
|
431 // ---------------------------------------------------------------------------- |
|
432 // |
|
433 void T_MountMan::TestAddMountEntry3L( ) |
|
434 { |
|
435 // be sure no mount entries are in CenRep |
|
436 ClearAllMountsL(); |
|
437 |
|
438 TInt err; |
|
439 err = AddMountEntryL(0, |
|
440 _L("drivename0"), |
|
441 DriveToChar(EDriveK), |
|
442 _L("http://url0.com"), |
|
443 _L("userName0"), |
|
444 _L("password0"), |
|
445 _L("iap0")); |
|
446 EUNIT_ASSERT(err == KErrNone); |
|
447 err = AddMountEntryL(1, |
|
448 _L("drivename1"), |
|
449 DriveToChar(EDriveK), |
|
450 _L("http://url1.com"), |
|
451 _L("userName1"), |
|
452 _L("password1"), |
|
453 _L("iap1")); |
|
454 EUNIT_ASSERT(err == KErrInUse); |
|
455 } |
|
456 |
|
457 // ---------------------------------------------------------------------------- |
|
458 // T_MountMan::TestEditMountEntryL |
|
459 // ---------------------------------------------------------------------------- |
|
460 // |
|
461 void T_MountMan::TestEditMountEntryL( ) |
|
462 { |
|
463 // be sure no mount entries are in CenRep |
|
464 ClearAllMountsL(); |
|
465 |
|
466 TInt err; |
|
467 err = AddMountEntryL(0, |
|
468 _L("drivename0"), |
|
469 DriveToChar(EDriveK), |
|
470 _L("http://url0.com"), |
|
471 _L("userName0"), |
|
472 _L("password0"), |
|
473 _L("iap0")); |
|
474 EUNIT_ASSERT(err == KErrNone); |
|
475 |
|
476 err = EditMountEntryL(0, |
|
477 _L("differentName"), |
|
478 DriveToChar(EDriveK), |
|
479 _L("http://different.com"), |
|
480 _L("differentUserName"), |
|
481 _L("differentPassword"), |
|
482 _L("differentIap")); |
|
483 EUNIT_ASSERT(err == KErrNone); |
|
484 |
|
485 const CRsfwMountEntry* entry = NULL; |
|
486 TRAP (err, entry = iMountMan->MountEntryL(DriveToChar(EDriveK))); |
|
487 EUNIT_ASSERT(err == KErrNone); |
|
488 |
|
489 err = CheckEntryL(entry, |
|
490 0, |
|
491 _L("differentName"), |
|
492 DriveToChar(EDriveK), |
|
493 _L("http://different.com"), |
|
494 _L("differentUserName"), |
|
495 _L("differentPassword"), |
|
496 _L("differentIap")); |
|
497 EUNIT_ASSERT(err == KErrNone); |
|
498 } |
|
499 |
|
500 // ---------------------------------------------------------------------------- |
|
501 // T_MountMan::TestEditMountEntry2L |
|
502 // tests that nonexising mount cannot be edited |
|
503 // ---------------------------------------------------------------------------- |
|
504 // |
|
505 void T_MountMan::TestEditMountEntry2L( ) |
|
506 { |
|
507 // be sure no mount entries are in CenRep |
|
508 ClearAllMountsL(); |
|
509 |
|
510 TInt err; |
|
511 // try to edit nonexisting mount |
|
512 err = EditMountEntryL(0, |
|
513 _L("drivename0"), |
|
514 DriveToChar(EDriveK), |
|
515 _L("http://url1.com"), |
|
516 _L("userName0"), |
|
517 _L("password0"), |
|
518 _L("iap0")); |
|
519 EUNIT_ASSERT(err == KErrNotFound); |
|
520 } |
|
521 |
|
522 // ---------------------------------------------------------------------------- |
|
523 // T_MountMan::TestEditMountEntry3L |
|
524 // tests that it is not allowed to change the name into the one |
|
525 // that is already in use |
|
526 // ---------------------------------------------------------------------------- |
|
527 // |
|
528 void T_MountMan::TestEditMountEntry3L( ) |
|
529 { |
|
530 // be sure no mount entries are in CenRep |
|
531 ClearAllMountsL(); |
|
532 |
|
533 TInt err; |
|
534 err = AddMountEntryL(0, |
|
535 _L("drivename0"), |
|
536 DriveToChar(EDriveK), |
|
537 _L("http://url0.com"), |
|
538 _L("userName0"), |
|
539 _L("password0"), |
|
540 _L("iap0")); |
|
541 EUNIT_ASSERT(err == KErrNone); |
|
542 |
|
543 err = AddMountEntryL(1, |
|
544 _L("drivename1"), |
|
545 DriveToChar(EDriveL), |
|
546 _L("http://url1.com"), |
|
547 _L("userName1"), |
|
548 _L("password1"), |
|
549 _L("iap1")); |
|
550 EUNIT_ASSERT(err == KErrNone); |
|
551 |
|
552 // change the name of the 1st mount into the one used by the 2nd one |
|
553 err = EditMountEntryL(0, |
|
554 _L("drivename0"), |
|
555 DriveToChar(EDriveL), |
|
556 _L("http://url1.com"), |
|
557 _L("userName1"), |
|
558 _L("password1"), |
|
559 _L("iap1")); |
|
560 EUNIT_ASSERT(err == KErrInUse); |
|
561 } |
|
562 |
|
563 // ---------------------------------------------------------------------------- |
|
564 // T_MountMan::TestDeleteMountEntryL |
|
565 // ---------------------------------------------------------------------------- |
|
566 // |
|
567 void T_MountMan::TestDeleteMountEntryL( ) |
|
568 { |
|
569 // be sure no mount entries are in CenRep |
|
570 ClearAllMountsL(); |
|
571 |
|
572 TInt err; |
|
573 err = AddMountEntryL(0, |
|
574 _L("drivename0"), |
|
575 DriveToChar(EDriveK), |
|
576 _L("http://url0.com"), |
|
577 _L("userName0"), |
|
578 _L("password0"), |
|
579 _L("iap0")); |
|
580 EUNIT_ASSERT(err == KErrNone); |
|
581 |
|
582 err = AddMountEntryL(1, |
|
583 _L("drivename1"), |
|
584 DriveToChar(EDriveL), |
|
585 _L("http://url1.com"), |
|
586 _L("userName1"), |
|
587 _L("password1"), |
|
588 _L("iap1")); |
|
589 EUNIT_ASSERT(err == KErrNone); |
|
590 |
|
591 TRAP (err, iMountMan->DeleteMountEntryL(_L("drivename0"))); |
|
592 EUNIT_ASSERT(err == KErrNone); |
|
593 |
|
594 TDriveList expectedList; |
|
595 expectedList.Append(DriveToChar(EDriveL)); |
|
596 |
|
597 TDriveList returnedList; |
|
598 TRAP(err,iMountMan->GetRemoteMountListL(returnedList)); |
|
599 EUNIT_ASSERT(err == KErrNone); |
|
600 |
|
601 err = expectedList.Compare(returnedList); |
|
602 EUNIT_ASSERT(err == KErrNone); |
|
603 } |
|
604 |
|
605 // ---------------------------------------------------------------------------- |
|
606 // T_MountMan::TestDeleteMountEntry2L |
|
607 // Tests that deleting nonexisting mount entry does not hurt |
|
608 // ---------------------------------------------------------------------------- |
|
609 // |
|
610 void T_MountMan::TestDeleteMountEntry2L( ) |
|
611 { |
|
612 // be sure no mount entries are in CenRep |
|
613 ClearAllMountsL(); |
|
614 |
|
615 TInt err; |
|
616 TRAP (err, iMountMan->DeleteMountEntryL(_L("drivename0"))); |
|
617 EUNIT_ASSERT(err == KErrNone); |
|
618 } |
|
619 |
|
620 // ---------------------------------------------------------------------------- |
|
621 // T_MountMan::TestDeleteMountEntry3L |
|
622 // tests DeleteMountEntryL(const TDesC& aName); |
|
623 // ---------------------------------------------------------------------------- |
|
624 // |
|
625 void T_MountMan::TestDeleteMountEntry3L( ) |
|
626 { |
|
627 // be sure no mount entries are in CenRep |
|
628 ClearAllMountsL(); |
|
629 |
|
630 TInt err; |
|
631 err = AddMountEntryL(0, |
|
632 _L("drivename0"), |
|
633 DriveToChar(EDriveK), |
|
634 _L("http://url0.com"), |
|
635 _L("userName0"), |
|
636 _L("password0"), |
|
637 _L("iap0")); |
|
638 EUNIT_ASSERT(err == KErrNone); |
|
639 |
|
640 err = AddMountEntryL(1, |
|
641 _L("drivename1"), |
|
642 DriveToChar(EDriveL), |
|
643 _L("http://url1.com"), |
|
644 _L("userName1"), |
|
645 _L("password1"), |
|
646 _L("iap1")); |
|
647 EUNIT_ASSERT(err == KErrNone); |
|
648 |
|
649 TRAP (err, iMountMan->DeleteMountEntryL(DriveToChar(EDriveK))); |
|
650 EUNIT_ASSERT(err == KErrNone); |
|
651 |
|
652 TDriveList expectedList; |
|
653 expectedList.Append(DriveToChar(EDriveL)); |
|
654 |
|
655 TDriveList returnedList; |
|
656 TRAP(err,iMountMan->GetRemoteMountListL(returnedList)); |
|
657 EUNIT_ASSERT(err == KErrNone); |
|
658 |
|
659 err = expectedList.Compare(returnedList); |
|
660 EUNIT_ASSERT(err == KErrNone); |
|
661 } |
|
662 |
|
663 // ---------------------------------------------------------------------------- |
|
664 // T_MountMan::TestMountEntryL |
|
665 // tests MountEntryL(TChar aDriveLetter) |
|
666 // ---------------------------------------------------------------------------- |
|
667 // |
|
668 void T_MountMan::TestMountEntryL( ) |
|
669 { |
|
670 // be sure no mount entries are in CenRep |
|
671 ClearAllMountsL(); |
|
672 |
|
673 TInt err; |
|
674 err = AddMountEntryL(0, |
|
675 _L("drivename0"), |
|
676 DriveToChar(EDriveK), |
|
677 _L("http://url0.com"), |
|
678 _L("userName0"), |
|
679 _L("password0"), |
|
680 _L("iap0")); |
|
681 EUNIT_ASSERT(err == KErrNone); |
|
682 |
|
683 err = AddMountEntryL(1, |
|
684 _L("drivename1"), |
|
685 DriveToChar(EDriveL), |
|
686 _L("http://url1.com"), |
|
687 _L("userName1"), |
|
688 _L("password1"), |
|
689 _L("iap1")); |
|
690 EUNIT_ASSERT(err == KErrNone); |
|
691 |
|
692 const CRsfwMountEntry* entry = NULL; |
|
693 TRAP (err, entry = iMountMan->MountEntryL(DriveToChar(EDriveK))); |
|
694 EUNIT_ASSERT(err == KErrNone); |
|
695 |
|
696 err = CheckEntryL(entry, |
|
697 0, |
|
698 _L("drivename0"), |
|
699 DriveToChar(EDriveK), |
|
700 _L("http://url0.com"), |
|
701 _L("userName0"), |
|
702 _L("password0"), |
|
703 _L("iap0")); |
|
704 EUNIT_ASSERT(err == KErrNone); |
|
705 |
|
706 TRAP (err, entry = iMountMan->MountEntryL(DriveToChar(EDriveL))); |
|
707 EUNIT_ASSERT(err == KErrNone); |
|
708 |
|
709 err = CheckEntryL(entry, |
|
710 1, |
|
711 _L("drivename1"), |
|
712 DriveToChar(EDriveL), |
|
713 _L("http://url1.com"), |
|
714 _L("userName1"), |
|
715 _L("password1"), |
|
716 _L("iap1")); |
|
717 EUNIT_ASSERT(err == KErrNone); |
|
718 } |
|
719 |
|
720 // ---------------------------------------------------------------------------- |
|
721 // T_MountMan::TestMountEntryL |
|
722 // tests MountEntryL(const TDesC& aName) |
|
723 // ---------------------------------------------------------------------------- |
|
724 // |
|
725 void T_MountMan::TestMountEntry2L( ) |
|
726 { |
|
727 // be sure no mount entries are in CenRep |
|
728 ClearAllMountsL(); |
|
729 |
|
730 TInt err; |
|
731 err = AddMountEntryL(0, |
|
732 _L("drivename0"), |
|
733 DriveToChar(EDriveK), |
|
734 _L("http://url0.com"), |
|
735 _L("userName0"), |
|
736 _L("password0"), |
|
737 _L("iap0")); |
|
738 EUNIT_ASSERT(err == KErrNone); |
|
739 |
|
740 err = AddMountEntryL(1, |
|
741 _L("drivename1"), |
|
742 DriveToChar(EDriveL), |
|
743 _L("http://url1.com"), |
|
744 _L("userName1"), |
|
745 _L("password1"), |
|
746 _L("iap1")); |
|
747 EUNIT_ASSERT(err == KErrNone); |
|
748 |
|
749 const CRsfwMountEntry* entry = NULL; |
|
750 TRAP (err, entry = iMountMan->MountEntryL(_L("drivename0"))); |
|
751 EUNIT_ASSERT(err == KErrNone); |
|
752 |
|
753 err = CheckEntryL(entry, |
|
754 0, |
|
755 _L("drivename0"), |
|
756 DriveToChar(EDriveK), |
|
757 _L("http://url0.com"), |
|
758 _L("userName0"), |
|
759 _L("password0"), |
|
760 _L("iap0")); |
|
761 EUNIT_ASSERT(err == KErrNone); |
|
762 |
|
763 TRAP (err, entry = iMountMan->MountEntryL(_L("drivename1"))); |
|
764 EUNIT_ASSERT(err == KErrNone); |
|
765 |
|
766 err = CheckEntryL(entry, |
|
767 1, |
|
768 _L("drivename1"), |
|
769 DriveToChar(EDriveL), |
|
770 _L("http://url1.com"), |
|
771 _L("userName1"), |
|
772 _L("password1"), |
|
773 _L("iap1")); |
|
774 EUNIT_ASSERT(err == KErrNone); |
|
775 } |
|
776 |
|
777 // ---------------------------------------------------------------------------- |
|
778 // T_MountMan::TestGetAllDrivesL |
|
779 // ---------------------------------------------------------------------------- |
|
780 // |
|
781 void T_MountMan::TestGetAllDrivesL( ) |
|
782 { |
|
783 // be sure no mount entries are in CenRep |
|
784 ClearAllMountsL(); |
|
785 |
|
786 TInt err; |
|
787 // add some remote drives |
|
788 err = AddMountEntryL(0, |
|
789 _L("drivename0"), |
|
790 DriveToChar(EDriveK), |
|
791 _L("http://url0.com"), |
|
792 _L("userName0"), |
|
793 _L("password0"), |
|
794 _L("iap0")); |
|
795 EUNIT_ASSERT(err == KErrNone); |
|
796 err = AddMountEntryL(1, |
|
797 _L("drivename1"), |
|
798 DriveToChar(EDriveL), |
|
799 _L("http://url1.com"), |
|
800 _L("userName1"), |
|
801 _L("password1"), |
|
802 _L("iap1")); |
|
803 EUNIT_ASSERT(err == KErrNone); |
|
804 err = AddMountEntryL(2, |
|
805 _L("drivename2"), |
|
806 DriveToChar(EDriveM), |
|
807 _L("http://url2.com"), |
|
808 _L("userName2"), |
|
809 _L("password2"), |
|
810 _L("iap2")); |
|
811 EUNIT_ASSERT(err == KErrNone); |
|
812 |
|
813 // prepare expected list |
|
814 TDriveList expectedList; |
|
815 |
|
816 // first populate the list with local drives |
|
817 TDriveList driveList; |
|
818 err = iFs.DriveList(driveList); |
|
819 EUNIT_ASSERT(err == KErrNone); |
|
820 TInt i; |
|
821 for ( i = EDriveC; i <= EDriveZ; i++) |
|
822 { |
|
823 if ( (driveList[i]) && (!(driveList[i] & KDriveAttRemote)) ) |
|
824 { |
|
825 TChar driveLetter; |
|
826 err = iFs.DriveToChar(i, driveLetter); |
|
827 EUNIT_ASSERT(err == KErrNone); |
|
828 expectedList.Append(driveLetter); |
|
829 } |
|
830 } |
|
831 // append remote drive that just has been added |
|
832 expectedList.Append(DriveToChar(EDriveK)); |
|
833 expectedList.Append(DriveToChar(EDriveL)); |
|
834 expectedList.Append(DriveToChar(EDriveM)); |
|
835 |
|
836 TDriveList returnedList; |
|
837 iMountMan->GetAllDrivesL(returnedList); |
|
838 |
|
839 err = expectedList.Compare(returnedList); |
|
840 EUNIT_ASSERT(err == KErrNone); |
|
841 } |
|
842 |
|
843 // ---------------------------------------------------------------------------- |
|
844 // T_MountMan::TestGetRemoteMountListL |
|
845 // ---------------------------------------------------------------------------- |
|
846 // |
|
847 void T_MountMan::TestGetRemoteMountListL( ) |
|
848 { |
|
849 // be sure no mount entries are in CenRep |
|
850 ClearAllMountsL(); |
|
851 |
|
852 TDriveList expectedList; |
|
853 TDriveList returnedList; |
|
854 |
|
855 TInt err; |
|
856 err = AddMountEntryL(0, |
|
857 _L("drivename0"), |
|
858 DriveToChar(EDriveK), |
|
859 _L("http://url0.com"), |
|
860 _L("userName0"), |
|
861 _L("password0"), |
|
862 _L("iap0")); |
|
863 EUNIT_ASSERT(err == KErrNone); |
|
864 expectedList.Append(DriveToChar(EDriveK)); |
|
865 err = AddMountEntryL(1, |
|
866 _L("drivename1"), |
|
867 DriveToChar(EDriveL), |
|
868 _L("http://url1.com"), |
|
869 _L("userName1"), |
|
870 _L("password1"), |
|
871 _L("iap1")); |
|
872 EUNIT_ASSERT(err == KErrNone); |
|
873 expectedList.Append(DriveToChar(EDriveL)); |
|
874 err = AddMountEntryL(2, |
|
875 _L("drivename2"), |
|
876 DriveToChar(EDriveM), |
|
877 _L("http://url2.com"), |
|
878 _L("userName2"), |
|
879 _L("password2"), |
|
880 _L("iap2")); |
|
881 EUNIT_ASSERT(err == KErrNone); |
|
882 expectedList.Append(DriveToChar(EDriveM)); |
|
883 |
|
884 TRAP(err,iMountMan->GetRemoteMountListL(returnedList)); |
|
885 EUNIT_ASSERT(err == KErrNone); |
|
886 |
|
887 err = expectedList.Compare(returnedList); |
|
888 EUNIT_ASSERT(err == KErrNone); |
|
889 } |
|
890 |
|
891 // ---------------------------------------------------------------------------- |
|
892 // T_MountMan::TestGetMountNamesL |
|
893 // ---------------------------------------------------------------------------- |
|
894 // |
|
895 void T_MountMan::TestGetMountNamesL( ) |
|
896 { |
|
897 // be sure no mount entries are in CenRep |
|
898 ClearAllMountsL(); |
|
899 |
|
900 TInt err; |
|
901 // add some remote drives |
|
902 err = AddMountEntryL(0, |
|
903 _L("drivename0"), |
|
904 DriveToChar(EDriveK), |
|
905 _L("http://url0.com"), |
|
906 _L("userName0"), |
|
907 _L("password0"), |
|
908 _L("iap0")); |
|
909 EUNIT_ASSERT(err == KErrNone); |
|
910 err = AddMountEntryL(1, |
|
911 _L("drivename1"), |
|
912 DriveToChar(EDriveL), |
|
913 _L("http://url1.com"), |
|
914 _L("userName1"), |
|
915 _L("password1"), |
|
916 _L("iap1")); |
|
917 EUNIT_ASSERT(err == KErrNone); |
|
918 err = AddMountEntryL(2, |
|
919 _L("drivename2"), |
|
920 DriveToChar(EDriveM), |
|
921 _L("http://url2.com"), |
|
922 _L("userName2"), |
|
923 _L("password2"), |
|
924 _L("iap2")); |
|
925 EUNIT_ASSERT(err == KErrNone); |
|
926 |
|
927 // prepare expected list of names |
|
928 CDesC16Array* expectedNames = new (ELeave) CDesC16ArraySeg(4); |
|
929 CleanupStack::PushL(expectedNames); |
|
930 expectedNames->AppendL(_L("drivename0")); |
|
931 expectedNames->AppendL(_L("drivename1")); |
|
932 expectedNames->AppendL(_L("drivename2")); |
|
933 |
|
934 CDesC16Array* names = new (ELeave) CDesC16ArraySeg(4); |
|
935 CleanupStack::PushL(names); |
|
936 TRAP (err, iMountMan->GetMountNamesL(names)); |
|
937 |
|
938 if (err == KErrNone) |
|
939 { |
|
940 err = CompareArrays(names, expectedNames); |
|
941 } |
|
942 CleanupStack::PopAndDestroy(names); |
|
943 CleanupStack::PopAndDestroy(expectedNames); |
|
944 EUNIT_ASSERT(err == KErrNone); |
|
945 } |
|
946 |
|
947 // ---------------------------------------------------------------------------- |
|
948 // T_MountMan::TestIsAppOnBlackListL |
|
949 // ---------------------------------------------------------------------------- |
|
950 // |
|
951 void T_MountMan::TestIsAppOnBlackListL( ) |
|
952 { |
|
953 const TUid app1 = TUid::Uid(0x00000000); |
|
954 const TUid app2 = TUid::Uid(0x11111111); |
|
955 |
|
956 TBool isOnList; |
|
957 |
|
958 isOnList = iMountMan->IsAppOnBlackList(app1); |
|
959 EUNIT_ASSERT(isOnList == EFalse); |
|
960 |
|
961 isOnList = iMountMan->IsAppOnBlackList(app2); |
|
962 EUNIT_ASSERT(isOnList == EFalse); |
|
963 } |
|
964 |
|
965 // ---------------------------------------------------------------------------- |
|
966 // T_MountMan::TestGetMountInfoL |
|
967 // ---------------------------------------------------------------------------- |
|
968 // |
|
969 void T_MountMan::TestGetMountInfoL( ) |
|
970 { |
|
971 // be sure no mount entries are in CenRep |
|
972 ClearAllMountsL(); |
|
973 |
|
974 TInt err; |
|
975 // add remote drive |
|
976 err = AddMountEntryL(0, |
|
977 _L("drivename"), |
|
978 DriveToChar(EDriveK), |
|
979 _L("http://testurl"), |
|
980 _L("username"), |
|
981 _L("password"), |
|
982 _L("")); |
|
983 EUNIT_ASSERT(err == KErrNone); |
|
984 |
|
985 TRsfwMountInfo mountInfo; |
|
986 TRAP (err, iMountMan->GetMountInfo(DriveToChar(EDriveK), mountInfo)); |
|
987 EUNIT_ASSERT(err == KErrNone); |
|
988 |
|
989 // check as much mount info as possible at this point |
|
990 EUNIT_ASSERT(mountInfo.iMountConfig.iDriveLetter == DriveToChar(EDriveK)); |
|
991 EUNIT_ASSERT(mountInfo.iMountConfig.iName.Compare(_L("drivename")) == KErrNone); |
|
992 EUNIT_ASSERT(mountInfo.iMountConfig.iUri.Compare(_L("http://testurl")) == KErrNone); |
|
993 EUNIT_ASSERT(mountInfo.iMountConfig.iUserName.Compare(_L("username")) == KErrNone); |
|
994 EUNIT_ASSERT(mountInfo.iMountConfig.iPassword.Compare(_L("password")) == KErrNone); |
|
995 EUNIT_ASSERT(mountInfo.iMountStatus.iVolumeId == EDriveK); |
|
996 EUNIT_ASSERT(mountInfo.iMountStatus.iMountState == KMountStateDormant); |
|
997 EUNIT_ASSERT(mountInfo.iMountStatus.iConnectionState == KMountNotConnected); |
|
998 } |
|
999 |
|
1000 // ---------------------------------------------------------------------------- |
|
1001 // T_MountMan::TestSetMountConnectionStateL |
|
1002 // ---------------------------------------------------------------------------- |
|
1003 // |
|
1004 void T_MountMan::TestSetMountConnectionStateL( ) |
|
1005 { |
|
1006 // be sure no mount entries are in CenRep |
|
1007 ClearAllMountsL(); |
|
1008 |
|
1009 TInt err; |
|
1010 // add remote drive |
|
1011 err = AddMountEntryL(0, |
|
1012 _L("drivename"), |
|
1013 DriveToChar(EDriveK), |
|
1014 _L("http://url"), |
|
1015 _L("username"), |
|
1016 _L("password"), |
|
1017 _L("")); |
|
1018 EUNIT_ASSERT(err == KErrNone); |
|
1019 |
|
1020 // set to not connected |
|
1021 TRAP (err, iMountMan->SetMountConnectionState(DriveToChar(EDriveK), KMountNotConnected)); |
|
1022 EUNIT_ASSERT(err == KErrNone); |
|
1023 |
|
1024 // get mount info |
|
1025 TRsfwMountInfo mountInfo; |
|
1026 TRAP (err, iMountMan->GetMountInfo(DriveToChar(EDriveK), mountInfo)); |
|
1027 EUNIT_ASSERT(err == KErrNone); |
|
1028 |
|
1029 // check mount status |
|
1030 EUNIT_ASSERT(mountInfo.iMountStatus.iVolumeId == EDriveK); |
|
1031 EUNIT_ASSERT(mountInfo.iMountStatus.iMountState == KMountStateDormant); |
|
1032 EUNIT_ASSERT(mountInfo.iMountStatus.iConnectionState == KMountNotConnected); |
|
1033 } |
|
1034 |
|
1035 // ---------------------------------------------------------------------------- |
|
1036 // T_MountMan::TestRefreshDirectoryL |
|
1037 // ---------------------------------------------------------------------------- |
|
1038 // |
|
1039 void T_MountMan::TestRefreshDirectoryL( ) |
|
1040 { |
|
1041 // be sure no mount entries are in CenRep |
|
1042 ClearAllMountsL(); |
|
1043 |
|
1044 TInt err = iMountMan->RefreshDirectory(_L("K:\\nonexisting\\")); |
|
1045 EUNIT_ASSERT(err == KErrNotFound); |
|
1046 } |
|
1047 |
|
1048 // ---------------------------------------------------------------------------- |
|
1049 // T_MountMan::TestCancelRemoteTransferL |
|
1050 // ---------------------------------------------------------------------------- |
|
1051 // |
|
1052 void T_MountMan::TestCancelRemoteTransferL( ) |
|
1053 { |
|
1054 // be sure no mount entries are in CenRep |
|
1055 ClearAllMountsL(); |
|
1056 |
|
1057 TInt err = iMountMan->CancelRemoteTransfer(_L("K:\\nonexisting\\")); |
|
1058 EUNIT_ASSERT(err == KErrNotFound); |
|
1059 } |
|
1060 |
|
1061 // ---------------------------------------------------------------------------- |
|
1062 // T_MountMan::TestSetMountConnectionStateBlindL |
|
1063 // ---------------------------------------------------------------------------- |
|
1064 // |
|
1065 void T_MountMan::TestSetMountConnectionStateBlindL( ) |
|
1066 { |
|
1067 // be sure no mount entries are in CenRep |
|
1068 ClearAllMountsL(); |
|
1069 |
|
1070 TInt err; |
|
1071 // add remote drive |
|
1072 err = AddMountEntryL(0, |
|
1073 _L("drivename"), |
|
1074 DriveToChar(EDriveK), |
|
1075 _L("http://url"), |
|
1076 _L("username"), |
|
1077 _L("password"), |
|
1078 _L("")); |
|
1079 EUNIT_ASSERT(err == KErrNone); |
|
1080 |
|
1081 // set to not connected |
|
1082 TRAP (err, iMountMan->SetMountConnectionStateBlind(DriveToChar(EDriveK), KMountNotConnected)); |
|
1083 EUNIT_ASSERT(err == KErrNone); |
|
1084 } |
|
1085 |
|
1086 |
|
1087 /////////////////////////////////////////////////////////////////////////////// |
|
1088 ////// CRsfwMountEntry /////////////////////////////////////////////////////// |
|
1089 /////////////////////////////////////////////////////////////////////////////// |
|
1090 |
|
1091 // ---------------------------------------------------------------------------- |
|
1092 // T_MountMan::TestExternalizeAndInternalizeL |
|
1093 // Tests TRsfwMountConfig::ExternalizeL & TRsfwMountConfig::InternalizeL |
|
1094 // ---------------------------------------------------------------------------- |
|
1095 // |
|
1096 void T_MountMan::TestExternalizeAndInternalizeL( ) |
|
1097 { |
|
1098 TInt err; |
|
1099 TRsfwMountConfig mountConfig; |
|
1100 |
|
1101 mountConfig.iDriveLetter = DriveToChar(EDriveK); |
|
1102 mountConfig.iName.Copy(_L("name")); |
|
1103 mountConfig.iUri.Copy(_L("uri")); |
|
1104 mountConfig.iUserName.Copy(_L("username")); |
|
1105 mountConfig.iPassword.Copy(_L("password")); |
|
1106 mountConfig.iAuxData.Copy(_L("auxdata")); |
|
1107 mountConfig.iFlags = KMountFlagNull; |
|
1108 mountConfig.iInactivityTimeout = 10; |
|
1109 |
|
1110 RFile f; |
|
1111 CleanupClosePushL(f); |
|
1112 err = f.Replace(iFs, _L("C:\\mountmantest.txt"), EFileShareAny | EFileWrite); |
|
1113 EUNIT_ASSERT(err == KErrNone); |
|
1114 RFileWriteStream wStream(f); |
|
1115 CleanupClosePushL(wStream); |
|
1116 mountConfig.ExternalizeL(wStream); |
|
1117 CleanupStack::PopAndDestroy(&wStream); |
|
1118 CleanupStack::PopAndDestroy(&f); |
|
1119 |
|
1120 f.Open(iFs, _L("C:\\mountmantest.txt"), EFileShareAny | EFileRead); |
|
1121 CleanupClosePushL(f); |
|
1122 RFileReadStream rStream(f); |
|
1123 CleanupClosePushL(rStream); |
|
1124 TRsfwMountConfig anotherMountConfig; |
|
1125 anotherMountConfig.InternalizeL(rStream); |
|
1126 CleanupStack::PopAndDestroy(&rStream); |
|
1127 CleanupStack::PopAndDestroy(&f); |
|
1128 |
|
1129 EUNIT_ASSERT(anotherMountConfig.iDriveLetter == DriveToChar(EDriveK)); |
|
1130 EUNIT_ASSERT(anotherMountConfig.iName.Compare(_L("name")) == KErrNone); |
|
1131 EUNIT_ASSERT(anotherMountConfig.iUri.Compare(_L("uri")) == KErrNone); |
|
1132 EUNIT_ASSERT(anotherMountConfig.iUserName.Compare(_L("username")) == KErrNone); |
|
1133 EUNIT_ASSERT(anotherMountConfig.iPassword.Compare(_L("password")) == KErrNone); |
|
1134 EUNIT_ASSERT(anotherMountConfig.iAuxData.Compare(_L("auxdata")) == KErrNone); |
|
1135 EUNIT_ASSERT(anotherMountConfig.iFlags == KMountFlagNull); |
|
1136 EUNIT_ASSERT(anotherMountConfig.iInactivityTimeout == 10); |
|
1137 } |
|
1138 |
|
1139 /////////////////////////////////////////////////////////////////////////////// |
|
1140 ////// Utility functions ////////////////////////////////////////////////////// |
|
1141 /////////////////////////////////////////////////////////////////////////////// |
|
1142 |
|
1143 // ---------------------------------------------------------------------------- |
|
1144 // T_MountMan::AddMountEntryL |
|
1145 // Helping function: based on given parameters creates CRsfwMountEntry object |
|
1146 // and attempts to add it using AddMountEntry() |
|
1147 // ---------------------------------------------------------------------------- |
|
1148 // |
|
1149 TInt T_MountMan::AddMountEntryL(TInt aIndex, |
|
1150 const TDesC& aName, |
|
1151 TChar aDriveLetter, |
|
1152 const TDesC& aUri, |
|
1153 const TDesC& aUserName, |
|
1154 const TDesC& aPassword, |
|
1155 const TDesC& aIap) |
|
1156 { |
|
1157 TInt err; |
|
1158 CRsfwMountEntry* mountEntry; |
|
1159 mountEntry = CRsfwMountEntry::NewLC(); |
|
1160 TRAP (err, mountEntry->SetEntryL(aIndex, |
|
1161 aName, |
|
1162 aDriveLetter, |
|
1163 aUri, |
|
1164 aUserName, |
|
1165 aPassword, |
|
1166 aIap)); |
|
1167 |
|
1168 if (err != KErrNone) |
|
1169 { |
|
1170 CleanupStack::PopAndDestroy(mountEntry); |
|
1171 return err; |
|
1172 } |
|
1173 |
|
1174 // release ownership and add entry |
|
1175 CleanupStack::Pop(mountEntry); |
|
1176 TRAP (err, iMountMan->AddMountEntryL(mountEntry)); |
|
1177 return err; |
|
1178 } |
|
1179 |
|
1180 // ---------------------------------------------------------------------------- |
|
1181 // T_MountMan::EditMountEntryL |
|
1182 // Helping function: based on given parameters creates CRsfwMountEntry object |
|
1183 // and attempts to edit it using EditMountEntry() |
|
1184 // ---------------------------------------------------------------------------- |
|
1185 // |
|
1186 TInt T_MountMan::EditMountEntryL(TInt aIndex, |
|
1187 const TDesC& aName, |
|
1188 TChar aDriveLetter, |
|
1189 const TDesC& aUri, |
|
1190 const TDesC& aUserName, |
|
1191 const TDesC& aPassword, |
|
1192 const TDesC& aIap) |
|
1193 { |
|
1194 TInt err; |
|
1195 CRsfwMountEntry* mountEntry; |
|
1196 mountEntry = CRsfwMountEntry::NewLC(); |
|
1197 TRAP (err, mountEntry->SetEntryL(aIndex, |
|
1198 aName, |
|
1199 aDriveLetter, |
|
1200 aUri, |
|
1201 aUserName, |
|
1202 aPassword, |
|
1203 aIap)); |
|
1204 |
|
1205 if (err != KErrNone) |
|
1206 { |
|
1207 CleanupStack::PopAndDestroy(mountEntry); |
|
1208 return err; |
|
1209 } |
|
1210 |
|
1211 // release ownership and edit entry |
|
1212 CleanupStack::Pop(mountEntry); |
|
1213 TRAP (err, iMountMan->EditMountEntryL(mountEntry)); |
|
1214 return err; |
|
1215 } |
|
1216 |
|
1217 // ---------------------------------------------------------------------------- |
|
1218 // T_MountMan::ClearAllMountsL |
|
1219 // Deletes all mount entries |
|
1220 // ---------------------------------------------------------------------------- |
|
1221 // |
|
1222 void T_MountMan::ClearAllMountsL( ) |
|
1223 { |
|
1224 TInt err; |
|
1225 CDesC16Array* names = new (ELeave) CDesC16ArraySeg(4); |
|
1226 CleanupStack::PushL(names); |
|
1227 TRAP (err, iMountMan->GetMountNamesL(names)); |
|
1228 if (err == KErrNone) |
|
1229 { |
|
1230 TInt i; |
|
1231 for ( i = 0; i < names->Count(); i++) |
|
1232 { |
|
1233 TRAP (err, iMountMan->DeleteMountEntryL((*names)[i])); |
|
1234 if (err != KErrNone) |
|
1235 { |
|
1236 break; |
|
1237 } |
|
1238 } |
|
1239 } |
|
1240 names->Reset(); |
|
1241 CleanupStack::PopAndDestroy(names); |
|
1242 EUNIT_ASSERT(err == KErrNone); |
|
1243 } |
|
1244 |
|
1245 // ---------------------------------------------------------------------------- |
|
1246 // T_MountMan::DriveToChar |
|
1247 // ---------------------------------------------------------------------------- |
|
1248 // |
|
1249 TChar T_MountMan::DriveToChar(TInt aDrive) |
|
1250 { |
|
1251 TChar c; |
|
1252 TInt err = iFs.DriveToChar(aDrive, c); |
|
1253 EUNIT_ASSERT(err == KErrNone); |
|
1254 return c; |
|
1255 } |
|
1256 |
|
1257 // ---------------------------------------------------------------------------- |
|
1258 // T_MountMan::CompareArrays |
|
1259 // Compares two arrays e.g. with mount names |
|
1260 // Note that order DOES matter! |
|
1261 // ---------------------------------------------------------------------------- |
|
1262 // |
|
1263 TInt T_MountMan::CompareArrays(CDesC16Array* aArray1, CDesC16Array* aArray2) |
|
1264 { |
|
1265 if (aArray1->Count() != aArray2->Count()) |
|
1266 { |
|
1267 return KErrNotFound; |
|
1268 } |
|
1269 TInt i; |
|
1270 for ( i = 0; i < aArray1->Count(); i++ ) |
|
1271 { |
|
1272 if ((*aArray1)[i].Compare((*aArray2)[i]) != KErrNone) |
|
1273 { |
|
1274 return KErrNotFound; |
|
1275 } |
|
1276 } |
|
1277 return KErrNone; |
|
1278 } |
|
1279 |
|
1280 // ---------------------------------------------------------------------------- |
|
1281 // T_MountMan::CheckEntryL |
|
1282 // Checks whether all fields in given entry matches |
|
1283 // ---------------------------------------------------------------------------- |
|
1284 // |
|
1285 TInt T_MountMan::CheckEntryL(const CRsfwMountEntry* aEntry, |
|
1286 TInt aIndex, |
|
1287 const TDesC& aName, |
|
1288 TChar aDriveLetter, |
|
1289 const TDesC& aUri, |
|
1290 const TDesC& aUserName, |
|
1291 const TDesC& aPassword, |
|
1292 const TDesC& aIap) |
|
1293 { |
|
1294 TInt err; |
|
1295 CRsfwMountEntry* entry; |
|
1296 entry = CRsfwMountEntry::NewLC(); |
|
1297 TRAP (err, entry->SetEntryL(aIndex, |
|
1298 aName, |
|
1299 aDriveLetter, |
|
1300 aUri, |
|
1301 aUserName, |
|
1302 aPassword, |
|
1303 aIap)); |
|
1304 if (err != KErrNone) |
|
1305 { |
|
1306 CleanupStack::PopAndDestroy(entry); |
|
1307 return err; |
|
1308 } |
|
1309 |
|
1310 TInt i; |
|
1311 for ( i = EMountEntryItemIndex; i < EMountEntryItemCount; i++ ) |
|
1312 { |
|
1313 const HBufC* item1 = aEntry->Item(i); |
|
1314 const HBufC* item2 = entry->Item(i); |
|
1315 if ( (item1 && !item2) || |
|
1316 (item2 && !item1) || |
|
1317 (item1 && item2 && (*item1).Compare(*item2)!=KErrNone) ) |
|
1318 { |
|
1319 CleanupStack::PopAndDestroy(entry); |
|
1320 return KErrNotFound; |
|
1321 } |
|
1322 } |
|
1323 |
|
1324 CleanupStack::PopAndDestroy(entry); |
|
1325 return KErrNone; |
|
1326 } |
|
1327 |
|
1328 |
|
1329 // TEST TABLE |
|
1330 |
|
1331 EUNIT_BEGIN_TEST_TABLE( |
|
1332 T_MountMan, |
|
1333 "Add test suite description here.", |
|
1334 "MODULE" ) |
|
1335 |
|
1336 EUNIT_TEST( |
|
1337 "SetMountEntryL - set mount entry with too long attributes", |
|
1338 "RsfwMountMan", |
|
1339 "SetMountEntryL", |
|
1340 "FUNCTIONALITY", |
|
1341 SetupL, TestSetMountEntryL, Teardown) |
|
1342 |
|
1343 EUNIT_TEST( |
|
1344 "TestSetItemL - set mount items - SetItemL(TInt aIndex, const TDesC8& aValue)", |
|
1345 "RsfwMountMan", |
|
1346 "SetItemL", |
|
1347 "FUNCTIONALITY", |
|
1348 SetupL, TestSetItemL, Teardown) |
|
1349 |
|
1350 EUNIT_TEST( |
|
1351 "TestSetItemL - set mount items - SetItemL(TInt aIndex, const TDesC& aValue)", |
|
1352 "RsfwMountMan", |
|
1353 "SetItemL", |
|
1354 "FUNCTIONALITY", |
|
1355 SetupL, TestSetItem2L, Teardown) |
|
1356 |
|
1357 EUNIT_TEST( |
|
1358 "TestClearL - clear mount entry", |
|
1359 "RsfwMountMan", |
|
1360 "Clear", |
|
1361 "FUNCTIONALITY", |
|
1362 SetupL, TestClearL, Teardown) |
|
1363 |
|
1364 EUNIT_TEST( |
|
1365 "TestCloneL - clone mount entry", |
|
1366 "RsfwMountMan", |
|
1367 "CloneL", |
|
1368 "FUNCTIONALITY", |
|
1369 SetupL, TestCloneL, Teardown) |
|
1370 |
|
1371 EUNIT_TEST( |
|
1372 "AddMountEntryL - add max number of mounts", |
|
1373 "RsfwMountMan", |
|
1374 "AddMountEntryL", |
|
1375 "FUNCTIONALITY", |
|
1376 SetupL, TestAddMountEntryL, Teardown) |
|
1377 |
|
1378 EUNIT_TEST( |
|
1379 "AddMountEntryL - add two mounts with the same name", |
|
1380 "RsfwMountMan", |
|
1381 "AddMountEntryL", |
|
1382 "FUNCTIONALITY", |
|
1383 SetupL, TestAddMountEntry2L, Teardown) |
|
1384 |
|
1385 EUNIT_TEST( |
|
1386 "AddMountEntryL - add two mounts with the same drive letter", |
|
1387 "RsfwMountMan", |
|
1388 "AddMountEntryL", |
|
1389 "FUNCTIONALITY", |
|
1390 SetupL, TestAddMountEntry3L, Teardown) |
|
1391 |
|
1392 EUNIT_TEST( |
|
1393 "EditMountEntryL - basic test", |
|
1394 "RsfwMountMan", |
|
1395 "EditMountEntryL", |
|
1396 "FUNCTIONALITY", |
|
1397 SetupL, TestEditMountEntryL, Teardown) |
|
1398 |
|
1399 EUNIT_TEST( |
|
1400 "EditMountEntryL - test nonexisting mount", |
|
1401 "RsfwMountMan", |
|
1402 "EditMountEntryL", |
|
1403 "FUNCTIONALITY", |
|
1404 SetupL, TestEditMountEntry2L, Teardown) |
|
1405 |
|
1406 EUNIT_TEST( |
|
1407 "EditMountEntryL - test the name that is in use", |
|
1408 "RsfwMountMan", |
|
1409 "EditMountEntryL", |
|
1410 "FUNCTIONALITY", |
|
1411 SetupL, TestEditMountEntry3L, Teardown) |
|
1412 |
|
1413 EUNIT_TEST( |
|
1414 "DeleteMountEntryL - basic test", |
|
1415 "RsfwMountMan", |
|
1416 "DeleteMountEntryL", |
|
1417 "FUNCTIONALITY", |
|
1418 SetupL, TestDeleteMountEntryL, Teardown) |
|
1419 |
|
1420 EUNIT_TEST( |
|
1421 "DeleteMountEntryL - test nonexisting mount", |
|
1422 "RsfwMountMan", |
|
1423 "DeleteMountEntryL", |
|
1424 "FUNCTIONALITY", |
|
1425 SetupL, TestDeleteMountEntry2L, Teardown) |
|
1426 |
|
1427 EUNIT_TEST( |
|
1428 "DeleteMountEntryL - by drive letter", |
|
1429 "RsfwMountMan", |
|
1430 "DeleteMountEntryL", |
|
1431 "FUNCTIONALITY", |
|
1432 SetupL, TestDeleteMountEntry3L, Teardown) |
|
1433 |
|
1434 EUNIT_TEST( |
|
1435 "TestMountEntryL - basic test", |
|
1436 "RsfwMountMan", |
|
1437 "MountEntryL", |
|
1438 "FUNCTIONALITY", |
|
1439 SetupL, TestMountEntryL, Teardown) |
|
1440 |
|
1441 EUNIT_TEST( |
|
1442 "TestMountEntryL - test nonexisting mount", |
|
1443 "RsfwMountMan", |
|
1444 "MountEntryL", |
|
1445 "FUNCTIONALITY", |
|
1446 SetupL, TestMountEntry2L, Teardown) |
|
1447 |
|
1448 EUNIT_TEST( |
|
1449 "GetAllDrivesL - basic test", |
|
1450 "RsfwMountMan", |
|
1451 "GetAllDrivesL", |
|
1452 "FUNCTIONALITY", |
|
1453 SetupL, TestGetAllDrivesL, Teardown) |
|
1454 |
|
1455 EUNIT_TEST( |
|
1456 "GetMountNamesL - basic test", |
|
1457 "RsfwMountMan", |
|
1458 "GetMountNamesL", |
|
1459 "FUNCTIONALITY", |
|
1460 SetupL, TestGetMountNamesL, Teardown) |
|
1461 |
|
1462 EUNIT_TEST( |
|
1463 "GetRemoteMountListL - basic test", |
|
1464 "RsfwMountMan", |
|
1465 "GetRemoteMountListL", |
|
1466 "FUNCTIONALITY", |
|
1467 SetupL, TestGetRemoteMountListL, Teardown) |
|
1468 |
|
1469 EUNIT_TEST( |
|
1470 "IsAppOnBlackList - basic test", |
|
1471 "RsfwMountMan", |
|
1472 "IsAppOnBlackList", |
|
1473 "FUNCTIONALITY", |
|
1474 SetupL, TestIsAppOnBlackListL, Teardown) |
|
1475 |
|
1476 EUNIT_TEST( |
|
1477 "GetMountInfoL - basic test", |
|
1478 "RsfwMountMan", |
|
1479 "GetMountInfoL", |
|
1480 "FUNCTIONALITY", |
|
1481 SetupL, TestGetMountInfoL, Teardown) |
|
1482 |
|
1483 EUNIT_TEST( |
|
1484 "SetMountConnectionStateL - basic test", |
|
1485 "RsfwMountMan", |
|
1486 "SetMountConnectionStateL", |
|
1487 "FUNCTIONALITY", |
|
1488 SetupL, TestSetMountConnectionStateL, Teardown) |
|
1489 |
|
1490 EUNIT_TEST( |
|
1491 "RefreshDirectory - basic test", |
|
1492 "RsfwMountMan", |
|
1493 "RefreshDirectory", |
|
1494 "FUNCTIONALITY", |
|
1495 SetupL, TestRefreshDirectoryL, Teardown) |
|
1496 |
|
1497 EUNIT_TEST( |
|
1498 "CancelRemoteTransfer - basic test", |
|
1499 "RsfwMountMan", |
|
1500 "CancelRemoteTransfer", |
|
1501 "FUNCTIONALITY", |
|
1502 SetupL, TestCancelRemoteTransferL, Teardown) |
|
1503 |
|
1504 EUNIT_TEST( |
|
1505 "SetMountConnectionStateBlindL - basic test", |
|
1506 "RsfwMountMan", |
|
1507 "SetMountConnectionStateBlindL", |
|
1508 "FUNCTIONALITY", |
|
1509 SetupL, TestSetMountConnectionStateBlindL, Teardown) |
|
1510 |
|
1511 EUNIT_TEST( |
|
1512 "Externalize and internalize - basic test", |
|
1513 "RsfwMountMan", |
|
1514 "InternalizeL, ExternalizeL", |
|
1515 "FUNCTIONALITY", |
|
1516 SetupL, TestExternalizeAndInternalizeL, Teardown) |
|
1517 |
|
1518 EUNIT_END_TEST_TABLE |
|
1519 |
|
1520 // END OF FILE |
|