|
1 // Copyright (c) 2007-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 "TE_EtelBase.h" |
|
17 #include "te_etelsetpriorityclient.h" |
|
18 |
|
19 CTestSetPrClientCapNsidPosCheck::CTestSetPrClientCapNsidPosCheck() |
|
20 /** Each test step initialises it's own name |
|
21 */ |
|
22 { |
|
23 SetTestStepName(_L("TestSetPrClientCapNsidPosCheck")); |
|
24 } |
|
25 |
|
26 enum TVerdict CTestSetPrClientCapNsidPosCheck::doTestStepL() |
|
27 // |
|
28 // Test connecting Positive check of Capability and SID check for SetPriorityClient API |
|
29 // |
|
30 { |
|
31 INFO_PRINTF1(_L("Test connecting Capability and SID check for SetPriorityClient API")); |
|
32 RTelServer first; |
|
33 TInt ret=first.Connect(); |
|
34 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
35 TESTCHECK(ret, KErrNone); |
|
36 INFO_PRINTF1(_L("Capability and SID check of setpriorityclient API")); |
|
37 ret=first.SetPriorityClient(); |
|
38 TESTCHECK(ret,KErrNone); |
|
39 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClient %d."),ret); |
|
40 return TestStepResult(); |
|
41 } |
|
42 |
|
43 CTestSetPrClientCapNsidNegCheck::CTestSetPrClientCapNsidNegCheck() |
|
44 /** Each test step initialises it's own name |
|
45 */ |
|
46 { |
|
47 SetTestStepName(_L("TestSetPrClientCapNsidNegCheck")); |
|
48 } |
|
49 |
|
50 enum TVerdict CTestSetPrClientCapNsidNegCheck::doTestStepL() |
|
51 // |
|
52 // Test connecting Negative check of Capability and SID check for SetPriorityClient API |
|
53 // |
|
54 { |
|
55 INFO_PRINTF1(_L("Test connecting Capability and SID check for SetPriorityClient API")); |
|
56 RTelServer first; |
|
57 TInt ret=first.Connect(); |
|
58 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
59 TESTCHECK(ret, KErrNone); |
|
60 INFO_PRINTF1(_L("Capability and SID check of setpriorityclient API")); |
|
61 ret=first.SetPriorityClient(); |
|
62 TESTCHECK(ret,KErrPermissionDenied); |
|
63 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClient %d."),ret); |
|
64 return TestStepResult(); |
|
65 } |
|
66 |
|
67 CTestSetPrClientMulCallFrSameSes::CTestSetPrClientMulCallFrSameSes() |
|
68 /** Each test step initialises it's own name |
|
69 */ |
|
70 { |
|
71 SetTestStepName(_L("TestSetPrClientMulCallFrSameSes")); |
|
72 } |
|
73 |
|
74 enum TVerdict CTestSetPrClientMulCallFrSameSes::doTestStepL() |
|
75 // |
|
76 // Test connecting Multiple call of setpriorityclient API from the same session |
|
77 // |
|
78 { |
|
79 INFO_PRINTF1(_L("Test connecting ultiple call of setpriorityclient API from the same session")); |
|
80 RTelServer first; |
|
81 TInt ret=first.Connect(); |
|
82 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
83 TESTCHECK(ret, KErrNone); |
|
84 INFO_PRINTF1(_L("Multiple call of setpriorityclient API on the same session")); |
|
85 ret=first.SetPriorityClient(); |
|
86 TESTCHECK(ret, KErrNone); |
|
87 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClient in same session %d."),ret); |
|
88 ret=first.SetPriorityClient(); |
|
89 TESTCHECK(ret, KErrAlreadyExists); |
|
90 INFO_PRINTF2(_L("Second call of RTelServer::SetPriorityClient in same session %d."),ret); |
|
91 first.Close(); |
|
92 |
|
93 return TestStepResult(); |
|
94 } |
|
95 // |
|
96 CTestSetPrClientMulCallFrDiffSubSes::CTestSetPrClientMulCallFrDiffSubSes() |
|
97 /** Each test step initialises it's own name |
|
98 */ |
|
99 { |
|
100 SetTestStepName(_L("TestSetPrClientMulCallFrDiffSubSes")); |
|
101 } |
|
102 |
|
103 enum TVerdict CTestSetPrClientMulCallFrDiffSubSes::doTestStepL() |
|
104 // |
|
105 // Test connecting Multiple call of setpriorityclient API from the different sub session |
|
106 // |
|
107 { |
|
108 INFO_PRINTF1(_L("Test connecting Multiple call of setpriorityclient API on the different sub session")); |
|
109 RTelServer first; |
|
110 TInt ret=first.Connect(); |
|
111 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
112 TESTCHECK(ret, KErrNone); |
|
113 RTelServer second; |
|
114 ret=second.Connect(); |
|
115 INFO_PRINTF2(_L("RTelServer::Connect (second) returned %d."),ret); |
|
116 INFO_PRINTF1(_L("Multiple call of setpriorityclient API on the different session")); |
|
117 ret=first.SetPriorityClient(); |
|
118 TESTCHECK(ret, KErrNone); |
|
119 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClient in different session %d."),ret); |
|
120 ret=second.SetPriorityClient(); |
|
121 TESTCHECK(ret, KErrAlreadyExists); |
|
122 INFO_PRINTF2(_L("second call of RTelServer::SetPriorityClient in different session %d."),ret); |
|
123 second.Close(); |
|
124 first.Close(); |
|
125 |
|
126 return TestStepResult(); |
|
127 } |
|
128 // |
|
129 CTestSetPrClientMulCallFrDiffClt::CTestSetPrClientMulCallFrDiffClt() |
|
130 /** Each test step initialises it's own name |
|
131 */ |
|
132 { |
|
133 SetTestStepName(_L("TestSetPrClientMulCallFrDiffClt")); |
|
134 } |
|
135 |
|
136 TInt CTestSetPrClientMulCallFrDiffClt ::FirstThreadFunctiona(TAny* aThreadData1) |
|
137 { |
|
138 RTelServer server; |
|
139 CTestStep* testStep = static_cast<CTestStep*>(aThreadData1); |
|
140 CTrapCleanup* cleanup; |
|
141 if ((cleanup=CTrapCleanup::New())==NULL) |
|
142 { |
|
143 return KErrGeneral; |
|
144 } |
|
145 TInt ret = server.Connect(); |
|
146 testStep->TEST1(ret==KErrNone,ETrue); |
|
147 testStep->INFO_PRINTF2(_L("Thread1 RTelServer::Connect returned %d."),ret); |
|
148 ret=server.SetPriorityClient(); |
|
149 testStep->TEST1((ret == KErrNone) || (ret == KErrAlreadyExists), ETrue); |
|
150 testStep->INFO_PRINTF2(_L("Thread1 RTelServer::SetPriorityClient returned %d."),ret); |
|
151 User::After(KETelThreadShutdownGuardPeriod); |
|
152 server.Close(); |
|
153 delete cleanup; |
|
154 return ret; |
|
155 } |
|
156 |
|
157 TInt CTestSetPrClientMulCallFrDiffClt ::SecondThreadFunctiona(TAny* aThreadData2) |
|
158 { |
|
159 RTelServer server; |
|
160 CTestStep* testStep = static_cast<CTestStep*>(aThreadData2); |
|
161 CTrapCleanup* cleanup; |
|
162 if ((cleanup=CTrapCleanup::New())==NULL) |
|
163 { |
|
164 return KErrGeneral; |
|
165 } |
|
166 TInt ret = server.Connect(); |
|
167 testStep->TEST1(ret==KErrNone,ETrue); |
|
168 testStep->INFO_PRINTF2(_L("Thread2 RTelServer::Connect returned %d."),ret); |
|
169 ret=server.SetPriorityClient(); |
|
170 testStep->TEST1((ret == KErrNone) || (ret == KErrAlreadyExists),ETrue); |
|
171 testStep->INFO_PRINTF2(_L("Thread2 RTelServer::SetPriorityClient returned %d."),ret); |
|
172 server.Close(); |
|
173 delete cleanup; |
|
174 return ret; |
|
175 } |
|
176 |
|
177 enum TVerdict CTestSetPrClientMulCallFrDiffClt::doTestStepL() |
|
178 // |
|
179 // Test connecting Multiple call of setpriorityclient API from the different threads |
|
180 // |
|
181 { |
|
182 RThread thread1; |
|
183 RThread thread2; |
|
184 TRequestStatus reqStatus1; |
|
185 TRequestStatus reqStatus2; |
|
186 Logger().ShareAuto(); |
|
187 INFO_PRINTF1(_L("Test connecting Multiple call of setpriorityclient API from the different threads")); |
|
188 const TInt KStackSize=0x8000; |
|
189 const TInt KHeapSize=0x8000; |
|
190 const TInt KMaxHeapSize=0x80000; |
|
191 _LIT(KFirstThreadName,"FirstThread"); |
|
192 _LIT(KSecondThreadName,"SecondThread"); |
|
193 TInt res1=thread1.Create(KFirstThreadName, FirstThreadFunctiona,KStackSize,KHeapSize,KMaxHeapSize,(void*)this, EOwnerThread); |
|
194 TESTCHECK(res1, KErrNone); |
|
195 if(res1!=KErrNone) |
|
196 { |
|
197 ERR_PRINTF1(_L("CTestSetPrClientMulCallFrDiffClt:thread1.Create Failed to create a thread1")); |
|
198 SetTestStepResult(EFail); |
|
199 } |
|
200 thread1.Logon(reqStatus1); //Request 1 |
|
201 TInt resu1=(reqStatus1.Int(), KRequestPending); |
|
202 TInt res2=thread2.Create(KSecondThreadName,SecondThreadFunctiona,KStackSize,KHeapSize,KMaxHeapSize,(void*)this, EOwnerThread); |
|
203 TESTCHECK(res2, KErrNone); |
|
204 if(res2!=KErrNone) |
|
205 { |
|
206 ERR_PRINTF1(_L("CTestSetPrClientMulCallFrDiffClt:thread2.Create Failed to create a thread2")); |
|
207 SetTestStepResult(EFail); |
|
208 } |
|
209 thread2.Logon(reqStatus2); //Request 2 |
|
210 TInt resu2=(reqStatus2.Int(), KRequestPending); |
|
211 thread1.Resume(); |
|
212 thread2.Resume(); |
|
213 User::WaitForRequest(reqStatus1); |
|
214 User::WaitForRequest(reqStatus2); |
|
215 TEST( ((reqStatus1==KErrNone) && (reqStatus2==KErrAlreadyExists)) || |
|
216 ((reqStatus2==KErrNone) && (reqStatus1==KErrAlreadyExists))); |
|
217 if (thread1.ExitType() != EExitKill && thread1.ExitReason() != 0) |
|
218 { |
|
219 User::Leave(thread1.ExitReason()); |
|
220 }//end of if (iThread1.ExitType() != EExitKill && iThread1.ExitReason() != 0) |
|
221 thread1.Close(); |
|
222 INFO_PRINTF2(_L("First thread opened ETel session and returned %d"), res1); |
|
223 if (thread2.ExitType() != EExitKill && thread2.ExitReason() != 0) |
|
224 { |
|
225 User::Leave(thread2.ExitReason()); |
|
226 }//end of if (iThread2.ExitType() != EExitKill && iThread2.ExitReason() != 0) |
|
227 thread2.Close(); |
|
228 INFO_PRINTF2(_L("Second thread opened ETel session and returned %d"), res2); |
|
229 |
|
230 return TestStepResult(); |
|
231 } |
|
232 |
|
233 CTestSetPrClientV2CapNsidPosCheck::CTestSetPrClientV2CapNsidPosCheck() |
|
234 { |
|
235 SetTestStepName(_L("TestSetPrClientV2CapNsidPosCheck")); |
|
236 } |
|
237 |
|
238 enum TVerdict CTestSetPrClientV2CapNsidPosCheck::doTestStepL() |
|
239 // |
|
240 // Test connecting Positive check of Capability and SID check for SetPriorityClientV2 API |
|
241 // |
|
242 { |
|
243 INFO_PRINTF1(_L("Test connecting Capability and SID check for SetPriorityClientV2 API")); |
|
244 RTelServer first; |
|
245 TInt ret=first.Connect(); |
|
246 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
247 TESTCHECK(ret, KErrNone); |
|
248 INFO_PRINTF1(_L("Capability and SID check of setpriorityclientV2 API")); |
|
249 ret=first.SetPriorityClientV2(); |
|
250 TESTCHECK(ret,KErrNone); |
|
251 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClientV2 %d."),ret); |
|
252 return TestStepResult(); |
|
253 } |
|
254 |
|
255 CTestSetPrClientV2CapNsidNegCheck::CTestSetPrClientV2CapNsidNegCheck() |
|
256 { |
|
257 SetTestStepName(_L("TestSetPrClientV2CapNsidNegCheck")); |
|
258 } |
|
259 |
|
260 enum TVerdict CTestSetPrClientV2CapNsidNegCheck::doTestStepL() |
|
261 // |
|
262 // Test connecting Negative check of Capability and SID check for SetPriorityClientV2 API |
|
263 // |
|
264 { |
|
265 INFO_PRINTF1(_L("Test connecting Capability and SID check for SetPriorityClientV2 API")); |
|
266 RTelServer first; |
|
267 TInt ret=first.Connect(); |
|
268 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
269 TESTCHECK(ret, KErrNone); |
|
270 INFO_PRINTF1(_L("Capability and SID check of setpriorityclientV2 API")); |
|
271 ret=first.SetPriorityClientV2(); |
|
272 TESTCHECK(ret,KErrPermissionDenied); |
|
273 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClientV2 %d."),ret); |
|
274 return TestStepResult(); |
|
275 } |
|
276 |
|
277 |
|
278 CTestSetPrClientV2MulCallFrSameSes::CTestSetPrClientV2MulCallFrSameSes() |
|
279 { |
|
280 SetTestStepName(_L("TestSetPrClientV2MulCallFrDiffSubSes")); |
|
281 } |
|
282 |
|
283 enum TVerdict CTestSetPrClientV2MulCallFrSameSes::doTestStepL() |
|
284 // |
|
285 // Test connecting Multiple call of setpriorityclientV2 API from the same session |
|
286 // |
|
287 { |
|
288 INFO_PRINTF1(_L("Test connecting Multiple call of setpriorityclientV2 API from the same session")); |
|
289 RTelServer first; |
|
290 TInt ret=first.Connect(); |
|
291 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
292 TESTCHECK(ret, KErrNone); |
|
293 INFO_PRINTF1(_L("Multiple call of setpriorityclientV2 API on the same session")); |
|
294 ret=first.SetPriorityClientV2(); |
|
295 TESTCHECK(ret, KErrNone); |
|
296 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClientV2 in same session %d."),ret); |
|
297 ret=first.SetPriorityClientV2(); |
|
298 TESTCHECK(ret, KErrAlreadyExists); |
|
299 INFO_PRINTF2(_L("Second call of RTelServer::SetPriorityClientV2 in same session %d."),ret); |
|
300 first.Close(); |
|
301 |
|
302 return TestStepResult(); |
|
303 } |
|
304 |
|
305 CTestSetPrClientV2MulCallFrDiffSubSes::CTestSetPrClientV2MulCallFrDiffSubSes() |
|
306 { |
|
307 SetTestStepName(_L("TestSetPrClientV2MulCallFrDiffSubSes")); |
|
308 } |
|
309 |
|
310 enum TVerdict CTestSetPrClientV2MulCallFrDiffSubSes::doTestStepL() |
|
311 // |
|
312 // Test connecting Multiple call of setpriorityclientV2 API from the different sub session |
|
313 // |
|
314 { |
|
315 INFO_PRINTF1(_L("Test connecting Multiple call of setpriorityclientV2 API from the different sub session")); |
|
316 RTelServer first; |
|
317 TInt ret=first.Connect(); |
|
318 INFO_PRINTF2(_L("RTelServer::Connect returned %d."),ret); |
|
319 TESTCHECK(ret, KErrNone); |
|
320 RTelServer second; |
|
321 ret=second.Connect(); |
|
322 INFO_PRINTF2(_L("RTelServer::Connect (second) returned %d."),ret); |
|
323 INFO_PRINTF1(_L("Multiple call of setpriorityclientV2 API on the different session")); |
|
324 ret=first.SetPriorityClientV2(); |
|
325 TESTCHECK(ret, KErrNone); |
|
326 INFO_PRINTF2(_L("first call of RTelServer::SetPriorityClientV2 in different session %d."),ret); |
|
327 ret=second.SetPriorityClientV2(); |
|
328 TESTCHECK(ret, KErrAlreadyExists); |
|
329 INFO_PRINTF2(_L("second call of RTelServer::SetPriorityClientV2 in different session %d."),ret); |
|
330 second.Close(); |
|
331 first.Close(); |
|
332 return TestStepResult(); |
|
333 } |
|
334 |
|
335 CTestSetPrClientV2MulCallFrDiffClt::CTestSetPrClientV2MulCallFrDiffClt() |
|
336 { |
|
337 SetTestStepName(_L("TestSetPrClientV2MulCallFrDiffClt")); |
|
338 } |
|
339 |
|
340 TInt CTestSetPrClientV2MulCallFrDiffClt ::FirstThreadFunctiona(TAny* aThreadData1) |
|
341 { |
|
342 RTelServer server; |
|
343 CTestStep* testStep = static_cast<CTestStep*>(aThreadData1); |
|
344 CTrapCleanup* cleanup; |
|
345 if ((cleanup=CTrapCleanup::New())==NULL) |
|
346 { |
|
347 return KErrGeneral; |
|
348 } |
|
349 TInt ret = server.Connect(); |
|
350 testStep->TEST1(ret==KErrNone,ETrue); |
|
351 testStep->INFO_PRINTF2(_L("Thread1 RTelServer::Connect returned %d."),ret); |
|
352 ret=server.SetPriorityClientV2(); |
|
353 testStep->TEST1(( (ret==KErrAlreadyExists) || (ret==KErrNone) ),ETrue); |
|
354 testStep->INFO_PRINTF2(_L("Thread1 RTelServer::SetPriorityClientV2 returned %d."),ret); |
|
355 User::After(KETelThreadShutdownGuardPeriod); |
|
356 server.Close(); |
|
357 delete cleanup; |
|
358 return ret; |
|
359 } |
|
360 |
|
361 TInt CTestSetPrClientV2MulCallFrDiffClt ::SecondThreadFunctiona(TAny* aThreadData2) |
|
362 { |
|
363 RTelServer server; |
|
364 CTestStep* testStep = static_cast<CTestStep*>(aThreadData2); |
|
365 CTrapCleanup* cleanup; |
|
366 if ((cleanup=CTrapCleanup::New())==NULL) |
|
367 { |
|
368 return KErrGeneral; |
|
369 } |
|
370 TInt ret = server.Connect(); |
|
371 testStep->TEST1(ret==KErrNone,ETrue); |
|
372 testStep->INFO_PRINTF2(_L("Thread2 RTelServer::Connect returned %d."),ret); |
|
373 ret=server.SetPriorityClientV2(); |
|
374 testStep->TEST1(( (ret==KErrAlreadyExists) || (ret==KErrNone) ),ETrue); |
|
375 testStep->INFO_PRINTF2(_L("Thread2 RTelServer::SetPriorityClientV2 returned %d."),ret); |
|
376 User::After(KETelThreadShutdownGuardPeriod); |
|
377 server.Close(); |
|
378 delete cleanup; |
|
379 return ret; |
|
380 } |
|
381 |
|
382 enum TVerdict CTestSetPrClientV2MulCallFrDiffClt::doTestStepL() |
|
383 // |
|
384 // Test connecting Multiple call of setpriorityclientV2 API from the different threads |
|
385 // |
|
386 { |
|
387 RThread thread1; |
|
388 RThread thread2; |
|
389 TRequestStatus reqStatus1; |
|
390 TRequestStatus reqStatus2; |
|
391 Logger().ShareAuto(); |
|
392 INFO_PRINTF1(_L("Test connecting Multiple call of setpriorityclientV2 API from the different threads")); |
|
393 const TInt KStackSize=0x8000; |
|
394 const TInt KHeapSize=0x8000; |
|
395 const TInt KMaxHeapSize=0x80000; |
|
396 _LIT(KFirstThreadName,"FirstThread"); |
|
397 _LIT(KSecondThreadName,"SecondThread"); |
|
398 TInt res1=thread1.Create(KFirstThreadName, FirstThreadFunctiona,KStackSize,KHeapSize,KMaxHeapSize,(void*)this, EOwnerThread); |
|
399 TESTCHECK(res1, KErrNone); |
|
400 if(res1!=KErrNone) |
|
401 { |
|
402 ERR_PRINTF1(_L("CTestSetPriorityClientc:thread1.Create Failed to create a thread1")); |
|
403 SetTestStepResult(EFail); |
|
404 } |
|
405 thread1.Logon(reqStatus1); //Request 1 |
|
406 TInt resu1=(reqStatus1.Int(), KRequestPending); |
|
407 TInt res2=thread2.Create(KSecondThreadName,SecondThreadFunctiona,KStackSize,KHeapSize,KMaxHeapSize,(void*)this, EOwnerThread); |
|
408 TESTCHECK(res2, KErrNone); |
|
409 if(res2!=KErrNone) |
|
410 { |
|
411 ERR_PRINTF1(_L("CTestSetPriorityClientc:thread2.Create Failed to create a thread2")); |
|
412 SetTestStepResult(EFail); |
|
413 } |
|
414 thread2.Logon(reqStatus2); //Request 2 |
|
415 TInt resu2=(reqStatus2.Int(), KRequestPending); |
|
416 thread1.Resume(); |
|
417 User::After(1); |
|
418 thread2.Resume(); |
|
419 User::WaitForRequest(reqStatus1); |
|
420 User::WaitForRequest(reqStatus2); |
|
421 TEST( ((reqStatus1==KErrNone) && (reqStatus2==KErrAlreadyExists)) || |
|
422 ((reqStatus2==KErrNone) && (reqStatus1==KErrAlreadyExists))); |
|
423 if (thread1.ExitType() != EExitKill && thread1.ExitReason() != 0) |
|
424 { |
|
425 User::Leave(thread1.ExitReason()); |
|
426 }//end of if (iThread1.ExitType() != EExitKill && iThread1.ExitReason() != 0) |
|
427 thread1.Close(); |
|
428 INFO_PRINTF2(_L("First thread opened ETel session and returned %d"), res1); |
|
429 if (thread2.ExitType() != EExitKill && thread2.ExitReason() != 0) |
|
430 { |
|
431 User::Leave(thread2.ExitReason()); |
|
432 }//end of if (iThread2.ExitType() != EExitKill && iThread2.ExitReason() != 0) |
|
433 thread2.Close(); |
|
434 INFO_PRINTF2(_L("Second thread opened ETel session and returned %d"), res2); |
|
435 return TestStepResult(); |
|
436 } |