|
1 /* |
|
2 * Copyright (c) 2009 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: Header declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef __TESTHOSTLET_H__ |
|
24 #define __TESTHOSTLET_H__ |
|
25 |
|
26 // EXTERNAL INCLUDES |
|
27 #include "hostconnTester.h" |
|
28 #include <MSenProperties.h> |
|
29 |
|
30 // INTERNAL INCLUDES |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 class CHostletConnectionBCTest; |
|
34 |
|
35 class CTestHostlet : public CBase, public MSenHostlet |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Two phase construction |
|
41 */ |
|
42 static CTestHostlet* NewL(ChostconnTester* aTestSuite, |
|
43 TInt (*ap2ServiceL) (ChostconnTester*, MSenHostletRequest&, MSenHostletResponse&) = NULL, |
|
44 TInt (*ap2OnServiceCompleteL) (ChostconnTester*, const TInt, TInt, const TDesC8&) = NULL, |
|
45 void (*ap2DescribeServiceL) (CSenXmlServiceDescription&) = NULL); |
|
46 |
|
47 static CTestHostlet* NewLC(ChostconnTester* aTestSuite, |
|
48 TInt (*ap2ServiceL) (ChostconnTester*, MSenHostletRequest&, MSenHostletResponse&) = NULL, |
|
49 TInt (*ap2OnServiceCompleteL) (ChostconnTester*, const TInt, TInt, const TDesC8&) = NULL, |
|
50 void (*ap2DescribeServiceL) (CSenXmlServiceDescription&) = NULL); |
|
51 |
|
52 /** |
|
53 * Destructor |
|
54 */ |
|
55 ~CTestHostlet(); |
|
56 virtual void DescribeServiceL(CSenXmlServiceDescription& aSD); |
|
57 |
|
58 virtual TPtrC8 Contract() const; |
|
59 |
|
60 virtual TPtrC8 Endpoint() const; |
|
61 |
|
62 virtual TInt ServiceL(MSenHostletRequest& aRequest, MSenHostletResponse& aResponse); |
|
63 virtual void OnServiceCompleteL(const TInt aTxnId, TInt aCompletionCode, const TDesC8& aDesc); |
|
64 |
|
65 public: // Public data => OK in testers, no benefit gained from getters => in real apps, these should be private: |
|
66 CSenXmlServiceDescription* ipHostletDescription; |
|
67 RPointerArray<HBufC8> iRequests; |
|
68 RPointerArray<HBufC8> iResponses; |
|
69 RPointerArray<HBufC8> iRequestProps; |
|
70 RArray<MSenProperties::TSenPropertiesClassType> iRequestPropTypes; |
|
71 RPointerArray<CSenTransportProperties> iResponseProps; |
|
72 RArray<TInt> iResponseCodes; |
|
73 TInt iRespondRetCode; // direct retCode from RespondL (async) |
|
74 RArray<TInt> iCompletionCodes; // from OnServiceCompleteL => indicates how Respond operation was delivered |
|
75 RArray<TInt> iTxnIds; |
|
76 //MSenHostlet |
|
77 |
|
78 inline virtual TPtrC8 FrameworkId() const |
|
79 { |
|
80 return KDefaultRestServicesFrameworkID(); |
|
81 } |
|
82 //MSenHostletRequest |
|
83 inline virtual TPtrC8 RequestUtf8() const |
|
84 { |
|
85 return _L8(""); |
|
86 } |
|
87 inline virtual TPtrC ThreadId() const |
|
88 { |
|
89 return _L(""); |
|
90 } |
|
91 inline virtual TPtrC8 ConsumerId() const |
|
92 { |
|
93 return _L8(""); |
|
94 } |
|
95 inline virtual TInt RequestId() const |
|
96 { |
|
97 return KErrNone; |
|
98 } |
|
99 inline virtual TPtrC8 Properties(MSenProperties::TSenPropertiesClassType& aType) const |
|
100 { |
|
101 return _L8(""); |
|
102 } |
|
103 private: // Constructor |
|
104 CTestHostlet(ChostconnTester* aTestSuite, |
|
105 TInt (*ap2ServiceL) (ChostconnTester*, MSenHostletRequest&, MSenHostletResponse&), |
|
106 TInt (*ap2OnServiceCompleteL) (ChostconnTester*, const TInt, TInt, const TDesC8&), |
|
107 void (*ap2DescribeServiceL) (CSenXmlServiceDescription&)); |
|
108 void ConstructL(); |
|
109 |
|
110 private: // Data |
|
111 ChostconnTester* ipTestSuite; |
|
112 |
|
113 private: // Function pointers |
|
114 TInt (*ip2ServiceL) (ChostconnTester*, MSenHostletRequest&, MSenHostletResponse&); |
|
115 TInt (*ip2OnServiceCompleteL) (ChostconnTester*, const TInt, TInt, const TDesC8&); |
|
116 void (*ip2DescribeServiceL)(CSenXmlServiceDescription&); |
|
117 }; |
|
118 |
|
119 #endif // __TESTHOSTLET_H__ |
|
120 |
|
121 // End of file |