|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(PTCPCLIENTTESTS_H) |
|
20 #define PTCPCLIENTTESTS_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <testexecutestepbase.h> |
|
24 #include "proxyprotocol.h" |
|
25 #include <comms-infras/eintsock.h> |
|
26 #include "es_mbuf.h" |
|
27 #include "testtcpserver.h" |
|
28 #include <elements/nm_node.h> |
|
29 #include "mtcpclienttestcase.h" |
|
30 #include <cchunkmanager.h> |
|
31 #include <rmemchunk.h> |
|
32 |
|
33 _LIT8 ( KTestCase1, "testcase1" ); |
|
34 _LIT8 ( KMissingContentLength, "HTTP/1.1 200 OK\r\nST: testcase1\r\nEXT: \r\nSERVER: Apache 9.x, UPnP/1.0\r\nUSN: uuid:ae30fdec-16e3-4d75-ac72-b61c5d6d30d5::urn:schemas-upnp-org:device:BinaryLight:1\r\nCACHE-CONTROL: max-age=900\r\nLOCATION: http://10.192.196.204:54042/\r\n\r\n"); |
|
35 |
|
36 |
|
37 NONSHARABLE_CLASS(CTcpClientTestBase) : protected CActive |
|
38 { |
|
39 public: |
|
40 static void StartTestL(const TDesC& aTestName, CProxyProvd* aProvd); |
|
41 virtual void RunL(); |
|
42 |
|
43 protected: |
|
44 CTcpClientTestBase(CProxyProvd* aProvd); |
|
45 virtual ~CTcpClientTestBase(); |
|
46 |
|
47 //Utilities function to be use in RunTest() |
|
48 void Reschedule(); |
|
49 CTestExecuteLogger iLogger; |
|
50 void CompleteSelf ( TInt aError ); |
|
51 void FinishTest(TVerdict result); |
|
52 enum TState |
|
53 { |
|
54 ECreateTestServer = 0, |
|
55 ECreateTestClient, |
|
56 ESendRequestData, |
|
57 ECleanup, |
|
58 EComplete, |
|
59 }; |
|
60 |
|
61 RMemoryAllocator iAllocator; |
|
62 CChunkManager* iChunkManager; |
|
63 TState iState; |
|
64 private: |
|
65 |
|
66 |
|
67 //Implemented you own of these |
|
68 virtual TVerdict RunTestL() = 0; |
|
69 virtual void Cleanup(); |
|
70 |
|
71 void DoCancel(); |
|
72 void ConstructL(); |
|
73 void SetLoggerL(); |
|
74 CTestExecuteLogger& Logger(); |
|
75 static CTcpClientTestBase* CreateTestL(const TDesC& aTestName, CProxyProvd* aProvd); |
|
76 |
|
77 private: |
|
78 CProxyProvd* iProvd; |
|
79 TBool iReschedule; //Determines whether rescheduling is required |
|
80 }; |
|
81 |
|
82 inline CTestExecuteLogger& CTcpClientTestBase::Logger() |
|
83 { |
|
84 return iLogger; |
|
85 } |
|
86 |
|
87 |
|
88 class MTestServerObserver |
|
89 { |
|
90 public: |
|
91 /** |
|
92 Callback method which returns the responses. |
|
93 @param aObserverInfo bundle containg the response. |
|
94 */ |
|
95 virtual void OnTestServerEventL ( TInt aError ) = 0; |
|
96 |
|
97 |
|
98 virtual MTcpClientTestCase* GetTestCase ( ) = 0; |
|
99 |
|
100 virtual CTestExecuteLogger& GetLogger ( ) = 0; |
|
101 //virtual void OnTestServerEventL ( TBool aFlag) = 0; |
|
102 /** |
|
103 Callback method which handles the errors of OnPnPEventL. |
|
104 @param aError error code. |
|
105 */ |
|
106 //virtual void OnTestServerError (TInt aError) = 0; |
|
107 }; |
|
108 |
|
109 /*class MTestClientObserver |
|
110 { |
|
111 public: |
|
112 /** |
|
113 Callback method which returns the responses. |
|
114 @param aObserverInfo bundle containg the response. |
|
115 * |
|
116 virtual void OnTestClientEventL ( TObserverBundle& aObserverInfo) = 0; |
|
117 /** |
|
118 Callback method which handles the errors of OnPnPEventL. |
|
119 @param aError error code. |
|
120 * |
|
121 virtual void OnTestClientError (TInt aError) = 0; |
|
122 }; |
|
123 */ |
|
124 //----------------------------------------------------------// |
|
125 /////////////////// CTcpClientTestUPnP ///////////////////////// |
|
126 //////Testcase: Send the test data from the test client///////// |
|
127 //----------------------------------------------------------// |
|
128 |
|
129 NONSHARABLE_CLASS(CTcpClientTestUPnP) : public CTcpClientTestBase, |
|
130 public Messages::ASimpleNodeIdBase, |
|
131 public MTestServerObserver, |
|
132 public MTcpClientTestCase |
|
133 { |
|
134 public: |
|
135 static CTcpClientTestUPnP* NewL ( CProxyProvd* aProvd ); |
|
136 |
|
137 //MTestServerObserver |
|
138 void OnTestServerEventL ( TInt aError ); |
|
139 MTcpClientTestCase* GetTestCase (); |
|
140 CTestExecuteLogger& GetLogger (); |
|
141 //MTcpClientTestCase |
|
142 const TDesC& TestCaseName () const; |
|
143 TInt TotalTransactionCount () const; |
|
144 TInt TransactionCount () const; |
|
145 |
|
146 const TDesC8& GetRawRequest ( TInt aTransIndex ); |
|
147 const TDesC8& GetRawResponse ( TInt aTransIndex ); |
|
148 |
|
149 |
|
150 ~CTcpClientTestUPnP (); |
|
151 |
|
152 void ReceivedL ( const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage ); |
|
153 |
|
154 private: |
|
155 |
|
156 CTcpClientTestUPnP ( CProxyProvd* aProvd ); |
|
157 void ConstructL (); |
|
158 virtual TVerdict RunTestL (); |
|
159 |
|
160 private: |
|
161 CTestTcpServer* iTestServer; |
|
162 Messages::TNodeId iClientId; |
|
163 RTimer iTimer; |
|
164 //TState iState; |
|
165 }; |
|
166 |
|
167 #endif //PTCPCLIENTTESTS_H |