|
1 // Copyright (c) 2001-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 // This contains ESock Test cases from section 12 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <in_sock.h> |
|
21 |
|
22 // Test system includes |
|
23 #include "EsockTestSection12.h" |
|
24 |
|
25 |
|
26 // Test step 12.1 |
|
27 const TDesC& CEsockTest12_1::GetTestName() |
|
28 { |
|
29 // store the name of this test case |
|
30 _LIT(ret,"Test12.1"); |
|
31 return ret; |
|
32 } |
|
33 |
|
34 CEsockTest12_1::~CEsockTest12_1() |
|
35 { |
|
36 } |
|
37 |
|
38 enum TVerdict CEsockTest12_1::easyTestStepL() |
|
39 { |
|
40 // simple construction |
|
41 TInetAddr addr; |
|
42 |
|
43 // check port has been assigned to zero (0) |
|
44 TESTL(addr.Port() == 0); |
|
45 |
|
46 // check address is unspecified |
|
47 // ouput address into a buffer - check length is 0 |
|
48 TBuf<39> buf; |
|
49 addr.OutputWithScope(buf); |
|
50 TESTL(buf.Length()==0); |
|
51 |
|
52 return EPass; |
|
53 } |
|
54 |
|
55 |
|
56 // Test step 12.2 |
|
57 const TDesC& CEsockTest12_2::GetTestName() |
|
58 { |
|
59 // store the name of this test case |
|
60 _LIT(ret,"Test12.2"); |
|
61 return ret; |
|
62 } |
|
63 |
|
64 CEsockTest12_2::~CEsockTest12_2() |
|
65 { |
|
66 } |
|
67 |
|
68 enum TVerdict CEsockTest12_2::easyTestStepL() |
|
69 { |
|
70 TInt port1, port2, port3, port4; |
|
71 |
|
72 // construction specifying a port number |
|
73 |
|
74 // get port numbers from script |
|
75 TESTL(GetIntFromConfig(_L("Test_12.2"), _L("port1"), port1)); |
|
76 TESTL(GetIntFromConfig(_L("Test_12.2"), _L("port2"), port2)); |
|
77 TESTL(GetIntFromConfig(_L("Test_12.2"), _L("port3"), port3)); |
|
78 TESTL(GetIntFromConfig(_L("Test_12.2"), _L("port4"), port4)); |
|
79 |
|
80 // construct TCP/IP address with port number |
|
81 TInetAddr addr1(port1); |
|
82 |
|
83 // check port number assigned correctly |
|
84 TESTL(addr1.Port() == (TUint)port1); |
|
85 |
|
86 // check address is unspecified |
|
87 // ouput address into a buffer - check length is 0 |
|
88 TBuf<39> buf; |
|
89 addr1.OutputWithScope(buf); |
|
90 TESTL(buf.Length()==0); |
|
91 |
|
92 // repeat for port2 |
|
93 TInetAddr addr2(port2); |
|
94 TESTL(addr2.Port() == (TUint)port2); |
|
95 addr2.OutputWithScope(buf); |
|
96 TESTL(buf.Length()==0); |
|
97 |
|
98 // repeat for port3 |
|
99 TInetAddr addr3(port3); |
|
100 TESTL(addr3.Port() == (TUint)port3); |
|
101 addr3.OutputWithScope(buf); |
|
102 TESTL(buf.Length()==0); |
|
103 |
|
104 // repeat for port4 |
|
105 TInetAddr addr4(port4); |
|
106 TESTL(addr4.Port() == (TUint)port4); |
|
107 addr4.OutputWithScope(buf); |
|
108 TESTL(buf.Length()==0); |
|
109 |
|
110 return EPass; |
|
111 } |
|
112 |
|
113 |
|
114 // Test step 12.3 |
|
115 const TDesC& CEsockTest12_3::GetTestName() |
|
116 { |
|
117 // store the name of this test case |
|
118 _LIT(ret,"Test12.3"); |
|
119 return ret; |
|
120 } |
|
121 |
|
122 CEsockTest12_3::~CEsockTest12_3() |
|
123 { |
|
124 } |
|
125 |
|
126 enum TVerdict CEsockTest12_3::easyTestStepL() |
|
127 { |
|
128 TInetAddr addr1, addr2, addr3, addr4; |
|
129 TInt port1, port2, port3, port4; |
|
130 |
|
131 // construction with IP address and port number |
|
132 |
|
133 // get IP addresses and port numbers from script |
|
134 TESTL(GetIpAddressFromConfig(_L("Test_12.3"), _L("ipAddress1"), addr1)); |
|
135 TESTL(GetIpAddressFromConfig(_L("Test_12.3"), _L("ipAddress2"), addr2)); |
|
136 TESTL(GetIpAddressFromConfig(_L("Test_12.3"), _L("ipAddress3"), addr3)); |
|
137 TESTL(GetIpAddressFromConfig(_L("Test_12.3"), _L("ipAddress4"), addr4)); |
|
138 TESTL(GetIntFromConfig(_L("Test_12.3"), _L("port1"), port1)); |
|
139 TESTL(GetIntFromConfig(_L("Test_12.3"), _L("port2"), port2)); |
|
140 TESTL(GetIntFromConfig(_L("Test_12.3"), _L("port3"), port3)); |
|
141 TESTL(GetIntFromConfig(_L("Test_12.3"), _L("port4"), port4)); |
|
142 |
|
143 // convert IP address to a TUint32 |
|
144 TUint32 longAddr=addr1.Address(); |
|
145 |
|
146 // construct TCP/IP address from TUint32 and port |
|
147 TInetAddr addrA(longAddr, port1); |
|
148 |
|
149 // check port number assigned correctly |
|
150 TESTL(addrA.Port() == (TUint)port1); |
|
151 |
|
152 // check ip address has been assigned correctly |
|
153 // check against ip address from script |
|
154 TESTL(addrA.Match(addr1)); |
|
155 |
|
156 // repeat for 2nd ip address |
|
157 longAddr=addr2.Address(); |
|
158 TInetAddr addrB(longAddr, port2); |
|
159 TESTL(addrB.Port() == (TUint)port2); |
|
160 TESTL(addrB.Match(addr2)); |
|
161 |
|
162 // repeat for 3rd ip address |
|
163 longAddr=addr3.Address(); |
|
164 TInetAddr addrC(longAddr, port3); |
|
165 TESTL(addrC.Port() == (TUint)port3); |
|
166 TESTL(addrC.Match(addr3)); |
|
167 |
|
168 // repeat for 4th ip address |
|
169 longAddr=addr4.Address(); |
|
170 TInetAddr addrD(longAddr, port4); |
|
171 TESTL(addrD.Port() == (TUint)port4); |
|
172 TESTL(addrD.Match(addr4)); |
|
173 |
|
174 return EPass; |
|
175 } |
|
176 |
|
177 |
|
178 // Test step 12.4 |
|
179 const TDesC& CEsockTest12_4::GetTestName() |
|
180 { |
|
181 // store the name of this test case |
|
182 _LIT(ret,"Test12.4"); |
|
183 return ret; |
|
184 } |
|
185 |
|
186 CEsockTest12_4::~CEsockTest12_4() |
|
187 { |
|
188 } |
|
189 |
|
190 enum TVerdict CEsockTest12_4::easyTestStepL() |
|
191 { |
|
192 TInetAddr addr1, addr2, addr3, addr4; |
|
193 TInt port1, port2, port3, port4; |
|
194 |
|
195 // get IP addresses and port numbers from script |
|
196 TESTL(GetIpAddressFromConfig(_L("Test_12.4"), _L("ipAddress1"), addr1)); |
|
197 TESTL(GetIpAddressFromConfig(_L("Test_12.4"), _L("ipAddress2"), addr2)); |
|
198 TESTL(GetIpAddressFromConfig(_L("Test_12.4"), _L("ipAddress3"), addr3)); |
|
199 TESTL(GetIpAddressFromConfig(_L("Test_12.4"), _L("ipAddress4"), addr4)); |
|
200 TESTL(GetIntFromConfig(_L("Test_12.4"), _L("port1"), port1)); |
|
201 TESTL(GetIntFromConfig(_L("Test_12.4"), _L("port2"), port2)); |
|
202 TESTL(GetIntFromConfig(_L("Test_12.4"), _L("port3"), port3)); |
|
203 TESTL(GetIntFromConfig(_L("Test_12.4"), _L("port4"), port4)); |
|
204 |
|
205 // set port number |
|
206 addr1.SetPort(port1); |
|
207 |
|
208 // construct TCP/IP address from another TInetAddr |
|
209 TInetAddr addrA((TSockAddr)addr1); |
|
210 |
|
211 // check port number |
|
212 TESTL(addrA.Port() == (TUint)port1); |
|
213 |
|
214 // check ip address has been assigned correctly |
|
215 // check against ip address from script |
|
216 TESTL(addrA.Match(addr1)); |
|
217 |
|
218 // repeat for 2nd ip address |
|
219 addr2.SetPort(port2); |
|
220 TInetAddr addrB((TSockAddr)addr2); |
|
221 TESTL(addrB.Port() == (TUint)port2); |
|
222 TESTL(addrB.Match(addr2)); |
|
223 |
|
224 // repeat for 3rd ip address |
|
225 addr3.SetPort(port3); |
|
226 TInetAddr addrC((TSockAddr)addr3); |
|
227 TESTL(addrC.Port() == (TUint)port3); |
|
228 TESTL(addrC.Match(addr3)); |
|
229 |
|
230 // repeat for 4th ip address |
|
231 addr4.SetPort(port4); |
|
232 TInetAddr addrD((TSockAddr)addr4); |
|
233 TESTL(addrD.Port() == (TUint)port4); |
|
234 TESTL(addrD.Match(addr4)); |
|
235 |
|
236 return EPass; |
|
237 } |
|
238 |