|
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 and initialization of POS Handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <epos_comasuplposhandlerbase.h> |
|
19 #include <epos_comasuplpossessionbase.h> |
|
20 #include <ecom/ecom.h> |
|
21 |
|
22 #include "epos_comasuplposhandlercreationtest.h" |
|
23 #include "epos_comasupltesthandler.h" |
|
24 #include "epos_comasuplpostesterlogger.h" |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Named constructor |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 COMASuplPosHandlerCreationTest* COMASuplPosHandlerCreationTest::NewL( |
|
31 const TUid& aUid |
|
32 , COMASuplPosTesterCategory* aCallBack) |
|
33 { |
|
34 COMASuplPosHandlerCreationTest* self |
|
35 = new(ELeave)COMASuplPosHandlerCreationTest( |
|
36 aUid, aCallBack); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // Destructor |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 COMASuplPosHandlerCreationTest::~COMASuplPosHandlerCreationTest() |
|
48 { |
|
49 Cancel(); |
|
50 delete iPosHandler; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // This function is called by test handler. It is entry point of execution |
|
55 // of a test case. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void COMASuplPosHandlerCreationTest::StartTestingL() |
|
59 { |
|
60 if(iCallBack) |
|
61 { |
|
62 iLogger->WriteTestHeader(KPosHandlerCreationTest, iTestNo); |
|
63 } |
|
64 iNextInSeq = EStartTest; |
|
65 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
66 DummyRequest(iStatus); |
|
67 SetActive(); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Handles an active object's request completion event. |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void COMASuplPosHandlerCreationTest::RunL() |
|
75 { |
|
76 switch(iNextInSeq) |
|
77 { |
|
78 case EStartTest: |
|
79 { |
|
80 TInt err = KErrNone; |
|
81 iLogger->GetRequestStartTime(); |
|
82 TRAP(err, iPosHandler = COMASuplPosHandlerBase::NewL(iUid)); |
|
83 if(KErrNone != err) |
|
84 { |
|
85 iError++; |
|
86 iLogger->WriteLine(KHandlerCreateFail, iTestNo); |
|
87 User::Leave(err); |
|
88 } |
|
89 iInfo++; |
|
90 iLogger->LogExecutionTime(_L8("Info: Execution Time of COMASuplPosHandlerBase::NewL()")); |
|
91 iInfo++; |
|
92 iLogger->WriteLine(_L8("Info: PosHandler Created."), iTestNo); |
|
93 iNextInSeq = EInitializeHandler; |
|
94 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
95 DummyRequest(iStatus); |
|
96 SetActive(); |
|
97 break; |
|
98 } |
|
99 case EInitializeHandler: |
|
100 { |
|
101 iNextInSeq = EInitComplete; |
|
102 __ASSERT_ALWAYS(!IsActive(),User::Panic(KPanicSetActive, KErrAlreadyExists)); |
|
103 iInfo++; |
|
104 iLogger->WriteLine(KInitializingHandler, iTestNo); |
|
105 iPosHandler->InitializeL(iStatus); |
|
106 SetActive(); |
|
107 break; |
|
108 } |
|
109 case EInitComplete: |
|
110 { |
|
111 if(iStatus == KErrNone) |
|
112 { |
|
113 iInfo++; |
|
114 iLogger->WriteLine(KInitializedHandler, iTestNo); |
|
115 TestingComplete(KPosHandlerCreationComplete); |
|
116 } |
|
117 else |
|
118 { |
|
119 iError++; |
|
120 iLogger->WriteStatus(KError, iStatus.Int(), iTestNo |
|
121 , &KReqCompWith()); |
|
122 TestingAborted(KPosHandlerCreationAborted); |
|
123 } |
|
124 } |
|
125 } |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // Implements cancellation of an outstanding request. |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void COMASuplPosHandlerCreationTest::DoCancel() |
|
133 { |
|
134 iPosHandler->CancelInitialize(); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // Handles a leave occurring in the request completion event handler RunL(). |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 TInt COMASuplPosHandlerCreationTest::RunError(TInt aError) |
|
142 { |
|
143 switch(iNextInSeq) |
|
144 { |
|
145 case EStartTest: |
|
146 { |
|
147 iError++; |
|
148 iLogger->WriteStatus(KLeaveInHandlerCreation, aError, iTestNo); |
|
149 break; |
|
150 } |
|
151 case EInitComplete: |
|
152 { |
|
153 iError++; |
|
154 iLogger->WriteStatus(KLeaveInHandlerInit, aError, iTestNo); |
|
155 break; |
|
156 } |
|
157 } |
|
158 |
|
159 TestingAborted(KPosHandlerCreationAborted); |
|
160 return KErrNone; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // Second phase constructor |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void COMASuplPosHandlerCreationTest::ConstructL() |
|
168 { |
|
169 CActiveScheduler::Add(this); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // Stores Uid of implementation to be tested. |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 COMASuplPosHandlerCreationTest::COMASuplPosHandlerCreationTest( |
|
177 const TUid& aUid |
|
178 , COMASuplPosTesterCategory* aCallBack) |
|
179 :COMASuplPosTesterCategory(aCallBack) |
|
180 { |
|
181 iUid = aUid; |
|
182 } |