|
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: NAT FW SDP Provider test console test manager |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32base.h> |
|
20 #include <e32debug.h> |
|
21 #include <e32cons.h> |
|
22 #include <badesca.h> |
|
23 #include <sdpconnectionfield.h> |
|
24 #include <sdpmediafield.h> |
|
25 #include "nsptestconsolecenrep.h" |
|
26 #include "nsptestmanager.h" |
|
27 #include "nsptest.h" |
|
28 #include "nspreleasetest.h" |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CNSPTestManager::NewL |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CNSPTestManager* CNSPTestManager::NewL( CNSPPlugin& aApi, CRepository& aRep ) |
|
35 { |
|
36 CNSPTestManager* self = CNSPTestManager::NewLC( aApi, aRep ); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CNSPTestManager::NewLC |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CNSPTestManager* CNSPTestManager::NewLC( CNSPPlugin& aApi, CRepository& aRep ) |
|
46 { |
|
47 CNSPTestManager* self = new ( ELeave ) CNSPTestManager( aApi, aRep ); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CNSPTestManager::~CNSPTestManager |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CNSPTestManager::~CNSPTestManager() |
|
58 { |
|
59 iTestArray.ResetAndDestroy(); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CNSPTestManager::CNSPTestManager |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CNSPTestManager::CNSPTestManager( CNSPPlugin& aApi, CRepository& aRep ) |
|
67 : iApi( aApi ), |
|
68 iRep( aRep ) |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CNSPTestManager::ConstructL |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CNSPTestManager::ConstructL() |
|
77 { |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CNSPTestManager::RelTestL |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 MNSPTest& CNSPTestManager::RelTestL() |
|
85 { |
|
86 CNSPTest* reltest = Find( ERelease ); |
|
87 |
|
88 if ( NULL == reltest ) |
|
89 { |
|
90 reltest = CNSPReleaseTest::NewLC( iApi, iRep ); |
|
91 iTestArray.AppendL( reltest ); |
|
92 CleanupStack::Pop( reltest ); |
|
93 } |
|
94 |
|
95 return *reltest; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CNSPTestManager::Remove |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TInt CNSPTestManager::Remove( MNSPTest& aTest ) |
|
103 { |
|
104 const TInt index = iTestArray.Find( static_cast<CNSPTest*>(&aTest) ); |
|
105 |
|
106 if ( KErrNotFound != index ) |
|
107 { |
|
108 delete iTestArray[index]; |
|
109 iTestArray.Remove(index); |
|
110 iTestArray.Compress(); |
|
111 return KErrNone; |
|
112 } |
|
113 |
|
114 return KErrNotFound; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CNSPTestManager::StartL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CNSPTestManager::StartL( MNSPTest& aTest, CConsoleBase& aConsole ) |
|
122 { |
|
123 const TInt index = iTestArray.Find( static_cast<CNSPTest*>(&aTest) ); |
|
124 User::LeaveIfError( index ); |
|
125 iTestArray[index]->StartL( aConsole ); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CNSPTestManager::Cancel |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CNSPTestManager::Cancel( MNSPTest& aTest ) |
|
133 { |
|
134 const TInt index = iTestArray.Find( static_cast<CNSPTest*>(&aTest) ); |
|
135 |
|
136 if ( KErrNotFound != index ) |
|
137 { |
|
138 iTestArray[index]->Cancel(); |
|
139 } |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CNSPTestManager::StartAllL |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CNSPTestManager::StartAllL( CConsoleBase& aConsole ) |
|
147 { |
|
148 for ( TInt i = 0; i < iTestArray.Count(); i++ ) |
|
149 { |
|
150 iTestArray[i]->StartL( aConsole ); |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CNSPTestManager::CancelAll |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CNSPTestManager::CancelAll() |
|
159 { |
|
160 for ( TInt i = 0; i < iTestArray.Count(); i++ ) |
|
161 { |
|
162 iTestArray[i]->Cancel(); |
|
163 } |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CNSPTestManager::AcceptL |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CNSPTestManager::AcceptL( MNSPTestVisitor& aVisitor ) |
|
171 { |
|
172 for ( TInt i = 0; i < iTestArray.Count(); i++ ) |
|
173 { |
|
174 iTestArray[i]->AcceptL( aVisitor ); |
|
175 } |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CNSPTestManager::Find |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 CNSPTest* CNSPTestManager::Find( TestType aType ) |
|
183 { |
|
184 TFinder finder( aType ); |
|
185 |
|
186 for ( TInt i = 0; i < iTestArray.Count(); i++ ) |
|
187 { |
|
188 iTestArray[i]->AcceptL( finder ); |
|
189 } |
|
190 |
|
191 return finder.Ptr(); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // TFinder::TFinder |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 TFinder::TFinder( CNSPTestManager::TestType aType ) |
|
199 : iType( aType ), |
|
200 iTest( NULL ) |
|
201 { |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // TFinder::VisitL |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 void TFinder::VisitL( MNSPTest& /*aTest*/ ) |
|
209 { |
|
210 User::Leave( KErrTotalLossOfPrecision ); |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // TFinder::VisitL |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void TFinder::VisitL( CNSPTest& aTest ) |
|
218 { |
|
219 iTest = ( !iTest && CNSPTestManager::ESingle == iType ? &aTest : iTest ); |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // TFinder::VisitL |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void TFinder::VisitL( CNSPReleaseTest& aTest ) |
|
227 { |
|
228 iTest = ( !iTest && CNSPTestManager::ERelease == iType ? &aTest : iTest ); |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // TFinder::Ptr |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 CNSPTest* TFinder::Ptr() |
|
236 { |
|
237 return iTest; |
|
238 } |