|
1 /* |
|
2 * Copyright (c) 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: This file contains CStatisticsContainer class |
|
15 * definition. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknlists.h> // ListBox |
|
21 #include <AknIconArray.h> // CAknIconArray |
|
22 #include <aknnotewrappers.h> |
|
23 |
|
24 #include <eikclbd.h> // CColumnListBoxData |
|
25 |
|
26 #include <Stifui.rsg> |
|
27 |
|
28 //#include "UIStoreIf.h" |
|
29 //#include "UIStore.h" |
|
30 //#include "UIEngine.h" |
|
31 //#include "UIEngineContainer.h" |
|
32 |
|
33 #include <stifinternal/UIStoreIf.h> |
|
34 #include <stifinternal/UIStore.h> |
|
35 #include <stifinternal/UIEngine.h> |
|
36 #include <stifinternal/UIEngineContainer.h> |
|
37 |
|
38 #include "StatisticsContainer.h" |
|
39 #include "Stifui.hrh" |
|
40 #include "AppUIAppUi.h" |
|
41 |
|
42 #include "MenuListBox.h" |
|
43 |
|
44 |
|
45 // ================= MEMBER FUNCTIONS ======================= |
|
46 // ---------------------------------------------------------------------------- |
|
47 // CStatisticsContainer::ConstructL |
|
48 // |
|
49 // Symbian OS two phased constructor. |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 void CStatisticsContainer::ConstructL( const TRect& aRect, |
|
53 MEikListBoxObserver* aListBoxObserver ) |
|
54 { |
|
55 |
|
56 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log( |
|
57 _L("StatisticsContainer: ConstructL")); |
|
58 |
|
59 CreateWindowL(); |
|
60 |
|
61 iUIStore = ( (CAppUIAppUi*)iCoeEnv->AppUi() )->UIStoreHandler(); |
|
62 |
|
63 //iTestCasesInView.Reset(); |
|
64 //((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: iTCInV Reset")); |
|
65 |
|
66 iListBox = CMenuListBox::NewL(EStatisticsViewId); |
|
67 iListBox->SetContainerWindowL( *this ); |
|
68 iListBox->SetListBoxObserver( aListBoxObserver /*this*/ ); // jos peritty MEikListBoxObserver:sta |
|
69 iListBox->ConstructL(this, EAknListBoxMarkableList /*EAknListBoxSelectionList*/); |
|
70 |
|
71 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: ListBox constructed")); |
|
72 |
|
73 //Create Scroller control for ListBox and set its visibility |
|
74 iListBox->CreateScrollBarFrameL(ETrue); |
|
75 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
76 |
|
77 if ( iUIStore ) |
|
78 { |
|
79 //RRefArray<CStartedTestCase> allStarted; |
|
80 RRefArray<CStartedTestCase> allStarted; |
|
81 TInt ret = iUIStore->StartedTestCases( allStarted ); |
|
82 if( KErrNone != ret ) |
|
83 { |
|
84 allStarted.Reset(); |
|
85 allStarted.Close(); |
|
86 User::Leave( ret ); |
|
87 } |
|
88 TInt count = allStarted.Count(); |
|
89 // TInt notstarted( 0 ); |
|
90 TInt ongoing( 0 ); |
|
91 TInt passed( 0 ); |
|
92 TInt failed( 0 ); |
|
93 TInt other( 0 ); |
|
94 //TInt aborted( 0 ); |
|
95 // TInt paused( 0 ); |
|
96 //TInt crashed( 0 ); |
|
97 //TInt executed( 0 ); |
|
98 // TInt state( 0 ); |
|
99 |
|
100 for( TInt a = 0; a < count; a++ ) |
|
101 { |
|
102 switch ( allStarted[a].Status() ) |
|
103 { |
|
104 case CUIStoreIf::EStatusRunning: |
|
105 { |
|
106 ongoing++; |
|
107 break; |
|
108 } |
|
109 case CUIStoreIf::EStatusExecuted | CUIStoreIf::EStatusPassed: |
|
110 { |
|
111 passed++; |
|
112 break; |
|
113 } |
|
114 case CUIStoreIf::EStatusExecuted |CUIStoreIf::EStatusFailed: |
|
115 { |
|
116 failed++; |
|
117 break; |
|
118 } |
|
119 //case CUIStoreIf::EStatusAborted: |
|
120 // { |
|
121 // aborted++; |
|
122 // break; |
|
123 // } |
|
124 /*case ECrashed: |
|
125 { |
|
126 crashed++; |
|
127 break; |
|
128 } |
|
129 */ |
|
130 /*case EExecuted: |
|
131 { |
|
132 executed++; |
|
133 break; |
|
134 } |
|
135 */ |
|
136 default: |
|
137 { |
|
138 other++; |
|
139 break; |
|
140 } |
|
141 } |
|
142 } |
|
143 |
|
144 allStarted.Reset(); |
|
145 allStarted.Close(); |
|
146 |
|
147 iTestCaseArray = new (ELeave) CDesC16ArrayFlat(6); |
|
148 iTestCaseArray->Reset(); |
|
149 |
|
150 HBufC* tmpHBuf = HBufC::NewL( 40 ); |
|
151 TPtr buffer( tmpHBuf->Des() ); |
|
152 |
|
153 buffer = ( _L("\t") ); |
|
154 buffer.AppendNum( ongoing ); |
|
155 buffer.Append( _L(" Running") ); |
|
156 iTestCaseArray->AppendL( buffer ); |
|
157 |
|
158 buffer = ( _L("\t") ); |
|
159 buffer.AppendNum( passed ); |
|
160 buffer.Append( _L(" Passed") ); |
|
161 iTestCaseArray->AppendL( buffer ); |
|
162 |
|
163 buffer = ( _L("\t") ); |
|
164 buffer.AppendNum( failed ); |
|
165 buffer.Append( _L(" Failed") ); |
|
166 iTestCaseArray->AppendL( buffer ); |
|
167 |
|
168 buffer = ( _L("\t") ); |
|
169 buffer.AppendNum( other ); |
|
170 buffer.Append( _L(" Crashed/Aborted") ); |
|
171 iTestCaseArray->AppendL( buffer ); |
|
172 |
|
173 delete tmpHBuf; |
|
174 |
|
175 iListBox->Model()->SetItemTextArray( iTestCaseArray ); |
|
176 ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: ListBox model set")); |
|
177 } |
|
178 else |
|
179 { |
|
180 //User::Leave( syy?? ) |
|
181 } |
|
182 |
|
183 // Creates graphic. |
|
184 //SetGraphicIconL( iListBox ); |
|
185 // ((CAppUIAppUi*)iCoeEnv->AppUi())->iLogger->Log(_L("StatisticsContainer: icons created")); |
|
186 |
|
187 iListBox->ActivateL(); |
|
188 ((CMenuListBox*)iListBox)->SetPreviousFocus(); |
|
189 |
|
190 SetRect(aRect); |
|
191 ActivateL(); |
|
192 |
|
193 } |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // CStatisticsContainer::~CStatisticsContainer |
|
197 // |
|
198 // Destructor. |
|
199 // ---------------------------------------------------------------------------- |
|
200 // |
|
201 CStatisticsContainer::~CStatisticsContainer() |
|
202 { |
|
203 //iTestCasesInView.Close(); // does not delete objects whose pointers are contained in the array |
|
204 //delete iListBox; |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CStatisticsContainer::SizeChanged |
|
209 // |
|
210 // Called by framework when the view size is changed. |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 void CStatisticsContainer::SizeChanged() |
|
214 { |
|
215 if ( iListBox ) |
|
216 { |
|
217 iListBox->SetRect( Rect() ); // Sets rectangle of listbox. |
|
218 } |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CStatisticsContainer::CountComponentControls |
|
223 // |
|
224 // Gets a count of the component controls of this list box control. |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 TInt CStatisticsContainer::CountComponentControls() const |
|
228 { |
|
229 return 1; // return nbr of controls inside this container |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CStatisticsContainer::ComponentControl |
|
234 // |
|
235 // Gets a pointer to the specified component control. |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 |
|
239 CCoeControl* CStatisticsContainer::ComponentControl(TInt aIndex) const |
|
240 { |
|
241 switch ( aIndex ) |
|
242 { |
|
243 case 0: |
|
244 return iListBox; |
|
245 default: |
|
246 return NULL; |
|
247 } |
|
248 } |
|
249 |
|
250 // ---------------------------------------------------------------------------- |
|
251 // CStatisticsContainer::Draw |
|
252 // |
|
253 // Draw a control, called by window server. |
|
254 // ---------------------------------------------------------------------------- |
|
255 // |
|
256 void CStatisticsContainer::Draw(const TRect& /*aRect*/) const |
|
257 { |
|
258 // CWindowGc& gc = SystemGc(); |
|
259 } |
|
260 |
|
261 // ---------------------------------------------------------------------------- |
|
262 // CStatisticsContainer::OfferKeyEventL |
|
263 // |
|
264 // Handles key events. |
|
265 // ---------------------------------------------------------------------------- |
|
266 // |
|
267 TKeyResponse CStatisticsContainer::OfferKeyEventL( |
|
268 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
269 { |
|
270 if (aType != EEventKey) |
|
271 { |
|
272 return EKeyWasNotConsumed; |
|
273 } |
|
274 |
|
275 if (iListBox) |
|
276 { |
|
277 return iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
278 } |
|
279 else |
|
280 { |
|
281 return EKeyWasNotConsumed; |
|
282 } |
|
283 |
|
284 } |
|
285 |
|
286 // ---------------------------------------------------------------------------- |
|
287 // CStatisticsContainer::SaveActiveLine |
|
288 // |
|
289 // Makes the iListBox member save its focus position |
|
290 // ---------------------------------------------------------------------------- |
|
291 // |
|
292 void CStatisticsContainer::SaveActiveLine() |
|
293 { |
|
294 ((CMenuListBox*)iListBox)->SaveFocusPosition(); |
|
295 } |
|
296 |
|
297 // End of File |