|
1 // Copyright (c) 2008-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 // Contains an active object that stops the active scheduler |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #ifndef ACTIVESTOPPER_H_ |
|
25 #define ACTIVESTOPPER_H_ |
|
26 |
|
27 #include <e32base.h> |
|
28 |
|
29 /** |
|
30 * CActiveStopper is an active object that stops the active scheduler in it's RunL. |
|
31 * |
|
32 * Used to aid in testing of active objects |
|
33 * |
|
34 * @test |
|
35 * @internalComponent |
|
36 */ |
|
37 class CActiveStopper : public CActive |
|
38 { |
|
39 public: |
|
40 |
|
41 CActiveStopper() |
|
42 : CActive(EPriorityNull) |
|
43 { |
|
44 CActiveScheduler::Add(this); |
|
45 // Set it up to run immediately |
|
46 iStatus = KRequestPending; |
|
47 SetActive(); |
|
48 TRequestStatus* statusPtr = &iStatus; |
|
49 User::RequestComplete(statusPtr, KErrNone); |
|
50 } |
|
51 |
|
52 virtual ~CActiveStopper() |
|
53 { |
|
54 Deque(); |
|
55 } |
|
56 |
|
57 protected: |
|
58 |
|
59 virtual void RunL() |
|
60 { |
|
61 // Set it up to run immediately |
|
62 iStatus = KRequestPending; |
|
63 SetActive(); |
|
64 TRequestStatus* statusPtr = &iStatus; |
|
65 User::RequestComplete(statusPtr, KErrNone); |
|
66 // Stop active scheduler |
|
67 CActiveScheduler::Stop(); |
|
68 } |
|
69 |
|
70 virtual void DoCancel() |
|
71 { |
|
72 // Nothing to do |
|
73 } |
|
74 |
|
75 virtual TInt DoError(TInt aError) |
|
76 { |
|
77 // Just return the error to the scheduler |
|
78 return aError; |
|
79 } |
|
80 }; |
|
81 |
|
82 #endif /*ACTIVESTOPPER_H_*/ |