51 MFileManObserver::TControl CFileManObserver::NotifyFileManEnded() |
51 MFileManObserver::TControl CFileManObserver::NotifyFileManEnded() |
52 // |
52 // |
53 // Called back after each FMan tick |
53 // Called back after each FMan tick |
54 // |
54 // |
55 { |
55 { |
56 (void) MFileManObserver::NotifyFileManEnded(); |
|
57 TInt lastError=iFileMan->GetLastError(); |
56 TInt lastError=iFileMan->GetLastError(); |
58 if (lastError!=KErrNone && lastError!=KErrBadName) |
57 if (lastError!=KErrNone && lastError!=KErrBadName) |
59 { |
58 { |
60 TFileName fileName=iFileMan->CurrentEntry().iName; |
59 TFileName fileName=iFileMan->CurrentEntry().iName; |
61 if (gAsynch==EFalse) |
60 if (gAsynch==EFalse) |
3134 test.Printf(_L(" %S already exists\n"),&fileName); |
3134 test.Printf(_L(" %S already exists\n"),&fileName); |
3135 } |
3135 } |
3136 } |
3136 } |
3137 return(MFileManObserver::EContinue); |
3137 return(MFileManObserver::EContinue); |
3138 } |
3138 } |
3139 |
|
3140 class CFileManObserverBytesCopied : public CBase, public MFileManObserver |
|
3141 { |
|
3142 public: |
|
3143 CFileManObserverBytesCopied(CFileMan* aFileMan); |
|
3144 TControl NotifyFileManEnded(); |
|
3145 TControl NotifyFileManOperation(); |
|
3146 TInt iBytesToBeCopied; |
|
3147 private: |
|
3148 CFileMan* iFileMan; |
|
3149 TInt iBytesCopied; |
|
3150 }; |
|
3151 |
|
3152 CFileManObserverBytesCopied::CFileManObserverBytesCopied(CFileMan* aFileMan) |
|
3153 // |
|
3154 // Constructor |
|
3155 // |
|
3156 { |
|
3157 __DECLARE_NAME(_S("CFileManObserverBytesCopied")); |
|
3158 iFileMan=aFileMan; |
|
3159 iBytesCopied=0; |
|
3160 } |
|
3161 |
|
3162 MFileManObserver::TControl CFileManObserverBytesCopied::NotifyFileManOperation() |
|
3163 // |
|
3164 // Observer for testBytesCopied tests |
|
3165 // |
|
3166 { |
|
3167 TFileName target; |
|
3168 iFileMan->GetCurrentTarget(target); |
|
3169 TInt match = target.MatchF(_L("?:\\bytesTransferred")); |
|
3170 if(match != 0) |
|
3171 { |
|
3172 RDebug::Print(_L("CFileManObserverBytesCopied::NotifyFileManOperation - target %s, match %d"),target.PtrZ(),match); |
|
3173 return MFileManObserver::EAbort; |
|
3174 } |
|
3175 |
|
3176 iBytesCopied += iFileMan->BytesTransferredByCopyStep(); |
|
3177 return(MFileManObserver::EContinue); |
|
3178 } |
|
3179 |
|
3180 MFileManObserver::TControl CFileManObserverBytesCopied::NotifyFileManEnded() |
|
3181 // |
|
3182 // Observer for testBytesCopied tests |
|
3183 // |
|
3184 { |
|
3185 if(iBytesCopied!=iBytesToBeCopied) |
|
3186 return (MFileManObserver::EAbort); |
|
3187 |
|
3188 return(MFileManObserver::EContinue); |
|
3189 } |
|
3190 |
|
3191 |
|
3192 |
3139 |
3193 LOCAL_C void TestOverWrite() |
3140 LOCAL_C void TestOverWrite() |
3194 // |
3141 // |
3195 // Test overwrite for copy and rename |
3142 // Test overwrite for copy and rename |
3196 // |
3143 // |
3977 #endif |
3924 #endif |
3978 |
3925 |
3979 MakeDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\")); |
3926 MakeDir(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\")); |
3980 TInt r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\*"),trgDrive,CFileMan::ERecurse); |
3927 TInt r=gFileMan->Move(_L("C:\\F32-TST\\TFMAN\\DRIVEMOVE\\*"),trgDrive,CFileMan::ERecurse); |
3981 test.Printf(_L("TestMoveEmptyDirectory(),gFileMan->Move(),r=%d\n"),r); |
3928 test.Printf(_L("TestMoveEmptyDirectory(),gFileMan->Move(),r=%d\n"),r); |
3982 test_Value(r, r == KErrNotFound); |
3929 test (r==KErrNotFound); |
3983 } |
3930 } |
3984 |
3931 |
3985 LOCAL_C void TestCopyAndRename() |
3932 LOCAL_C void TestCopyAndRename() |
3986 // |
3933 // |
3987 // Rename while copying files and directories |
3934 // Rename while copying files and directories |
4356 } // End of OOM loop |
4303 } // End of OOM loop |
4357 |
4304 |
4358 // cleanup |
4305 // cleanup |
4359 RmDir(_L("C:\\TestDEF130678\\")); |
4306 RmDir(_L("C:\\TestDEF130678\\")); |
4360 } |
4307 } |
4361 |
|
4362 void TestBytesTransferredByCopyStep() |
|
4363 { |
|
4364 // |
|
4365 // Test BytesCopied |
|
4366 // |
|
4367 test.Next(_L("TestBytesTransferredByCopyStep")); |
|
4368 (void)gFileMan->Delete(_L("\\bytesTransferred")); |
|
4369 |
|
4370 RFile tempFile; |
|
4371 TFileName tempname; |
|
4372 TInt r = tempFile.Temp(TheFs,_L("\\"),tempname,EFileWrite); |
|
4373 test_KErrNone(r); |
|
4374 r = tempFile.SetSize(50); |
|
4375 test_KErrNone(r); |
|
4376 tempFile.Flush(); |
|
4377 tempFile.Close(); |
|
4378 |
|
4379 CFileManObserverBytesCopied* fManObserver=new(ELeave) CFileManObserverBytesCopied(gFileMan); |
|
4380 CleanupStack::PushL(fManObserver); |
|
4381 gFileMan->SetObserver(fManObserver); |
|
4382 fManObserver->iBytesToBeCopied=50; |
|
4383 |
|
4384 if (!gAsynch) |
|
4385 { |
|
4386 r=gFileMan->Copy(tempname,_L("\\bytesTransferred"),CFileMan::EOverWrite); |
|
4387 test_KErrNone(r); |
|
4388 } |
|
4389 else |
|
4390 { |
|
4391 TInt r=gFileMan->Copy(tempname,_L("\\bytesTransferred"),CFileMan::EOverWrite,gStat); |
|
4392 test_KErrNone(r); |
|
4393 WaitForSuccess(); |
|
4394 } |
|
4395 |
|
4396 (void)gFileMan->Delete(_L("\\bytesTransferred")); |
|
4397 (void)TheFs.Delete(tempname); |
|
4398 CleanupStack::PopAndDestroy(); |
|
4399 } |
|
4400 |
|
4401 void TestGetMoreErrorInfo() |
|
4402 { |
|
4403 // |
|
4404 // Test GetMoreErrorInfo |
|
4405 // |
|
4406 test.Next(_L("TestGetMoreErrorInfo")); |
|
4407 |
|
4408 CFileManObserver* fManObserver=new(ELeave) CFileManObserver(gFileMan); |
|
4409 CleanupStack::PushL(fManObserver); |
|
4410 gFileMan->SetObserver(fManObserver); |
|
4411 |
|
4412 if (!gAsynch) |
|
4413 { |
|
4414 TInt r=gFileMan->Copy(_L("\\SRC"),_L("\\TRG"),0); |
|
4415 if(r!=KErrNone) //correct behaviour |
|
4416 { |
|
4417 TFileManError error = gFileMan->GetMoreInfoAboutError(); |
|
4418 test_Equal((TFileManError)ENoFilesProcessed,error); |
|
4419 } |
|
4420 else { test_Equal(!KErrNone,r); } |
|
4421 } |
|
4422 else |
|
4423 { |
|
4424 TInt r=gFileMan->Copy(_L("\\SRC"),_L("\\TRG"),0,gStat); |
|
4425 if(r!=KErrNone) //correct behaviour |
|
4426 { |
|
4427 TFileManError error = gFileMan->GetMoreInfoAboutError(); |
|
4428 test_Equal((TFileManError)ENoFilesProcessed,error); |
|
4429 } |
|
4430 else { test_Equal(!KErrNone,r); } |
|
4431 } |
|
4432 CleanupStack::PopAndDestroy(); |
|
4433 } |
|
4434 |
4308 |
4435 GLDEF_C void CallTestsL() |
4309 GLDEF_C void CallTestsL() |
4436 // |
4310 // |
4437 // Do tests |
4311 // Do tests |
4438 // |
4312 // |
4525 TestMove(); |
4399 TestMove(); |
4526 TestCopyAndRename(); |
4400 TestCopyAndRename(); |
4527 TestCopyAllCancel(); |
4401 TestCopyAllCancel(); |
4528 |
4402 |
4529 TestDEF130678(); // Test CFileMan::Move does not leak any memory |
4403 TestDEF130678(); // Test CFileMan::Move does not leak any memory |
4530 TestBytesTransferredByCopyStep(); |
|
4531 TestGetMoreErrorInfo(); |
|
4532 #ifndef __WINS__ |
4404 #ifndef __WINS__ |
4533 RThread t; |
4405 RThread t; |
4534 TThreadStackInfo stack; |
4406 TThreadStackInfo stack; |
4535 test_KErrNone(t.StackInfo(stack)); |
4407 test_KErrNone(t.StackInfo(stack)); |
4536 TestStackUsage(0, stack); |
4408 TestStackUsage(0, stack); |
4537 #endif |
4409 #endif |
4538 |
4410 |
4539 |
|
4540 Cleanup(); |
4411 Cleanup(); |
4541 DeleteTestDirectory(); |
4412 DeleteTestDirectory(); |
4542 test_KErrNone(TheFs.RmDir(_L("\\F32-TST\\"))); |
4413 test_KErrNone(TheFs.RmDir(_L("\\F32-TST\\"))); |
4543 } |
4414 } |
4544 |
4415 |