コード例 #1
0
LOCAL_C void TestStoreExistsL()
	{
	CMsgsTestUtils::SetDriveL(EDriveC);
	
	//Check that message store exists on the drive at this stage
	CSessionObserver* ob = new(ELeave)CSessionObserver;
	CleanupStack::PushL(ob);
       
	// Set session in observer
	CMsvSession* session = CMsvSession::OpenAsyncL(*ob);
	ob->iSession = session; 
	CleanupStack::PushL(session);
    
	CActiveScheduler::Start();
	test(ob->iType==MMsvSessionObserver::EMsvServerReady);
	
	CTestActive* active = new(ELeave)CTestActive;
	CleanupStack::PushL(active);
     
	// Test Copy MailStore 
	active->StartL();
	CMsvOperation* operation = NULL;
	TDriveUnit unit = EDriveD;
	operation = session->CopyStoreL(unit, active->iStatus);
	test(operation->Mtm() == KUidMsvServerMtm);
	CleanupStack::PushL(operation);
	
	CActiveScheduler::Start();
	
	//Retrieve progress 
	//Should retrun KErrAlreadyExists
	TPckgBuf<TMsvCopyProgress> package;
	package.Copy(operation->ProgressL());
	test(package().iError == KErrAlreadyExists);
		
	//delete session;
	CleanupStack::PopAndDestroy(4, ob);
	
	CMsgsTestUtils::WaitForServerClose();
		
  	}
コード例 #2
0
/* Test to check the new API
** CopyStoreL(TInt aDrive, TMsvOp aOperationId, TRequestStatus& aStatus) 
*/
LOCAL_C void TestCopyStoreOperationL()
	{
	CMsgsTestUtils::SetDriveL(EDriveC);
    
	CSessionObserver* ob = new(ELeave)CSessionObserver;
	CleanupStack::PushL(ob);
       
	// Set session in observer
	CMsvSession* session = CMsvSession::OpenAsyncL(*ob);
	ob->iSession = session; 
	CleanupStack::PushL(session);
    
	CActiveScheduler::Start();
	test(ob->iType==MMsvSessionObserver::EMsvServerReady);
	
	//Create an entry in the mail
	
	CMsvEntry* entry=session->GetEntryL(KMsvDraftEntryId);
	CleanupStack::PushL(entry);
	// create entry to work under
	TMsvEntry folder;
	folder.iType = KUidMsvFolderEntry;
	folder.iMtm = KUidMsvLocalServiceMtm;
	folder.iServiceId = KMsvLocalServiceIndexEntryId;
	_LIT(KTestDescription,"A Description");
	_LIT(KTestDetails,"A Details");
	folder.iDescription.Set(KTestDescription);
	folder.iDetails.Set(KTestDetails);
	entry->CreateL(folder);
	entry->SetEntryL(folder.Id());
	CMsvStore* store=entry->EditStoreL();
	CleanupStack::PushL(store);
	RMsvWriteStream stream;
	stream.AssignLC(*store,TUid::Uid(0x1000));
	stream.WriteL(KTestDescription);
	stream.CommitL();
	store->CommitL();
	CleanupStack::PopAndDestroy(3);
            
	CTestActive* active = new(ELeave)CTestActive;
	CleanupStack::PushL(active);
     
	// Test Copy MailStore 
	active->StartL();
	CMsvOperation* operation = NULL;
	TDriveUnit unit =(EDriveD);
	operation = session->CopyStoreL(unit, active->iStatus);
	test(operation->Mtm() == KUidMsvServerMtm);
	CleanupStack::PushL(operation);
	
	CActiveScheduler::Start();
	
	//Retrieve progress 
	TPckgBuf<TMsvCopyProgress> package;
	package.Copy(operation->ProgressL());
	test(package().iError == KErrNone);
		
	//delete session;
	CleanupStack::PopAndDestroy(4);
		
	//Check that both the source and destination
	//MailStore directory structure is same
	
	CMsgsTestUtils::WaitForServerClose();
	
	CDir 		 *srcDir;
	CDir 	     *destDir;
	_LIT(intro, "Testing the directory structure");
	_LIT(KEntryname,"%S");
	
	theUtils->Printf(intro);
	
	TFileName dest = unit.Name();
	dest.Append(KMsvDefaultFolder2);

	User::LeaveIfError(theUtils->FileSession().GetDir(dest, KEntryAttDir|KEntryAttNormal, ESortByName, destDir));
	
	unit =EDriveC;
	TFileName src = unit.Name();
	src.Append(KMsvDefaultFolder2);

	User::LeaveIfError(theUtils->FileSession().GetDir(src, KEntryAttDir|KEntryAttNormal, ESortByName, srcDir));
	
	TInt counter=0;
	TEntry srcEntry;
	TEntry destEntry;

	while (counter<srcDir->Count())
		{
		srcEntry = (*srcDir)[counter];
		destEntry = (*destDir)[counter];
		//Check the sizes 
		test(srcEntry.iSize == destEntry.iSize);
		//Check the names
		test(srcEntry.iName == destEntry.iName);
		//Print out the names on the log
		theUtils->Printf(KEntryname,&(srcEntry.iName));
		counter++;
		}
		
	delete srcDir;
	delete destDir;
	
	}