|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef LOADGEN_APPLICATIONS_H |
|
20 #define LOADGEN_APPLICATIONS_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <w32std.h> |
|
26 |
|
27 #include "loadgen_loadbase.h" |
|
28 #include "loadgen_loadattributes.h" |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CLauncherEngine; |
|
33 |
|
34 // CLASS DECLARATIONS |
|
35 |
|
36 class CAppLauncher : public CLoadBase |
|
37 { |
|
38 public: |
|
39 static CAppLauncher* NewL( TApplicationsAttributes& aAttributes, |
|
40 TInt aReferenceNumber ); |
|
41 virtual ~CAppLauncher(); |
|
42 |
|
43 private: // Constructors |
|
44 CAppLauncher( TApplicationsAttributes& aAttributes, |
|
45 TInt aReferenceNumber ); |
|
46 void ConstructL(); |
|
47 |
|
48 public: // New methods |
|
49 virtual void Resume(); |
|
50 virtual void Suspend(); |
|
51 virtual void SetPriority(); |
|
52 virtual void Close(); |
|
53 virtual TPtrC Description(); |
|
54 inline TApplicationsAttributes& Attributes() { return iAttributes; } |
|
55 |
|
56 public: // New static methods |
|
57 static TInt ThreadFunction( TAny* aThreadArg ); |
|
58 |
|
59 private: // New static methods |
|
60 static void GenerateLoad( TApplicationsAttributes& aAttributes ); |
|
61 |
|
62 private: // Data |
|
63 TApplicationsAttributes iAttributes; |
|
64 RThread iThread; |
|
65 }; |
|
66 |
|
67 // Class to start launching applications in given period |
|
68 |
|
69 // CLASS DECLARATIONS |
|
70 class CAppLauncherManager : public CActive |
|
71 { |
|
72 public: |
|
73 static CAppLauncherManager* NewL( TApplicationsAttributes& aAttributes ); |
|
74 ~CAppLauncherManager(); |
|
75 |
|
76 private: |
|
77 CAppLauncherManager( TApplicationsAttributes& aAttributes ); |
|
78 void ConstructL(); |
|
79 |
|
80 private: |
|
81 void RunL(); |
|
82 void DoCancel(); |
|
83 |
|
84 private: |
|
85 static TInt PeriodicTimerCallBack( TAny* aAny ); |
|
86 void SimulateEventL(); |
|
87 |
|
88 public: |
|
89 inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } |
|
90 |
|
91 private: |
|
92 TApplicationsAttributes& iAttributes; |
|
93 CPeriodic* iPeriodicTimer; |
|
94 RWsSession iWsSession; |
|
95 CLauncherEngine* iLauncherEngine; |
|
96 TInt iAppEventType; |
|
97 }; |
|
98 |
|
99 // A class where applicationg launching and ending is implemented |
|
100 #include <aknappui.h> |
|
101 #include <apgcli.h> |
|
102 |
|
103 // FORWARD DECLARATIONS |
|
104 class CAppKeyPressManager; |
|
105 |
|
106 // CLASS DECLARATIONS |
|
107 class CLauncherEngine : public CBase |
|
108 { |
|
109 public: |
|
110 static CLauncherEngine* NewL( TApplicationsAttributes& aAttributes ); |
|
111 ~CLauncherEngine(); |
|
112 |
|
113 public: |
|
114 void StartAppLaunchingL(); |
|
115 void StopApplication( TBool aRandomApplication ); |
|
116 |
|
117 |
|
118 private: |
|
119 CLauncherEngine( TApplicationsAttributes& aAttributes ); |
|
120 void ConstructL(); |
|
121 TBool LaunchApplicationL(); |
|
122 void DoLaunchApplicationL(); |
|
123 |
|
124 public: |
|
125 inline TInt AppLaunchCounter() { return iAppLaunchCounter; } |
|
126 |
|
127 private: |
|
128 RTimer iTimer; |
|
129 RApaLsSession iLs; |
|
130 RWsSession iWs; |
|
131 TInt iAppLaunchCounter; |
|
132 TUid iCurrentAppUid; |
|
133 TThreadId iCurrentAppThreadId; |
|
134 TBuf<128> iCurrentAppNameAndExt; |
|
135 RThread iCurrentAppThread; |
|
136 TInt iParallelApplicationsCounter; |
|
137 TApplicationsAttributes& iAttributes; |
|
138 |
|
139 CAppKeyPressManager* iAppKeyPressManager; |
|
140 }; |
|
141 |
|
142 |
|
143 // A class where key presses can be added to application |
|
144 #include <e32cmn.h> |
|
145 // FORWARD DECLARATIONS |
|
146 class CApplicationKeyPresses; |
|
147 // CLASS DECLARATIONS |
|
148 class CAppKeyPressManager : public CBase |
|
149 { |
|
150 public: |
|
151 static CAppKeyPressManager* NewL( TApplicationsAttributes& aAttributes ); |
|
152 ~CAppKeyPressManager(); |
|
153 void AddNewApplicationUidToKeyEventsL( TUid aUid ); |
|
154 TUid KillApplication( TBool aRandomApplication ); |
|
155 |
|
156 private: |
|
157 CAppKeyPressManager( TApplicationsAttributes& aAttributes ); |
|
158 void ConstructL(); |
|
159 |
|
160 private: |
|
161 RPointerArray<CApplicationKeyPresses> iKeyPresses; |
|
162 TApplicationsAttributes& iAttributes; |
|
163 }; |
|
164 |
|
165 // A class which sends key press events to application |
|
166 // CLASS DECLARATIONS |
|
167 class CApplicationKeyPresses : public CBase |
|
168 { |
|
169 public: |
|
170 static CApplicationKeyPresses* NewL( TUid aUid, |
|
171 TApplicationsAttributes& aAttributes ); |
|
172 ~CApplicationKeyPresses(); |
|
173 |
|
174 private: |
|
175 CApplicationKeyPresses( TUid aUid, TApplicationsAttributes& aAttributes ); |
|
176 void ConstructL(); |
|
177 |
|
178 private: |
|
179 static TInt PeriodicTimerCallBack( TAny* aAny ); |
|
180 void SimulateKeyEvent(); |
|
181 |
|
182 public: |
|
183 inline CPeriodic* PeriodicTimer() { return iPeriodicTimer; } |
|
184 |
|
185 private: |
|
186 TUid iUid; |
|
187 TApplicationsAttributes& iAttributes; |
|
188 CPeriodic* iPeriodicTimer; |
|
189 RWsSession iWsSession; |
|
190 public: |
|
191 inline TUid ApplicationUid() { return iUid; }; |
|
192 }; |
|
193 |
|
194 #endif // LOADGEN_APPLICATIONS |