|
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(PTCPSERVERTESTS_H) |
|
20 #define PTCPSERVERTESTS_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 <elements/nm_node.h> |
|
28 |
|
29 #include <rsockethandler.h> |
|
30 #include <csocketopener.h> |
|
31 #include <cchunkmanager.h> |
|
32 #include <rmemchunk.h> |
|
33 |
|
34 NONSHARABLE_CLASS(CTcpServerTestBase) : public CActive |
|
35 { |
|
36 public: |
|
37 static void StartTestL(const TDesC& aTestName, CProxyProvd* aProvd); |
|
38 virtual void RunL(); |
|
39 |
|
40 protected: |
|
41 CTcpServerTestBase(CProxyProvd* aProvd); |
|
42 virtual ~CTcpServerTestBase(); |
|
43 |
|
44 //Utilities function to be use in RunTest() |
|
45 void Reschedule(); |
|
46 CTestExecuteLogger iLogger; |
|
47 void CompleteSelf ( TInt aError ); |
|
48 void FinishTest(TVerdict result); |
|
49 |
|
50 CChunkManager* iChunkManager; |
|
51 private: |
|
52 //Implemented you own of these |
|
53 virtual TVerdict RunTestL() = 0; |
|
54 virtual void Cleanup(); |
|
55 |
|
56 void DoCancel(); |
|
57 void ConstructL(); |
|
58 void SetLoggerL(); |
|
59 CTestExecuteLogger& Logger(); |
|
60 static CTcpServerTestBase* CreateTestL(const TDesC& aTestName, CProxyProvd* aProvd); |
|
61 |
|
62 private: |
|
63 CProxyProvd* iProvd; |
|
64 TBool iReschedule; //Determines whether rescheduling is required |
|
65 }; |
|
66 |
|
67 inline CTestExecuteLogger& CTcpServerTestBase::Logger() |
|
68 { |
|
69 return iLogger; |
|
70 } |
|
71 |
|
72 //----------------------------------------------------------// |
|
73 /////////////////// CTcpServerTestUPnP ///////////////////////// |
|
74 //////Testcase: Send the test data from the test client///////// |
|
75 //----------------------------------------------------------// |
|
76 |
|
77 |
|
78 NONSHARABLE_CLASS(CTcpServerTestUPnP) : public CTcpServerTestBase, |
|
79 public Messages::ASimpleNodeIdBase, |
|
80 public MSocketHandlerObserver |
|
81 { |
|
82 public: |
|
83 static CTcpServerTestUPnP* NewL ( CProxyProvd* aProvd ); |
|
84 ~CTcpServerTestUPnP (); |
|
85 |
|
86 void ReceivedL ( const Messages::TRuntimeCtxId& aSender, const Messages::TNodeId& aRecipient, Messages::TSignatureBase& aMessage ); |
|
87 |
|
88 // From MSocketHandlerObserver |
|
89 void OpenComplete ( RInternalSocket& aSocket ); |
|
90 void ConnectComplete (); |
|
91 void AcceptComplete ( RInternalSocket& /*aSocket*/ ) |
|
92 { } |
|
93 void SendComplete ( TInt aLength ); |
|
94 void SendToComplete ( TInt /*aLength*/ ) |
|
95 { } |
|
96 void RecvComplete ( RMBufChain& aData ); |
|
97 void RecvFromComplete ( RMBufChain& /*aData*/, const TSockAddr& /*aAddr*/ ) |
|
98 { } |
|
99 void IoctlComplete () |
|
100 { } |
|
101 void Error ( TOperation /*aOperation*/, TInt /*aError*/ ) |
|
102 { } |
|
103 |
|
104 private: |
|
105 enum TState |
|
106 { |
|
107 ECreateServer = 0, |
|
108 EStartServer, |
|
109 EOpenClientSocketAndConnect, |
|
110 ESendData, |
|
111 ESendStopServer, |
|
112 EServerStopped, |
|
113 ECleanup, |
|
114 }; |
|
115 |
|
116 CTcpServerTestUPnP ( CProxyProvd* aProvd ); |
|
117 void ConstructL (); |
|
118 virtual TVerdict RunTestL (); |
|
119 |
|
120 private: |
|
121 Messages::TNodeId iTcpServer; |
|
122 RBuf8 iServiceUri; |
|
123 |
|
124 RInternalSocket iClientSocket; |
|
125 RSocketHandler iSocketHandler; |
|
126 CSocketOpener* iSocketOpener; |
|
127 |
|
128 RMBufChain iSendChain; |
|
129 TInetAddr iHostAddr; |
|
130 TVerdict iResponse; |
|
131 |
|
132 RTimer iTimer; |
|
133 TState iState; |
|
134 }; |
|
135 |
|
136 #endif //PTCPSERVERTESTS_H |