1 /* |
|
2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Thumbnail task unit tests. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __DUMMYTASKMANAGER_H__ |
|
21 #define __DUMMYTASKMANAGER_H__ |
|
22 |
|
23 // HACK: Make CDummyTaskManager a friend of CGlxtnTask |
|
24 #define CDummyTaskManager CGlxtnTaskManager |
|
25 |
|
26 // CLASS DEFINITION |
|
27 |
|
28 /** |
|
29 * Dummy task manager to run a single task within a unit test. |
|
30 */ |
|
31 NONSHARABLE_CLASS( CDummyTaskManager ) : public CActive |
|
32 { |
|
33 public: |
|
34 enum TExecutionOrder |
|
35 { |
|
36 ELastOut, // Old tasks with the same priority get executed before the new task |
|
37 EFirstOut // New task gets executed before other tasks with the same priority |
|
38 }; |
|
39 |
|
40 CDummyTaskManager(CGlxtnTask* aTask); |
|
41 void StartTaskL(); |
|
42 void AddTaskL(CGlxtnTask* aTask, TExecutionOrder aExecutionOrder = ELastOut); |
|
43 |
|
44 private: // From CActive |
|
45 void RunL(); |
|
46 void DoCancel(); |
|
47 TInt RunError(TInt aError); |
|
48 |
|
49 private: |
|
50 CGlxtnTask* iTask; // Not owned |
|
51 }; |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 |
|
55 CDummyTaskManager::CDummyTaskManager(CGlxtnTask* aTask) |
|
56 : CActive(EPriorityStandard), iTask(aTask) |
|
57 { |
|
58 CActiveScheduler::Add(this); |
|
59 } |
|
60 |
|
61 void CDummyTaskManager::StartTaskL() |
|
62 { |
|
63 iTask->StartL(iStatus); |
|
64 if ( iTask->State() != CGlxtnTask::EComplete ) |
|
65 { |
|
66 SetActive(); |
|
67 CActiveScheduler::Start(); |
|
68 } |
|
69 } |
|
70 |
|
71 void CDummyTaskManager::AddTaskL(CGlxtnTask* /*aTask*/, TExecutionOrder /*aExecutionOrder*/) |
|
72 { |
|
73 User::Leave(KErrNotSupported); |
|
74 } |
|
75 |
|
76 void CDummyTaskManager::RunL() |
|
77 { |
|
78 iTask->RunL(iStatus); |
|
79 if ( iTask->State() == CGlxtnTask::EComplete ) |
|
80 { |
|
81 CActiveScheduler::Stop(); |
|
82 } |
|
83 else |
|
84 { |
|
85 SetActive(); |
|
86 } |
|
87 } |
|
88 |
|
89 void CDummyTaskManager::DoCancel() |
|
90 { |
|
91 iTask->Cancel(); |
|
92 } |
|
93 |
|
94 TInt CDummyTaskManager::RunError(TInt aError) |
|
95 { |
|
96 EUNIT_PRINT(_L("CDummyTaskManager RunError(%d)"), aError); |
|
97 iTask->RunError(aError); |
|
98 if ( CGlxtnTask::ERunning == iTask->State() ) |
|
99 { |
|
100 SetActive(); |
|
101 } |
|
102 else |
|
103 { |
|
104 CActiveScheduler::Stop(); |
|
105 } |
|
106 return KErrNone; |
|
107 } |
|
108 |
|
109 #endif // __DUMMYTASKMANAGER_H__ |
|
110 |
|
111 // End of file |
|