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