os/security/authorisation/userpromptservice/policies/test/tupspolicies/source/activewaiter.h
Update contrib.
2 * Copyright (c) 2006-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.
15 * Copied from messaging IMAP tests
20 #ifndef ACTIVEWAITER_H
21 #define ACTIVEWAITER_H
23 #include <test/tefunit.h>
29 class MActiveWaiterObserver
32 virtual void DoCancel() =0;
36 An generic active object that can be used to wait for an iStatus to be signalled.
37 This has a similar effect to User::WaitForRequest(), but works without
38 blocking the thread (which allows other active objects within the thread
39 to continue). Instead, a nested active scheduler loop is used.
41 To use a CActiveWaiter, pass its iStatus to an asynchronous method, as usual.
42 Then call WaitActive() instead of SetActive().
44 The call will block until the asynchronous completes.
50 CActiveWaiter* waiter = new(ELeave)CActiveWaiter;
52 iAsyncObj->Bar(waiter->iStatus);
60 class CActiveWaiter : public CActive
63 CActiveWaiter(CTestExecuteLogger& aLogger);
66 void WaitActive(TInt aExpectedStatus = KErrNone);
67 void SetActiveAndCancel(MActiveWaiterObserver& aCancelObserver);
68 void CancelWaitActive(MActiveWaiterObserver& aCancelObserver);
75 CTestExecuteLogger& Logger();
76 CActiveSchedulerWait iScheduler;
77 MActiveWaiterObserver* iCancelObserver;
78 CTestExecuteLogger& iLogger;
81 #endif // ACTIVEWAITER_H