|
1 /* |
|
2 * Copyright (c) 2006 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: XIMP Framewor Test code prfwtestmessenger.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPRFWTESTMESSENGER_H |
|
20 #define CPRFWTESTMESSENGER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32def.h> |
|
24 #include <e32base.h> |
|
25 #include <e32property.h> |
|
26 #include "prfwtestmessaging.h" |
|
27 |
|
28 // CLASS DESCRIPTION |
|
29 |
|
30 class TXIMPTestMsg; |
|
31 class MXIMPRestrictedObjectCollection; |
|
32 |
|
33 /** |
|
34 * Asynchronous protocol for PRFW testing. |
|
35 * Implementation class and helper routines. |
|
36 * Done using Publish and Subscribe, although it's used as a collection of |
|
37 * "flags". |
|
38 * |
|
39 * RMsgQueue is not good, because we do not know the length of the array in |
|
40 * advance: there is often 1 in the array, but there could be 2 or 3 or more. |
|
41 * Each time someone writes, the array should be read. This becomes a bit |
|
42 * problematic, an easier and more robust way is to use pubsub. |
|
43 * |
|
44 * The descriptions of API methods rely on the protocol implementation, thus |
|
45 * the descriptions are meant to document what kind of effects the clients and |
|
46 * users of this class expect this class to cause. |
|
47 */ |
|
48 class CXIMPTestMessenger : public CBase |
|
49 { |
|
50 public: |
|
51 |
|
52 /** |
|
53 * @param aMsgQName The name for the queue |
|
54 */ |
|
55 IMPORT_C static CXIMPTestMessenger* NewForClientSideL( TInt aId ); |
|
56 IMPORT_C static CXIMPTestMessenger* NewForAdaptationSideL( TInt aId ); |
|
57 ~CXIMPTestMessenger(); |
|
58 |
|
59 private: |
|
60 |
|
61 CXIMPTestMessenger( TInt aId ); |
|
62 |
|
63 void ConstructL(); |
|
64 |
|
65 public: |
|
66 |
|
67 /** |
|
68 * Define and reset pubsub keys. |
|
69 */ |
|
70 IMPORT_C void ResetPubSub(); |
|
71 |
|
72 /** |
|
73 * Delete all pubsub keys. |
|
74 */ |
|
75 IMPORT_C void DeletePubSubKeys(); |
|
76 |
|
77 /** |
|
78 * Set index for plugin. Call before Bind-operation. |
|
79 * Default of KErrNotFound (-1) will set the key to |
|
80 * unused. |
|
81 */ |
|
82 IMPORT_C void SetPluginIndex( TInt aIndex = KErrNotFound ); |
|
83 |
|
84 /** |
|
85 * Get index for plugin. |
|
86 * @return Plugin index, or KErrNotFound if not found. |
|
87 */ |
|
88 IMPORT_C static TInt GetPluginIndex(); |
|
89 |
|
90 /** |
|
91 * Clears the error behavior. |
|
92 */ |
|
93 IMPORT_C void SetNoError(); |
|
94 |
|
95 /** |
|
96 * Setup for general error. Next operation will fail with this error |
|
97 * code. |
|
98 * @param aErrorCode The error code e.g. KErrNotFound |
|
99 */ |
|
100 IMPORT_C void SetError( TInt aErrorCode ); |
|
101 |
|
102 /** |
|
103 * @return The currently set error code. |
|
104 */ |
|
105 IMPORT_C TInt GetError(); |
|
106 |
|
107 /** |
|
108 * Setup a specialized error which has a boolean value. |
|
109 * Next operation will do the given specialized error, e.g. complete request |
|
110 * with invalid request id (EXIMPTestPlgBehaveInvalidReqId) |
|
111 * @param aKey The type defining the error, e.g. EXIMPTestPlgBehaveInvalidReqId |
|
112 */ |
|
113 IMPORT_C void SetBoolean( TXIMPTestPropertyKeys aKey ); |
|
114 |
|
115 /** |
|
116 * @param aKey The type defining the error, e.g. EXIMPTestPlgBehaveInvalidReqId |
|
117 * @return The value of the boolean-valued specialized error |
|
118 */ |
|
119 IMPORT_C TBool GetBoolean( TXIMPTestPropertyKeys aKey ) const; |
|
120 |
|
121 /** |
|
122 * Setup for leave. Next operation will leave with given leave code. |
|
123 * @param aLeaveCode Code with which to leave |
|
124 */ |
|
125 IMPORT_C void SetLeave( TInt aLeaveCode ); |
|
126 |
|
127 /** |
|
128 * @return The currently set leave code |
|
129 */ |
|
130 IMPORT_C TInt GetLeave(); |
|
131 |
|
132 /** |
|
133 * Leaves if leave has been requested. Uses value obtained from pubsub. |
|
134 */ |
|
135 IMPORT_C void HandleLeaveL(); |
|
136 |
|
137 /** |
|
138 * General messaging support for direct access. |
|
139 * @param aKey The key to set |
|
140 * @param aValue The value to set to given key |
|
141 */ |
|
142 IMPORT_C void SetValueFor( TXIMPTestPropertyKeys aKey, TInt aValue ); |
|
143 |
|
144 /** |
|
145 * General messaging support for direct access. |
|
146 * @param aKey The key to set |
|
147 * @return The value in the given key |
|
148 */ |
|
149 IMPORT_C TInt GetValueFor( TXIMPTestPropertyKeys aKey ) const; |
|
150 |
|
151 /** |
|
152 * Assert-methods. |
|
153 * @param aState ETrue, if successful case is expected. |
|
154 * |
|
155 * E.g. in the case of AssertPluginDied, |
|
156 * ETrue means: |
|
157 * "I expect the plugin to have died, check that it did" |
|
158 * and EFalse means: |
|
159 * "I expect the plugin to NOT have died, check that it didn't". |
|
160 */ |
|
161 IMPORT_C void AssertPluginDied( TBool aState ); |
|
162 IMPORT_C void AssertOpenSessionCalled( TBool aState ); |
|
163 IMPORT_C void AssertCloseSessionCalled( TBool aState ); |
|
164 IMPORT_C void AssertShareSessionCalled( TBool aState ); |
|
165 IMPORT_C void AssertUnshareSessionCalled( TBool aState ); |
|
166 IMPORT_C void AssertSubscribePresentityGroupContentCalled( TBool aState ); |
|
167 IMPORT_C void AssertSubscribePresentityGroupListCalled( TBool aState ); |
|
168 IMPORT_C void AssertUnsubscribePresentityGroupContentCalled( TBool aState ); |
|
169 IMPORT_C void AssertUnsubscribePresentityGroupListCalled( TBool aState ); |
|
170 IMPORT_C void AssertAddPresentityGroupMemberCalled( TBool aState ); |
|
171 IMPORT_C void AssertCreatePresentityGroupCalled( TBool aState ); |
|
172 IMPORT_C void AssertRemovePresentityGroupMemberCalled( TBool aState ); |
|
173 IMPORT_C void AssertUpdatePresentityGroupMemberDisplayNameCalled( TBool aState ); |
|
174 IMPORT_C void AssertUpdatePresentityGroupDisplayNameCalled( TBool aState ); |
|
175 |
|
176 IMPORT_C void SetReqCompleteParams( MXIMPRestrictedObjectCollection* aParams ); |
|
177 IMPORT_C MXIMPRestrictedObjectCollection* GetReqCompleteParams(); |
|
178 |
|
179 private: |
|
180 |
|
181 /** |
|
182 * Send the given message. |
|
183 * @param aMessage The message to send with the key and value fields set |
|
184 */ |
|
185 void Send( TXIMPTestMsg& aMsg ); |
|
186 |
|
187 /** |
|
188 * Receive message. |
|
189 * Returns the message with the value field set, using the same |
|
190 * message parameter which was given as input. |
|
191 * @param aMsg [inout] The message with the key field set |
|
192 */ |
|
193 void Receive( TXIMPTestMsg& aMsg ) const; |
|
194 |
|
195 /** |
|
196 * Common internal assert method for all Assert* methods. |
|
197 * @param aKey The key to assert |
|
198 * @param aCompareState The expected state (ETrue for success) |
|
199 * @param aTrueDesc Description for success case failing |
|
200 * @param aFalseDesc Description for failure case failing |
|
201 */ |
|
202 IMPORT_C void CommonAssert( TXIMPTestPropertyKeys aKey, |
|
203 TBool aCompareState, |
|
204 const TDesC8& aTrueDesc, |
|
205 const TDesC8& aFalseDesc ) const; |
|
206 private: |
|
207 |
|
208 // id number for this message queue |
|
209 TInt iId; |
|
210 TUid iMyUid; |
|
211 |
|
212 //OWN: Description buffer to hold the failure description |
|
213 mutable RBuf8 iDescription; |
|
214 |
|
215 // Params for next reqcomplete |
|
216 MXIMPRestrictedObjectCollection* iReqCompleteParams; |
|
217 }; |
|
218 |
|
219 #endif // CPRFWTESTMESSENGER_H |
|
220 |
|
221 |