|
1 // Copyright (c) 2002-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 <eikenv.h> |
|
17 |
|
18 // =============================================== // |
|
19 class CSendPopCommandMessage; |
|
20 |
|
21 enum TTestMode{ |
|
22 ESingleDefaultConn = 0, |
|
23 ESingleSpecifiedConn, |
|
24 ETwoDefaultSerialConn, |
|
25 ETwoDefaultParallelConn, |
|
26 ETwoDifferentSerialConn, |
|
27 ETwoDifferentParallelConn, |
|
28 EExplicitDefaultConn |
|
29 }; |
|
30 |
|
31 // Parent active object which controls the children the sequence of |
|
32 // Connect, Send and count messages and Disconnect. |
|
33 class CTestHarnessParent : public CActive |
|
34 { |
|
35 public: |
|
36 static CTestHarnessParent* NewL(); |
|
37 static CTestHarnessParent* NewLC(); |
|
38 void ChildFinished(); |
|
39 CSendPopCommandMessage* MakeBasicConnectionLC(TDes& aServAddress, |
|
40 TDes8& aUser, TDes8& aPass); |
|
41 CSendPopCommandMessage* MakeOverrideConnectionLC(TDes& aServAddress, |
|
42 TDes8& aUser, TDes8& aPass); |
|
43 CSendPopCommandMessage* MakeExplicitDefaultConnectionLC(TDes& aServAddress, |
|
44 TDes8& aUser, TDes8& aPass); |
|
45 void TestSingleDefaultConnL(); |
|
46 void TestSingleSpecifiedConnL(); |
|
47 void TestTwoDefaultConnectionsSeriallyL(); |
|
48 void TestTwoDefaultConnectionsParallellyL(); |
|
49 void TestTwoDifferentConnectionsSeriallyL(); |
|
50 void TestTwoDifferentConnectionsParallellyL(); |
|
51 void TestExplicitDefaultConnL(); |
|
52 void SetTestMode(TTestMode aTestMode); |
|
53 private: |
|
54 CTestHarnessParent(); |
|
55 ~CTestHarnessParent(); |
|
56 void ConstructL(); |
|
57 void RunL(); |
|
58 void DoCancel(); |
|
59 void SingleDefaultConnection(); |
|
60 void SingleSpecifiedConnection(); |
|
61 void TwoSerialConnectionsL(); |
|
62 void TwoParallelConnections(); |
|
63 typedef enum TState{ |
|
64 EConnect = 0, |
|
65 ESend, |
|
66 EDisConnect, |
|
67 EConnect2, |
|
68 ESend2, |
|
69 EDisConnect2, |
|
70 EStop |
|
71 }; |
|
72 TState iState; |
|
73 CSendPopCommandMessage *iPopCmdServiceA; |
|
74 CSendPopCommandMessage *iPopCmdServiceB; |
|
75 TInt iConnectionType; |
|
76 TTestMode iTestMode; |
|
77 |
|
78 }; |
|
79 |
|
80 // =============================================== // |
|
81 |
|
82 // Child active object whose instances will be controled by parent for |
|
83 // Connect,Send and count messages and Disconnect |
|
84 |
|
85 class CSendPopCommandMessage : public CActive |
|
86 { |
|
87 public: // functions |
|
88 // construct/destruct |
|
89 static CSendPopCommandMessage *NewL(TDesC& aServerAddress, |
|
90 TInt aPort, |
|
91 TDesC8& aUser, |
|
92 TDesC8& aPass, |
|
93 CTestHarnessParent* aParent, |
|
94 CImIAPPreferences* aConnPref = NULL); |
|
95 |
|
96 static CSendPopCommandMessage *NewLC(TDesC& aServerAddress, |
|
97 TInt aPort, |
|
98 TDesC8& aUser, |
|
99 TDesC8& aPass, |
|
100 CTestHarnessParent* aParent, |
|
101 CImIAPPreferences* aConnPrefaConnPref = NULL); |
|
102 |
|
103 // issue request |
|
104 void RequestSend(); |
|
105 void SetConnectionPrefs(CImIAPPreferences* aConnPref); |
|
106 void Complete(TInt aError); |
|
107 TInt RunError(TInt aError); |
|
108 void ConnectionL(); |
|
109 void List(); |
|
110 TBool IsChildCompleteSet(); |
|
111 ~CSendPopCommandMessage(); |
|
112 void DisConnect(); |
|
113 void SetLastError(TInt aError); |
|
114 TInt GetLastError(); |
|
115 private: |
|
116 void RunL(); |
|
117 void QueueNextReceive(); |
|
118 void ConstructL(); |
|
119 void SetSelfComplete(TBool aComplete); |
|
120 |
|
121 CSendPopCommandMessage(); |
|
122 CSendPopCommandMessage(TDesC& aServerAddress, |
|
123 TInt aPort, |
|
124 TDesC8& aUser, |
|
125 TDesC8& aPass, |
|
126 CTestHarnessParent* aParent, |
|
127 CImIAPPreferences* aConnPref); |
|
128 |
|
129 void Quit(); |
|
130 void DisplayErrorReason(TInt& aReason); |
|
131 void DoCancel(); |
|
132 typedef enum TSendState{ |
|
133 EConnect = 0, |
|
134 EUserName, |
|
135 EPassword, |
|
136 EStat, |
|
137 EList, |
|
138 EQuit, |
|
139 EComplete, |
|
140 EConnectDone, |
|
141 EQuitDone |
|
142 }; |
|
143 CImTextServerSession* iImSocket; |
|
144 TSendState iSendState; |
|
145 TStreamId iId; |
|
146 HBufC* iBuf; |
|
147 TInt iCurrentState; |
|
148 TInt iLineStatus; |
|
149 TBool iReceive; |
|
150 TSockXfrLength iLen; |
|
151 TDesC& iServerAddress; |
|
152 TInt iPort; |
|
153 TDesC8& iUserName; |
|
154 TDesC8& iPass; |
|
155 CTestHarnessParent* iParent; |
|
156 CImIAPPreferences* iIAPPreferences; |
|
157 TInt iLastError; |
|
158 TBool iComplete; |
|
159 }; |
|
160 |
|
161 //====================================// |
|
162 |
|
163 // Test harness calss which installs the scheduler and loads the logical |
|
164 // and physical device |
|
165 |
|
166 class CTestHarnessUtil : public CBase |
|
167 { |
|
168 public: |
|
169 static CTestHarnessUtil* NewL(); |
|
170 ~CTestHarnessUtil(); |
|
171 private: |
|
172 void ConstructL(); |
|
173 CTestHarnessUtil(); |
|
174 void InitSchedulerL(); |
|
175 TInt CommInit(); |
|
176 private: |
|
177 RFs iFs; |
|
178 CActiveScheduler *iScheduler; |
|
179 }; |
|
180 |
|
181 //====================================// |
|
182 |
|
183 |
|
184 |