|
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 <e32base.h> |
|
17 #include "rmocksy.h" |
|
18 |
|
19 /** |
|
20 Conect to the server |
|
21 */ |
|
22 EXPORT_C TInt RMockSY::Connect() |
|
23 { |
|
24 return CreateSession(ServerName(),TVersion(1,0,0)); |
|
25 } |
|
26 |
|
27 /** |
|
28 Notify when mockSY is done handling queued call and completion, either because |
|
29 it handled all posted messages or because there was an error |
|
30 |
|
31 @param aStatus |
|
32 */ |
|
33 EXPORT_C void RMockSY::NotifyTerminated(TRequestStatus& aStatus) |
|
34 { |
|
35 SendReceive(KNotifyTerminated,aStatus); |
|
36 } |
|
37 |
|
38 /** |
|
39 Get the next line of the rotating log |
|
40 |
|
41 @param aLine Empty if there is no more line |
|
42 */ |
|
43 EXPORT_C void RMockSY::GetNextLogLine(TDes& aLine) |
|
44 { |
|
45 TInt err=SendReceive(KGetNextLogLine,TIpcArgs(&aLine)); |
|
46 ASSERT(err == KErrNone); // just fail if we run out of mem there is not a lot to do in this case |
|
47 } |
|
48 |
|
49 |
|
50 /** |
|
51 Get MockSY status |
|
52 |
|
53 @param aPendingEvents number of waiting/pending events |
|
54 @param aError true if there was an error |
|
55 */ |
|
56 EXPORT_C void RMockSY::GetStatus(TBool& aHasWaitingExpect, TBool& aHasPendingComplete, TBool& aHasError) |
|
57 { |
|
58 TPckg<TBool> hasWaitingExpectPckg(aHasWaitingExpect); |
|
59 TPckg<TBool> hasPendingComplete(aHasPendingComplete); |
|
60 TPckg<TBool> hasErrorPckg(aHasError); |
|
61 TInt err=SendReceive(KGetStatus,TIpcArgs(&hasWaitingExpectPckg,&hasPendingComplete,&hasErrorPckg)); |
|
62 ASSERT(err == KErrNone); // just fail if we run out of mem there is not a lot to do in this case |
|
63 } |
|
64 |
|
65 /** |
|
66 Set the next command SY is expected to receive. |
|
67 param |
|
68 @param aCmdId |
|
69 @param aErrorCode |
|
70 @param aLeave |
|
71 @param aData |
|
72 */ |
|
73 EXPORT_C void RMockSY::DoExpect(TInt aCmdId, TInt aErrorCode, TBool aLeave, const TDesC8& aData) |
|
74 { |
|
75 TInt err=SendReceive(KExpect,TIpcArgs(aCmdId,aErrorCode,aLeave,&aData)); |
|
76 ASSERT(err == KErrNone); // just fail if we run out of mem there is not a lot to do in this case |
|
77 } |
|
78 |
|
79 /** |
|
80 Queue completion to send after the next expected message |
|
81 |
|
82 @param aCmdId |
|
83 @param aErrorCode |
|
84 @param aDelay |
|
85 @param aData |
|
86 */ |
|
87 EXPORT_C void RMockSY::DoComplete(TInt aCmdId, TInt aErrorCode, TInt aDelay, const TDesC8& aData) |
|
88 { |
|
89 TInt err=SendReceive(KComplete,TIpcArgs(aCmdId,aErrorCode,aDelay,&aData)); |
|
90 ASSERT(err == KErrNone); // just fail if we run out of mem there is not a lot to do in this case |
|
91 } |
|
92 |
|
93 /** |
|
94 Pause MockSY from sending completion till a resume is send. |
|
95 Use this when you want to make sure that the Mock will not complete anything until you had time to |
|
96 tell the mock what to expect. |
|
97 |
|
98 */ |
|
99 EXPORT_C TInt RMockSY::PauseCompletion() |
|
100 { |
|
101 return Send(KPause); |
|
102 } |
|
103 |
|
104 /** |
|
105 Resume MockSY completion sending. Use this after you finished telling the mock |
|
106 what to expect, in order to start completing again. |
|
107 |
|
108 */ |
|
109 EXPORT_C TInt RMockSY::ResumeCompletion() |
|
110 { |
|
111 return Send(KResume); |
|
112 } |
|
113 |