|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Tests creation of single POS session. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 #include <ecom/implementationinformation.h> |
|
21 #include <epos_comasuplposhandlerbase.h> |
|
22 #include <epos_comasuplpossessionbase.h> |
|
23 |
|
24 #include "epos_comasuplpossessioncreationtest.h" |
|
25 #include "epos_comasuplpostesterlogger.h" |
|
26 #include "epos_comasupltesthandler.h" |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // Named constructor |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 COMASuplPosSessionCreationTest* COMASuplPosSessionCreationTest |
|
33 ::NewL(CImplementationInformation& aImplInfo |
|
34 , COMASuplPosTesterCategory* aCallBack) |
|
35 { |
|
36 COMASuplPosSessionCreationTest* self |
|
37 = new(ELeave)COMASuplPosSessionCreationTest(aImplInfo, aCallBack); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Destructor |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 COMASuplPosSessionCreationTest::~COMASuplPosSessionCreationTest() |
|
49 { |
|
50 Cancel(); |
|
51 delete iSessionBase; |
|
52 delete iPosHandler; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // This function is called by test handler. It is entry point of execution |
|
57 // of a test case. |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void COMASuplPosSessionCreationTest::StartTestingL() |
|
61 { |
|
62 if(iCallBack) |
|
63 { |
|
64 iLogger->WriteTestHeader(KPosSessionCreationTest, iTestNo); |
|
65 } |
|
66 iNextInSeq = EStartTest; |
|
67 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
68 DummyRequest(iStatus); |
|
69 SetActive(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Handles an active object's request completion event. |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void COMASuplPosSessionCreationTest::RunL() |
|
77 { |
|
78 switch(iNextInSeq) |
|
79 { |
|
80 case EStartTest: |
|
81 { |
|
82 TInt err = KErrNone; |
|
83 TRAP(err, iPosHandler = COMASuplPosHandlerBase::NewL(iImplInfo->ImplementationUid())); |
|
84 if(KErrNone != err) |
|
85 { |
|
86 iError++; |
|
87 iLogger->WriteLine(KCreatingSessionFail, iTestNo); |
|
88 User::Leave(err); |
|
89 } |
|
90 iInfo++; |
|
91 iLogger->WriteLine(_L8("Info: PosHandler created."), iTestNo); |
|
92 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
93 iNextInSeq = EInitializeHandler; |
|
94 DummyRequest(iStatus); |
|
95 SetActive(); |
|
96 break; |
|
97 } |
|
98 case EInitializeHandler: |
|
99 { |
|
100 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
101 iNextInSeq = ECreatePosSession; |
|
102 iInfo++; |
|
103 iLogger->WriteLine(KInitializingHandler, iTestNo); |
|
104 iPosHandler->InitializeL(iStatus); |
|
105 SetActive(); |
|
106 break; |
|
107 } |
|
108 case ECreatePosSession: |
|
109 { |
|
110 iNextInSeq = EInitializeSession; |
|
111 if(iStatus != KErrNone) |
|
112 { |
|
113 iError++; |
|
114 //Could not initialize POS handler |
|
115 iLogger->WriteStatus(KError, iStatus.Int(), iTestNo |
|
116 , &KReqCompWith()); |
|
117 //Abort testing |
|
118 TestingAborted(KPosSessionCreationTestAborted); |
|
119 return; |
|
120 } |
|
121 iInfo++; |
|
122 iLogger->WriteLine(_L8("Info: PosHandler Initialized."), iTestNo); |
|
123 iLogger->GetRequestStartTime(); |
|
124 TRAPD(err, iSessionBase = iPosHandler->CreateNewSessionL( |
|
125 iSuplObserver)); |
|
126 if(KErrNone != err) |
|
127 { |
|
128 iError++; |
|
129 iLogger->WriteLine(KCreatingSessionFail, iTestNo); |
|
130 User::Leave(err); |
|
131 } |
|
132 iInfo++; |
|
133 iLogger->LogExecutionTime(KExecCreateNewSessionL); |
|
134 iInfo++; |
|
135 iLogger->WriteLine(KSessionCreated, iTestNo); |
|
136 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
137 |
|
138 DummyRequest(iStatus); |
|
139 SetActive(); |
|
140 break; |
|
141 } |
|
142 case EInitializeSession: |
|
143 { |
|
144 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
145 iNextInSeq = EPosSessionTestComplete; |
|
146 //initializing POS session |
|
147 iInfo++; |
|
148 iLogger->WriteLine(KInitializingSession, iTestNo); |
|
149 iSessionBase->InitializeL(iRequestID, iStatus); |
|
150 SetActive(); |
|
151 break; |
|
152 } |
|
153 case EPosSessionTestComplete: |
|
154 { |
|
155 if(iStatus == KErrNone) |
|
156 { |
|
157 iInfo++; |
|
158 iLogger->WriteLine(KSessionInitialized, iTestNo); |
|
159 TestingComplete(KPosSessionCreationTestComplete); |
|
160 } |
|
161 else |
|
162 { |
|
163 iError++; |
|
164 //Could not initialize POS session |
|
165 iLogger->WriteStatus(KError, iStatus.Int(), iTestNo |
|
166 , &KReqCompWith()); |
|
167 //Abort testing |
|
168 TestingAborted(KPosSessionCreationTestAborted); |
|
169 } |
|
170 break; |
|
171 } |
|
172 } |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // Implements cancellation of an outstanding request. |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void COMASuplPosSessionCreationTest::DoCancel() |
|
180 { |
|
181 if(ECreatePosSession == iNextInSeq) |
|
182 { |
|
183 iPosHandler->CancelInitialize(); |
|
184 } |
|
185 |
|
186 if(EPosSessionTestComplete == iNextInSeq && iSessionBase) |
|
187 { |
|
188 iSessionBase->CancelInitialize(); |
|
189 } |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // Handles a leave occurring in the request completion event handler RunL(). |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 TInt COMASuplPosSessionCreationTest::RunError(TInt aError) |
|
197 { |
|
198 switch(iNextInSeq) |
|
199 { |
|
200 case EStartTest: |
|
201 { |
|
202 iError++; |
|
203 iLogger->WriteStatus(KLeaveInHandlerCreation, aError, iTestNo); |
|
204 break; |
|
205 } |
|
206 case ECreatePosSession: |
|
207 { |
|
208 iError++; |
|
209 iLogger->WriteStatus(KLeaveInHandlerInit, aError, iTestNo); |
|
210 break; |
|
211 } |
|
212 case EInitializeSession: |
|
213 { |
|
214 iError++; |
|
215 iLogger->WriteStatus(KLeaveInCreateNewSession, aError, iTestNo); |
|
216 break; |
|
217 } |
|
218 case EPosSessionTestComplete: |
|
219 { |
|
220 iError++; |
|
221 iLogger->WriteStatus(KLeaveInSessionInit, aError, iTestNo); |
|
222 break; |
|
223 } |
|
224 } |
|
225 TestingAborted(KPosSessionCreationTestAborted); |
|
226 return KErrNone; |
|
227 } |
|
228 |
|
229 COMASuplPosSessionCreationTest::COMASuplPosSessionCreationTest( |
|
230 CImplementationInformation& aImplInfo |
|
231 , COMASuplPosTesterCategory* aCallBack) |
|
232 :COMASuplPosTesterCategory(aCallBack) |
|
233 { |
|
234 iImplInfo = &aImplInfo; |
|
235 iNextInSeq = EPosSessionTestComplete; |
|
236 iRequestID = 0; |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // Second phase constructor |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void COMASuplPosSessionCreationTest::ConstructL() |
|
244 { |
|
245 CActiveScheduler::Add(this); |
|
246 iSuplObserver = this; |
|
247 } |