pimappservices/calendar/tsrc/tcal_notification.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "caltestlib.h"
       
    17 #include <e32test.h>
       
    18 #include <calentryview.h>
       
    19 #include <calprogresscallback.h>
       
    20 #include <calsession.h>
       
    21 
       
    22 LOCAL_D RTest test(_L("tcal_notification"));
       
    23 
       
    24 _LIT8(KEntryGuid, "A_DUMMY_GUID");
       
    25 _LIT(KCalendarFile1, "tcal_notification1");
       
    26 _LIT(KCalendarFile2, "tcal_notification2");
       
    27 _LIT(KSemName, "TCAL_NOTIFICATION_SEM");
       
    28 
       
    29 LOCAL_D const TInt KMaxHeapSize = 0x20000;
       
    30 
       
    31 class CTestApp : public CBase
       
    32 	{
       
    33 public:
       
    34 	virtual void RunTestL() = 0;
       
    35 	~CTestApp();
       
    36 
       
    37 protected:
       
    38 	CCalTestLibrary* iTestLib;	
       
    39 	CPeriodic* iTimer;
       
    40 	};
       
    41 	
       
    42 CTestApp::~CTestApp()
       
    43 	{
       
    44 	if (iTimer)
       
    45 		{
       
    46 		iTimer->Cancel();
       
    47 		}
       
    48 	delete iTimer;
       
    49 	delete iTestLib;
       
    50 	}
       
    51 		
       
    52 
       
    53 class CNotificationTestManager : public CTestApp, public MCalChangeCallBack
       
    54 	{
       
    55 public:
       
    56 	void InitialiseL();
       
    57 	static TInt StopWaitingForNotification(TAny* );
       
    58 	void DoStopWaitingForNotification();
       
    59 	void RunTestL();
       
    60 
       
    61 	// from MCalChangeCallBack
       
    62 	void CalChangeNotification(TChangeEntryType aChangeEntryType);
       
    63 
       
    64 public:
       
    65 	enum TCallBackState
       
    66 		{
       
    67 		ENotStarted = 0,
       
    68 		EWaitingForAddApptInRange,
       
    69 		EWaitingForAddApptOutRange,
       
    70 		EWaitingForAddTodoInRange,
       
    71 		EWaitingForAddTodoOutRange,
       
    72 		ENotificationReceived,
       
    73 		EWaitingToDeleteAppt,
       
    74 		EWaitingToDeleteTodo,
       
    75 		};
       
    76 
       
    77 private:
       
    78 	TCallBackState	iState;
       
    79 	};
       
    80 
       
    81 
       
    82 class CTestAppModifier : public CTestApp
       
    83 	{
       
    84 public:
       
    85 	void RunTestL();
       
    86 	static TInt RunTestThread(TAny* aArgs);
       
    87 
       
    88 private:
       
    89 	void StoreAndDestroyEntryL(CCalEntry* aEntry);
       
    90 	CCalEntry* CreateEntryL(CCalEntry::TType aType, TTime aTime);
       
    91 	void ClearEntryL();
       
    92 	};
       
    93 
       
    94 
       
    95 //CNotificationTestManager-------------------------------------------------------------------------
       
    96 
       
    97 TInt CNotificationTestManager::StopWaitingForNotification(TAny* aPtr)
       
    98 	{
       
    99 	CNotificationTestManager* manager = static_cast<CNotificationTestManager*>(aPtr);
       
   100 	
       
   101 	if (manager)
       
   102 		{
       
   103 		manager->DoStopWaitingForNotification();
       
   104 		}
       
   105 		
       
   106 	CActiveScheduler::Stop();
       
   107 	
       
   108 	return KErrNone;
       
   109 	}
       
   110 
       
   111 
       
   112 void CNotificationTestManager::DoStopWaitingForNotification()
       
   113 	{
       
   114 	test.Printf(_L("No notification received\n"));
       
   115 	
       
   116 	iTimer->Cancel();
       
   117 	}
       
   118 
       
   119 
       
   120 // callback function for change notification
       
   121 void CNotificationTestManager::CalChangeNotification(TChangeEntryType aChangeEntryType)
       
   122 	{
       
   123 	test.Printf(_L("Notification received - type = %d\n"), aChangeEntryType);
       
   124 	
       
   125 	switch (iState)
       
   126 		{
       
   127 		case EWaitingForAddApptInRange:
       
   128 		case EWaitingToDeleteAppt:
       
   129 			__ASSERT_ALWAYS(aChangeEntryType == EChangeEntryEvent, User::Invariant());
       
   130 			break;
       
   131 		case EWaitingForAddTodoInRange:
       
   132 		case EWaitingToDeleteTodo:
       
   133 			__ASSERT_ALWAYS(aChangeEntryType != EChangeEntryEvent, User::Invariant());
       
   134 			break;
       
   135 		case EWaitingForAddApptOutRange:
       
   136 		case EWaitingForAddTodoOutRange:
       
   137 			test.Printf(_L("Got call back from an out-of-range entry!!\n"));
       
   138 			test(0);
       
   139 			break;
       
   140 		default:
       
   141 			break;
       
   142 		}
       
   143 		
       
   144 	iTimer->Cancel();
       
   145 	iState = ENotificationReceived;
       
   146 	
       
   147 	CActiveScheduler::Stop();
       
   148 	}
       
   149 
       
   150 	
       
   151 void CNotificationTestManager::InitialiseL()
       
   152 	{
       
   153 	iTestLib = CCalTestLibrary::NewL();
       
   154 	
       
   155 	test.Printf(_L("Opening calendar file...\n"));		
       
   156 	
       
   157 	iTestLib->ReplaceFileL(KCalendarFile2());	
       
   158 	iTestLib->OpenFileL(KCalendarFile2());
       
   159 	
       
   160 	// force creation of a CEntryView object
       
   161 	test.Printf(_L("Opening entry view...\n"));
       
   162 	
       
   163 	iTestLib->AsynCGetEntryViewL();
       
   164 	CActiveScheduler::Start();
       
   165 	}
       
   166 
       
   167 
       
   168 
       
   169 void CNotificationTestManager::RunTestL()
       
   170 	{
       
   171 	TInt err;	
       
   172 		
       
   173 	test.Next(_L("Running Notification Test\n"));
       
   174 
       
   175 	iTestLib = CCalTestLibrary::NewL();
       
   176 	iTestLib->ReplaceFileL(KCalendarFile1());
       
   177 	test.Printf(_L("Opening calendar file...\n"));	
       
   178 	iTestLib->OpenFileL(KCalendarFile1());
       
   179 	
       
   180 	// force creation of a CEntryView object
       
   181 	test.Printf(_L("Opening entry view...\n"));	
       
   182 	iTestLib->SynCGetEntryViewL();
       
   183 	
       
   184 	iTimer = CPeriodic::NewL(CActive::EPriorityStandard);
       
   185 	const TTimeIntervalMicroSeconds32 KWait1second(1000000); // 1 second
       
   186 	
       
   187 	// set up notification (all entries in 2005)
       
   188 	TTime startTime(TDateTime(2005, EJanuary, 0, 0, 0, 0, 0)); // 1 Jan 05
       
   189 	TTime endTime(startTime + TTimeIntervalYears(1)); // 1 Jan 06
       
   190 	iTestLib->GetSession().StartChangeNotification(this, EChangeEntryAll, ETrue, startTime, endTime);
       
   191 
       
   192 	
       
   193 	// Create another thread to test the change callback.
       
   194 	test.Printf(_L("Setting up other thread for modifier object...\n"));
       
   195 	RThread otherThread;
       
   196 	TName threadName = _L("TestModifierThread");
       
   197 	err = otherThread.Create(threadName, CTestAppModifier::RunTestThread, KDefaultStackSize, 
       
   198 							      KMinHeapSize, KMaxHeapSize, NULL, EOwnerProcess);
       
   199 	if (err != KErrNone)
       
   200 		{
       
   201 		User::Panic(_L("Thread's not been created"), err);
       
   202 		}
       
   203 
       
   204 	// Create a semaphore
       
   205 	TName semName;
       
   206 	semName.Append(KSemName);
       
   207 
       
   208 	RSemaphore sem;
       
   209 	err = sem.CreateGlobal(semName, 0);
       
   210 	if (err == KErrAlreadyExists)
       
   211 		{
       
   212 		sem.OpenGlobal(semName);
       
   213 		}
       
   214 
       
   215 	// add appt within time range
       
   216 
       
   217 	test.Next(_L("Add an appointment within the notification time range"));
       
   218 
       
   219 	iState = EWaitingForAddApptInRange;
       
   220 	
       
   221 	// CNotificationTestManager::RunTestL hands over execution to the function 
       
   222 	// CTestAppModifier::RunTestL in the other thread for it to make 
       
   223 	// changes. The manager waits until the modifier has done what it 
       
   224 	// needs to and then signals the manager.
       
   225 	// 
       
   226 	// See "// Sync point 1" comments to trace back and forth between 
       
   227 	// the two functions.
       
   228 	
       
   229 	otherThread.Resume();
       
   230 	sem.Wait(); // Sync point 1
       
   231 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   232 	CActiveScheduler::Start();
       
   233 	test(iState == ENotificationReceived); // check callback notification was received for adding appt
       
   234 
       
   235 	test.Next(_L("Delete this appointment"));
       
   236 
       
   237 	iState = EWaitingToDeleteAppt;
       
   238 	otherThread.Resume();
       
   239 	sem.Wait(); // Sync point 2
       
   240 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   241 	CActiveScheduler::Start();
       
   242 	test(iState == ENotificationReceived); // check callback notification was received for delete
       
   243 	
       
   244 	// add appt outside time range
       
   245 
       
   246 	test.Next(_L("Add an appointment outside the notification time range"));
       
   247 
       
   248 	iState = EWaitingForAddApptOutRange;
       
   249 	otherThread.Resume();
       
   250 	sem.Wait(); // Sync point 3
       
   251 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   252 	CActiveScheduler::Start();
       
   253 	test(iState != ENotificationReceived); // check callback notification was NOT received for adding appt
       
   254 
       
   255 	test.Next(_L("Delete this appointment"));
       
   256 
       
   257 	iState = EWaitingToDeleteAppt;
       
   258 	otherThread.Resume();
       
   259 	sem.Wait(); // Sync point 4
       
   260 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   261 	CActiveScheduler::Start();
       
   262 	test(iState != ENotificationReceived); // check callback notification was NOT received for delete
       
   263 	
       
   264 	// notification should now be disabled by the other thread
       
   265 
       
   266 	// add todo within time range
       
   267 
       
   268 	test.Next(_L("Disable change notification then add a todo within the notification time range"));
       
   269 
       
   270 	iState = EWaitingForAddTodoInRange;
       
   271 	otherThread.Resume();
       
   272 	sem.Wait(); // Sync point 5
       
   273 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   274 	CActiveScheduler::Start();
       
   275 	test(iState != ENotificationReceived); // check callback notification was NOT received (disabled notification)
       
   276 
       
   277 	// notification should now be re-enabled by the other thread
       
   278 
       
   279 	test.Next(_L("Re-enable change notification"));
       
   280 
       
   281 	otherThread.Resume();
       
   282 	sem.Wait(); // Sync point 6
       
   283 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   284 	CActiveScheduler::Start();
       
   285 	test(iState == ENotificationReceived); // check callback notification was received for todo added during disable
       
   286 
       
   287 	test.Next(_L("Delete this todo"));
       
   288 
       
   289 	iState = EWaitingToDeleteTodo;
       
   290 	otherThread.Resume();
       
   291 	sem.Wait(); // Sync point 7
       
   292 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   293 	CActiveScheduler::Start();
       
   294 	test(iState == ENotificationReceived); // check callback notification was received for delete
       
   295 	
       
   296 	// add todo out of time range
       
   297 
       
   298 	test.Next(_L("Add a todo entry outside the notification time range"));
       
   299 
       
   300 	iState = EWaitingForAddTodoOutRange;
       
   301 	otherThread.Resume();
       
   302 	sem.Wait(); // Sync point 8
       
   303 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   304 	CActiveScheduler::Start();
       
   305 	test(iState != ENotificationReceived); // check callback notification was NOT received for adding todo
       
   306 
       
   307 	test.Next(_L("Delete this todo"));
       
   308 
       
   309 	iState = EWaitingToDeleteTodo;
       
   310 	otherThread.Resume();
       
   311 	sem.Wait(); // Sync point 9
       
   312 	iTimer->Start(KWait1second, KWait1second, TCallBack(StopWaitingForNotification, this));
       
   313 	CActiveScheduler::Start();
       
   314 	test(iState != ENotificationReceived); // check callback notification was NOT received for delete
       
   315 
       
   316 	otherThread.Resume(); // allow the thread to tidy up;
       
   317 	sem.Wait();
       
   318 
       
   319 	otherThread.Close();
       
   320 	sem.Close();
       
   321 
       
   322 	iTestLib->GetSession().StopChangeNotification();
       
   323 	}
       
   324 
       
   325 
       
   326 
       
   327 //CTestAppModifier------------------------------------------------------------------------
       
   328 
       
   329 // this function deletes all entries with the UID used in this test harness
       
   330 void CTestAppModifier::ClearEntryL()
       
   331 	{
       
   332 	CDesC8Array* uidArray = new (ELeave) CDesC8ArrayFlat(1);
       
   333 	CleanupStack::PushL(uidArray);
       
   334 	
       
   335 	uidArray->AppendL(KEntryGuid());
       
   336 	iTestLib->SynCGetEntryViewL().DeleteL(*uidArray);
       
   337 	
       
   338 	CleanupStack::PopAndDestroy(uidArray);
       
   339 	}
       
   340 
       
   341 // this function creates an entries with the type and time specified
       
   342 CCalEntry* CTestAppModifier::CreateEntryL(CCalEntry::TType aType, TTime aTime)
       
   343 	{
       
   344 	HBufC8* guid1 = KEntryGuid().AllocLC();
       
   345 	CCalEntry* entry = CCalEntry::NewL(aType, guid1, CCalEntry::EMethodNone, 0);
       
   346 	CleanupStack::Pop(guid1);
       
   347 	
       
   348 	TCalTime calTime1;
       
   349 	TCalTime calTime2;
       
   350 	calTime1.SetTimeLocalL(aTime);
       
   351 	calTime2.SetTimeLocalL(aTime + TTimeIntervalHours(1));
       
   352 	entry->SetStartAndEndTimeL(calTime1, calTime2);
       
   353 	
       
   354 	return entry;
       
   355 	}
       
   356 	
       
   357 // this function stores an entry then deletes it
       
   358 void CTestAppModifier::StoreAndDestroyEntryL(CCalEntry* aEntry)
       
   359 	{
       
   360 	CleanupStack::PushL(aEntry);
       
   361 	
       
   362 	RPointerArray<CCalEntry> entriesToAdd;
       
   363 	CleanupClosePushL(entriesToAdd);
       
   364 	
       
   365 	entriesToAdd.AppendL(aEntry);
       
   366 	
       
   367 	TInt successfulAdd(0);
       
   368 	iTestLib->SynCGetEntryViewL().StoreL(entriesToAdd, successfulAdd);
       
   369 		
       
   370 	test(successfulAdd == entriesToAdd.Count());
       
   371 	
       
   372 	CleanupStack::PopAndDestroy(); // entriesToAdd.Close()
       
   373 	CleanupStack::PopAndDestroy(aEntry);
       
   374 	}
       
   375 
       
   376 TInt CTestAppModifier::RunTestThread(TAny* /*aArgs*/)
       
   377 	{
       
   378 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
   379 	CActiveScheduler* scheduler = new CActiveScheduler;
       
   380 	if ( ! scheduler)
       
   381 		{
       
   382 		return KErrNoMemory;
       
   383 		}
       
   384 	CActiveScheduler::Install(scheduler);
       
   385 
       
   386 	// Create a semaphore
       
   387 	TName semName;
       
   388 	semName.Append(KSemName);
       
   389 
       
   390 	RSemaphore sem;
       
   391 	TInt err = sem.CreateGlobal(semName, 0);
       
   392 	if (err == KErrAlreadyExists)
       
   393 		{
       
   394 		sem.OpenGlobal(semName);
       
   395 		}
       
   396 
       
   397 	CTestAppModifier* modifier = new CTestAppModifier;
       
   398 	if ( ! modifier)
       
   399 		{
       
   400 		return KErrNoMemory;
       
   401 		}
       
   402 	TRAP(err, modifier->RunTestL());
       
   403 
       
   404 	delete modifier;
       
   405 	delete scheduler;
       
   406 	delete trapCleanup;
       
   407 
       
   408 	sem.Signal();
       
   409 	sem.Close();
       
   410 	return err;
       
   411 	}
       
   412 
       
   413 void CTestAppModifier::RunTestL()
       
   414 	{
       
   415 	RThread thisThread;
       
   416 	thisThread.Duplicate(RThread()); // get a handle to the current thread
       
   417 
       
   418 
       
   419 	iTestLib = CCalTestLibrary::NewL();
       
   420 	iTestLib->OpenFileL(KCalendarFile1());
       
   421 	
       
   422 	// force creation of a CEntryView object
       
   423 	iTestLib->SynCGetEntryViewL();
       
   424 		
       
   425 	// Create a semaphore
       
   426 	TName semName;
       
   427 	semName.Append(KSemName);
       
   428 
       
   429 	RSemaphore sem;
       
   430 	TInt err = sem.CreateGlobal(semName, 0);
       
   431 	if (err == KErrAlreadyExists)
       
   432 		{
       
   433 		sem.OpenGlobal(semName);
       
   434 		}
       
   435 
       
   436 	// The function CNotificationTestManager::RunTestL hands over execution 
       
   437 	// from the other thread to CTestAppModifier::RunTestL for it to 
       
   438 	// make changes. The manager waits until the modifier has done 
       
   439 	// what it needs to and then signals the manager.
       
   440 	// 
       
   441 	// See "// Sync point 1" comments to trace back and forth between 
       
   442 	// the two functions.
       
   443 	
       
   444 	// Sync point 1
       
   445 	// add appt within time range
       
   446 	TTime startTime(TDateTime(2005, EJanuary, 0, 0, 0, 0, 0)); // 1 Jan 05
       
   447 	TTime endTime(startTime + TTimeIntervalYears(1)); // 1 Jan 06
       
   448 	CCalEntry* apptInRange = CreateEntryL(CCalEntry::EAppt, startTime + TTimeIntervalDays(5));
       
   449 	StoreAndDestroyEntryL(apptInRange);
       
   450 	sem.Signal();
       
   451 	thisThread.Suspend();	
       
   452 	
       
   453 	// Sync point 2
       
   454 	// delete it
       
   455 	ClearEntryL();
       
   456 	sem.Signal();
       
   457 	thisThread.Suspend();	
       
   458 	
       
   459 	// Sync point 3
       
   460 	// add appt outside time range
       
   461 	CCalEntry* apptOutOfRange = CreateEntryL(CCalEntry::EAppt, startTime - TTimeIntervalMonths(3));
       
   462 	StoreAndDestroyEntryL(apptOutOfRange);
       
   463 	sem.Signal();
       
   464 	thisThread.Suspend();	
       
   465 
       
   466 	// Sync point 4
       
   467 	// delete it
       
   468 	ClearEntryL();
       
   469 	sem.Signal();
       
   470 	thisThread.Suspend();	
       
   471 
       
   472 	// Sync point 5
       
   473 	iTestLib->GetSession().DisableChangeBroadcast();
       
   474 
       
   475 	// add todo within time range
       
   476 	CCalEntry* disableAppt = CreateEntryL(CCalEntry::ETodo, startTime + TTimeIntervalDays(5));
       
   477 	StoreAndDestroyEntryL(disableAppt);
       
   478 	sem.Signal();
       
   479 	thisThread.Suspend();	
       
   480 
       
   481 	// Sync point 6
       
   482 	iTestLib->GetSession().EnableChangeBroadcast();
       
   483 	sem.Signal();
       
   484 	thisThread.Suspend();	
       
   485 
       
   486 	// Sync point 7
       
   487 	// delete it
       
   488 	ClearEntryL();
       
   489 	sem.Signal();
       
   490 	thisThread.Suspend();	
       
   491 	
       
   492 	// Sync point 8
       
   493 	// add todo out of time range
       
   494 
       
   495 	CCalEntry* todoOutRange = CreateEntryL(CCalEntry::ETodo, endTime + TTimeIntervalHours(4));
       
   496 	StoreAndDestroyEntryL(todoOutRange);
       
   497 	sem.Signal();
       
   498 	thisThread.Suspend();	
       
   499 
       
   500 	// Sync point 9
       
   501 	// delete it
       
   502 	ClearEntryL();
       
   503 	sem.Signal();
       
   504 	thisThread.Suspend();	
       
   505 
       
   506 	sem.Close();
       
   507 	}
       
   508 	
       
   509 	
       
   510 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
       
   511  * DoTestL()
       
   512  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
       
   513 
       
   514 static void DoTestL()
       
   515 	{
       
   516 	CNotificationTestManager* testManager = new (ELeave) CNotificationTestManager();
       
   517 	CleanupStack::PushL(testManager);
       
   518 	
       
   519 	
       
   520 	TPerformanceTimer timer(test);
       
   521 	timer.Start();
       
   522 	
       
   523 	
       
   524 	// Run the test suite	
       
   525 
       
   526 	// initialise the calendar file
       
   527 	testManager->RunTestL();
       
   528 
       
   529 
       
   530 	timer.Stop();
       
   531 	test.Printf(_L("Done\n"));
       
   532 	// printout performance time
       
   533 	timer.PrintOut();
       
   534 	
       
   535 	
       
   536 	CleanupStack::PopAndDestroy(testManager);
       
   537 	
       
   538 	
       
   539 	//Test code added for DEF063285
       
   540 	test.Next(_L("To initialise CalenderProgressObserver,Entryview,CalSession..."));
       
   541 
       
   542 	test.Next(_L("...and destroy entryview before it is built completely..."));
       
   543 
       
   544 	test.Next(_L("...to check any asynchronous operation is cancelled"));
       
   545 
       
   546 	
       
   547 	testManager = new (ELeave) CNotificationTestManager();
       
   548 	CleanupStack::PushL(testManager);
       
   549 	
       
   550 	//Intialise CalenderProgressObserver,Entryview,CalSession
       
   551 	TRAPD(err, testManager->InitialiseL());
       
   552 	test(err == KErrNone);
       
   553 	
       
   554 	//After initialising try to destroy CalenderProgressObserver which contains entryview
       
   555 	//and session to check any asynchronous operation is cancelled if the entryview is not built completely
       
   556 	CleanupStack::PopAndDestroy(testManager);
       
   557 	}
       
   558 	
       
   559 	
       
   560 /**
       
   561 
       
   562 @SYMTestCaseID     PIM-TCAL-NOTIFICATION-0001
       
   563 
       
   564 */
       
   565 
       
   566 TInt E32Main()
       
   567     {
       
   568 	__UHEAP_MARK;
       
   569 
       
   570 	test.Start(_L("@SYMTESTCaseID:PIM-TCAL-NOTIFICATION-0001 Calendar Interim API Notification test suite"));
       
   571 
       
   572 	test.Title();
       
   573 
       
   574 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
   575 	if (!trapCleanup)
       
   576 		{
       
   577 		return KErrNoMemory;
       
   578 		}
       
   579 
       
   580 	CActiveScheduler* scheduler = new CActiveScheduler();
       
   581 	if (!scheduler)
       
   582 		{
       
   583 		delete trapCleanup;
       
   584 		return KErrNoMemory;
       
   585 		}
       
   586 	CActiveScheduler::Install(scheduler);	
       
   587 
       
   588 	TRAPD(ret, DoTestL());
       
   589 	test(ret == KErrNone);
       
   590 	
       
   591 	delete scheduler;
       
   592 	delete trapCleanup;	
       
   593 
       
   594 	test.End();
       
   595 	test.Close();
       
   596 
       
   597 	__UHEAP_MARKEND;
       
   598 
       
   599 	return (KErrNone);
       
   600     }
       
   601