os/security/authorisation/userpromptservice/policies/test/tupspolicies/source/activewaiter.cpp
First public contribution.
2 * Copyright (c) 2007-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::WaitActive(TInt aExpectedStatus /*=KErrNone*/)
33 ASSERT(!iScheduler.IsStarted());
38 if (iStatus.Int() != aExpectedStatus)
40 INFO_PRINTF3(_L("CActiveWaiter::WaitActive() Expected %d, Got %d"), aExpectedStatus, iStatus.Int());
42 ASSERT_EQUALS(iStatus.Int(), aExpectedStatus);
46 Sets the active scheduler active and immidiately Cancels, calling the
47 supplied cancel observer during DoCancel();
48 @param aCancelObserver performs and DoCancel() operations on behalf of this object
50 void CActiveWaiter::SetActiveAndCancel(MActiveWaiterObserver& aCancelObserver)
52 ASSERT(!iScheduler.IsStarted());
53 ASSERT(iCancelObserver == NULL);
56 iCancelObserver = &aCancelObserver;
62 Cancels the current operation, and stops the active scheduler loop,
63 allowing a previous call to WaitActive() to return.
64 @param aCancelObserver performs and DoCancel() operations on behalf of this object
66 void CActiveWaiter::CancelWaitActive(MActiveWaiterObserver& aCancelObserver)
68 ASSERT(iScheduler.IsStarted());
69 ASSERT(iCancelObserver == NULL);
71 iCancelObserver = &aCancelObserver;
75 ASSERT(iScheduler.CanStopNow());
76 iScheduler.AsyncStop();
79 void CActiveWaiter::RunL()
81 if (iScheduler.IsStarted())
83 ASSERT(iScheduler.CanStopNow());
84 iScheduler.AsyncStop();
88 void CActiveWaiter::DoCancel()
90 ASSERT(iCancelObserver != NULL);
92 iCancelObserver->DoCancel();
93 iCancelObserver = NULL;
95 CTestExecuteLogger& CActiveWaiter::Logger()