// ----------------------------------------------------------------------------- // CDelayTimer::NewL() // Two-phased constructor. // ----------------------------------------------------------------------------- // CDelayTimer* CDelayTimer::NewL( MActionObserver& aObserver ) { CDelayTimer* self = new ( ELeave ) CDelayTimer(aObserver); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); return self; }
void CPopsTestHarness::FillDiskL() // // Fill all available space on C: drive leaving aLeaveFreeByes free. // { TInt leaveFreeBytes = KTestDiskSpace; // Check that there is a C-drive and that it is less than 10MB in size. TestAvailableSpaceOnDriveL(); // NOTE: This test harness should be used with a dedicated small partition or // subst'ed floppy drive as the EPOC C: drive. As a safety precaution, it // tests the free space on the partition to ensure that it does not attempt // to eat 20 GB of free space and either crash Windows or at least cause a // headache of some sort... // Delete any old dummy fill files - if there is one to delete. iTestUtils->FileSession().Delete(KMsvTestFillDiskFile); // Create the delay timer CDelayTimer* delayTimer = new(ELeave)CDelayTimer; CleanupStack::PushL(delayTimer); delayTimer->ConstructL(); // Check that available disk space does not exceed the max free space to fill. // See above... TInt64 freeSpace; TInt64 freeSpaceLeft; TInt error = CheckDiskSpace(freeSpace); TInt reclaimActive = 0; do { delayTimer->Delay(KMsvTestBackgroundDeleteInitialWait); error = CheckDiskSpace(freeSpaceLeft); if (freeSpaceLeft == freeSpace) reclaimActive++; freeSpace = freeSpaceLeft; } while (!error && reclaimActive<3); User::LeaveIfError(error); CleanupStack::PopAndDestroy(); //delayTimer // Free space in kb. freeSpace/=KFillDiskOneKByte; // Check free space on C: drive is not too big. TInt freeSpaceInKb = I64INT(freeSpace); if (freeSpaceInKb>KFillDiskTooBigFreeSize) User::Leave(KErrTooBig); // Fill disk with large file. TBuf8<KFillDiskMaxBlockSize> dummy; dummy.SetMax(); dummy.Fill('?'); // Open dummy file. RFile fillDiskFile; User::LeaveIfError(fillDiskFile.Replace(iTestUtils->FileSession(), KMsvTestFillDiskFile, EFileWrite)); // Establish required dummy file size. freeSpaceLeft-=leaveFreeBytes; if (freeSpaceLeft<0) // Uh oh, we have less space available than what was asked for... User::Leave(KErrDiskFull); // Write dummy file. while (freeSpaceLeft>0 && error==KErrNone) { dummy.SetLength(Min(KFillDiskMaxBlockSize,I64INT(freeSpaceLeft))); error=fillDiskFile.Write(dummy); freeSpaceLeft-=KFillDiskMaxBlockSize; } fillDiskFile.Close(); if (error==KErrDiskFull) error=KErrNone; User::LeaveIfError(error); }