1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
25 // - Send integer message arguments from client and test that the server receives the |
25 // - Send integer message arguments from client and test that the server receives the |
26 // same integers. |
26 // same integers. |
27 // - Send pointers as message arguments from client and test that the server receives the |
27 // - Send pointers as message arguments from client and test that the server receives the |
28 // same pointers. |
28 // same pointers. |
29 // - Test Client() method of RMessage2 and verify it opened a handle to the client thread |
29 // - Test Client() method of RMessage2 and verify it opened a handle to the client thread |
|
30 // - Test ClientProcessFlags() method of RMessagePtr2 and verify it matches to a known flag |
|
31 // - Test ClientIsRealtime() method of RMessagePtr2 and check that it isn't true |
30 // - Complete several messages using RMessage2::Complete and verify the client gets the |
32 // - Complete several messages using RMessage2::Complete and verify the client gets the |
31 // error codes back correctly. |
33 // error codes back correctly. |
32 // - Complete several messages using RMessagePtr2::Complete and verify the client gets the |
34 // - Complete several messages using RMessagePtr2::Complete and verify the client gets the |
33 // error codes back correctly. |
35 // error codes back correctly. |
34 // - Check RMessage construction from RMessagePtr2 is successful. |
36 // - Check RMessage construction from RMessagePtr2 is successful. |
64 IMPORT_C CTestServer(TInt aPriority); |
67 IMPORT_C CTestServer(TInt aPriority); |
65 enum TPanicType{ |
68 enum TPanicType{ |
66 EInt0Error=1, EInt1Error, EInt2Error, EInt3Error, |
69 EInt0Error=1, EInt1Error, EInt2Error, EInt3Error, |
67 EPtr0Error, EPtr1Error, EPtr2Error, EPtr3Error, |
70 EPtr0Error, EPtr1Error, EPtr2Error, EPtr3Error, |
68 ECreateNameError, ENewSessionError, |
71 ECreateNameError, ENewSessionError, |
69 EClientError |
72 EClientError, EClientProcessFlagsError, |
|
73 EClientIsRealtimeError |
70 }; |
74 }; |
71 static void Panic(TPanicType aReason); |
75 static void Panic(TPanicType aReason); |
72 protected: |
76 protected: |
73 //override the pure virtual functions: |
77 //override the pure virtual functions: |
74 IMPORT_C virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; |
78 IMPORT_C virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; |
76 |
80 |
77 |
81 |
78 class CTestSession : public CSession2 |
82 class CTestSession : public CSession2 |
79 { |
83 { |
80 public: |
84 public: |
81 enum {EStop,ETestInt,ETestPtr,ETestClient,ETestComplete,ETestPtrComplete,ETestCompletePanic,ETestOtherSession,ETestCompleteAfter,ETestMessageConstruction, |
85 enum {EStop,ETestInt,ETestPtr,ETestClient,ETestClientProcessFlags,ETestClientIsRealtime,ETestComplete,ETestPtrComplete,ETestCompletePanic,ETestOtherSession,ETestCompleteAfter,ETestMessageConstruction, |
82 ETestRMessagePtr2LeavingInterface, ETestKillCompletePanic}; |
86 ETestRMessagePtr2LeavingInterface, ETestKillCompletePanic}; |
83 //Override pure virtual |
87 //Override pure virtual |
84 IMPORT_C virtual void ServiceL(const RMessage2& aMessage); |
88 IMPORT_C virtual void ServiceL(const RMessage2& aMessage); |
85 private: |
89 private: |
86 void TestInt(const RMessage2& aMessage); |
90 void TestInt(const RMessage2& aMessage); |
87 void TestPtr(const RMessage2& aMessage); |
91 void TestPtr(const RMessage2& aMessage); |
88 void TestClient(const RMessage2& aMessage); |
92 void TestClient(const RMessage2& aMessage); |
|
93 void TestClientProcessFlags(const RMessage2& aMessage); |
|
94 void TestClientIsRealtime(const RMessage2& aMessage); |
89 void TestComplete(const RMessage2& aMessage); |
95 void TestComplete(const RMessage2& aMessage); |
90 void TestPtrComplete(const RMessage2& aMessage); |
96 void TestPtrComplete(const RMessage2& aMessage); |
91 void TestCompletePanic(); |
97 void TestCompletePanic(); |
92 TInt TestMessageConstruction(const RMessage2& aMessage); |
98 TInt TestMessageConstruction(const RMessage2& aMessage); |
93 TInt TestRMessagePtr2LeavingInterface(const RMessage2& aMessage); |
99 TInt TestRMessagePtr2LeavingInterface(const RMessage2& aMessage); |
210 CTestServer::Panic(CTestServer::EClientError); |
216 CTestServer::Panic(CTestServer::EClientError); |
211 } |
217 } |
212 t.Close(); |
218 t.Close(); |
213 } |
219 } |
214 |
220 |
|
221 |
|
222 void CTestSession::TestClientProcessFlags(const RMessage2& aMessage) |
|
223 // |
|
224 // Tests ClientProcessFlags() |
|
225 // |
|
226 { |
|
227 TBool justInTime=User::JustInTime(); |
|
228 TUint flags=aMessage.ClientProcessFlags(); |
|
229 |
|
230 if ((flags&KProcessFlagJustInTime) && justInTime) |
|
231 { |
|
232 return; //OK |
|
233 } |
|
234 else if ((flags&KProcessFlagJustInTime) || justInTime) |
|
235 { |
|
236 //mismatch |
|
237 clientThread.Kill(0); |
|
238 CTestServer::Panic(CTestServer::EClientProcessFlagsError); |
|
239 } |
|
240 } |
|
241 |
|
242 void CTestSession::TestClientIsRealtime(const RMessage2& aMessage) |
|
243 // |
|
244 // Tests ClientIsRealtime() |
|
245 // |
|
246 { |
|
247 if(aMessage.ClientIsRealtime()) |
|
248 { |
|
249 clientThread.Kill(0); |
|
250 CTestServer::Panic(CTestServer::EClientIsRealtimeError); |
|
251 } |
|
252 } |
|
253 |
|
254 |
215 void CTestSession::TestComplete(const RMessage2& aMessage) |
255 void CTestSession::TestComplete(const RMessage2& aMessage) |
216 // |
256 // |
217 // Stores messages up then Completes in reverse order |
257 // Stores messages up then Completes in reverse order |
218 // |
258 // |
219 { |
259 { |
302 TestPtr(aMessage); |
342 TestPtr(aMessage); |
303 break; |
343 break; |
304 case ETestClient: |
344 case ETestClient: |
305 TestClient(aMessage); |
345 TestClient(aMessage); |
306 break; |
346 break; |
|
347 case ETestClientProcessFlags: |
|
348 TestClientProcessFlags(aMessage); |
|
349 break; |
|
350 case ETestClientIsRealtime: |
|
351 TestClientIsRealtime(aMessage); |
|
352 break; |
307 case ETestComplete: |
353 case ETestComplete: |
308 TestComplete(aMessage); |
354 TestComplete(aMessage); |
309 return; |
355 return; |
310 case ETestPtrComplete: |
356 case ETestPtrComplete: |
311 TestPtrComplete(aMessage); |
357 TestPtrComplete(aMessage); |
373 r=session.PublicSendReceive(CTestSession::ETestPtr, TIpcArgs(&clientThread, &serverThread, &session, &sem)); |
419 r=session.PublicSendReceive(CTestSession::ETestPtr, TIpcArgs(&clientThread, &serverThread, &session, &sem)); |
374 test(r==KErrNone); |
420 test(r==KErrNone); |
375 |
421 |
376 test.Next(_L("Signal to test Client()")); |
422 test.Next(_L("Signal to test Client()")); |
377 r=session.PublicSendReceive(CTestSession::ETestClient, TIpcArgs()); |
423 r=session.PublicSendReceive(CTestSession::ETestClient, TIpcArgs()); |
|
424 test(r==KErrNone); |
|
425 |
|
426 test.Next(_L("Signal to test ClientProcessFlags()")); |
|
427 r=session.PublicSendReceive(CTestSession::ETestClientProcessFlags, TIpcArgs()); |
|
428 test(r==KErrNone); |
|
429 |
|
430 test.Next(_L("Signal to test ClientIsRealtime()")); |
|
431 r=session.PublicSendReceive(CTestSession::ETestClientIsRealtime, TIpcArgs()); |
378 test(r==KErrNone); |
432 test(r==KErrNone); |
379 |
433 |
380 test.Next(_L("Test RMessage2::Complete()")); |
434 test.Next(_L("Test RMessage2::Complete()")); |
381 TRequestStatus stat[7]; |
435 TRequestStatus stat[7]; |
382 for (r=0;r<4;r++) |
436 for (r=0;r<4;r++) |