os/persistentdata/loggingservices/eventlogger/test/tef/teflogengbur/src/testactive.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-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 // Implementation of test active object for log engine testing 
    15 // Identical implementation exists in common\syslibs\logeng\ongoing\test\src\test.cpp
    16 // 
    17 //
    18 
    19 /**
    20  @file
    21  @internalComponent
    22 */
    23 
    24 #include "testactive.h"
    25 
    26 CTestActive::CTestActive(TInt aPriority)
    27 :	CActive(aPriority)
    28 	{
    29 	CActiveScheduler::Add(this);
    30 	iDelayTime=0;
    31 	}
    32 
    33 CTestActive::~CTestActive()
    34 	{
    35 	Cancel();
    36 	}
    37 
    38 void CTestActive::DoCancel()
    39 	{
    40 	TRequestStatus* s=&iStatus;
    41 	User::RequestComplete(s, KErrNone);
    42 	}
    43 
    44 void CTestActive::Start()
    45 	{
    46 	iDelayCompletion=EFalse;
    47 	iDelayTime=0;
    48 	iStatus = KRequestPending;
    49 	SetActive();
    50 	}
    51 
    52 void CTestActive::Start(TInt aDelay)
    53 	{
    54 	iDelayCompletion=ETrue;
    55 	iDelayTime=aDelay;
    56 	iStatus = KRequestPending;
    57 	SetActive();
    58 	}
    59 
    60 void CTestActive::RunL() 
    61 	{
    62 	if(iDelayCompletion && iDelayTime)
    63 		{
    64 		// Wait for events in other threads to have a go....
    65 		User::After(iDelayTime);
    66 		iDelayTime=0;
    67 		iStoredStatus=iStatus;
    68 		SetActive();
    69 		TRequestStatus* s=&iStatus;
    70 		User::RequestComplete(s, KErrNone);
    71 		}
    72 	else
    73 		{
    74 		if(iDelayCompletion)
    75 			iStatus=iStoredStatus;
    76 
    77 		CActiveScheduler::Stop();
    78 		}
    79 	}