os/security/authorisation/userpromptservice/database/test/tupsdb/source/activewaiter.cpp
First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "activewaiter.h"
21 CActiveWaiter::CActiveWaiter(CTestExecuteLogger& aLogger)
22 : CActive(CActive::EPriorityStandard)
25 CActiveScheduler::Add(this);
28 CActiveWaiter::~CActiveWaiter()
31 void CActiveWaiter::WaitActiveL(TInt aExpectedStatus /*=KErrNone*/)
33 ASSERT(!iScheduler.IsStarted());
38 if (iStatus.Int() != aExpectedStatus)
40 INFO_PRINTF3(_L("CActiveWaiter::WaitActiveL() Expected %d, Got %d"), aExpectedStatus, iStatus.Int());
42 if(iStatus.Int() != aExpectedStatus)
44 User::Leave(iStatus.Int());
46 //ASSERT_EQUALS(iStatus.Int(), aExpectedStatus);
50 Sets the active scheduler active and immidiately Cancels, calling the
51 supplied cancel observer during DoCancel();
52 @param aCancelObserver performs and DoCancel() operations on behalf of this object
54 void CActiveWaiter::SetActiveAndCancel(MActiveWaiterObserver& aCancelObserver)
56 ASSERT(!iScheduler.IsStarted());
57 ASSERT(iCancelObserver == NULL);
60 iCancelObserver = &aCancelObserver;
66 Cancels the current operation, and stops the active scheduler loop,
67 allowing a previous call to WaitActiveL() to return.
68 @param aCancelObserver performs and DoCancel() operations on behalf of this object
70 void CActiveWaiter::CancelWaitActive(MActiveWaiterObserver& aCancelObserver)
72 ASSERT(iScheduler.IsStarted());
73 ASSERT(iCancelObserver == NULL);
75 iCancelObserver = &aCancelObserver;
79 ASSERT(iScheduler.CanStopNow());
80 iScheduler.AsyncStop();
83 void CActiveWaiter::RunL()
85 if (iScheduler.IsStarted())
87 ASSERT(iScheduler.CanStopNow());
88 iScheduler.AsyncStop();
92 void CActiveWaiter::DoCancel()
94 ASSERT(iCancelObserver != NULL);
96 iCancelObserver->DoCancel();
97 iCancelObserver = NULL;
100 CTestExecuteLogger& CActiveWaiter::Logger()