|
1 /* |
|
2 * Copyright (c) 2008-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ts_testincomming.h" |
|
20 |
|
21 |
|
22 |
|
23 CTS_TestIncomming::CTS_TestIncomming() |
|
24 { |
|
25 iTestStepName = KTestIncomming; |
|
26 } |
|
27 |
|
28 CTS_TestIncomming::~CTS_TestIncomming() |
|
29 { |
|
30 } |
|
31 |
|
32 enum TVerdict CTS_TestIncomming::doTestStepPreambleL(void) |
|
33 /** |
|
34 * Implements OOM testing in each test |
|
35 */ |
|
36 { |
|
37 if (!(GetBoolFromConfig(KTestIncomming,KOomTest,iIsOOMTest))) |
|
38 iIsOOMTest=EFalse; |
|
39 return EPass; |
|
40 } |
|
41 |
|
42 |
|
43 enum TVerdict CTS_TestIncomming::doTestStepL(void) |
|
44 /** |
|
45 * Creates and starts one or more Explicit Connection(s) |
|
46 * and appends it/them to the array of |
|
47 * connections in the MultiHoming Suite |
|
48 * @return The test step outcome. |
|
49 * |
|
50 */ |
|
51 { |
|
52 TInt err = KErrNone; |
|
53 TInt numOfSockets = 0; |
|
54 |
|
55 |
|
56 err = GetIntFromConfig(KTestIncomming, KNumOfSocks, numOfSockets); |
|
57 |
|
58 |
|
59 if ((!err) || (numOfSockets < 1)) |
|
60 { |
|
61 return EInconclusive; |
|
62 } |
|
63 |
|
64 RArray<CSplitEchoSocket*> sockArray; |
|
65 RArray<TBool> expectSocketsToSucceedArray; |
|
66 TConnDetails *theConn; |
|
67 |
|
68 TInt i; |
|
69 for (i = 0; i < numOfSockets; i++) |
|
70 { |
|
71 // Get some configuration data... |
|
72 TInetAddr dest; |
|
73 TInetAddr src; |
|
74 |
|
75 TInt protocol = KProtocolInetUdp; |
|
76 TInt packSize = PACKET_SIZE; |
|
77 TInt packCount = NUM_OF_PACKETS; |
|
78 TInt aTol = UDP_TOLERANCE; |
|
79 TBool expectSuccess = ETrue; |
|
80 TBool isListener = EFalse; |
|
81 |
|
82 |
|
83 err = GetSockConfig(i,protocol,packSize,packCount, aTol, dest, src, |
|
84 expectSuccess, isListener, &theConn); |
|
85 |
|
86 |
|
87 expectSocketsToSucceedArray.Append(expectSuccess); |
|
88 |
|
89 if (err!=KErrNone) |
|
90 { |
|
91 LogExtra((TText8*)__FILE__, __LINE__, ESevrErr, KEConfigFile); |
|
92 } |
|
93 |
|
94 CSplitEchoSocket* newSocket = CSplitEchoSocket::NewL(); |
|
95 |
|
96 err = newSocket->Echo(dest, src, packSize,packCount,protocol,aTol, theConn, i, isListener, this); |
|
97 if (err == KErrNone) |
|
98 { |
|
99 err = sockArray.Append(newSocket); |
|
100 if (err != KErrNone) |
|
101 { |
|
102 newSocket->DoCancel(); |
|
103 delete newSocket; |
|
104 newSocket = NULL; |
|
105 } |
|
106 } |
|
107 else |
|
108 { |
|
109 TPtrC Errortxt = EpocErrorToText(err); |
|
110 Log(KELogger, &Errortxt); |
|
111 delete newSocket; |
|
112 } |
|
113 } // for (i<numOfSockets) |
|
114 |
|
115 |
|
116 if(sockArray.Count() > 0) |
|
117 CEnhancedScheduler::Start(); // And start them off... |
|
118 // Wait for all to finish / time out. |
|
119 |
|
120 for (i = 0; i < sockArray.Count(); i++) |
|
121 { |
|
122 TInt err = KErrNone; |
|
123 TBool boolResult = EFalse; |
|
124 TInt percent = 0; |
|
125 TInt numSent = -1; |
|
126 err = sockArray[i]->LogReport(boolResult, numSent, percent); |
|
127 if (expectSocketsToSucceedArray[i] && |
|
128 (KErrNone == err) && boolResult |
|
129 || |
|
130 // Failure means there was a socket error or no packets received |
|
131 !expectSocketsToSucceedArray[i] && (KErrNone != err || !boolResult)) |
|
132 { |
|
133 Log(KSockPassed, i, numSent, percent); |
|
134 } |
|
135 else |
|
136 { |
|
137 TPtrC errorText = EpocErrorToText(err); |
|
138 Log(KSockFailed, i, &errorText, numSent, percent); |
|
139 iTestStepResult = EFail; |
|
140 } |
|
141 delete sockArray[i]; |
|
142 } |
|
143 |
|
144 |
|
145 expectSocketsToSucceedArray.Close(); |
|
146 sockArray.Close(); |
|
147 return iTestStepResult; |
|
148 } |
|
149 |