|
1 // Copyright (c) 2003-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 // |
|
15 |
|
16 #include <c32comm.h> |
|
17 #include "TestObexErrorCodes.h" |
|
18 |
|
19 #if defined (__WINS__) |
|
20 #define PDD_NAME _L("ECDRV") |
|
21 #define LDD_NAME _L("ECOMM") |
|
22 #else // __GCC32__ |
|
23 #define PDD_NAME _L("EUART2") |
|
24 #define LDD_NAME _L("ECOMM") |
|
25 #define FIR_PDD_NAME _L("DIFIR") // Brutus FIR PDD |
|
26 #define FIR_LDD_NAME _L("EFIR") // Brutus FIR LDD |
|
27 #endif |
|
28 |
|
29 |
|
30 |
|
31 void Startup() |
|
32 { |
|
33 CActiveScheduler *pA=new CActiveScheduler; |
|
34 CActiveScheduler::Install(pA); |
|
35 |
|
36 CControllerTestMasterClass* bigBoss = CControllerTestMasterClass::NewL(); |
|
37 |
|
38 CActiveScheduler::Start(); |
|
39 delete bigBoss; |
|
40 bigBoss = NULL; |
|
41 delete pA; |
|
42 } |
|
43 |
|
44 |
|
45 void CControllerTestMasterClass::ConstructL() |
|
46 { |
|
47 //make the initial active object everything |
|
48 iConsoleTest = CControllerConsoleTest::NewL(this); |
|
49 |
|
50 iConsoleTest->IssueRequest(); |
|
51 |
|
52 } |
|
53 |
|
54 CControllerTestMasterClass* CControllerTestMasterClass::NewL() |
|
55 { |
|
56 CControllerTestMasterClass* self = NewLC(); |
|
57 CleanupStack::Pop(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 CControllerTestMasterClass* CControllerTestMasterClass::NewLC() |
|
62 { |
|
63 CControllerTestMasterClass* self=new (ELeave) CControllerTestMasterClass; |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 |
|
71 CControllerTestMasterClass::~CControllerTestMasterClass() |
|
72 { |
|
73 delete iConsoleTest; |
|
74 iConsoleTest = NULL; |
|
75 } |
|
76 |
|
77 |
|
78 |
|
79 GLDEF_C TInt E32Main() |
|
80 { |
|
81 |
|
82 __UHEAP_MARK; |
|
83 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack |
|
84 |
|
85 |
|
86 // start scheduler |
|
87 TRAPD(error, Startup() ); |
|
88 __ASSERT_ALWAYS(!error,User::Panic(_L("Testing Registry"),error)); |
|
89 |
|
90 |
|
91 delete cleanup; // destroy clean-up stack |
|
92 __UHEAP_MARKEND; |
|
93 return KErrNone; |
|
94 } |
|
95 |
|
96 |
|
97 |
|
98 // |
|
99 // CRegistryConsoleTest |
|
100 // |
|
101 CControllerConsoleTest::~CControllerConsoleTest() |
|
102 { |
|
103 Cancel(); |
|
104 |
|
105 |
|
106 delete iTest; |
|
107 delete iConsole; |
|
108 iConsole = NULL; |
|
109 iOwner = NULL; |
|
110 |
|
111 } |
|
112 |
|
113 |
|
114 void CControllerConsoleTest::DoCancel() |
|
115 { |
|
116 iConsole->ReadCancel(); |
|
117 } |
|
118 |
|
119 |
|
120 void CControllerConsoleTest::Menu() |
|
121 { |
|
122 iConsole->Printf(_L("\nOBEX error code tests ...")); |
|
123 iConsole->Printf(_L("\nPress '1' to start Client Side Tests")); |
|
124 iConsole->Printf(_L("\nPress '2' to start Server Side Tests")); |
|
125 iConsole->Printf(_L("\nPress '3' to start")); |
|
126 iConsole->Printf(_L("\nPress '4' to stop")); |
|
127 iConsole->Printf(_L("\nAny other key to exit")); |
|
128 } |
|
129 |
|
130 void CControllerConsoleTest::IssueRequest() |
|
131 { |
|
132 Menu(); |
|
133 iConsole->Read(iStatus); |
|
134 SetActive(); |
|
135 } |
|
136 void CControllerConsoleTest::ConstructL(CControllerTestMasterClass* aOwner) |
|
137 { |
|
138 |
|
139 iOwner = aOwner; |
|
140 iConsole = Console::NewL(_L("Controller Test"), |
|
141 TSize(-1,-1)); |
|
142 DoTest(); //set everything up, load everything |
|
143 |
|
144 |
|
145 CActiveScheduler::Add(this); |
|
146 } |
|
147 |
|
148 TInt CControllerConsoleTest::RunError(TInt) |
|
149 { |
|
150 IssueRequest(); |
|
151 return KErrNone; |
|
152 } |
|
153 |
|
154 |
|
155 void CControllerConsoleTest::StartTest() |
|
156 { |
|
157 iTest->Start(); |
|
158 |
|
159 iStarted = ETrue; |
|
160 |
|
161 } |
|
162 |
|
163 void CControllerConsoleTest::StopTest() |
|
164 { |
|
165 |
|
166 if ( iStarted ) |
|
167 { |
|
168 iTest->Stop(); |
|
169 |
|
170 iStarted = EFalse; |
|
171 } |
|
172 else |
|
173 { |
|
174 iConsole->Printf(_L("DOOH, can't stop a test which hasn't started\n")); |
|
175 } |
|
176 } |
|
177 |
|
178 void CControllerConsoleTest::DoTest() |
|
179 { |
|
180 iStarted = EFalse; |
|
181 iConsole->Printf(_L("\n Loading tests")); |
|
182 |
|
183 |
|
184 |
|
185 TInt ret; |
|
186 #ifdef __EPOC32__ |
|
187 iConsole->Printf(_L("Loading C32...\n")); |
|
188 ret=StartC32(); |
|
189 if (ret!=KErrNone && ret!=KErrAlreadyExists) |
|
190 iConsole->Printf(_L(" Failed %d\n"), ret); |
|
191 else |
|
192 iConsole->Printf(_L(" Success\n")); |
|
193 #endif |
|
194 |
|
195 // load up the drivers |
|
196 iConsole->Printf(_L("Loading SIR PDD...\n")); |
|
197 ret=User::LoadPhysicalDevice(PDD_NAME); |
|
198 if (ret!=KErrNone && ret!=KErrAlreadyExists) |
|
199 iConsole->Printf(_L(" Failed %d\n"), ret); |
|
200 else |
|
201 iConsole->Printf(_L(" Success\n")); |
|
202 |
|
203 iConsole->Printf(_L("Loading SIR LDD...\n")); |
|
204 ret=User::LoadLogicalDevice(LDD_NAME); |
|
205 if (ret!=KErrNone && ret!=KErrAlreadyExists) |
|
206 iConsole->Printf(_L(" Failed %d\n"), ret); |
|
207 else |
|
208 iConsole->Printf(_L(" Success\n")); |
|
209 #ifdef __EPOC32__ |
|
210 iConsole->Printf(_L("Loading Fast IR PDD\n")); |
|
211 |
|
212 ret=User::LoadPhysicalDevice(FIR_PDD_NAME); |
|
213 if (ret!=KErrNone && ret!=KErrAlreadyExists) |
|
214 iConsole->Printf(_L(" Failed %d\n"), ret); |
|
215 else |
|
216 iConsole->Printf(_L(" Success\n")); |
|
217 |
|
218 iConsole->Printf(_L("Loading Fast IR LDD\n")); |
|
219 ret=User::LoadLogicalDevice(FIR_LDD_NAME); |
|
220 if (ret!=KErrNone && ret!=KErrAlreadyExists) |
|
221 iConsole->Printf(_L(" Failed %d\n"), ret); |
|
222 else |
|
223 iConsole->Printf(_L(" Success\n")); |
|
224 #endif |
|
225 |
|
226 |
|
227 } |
|
228 |
|
229 |
|
230 void CControllerConsoleTest::RunL() |
|
231 { |
|
232 |
|
233 TInt key = iConsole->KeyCode(); |
|
234 switch (key) |
|
235 { |
|
236 case '1': |
|
237 { |
|
238 iTest = CTestObexErrorCodesClient::NewL(this); |
|
239 IssueRequest(); //back to main menu |
|
240 } |
|
241 break; |
|
242 case '2': |
|
243 { |
|
244 iTest = CTestObexErrorCodesServer::NewL(this); |
|
245 IssueRequest(); //back to main menu |
|
246 } |
|
247 break; |
|
248 case '3': |
|
249 { |
|
250 if ( !iStarted ) |
|
251 StartTest(); |
|
252 else |
|
253 iConsole->Printf(_L("Already Started\n")); |
|
254 |
|
255 IssueRequest(); //back to main menu |
|
256 |
|
257 } |
|
258 break; |
|
259 case '4': |
|
260 { |
|
261 if ( iStarted ) |
|
262 StopTest(); |
|
263 else |
|
264 iConsole->Printf(_L("Not started yet\n")); |
|
265 |
|
266 IssueRequest(); //back to main menu |
|
267 } |
|
268 break; |
|
269 default: |
|
270 CActiveScheduler::Stop(); |
|
271 break; |
|
272 } |
|
273 |
|
274 } |
|
275 |
|
276 |
|
277 CControllerConsoleTest* CControllerConsoleTest::NewL(CControllerTestMasterClass* aOwner) |
|
278 { |
|
279 CControllerConsoleTest* self = NewLC(aOwner); |
|
280 CleanupStack::Pop(); |
|
281 return self; |
|
282 } |
|
283 |
|
284 CControllerConsoleTest* CControllerConsoleTest::NewLC(CControllerTestMasterClass* aOwner) |
|
285 { |
|
286 CControllerConsoleTest* self=new (ELeave) CControllerConsoleTest; |
|
287 CleanupStack::PushL(self); |
|
288 self->ConstructL(aOwner); |
|
289 return self; |
|
290 |
|
291 } |
|
292 |
|
293 CControllerConsoleTest::CControllerConsoleTest() |
|
294 : CActive(CActive::EPriorityStandard) |
|
295 { |
|
296 } |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 CBaseErrorCodeTest* CBaseErrorCodeTest::NewL(CControllerConsoleTest* aOwner) |
|
303 { |
|
304 CBaseErrorCodeTest* self = new(ELeave) CBaseErrorCodeTest; |
|
305 CleanupStack::PushL(self); |
|
306 self->ConstructL(aOwner); |
|
307 CleanupStack::Pop( self ); |
|
308 return self; |
|
309 } |
|
310 |
|
311 CBaseErrorCodeTest::~CBaseErrorCodeTest() |
|
312 { |
|
313 delete iObject; |
|
314 delete iBuf; |
|
315 iLibrary.Close(); |
|
316 } |
|
317 |
|
318 |
|
319 CBaseErrorCodeTest::CBaseErrorCodeTest() |
|
320 { |
|
321 } |
|
322 |
|
323 void CBaseErrorCodeTest::ConstructL(CControllerConsoleTest* aOwner) |
|
324 { |
|
325 iOwner = aOwner; |
|
326 |
|
327 iOwner->iConsole->Printf(_L("About to load the IRObex DLL...\n")); |
|
328 |
|
329 |
|
330 TRAPD(ret,LoadObexL()); // Load Protocol |
|
331 if (ret!=KErrNone) |
|
332 iOwner->iConsole->Printf(_L("Error %d on loading IrObex DLL\r\n"),ret); |
|
333 else |
|
334 iOwner->iConsole->Printf(_L("Successfully loaded IrObex DLL\r\n")); |
|
335 } |
|
336 |
|
337 void CBaseErrorCodeTest::LoadObexL() |
|
338 { |
|
339 User::LeaveIfError(iLibrary.Load(_L("IROBEX.DLL"))); |
|
340 } |
|
341 |
|
342 void CBaseErrorCodeTest::Start() |
|
343 { |
|
344 } |
|
345 |
|
346 void CBaseErrorCodeTest::Stop() |
|
347 { |
|
348 } |