64
|
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: CAlfPerfAppTestCaseSelectionView implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <AknUtils.h>
|
|
20 |
#include <aknViewAppUi.h>
|
|
21 |
#include <alfperfapp.rsg>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <AknBidiTextUtils.h>
|
|
24 |
#include <aknutils.h>
|
|
25 |
#include <aknnotewrappers.h>
|
|
26 |
#include <eiksbfrm.h>
|
|
27 |
#include <akndef.h>
|
|
28 |
#include <bautils.h>
|
|
29 |
#include "alfperfapptestcaseselectionview.h"
|
|
30 |
#include "alfperfapp.hrh"
|
|
31 |
#include "alfperfappconstants.h"
|
|
32 |
#include "alfperfappmodel.h"
|
|
33 |
|
|
34 |
// Execution ongoing
|
|
35 |
_LIT( KAlfPerfAppExecuting, "Executing..\n" );
|
|
36 |
|
|
37 |
// Print output path
|
|
38 |
_LIT( KAlfPerfAppPrintOutputFormat, "Result files are in %S\n" );
|
|
39 |
|
|
40 |
// Error message display
|
|
41 |
_LIT( KAlfPerfAppNoErrors, "No errors.\n\n" );
|
|
42 |
_LIT( KAlfPerfAppErrorHeader, "Errors:\n" );
|
|
43 |
_LIT( KAlfPerfappErrorItem, " %S\n" );
|
|
44 |
_LIT( KAlfPerfAppErrorFooter, "\n" );
|
|
45 |
|
|
46 |
// Results display
|
|
47 |
_LIT( KAlfPerfAppInfoNote, "Program records results directly to two files, results are appended to the end of each file.\n\n");
|
|
48 |
_LIT( KAlfPerfAppClearFilesQueryLine1, "Earlier results present.");
|
|
49 |
_LIT( KAlfPerfAppClearFilesQueryLine2, "Clear the result files?");
|
|
50 |
_LIT( KAlfPerfAppResultsHeader,
|
|
51 |
"*** Field Guide ***\n- Time spend\n- Mem.usage of app,server and system\n- Frame count and fps\n");
|
|
52 |
//_LIT( KAlfPerfAppResultsCaseStart, "%.2f s: Case: %x\n" );
|
|
53 |
_LIT( KAlfPerfAppResultsCaseStart, "Started at: %.2f s\n");
|
|
54 |
_LIT( KAlfPerfAppResultsCaseTitle, "\n=== %S / %S (0x%x) ===\n");
|
|
55 |
_LIT( KAlfPerfAppResultsNone, "No results.\n\n" );
|
|
56 |
_LIT( KAlfPerfAppSpecificResultFooter,"\n");
|
|
57 |
|
|
58 |
_LIT( KAlfPerfAppResultsPhaseTitle0,"\n*** Startup ***\n" );
|
|
59 |
_LIT( KAlfPerfAppResultsPhaseTitle1,"\n*** Run ***\n" );
|
|
60 |
_LIT( KAlfPerfAppResultsPhaseTitle2,"\n*** Teardown ***\n" );
|
|
61 |
_LIT( KAlfPerfAppResultsCaseTotalTitle,"\n*** Case total ***\n" );
|
|
62 |
_LIT( KAlfPerfAppResultsCaseItem,
|
|
63 |
"Time: %.2f s\nMem.usage: %d/%d/%d kb\nFrames: %d (%3.1f fps)\n" );
|
|
64 |
|
|
65 |
// Buffer full
|
|
66 |
const TInt KAlfPerfAppDisplayResultMaxChars = 35000; //increase is needed for Sequence test cases
|
|
67 |
_LIT( KAlfPerfAppDisplayBufferFull,"\n*** Display buffer full ***\n");
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
/**
|
|
73 |
* CAlfPerfAppTestCaseSelectionView::CContainer container class.
|
|
74 |
*/
|
|
75 |
class CAlfPerfAppTestCaseSelectionView::CContainer : public CCoeControl, MCoeControlObserver, MEikScrollBarObserver
|
|
76 |
{
|
|
77 |
public:
|
|
78 |
CContainer(CAlfPerfAppModel* aModel);
|
|
79 |
void ConstructL();
|
|
80 |
~CContainer();
|
|
81 |
|
|
82 |
public: // New functions
|
|
83 |
TBool PrintText(const TDesC& aDes);
|
|
84 |
void ClearOutputWindowL();
|
|
85 |
void UpdateVisualContentL(TBool aScrollToBottom);
|
|
86 |
|
|
87 |
public: // From base classes
|
|
88 |
virtual TKeyResponse OfferKeyEventL(
|
|
89 |
const TKeyEvent& aKeyEvent, TEventCode aType );
|
|
90 |
virtual void HandleResourceChange( TInt aType );
|
|
91 |
virtual void Draw(const TRect& aRect) const;
|
|
92 |
virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
|
|
93 |
virtual void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType); // From MEikScrollBarObserver
|
|
94 |
|
|
95 |
private:
|
|
96 |
CEikScrollBarFrame* iScrollBarFrame;
|
|
97 |
HBufC* iText;
|
|
98 |
CFont* iFont;
|
|
99 |
HBufC* iWrapperString;
|
|
100 |
CArrayFix<TPtrC>* iWrappedArray;
|
|
101 |
TInt iCurrentLine;
|
|
102 |
TInt iLineCount;
|
|
103 |
TInt iNumberOfLinesFitsScreen;
|
|
104 |
TInt iLeftDrawingPosition;
|
|
105 |
TReal iX_factor;
|
|
106 |
TReal iY_factor;
|
|
107 |
TBool iNotPrintedResultDisplayBufferExceeded;
|
|
108 |
CAlfPerfAppModel* iModel;
|
|
109 |
};
|
|
110 |
|
|
111 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
112 |
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
CAlfPerfAppTestCaseSelectionView* CAlfPerfAppTestCaseSelectionView::NewLC(
|
|
117 |
CAlfPerfAppModel& aModel )
|
|
118 |
{
|
|
119 |
CAlfPerfAppTestCaseSelectionView* self =
|
|
120 |
new (ELeave) CAlfPerfAppTestCaseSelectionView( aModel );
|
|
121 |
CleanupStack::PushL( self );
|
|
122 |
self->ConstructL();
|
|
123 |
return self;
|
|
124 |
}
|
|
125 |
|
|
126 |
// -----------------------------------------------------------------------------
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
CAlfPerfAppTestCaseSelectionView::~CAlfPerfAppTestCaseSelectionView()
|
|
130 |
{
|
|
131 |
}
|
|
132 |
|
|
133 |
// -----------------------------------------------------------------------------
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
CAlfPerfAppTestCaseSelectionView::CAlfPerfAppTestCaseSelectionView(
|
|
137 |
CAlfPerfAppModel& aModel )
|
|
138 |
: iModel( aModel )
|
|
139 |
{
|
|
140 |
}
|
|
141 |
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
// -----------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void CAlfPerfAppTestCaseSelectionView::ConstructL()
|
|
146 |
{
|
|
147 |
BaseConstructL( R_ALFPERFAPP_TEST_CASE_SELECTION_VIEW );
|
|
148 |
}
|
|
149 |
|
|
150 |
// -----------------------------------------------------------------------------
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
void CAlfPerfAppTestCaseSelectionView::CmdRunAllL()
|
|
154 |
{
|
|
155 |
// Run all test cases (that are not excluded from 'run all').
|
|
156 |
iModel.ResetErrorArray();
|
|
157 |
if (iContainer)
|
|
158 |
{
|
|
159 |
iContainer->ClearOutputWindowL();
|
|
160 |
iContainer->PrintText( KAlfPerfAppExecuting );
|
|
161 |
}
|
|
162 |
iModel.ResetExecuteArray();
|
|
163 |
|
|
164 |
const TInt suiteCount = iModel.SuiteCount();
|
|
165 |
for ( TInt ii = 0; ii < suiteCount; ii++ )
|
|
166 |
{
|
|
167 |
// If suite is not excluded from run all,
|
|
168 |
// add all test cases to execute array.
|
|
169 |
if ( !( iModel.SuiteFlags( ii ) &
|
|
170 |
EAlfPerfAppTestSuiteFlagExcludeFromRunAll ) )
|
|
171 |
{
|
|
172 |
// Add all test cases to execute array.
|
|
173 |
const TInt testCount = iModel.TestCaseCount( ii );
|
|
174 |
for ( TInt jj = 0; jj < testCount; jj++ )
|
|
175 |
{
|
|
176 |
TPtrC testName;
|
|
177 |
TInt testCaseId;
|
|
178 |
TInt testCaseFlags;
|
|
179 |
TInt testCaseSequenceLength;
|
|
180 |
|
|
181 |
iModel.GetTestCase(
|
|
182 |
ii,
|
|
183 |
jj,
|
|
184 |
testName,
|
|
185 |
testCaseId,
|
|
186 |
testCaseFlags,
|
|
187 |
testCaseSequenceLength);
|
|
188 |
|
|
189 |
// Add the test case multiple times to fill the sequence (at least once though)
|
|
190 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
191 |
for(TInt index = 1; index < testCaseSequenceLength;index++)
|
|
192 |
{
|
|
193 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
194 |
}
|
|
195 |
}
|
|
196 |
}
|
|
197 |
|
|
198 |
}
|
|
199 |
|
|
200 |
AppUi()->ActivateLocalViewL( KAlfPerfAppTestCaseExecutionViewId );
|
|
201 |
}
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
void CAlfPerfAppTestCaseSelectionView::CmdRunAllContinuouslyL()
|
|
206 |
{
|
|
207 |
// Run all test cases (that are not excluded from 'run all').
|
|
208 |
iModel.ResetErrorArray();
|
|
209 |
if (iContainer)
|
|
210 |
{
|
|
211 |
iContainer->ClearOutputWindowL();
|
|
212 |
iContainer->PrintText( KAlfPerfAppExecuting );
|
|
213 |
}
|
|
214 |
iModel.ResetExecuteArray();
|
|
215 |
|
|
216 |
const TInt suiteCount = iModel.SuiteCount();
|
|
217 |
for ( TInt ii = 0; ii < suiteCount; ii++ )
|
|
218 |
{
|
|
219 |
// If suite is not excluded from run all,
|
|
220 |
// add all test cases to execute array.
|
|
221 |
if ( !( iModel.SuiteFlags( ii ) &
|
|
222 |
EAlfPerfAppTestSuiteFlagExcludeFromRunAll ) )
|
|
223 |
{
|
|
224 |
// Add all test cases to execute array.
|
|
225 |
const TInt testCount = iModel.TestCaseCount( ii );
|
|
226 |
for ( TInt jj = 0; jj < testCount; jj++ )
|
|
227 |
{
|
|
228 |
TPtrC testName;
|
|
229 |
TInt testCaseId;
|
|
230 |
TInt testCaseFlags;
|
|
231 |
TInt testCaseSequenceLength;
|
|
232 |
|
|
233 |
iModel.GetTestCase(
|
|
234 |
ii,
|
|
235 |
jj,
|
|
236 |
testName,
|
|
237 |
testCaseId,
|
|
238 |
testCaseFlags,
|
|
239 |
testCaseSequenceLength);
|
|
240 |
|
|
241 |
// Add the test case multiple times to fill the sequence (at least once though)
|
|
242 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
243 |
for(TInt index = 1; index < testCaseSequenceLength;index++)
|
|
244 |
{
|
|
245 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
246 |
}
|
|
247 |
}
|
|
248 |
}
|
|
249 |
|
|
250 |
}
|
|
251 |
|
|
252 |
// Finally tell ExecutionView to use Continuous Run
|
|
253 |
const TUid KCustomMessageUid = {2};
|
|
254 |
TBuf8<KAlfPerfAppMaxCharsInLine> customMessage;
|
|
255 |
customMessage.Copy(_L8("UseContinuousRun"));
|
|
256 |
AppUi()->ActivateLocalViewL( KAlfPerfAppTestCaseExecutionViewId,KCustomMessageUid,customMessage);
|
|
257 |
}
|
|
258 |
|
|
259 |
|
|
260 |
// -----------------------------------------------------------------------------
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void CAlfPerfAppTestCaseSelectionView::CmdRunAllFromSuiteL(
|
|
264 |
TInt aSuiteIndex )
|
|
265 |
{
|
|
266 |
// Run all test cases related to specific suite.
|
|
267 |
const TInt testCaseCount = iModel.TestCaseCount( aSuiteIndex );
|
|
268 |
iModel.ResetErrorArray();
|
|
269 |
|
|
270 |
if (iContainer)
|
|
271 |
{
|
|
272 |
iContainer->ClearOutputWindowL();
|
|
273 |
iContainer->PrintText( KAlfPerfAppExecuting );
|
|
274 |
}
|
|
275 |
|
|
276 |
iModel.ResetExecuteArray();
|
|
277 |
|
|
278 |
for ( TInt ii = 0; ii < testCaseCount; ii++ )
|
|
279 |
{
|
|
280 |
TPtrC testCaseName;
|
|
281 |
TInt testCaseId;
|
|
282 |
TInt testCaseFlags;
|
|
283 |
TInt testCaseSequenceLength;
|
|
284 |
|
|
285 |
iModel.GetTestCase(
|
|
286 |
aSuiteIndex,
|
|
287 |
ii,
|
|
288 |
testCaseName,
|
|
289 |
testCaseId,
|
|
290 |
testCaseFlags,
|
|
291 |
testCaseSequenceLength);
|
|
292 |
|
|
293 |
// Add the test case multiple times to fill the sequence (at least once though)
|
|
294 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
295 |
for(TInt index = 1; index < testCaseSequenceLength;index++)
|
|
296 |
{
|
|
297 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
298 |
}
|
|
299 |
|
|
300 |
AppUi()->ActivateLocalViewL( KAlfPerfAppTestCaseExecutionViewId );
|
|
301 |
}
|
|
302 |
}
|
|
303 |
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
// -----------------------------------------------------------------------------
|
|
306 |
//
|
|
307 |
void CAlfPerfAppTestCaseSelectionView::CmdRunTestCaseL(
|
|
308 |
TInt aSuiteIndex, TInt aTestCaseIndex )
|
|
309 |
{
|
|
310 |
TPtrC testCaseName;
|
|
311 |
TInt testCaseId;
|
|
312 |
TInt testCaseFlags;
|
|
313 |
TInt testCaseSequenceLength;
|
|
314 |
|
|
315 |
iModel.GetTestCase(
|
|
316 |
aSuiteIndex,
|
|
317 |
aTestCaseIndex,
|
|
318 |
testCaseName,
|
|
319 |
testCaseId,
|
|
320 |
testCaseFlags,
|
|
321 |
testCaseSequenceLength);
|
|
322 |
|
|
323 |
iModel.ResetErrorArray();
|
|
324 |
if (iContainer)
|
|
325 |
{
|
|
326 |
iContainer->ClearOutputWindowL();
|
|
327 |
iContainer->PrintText( KAlfPerfAppExecuting );
|
|
328 |
}
|
|
329 |
iModel.ResetExecuteArray();
|
|
330 |
|
|
331 |
// Add the test case multiple times to fill the sequence (at least once though)
|
|
332 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
333 |
for(TInt index = 1; index < testCaseSequenceLength;index++)
|
|
334 |
{
|
|
335 |
iModel.AddToExecuteArrayL( testCaseId );
|
|
336 |
}
|
|
337 |
|
|
338 |
AppUi()->ActivateLocalViewL( KAlfPerfAppTestCaseExecutionViewId );
|
|
339 |
}
|
|
340 |
|
|
341 |
// -----------------------------------------------------------------------------
|
|
342 |
// -----------------------------------------------------------------------------
|
|
343 |
//
|
|
344 |
TUid CAlfPerfAppTestCaseSelectionView::Id() const
|
|
345 |
{
|
|
346 |
return KAlfPerfAppTestCaseSelectionViewId;
|
|
347 |
}
|
|
348 |
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
// Handles view activation
|
|
351 |
// -----------------------------------------------------------------------------
|
|
352 |
//
|
|
353 |
void CAlfPerfAppTestCaseSelectionView::DoActivateL(
|
|
354 |
const TVwsViewId& /*aPrevViewId*/,
|
|
355 |
TUid /*aCustomMessageId*/,
|
|
356 |
const TDesC8& /*aCustomMessage*/ )
|
|
357 |
{
|
|
358 |
ResetContainerL();
|
|
359 |
|
|
360 |
DisplayResultsL();
|
|
361 |
|
|
362 |
// Pop up the "Clear result files?"-dialog if either of the files existed.
|
|
363 |
static TBool firstTime = ETrue;
|
|
364 |
if(firstTime)
|
|
365 |
{
|
|
366 |
if(iModel.TargetFilesExisted())
|
|
367 |
{
|
|
368 |
if(CEikonEnv::Static()->QueryWinL(KAlfPerfAppClearFilesQueryLine1,KAlfPerfAppClearFilesQueryLine2))
|
|
369 |
{
|
|
370 |
// Clear the files
|
|
371 |
iModel.OpenFilesL(true);
|
|
372 |
}
|
|
373 |
firstTime = EFalse;
|
|
374 |
}
|
|
375 |
}
|
|
376 |
}
|
|
377 |
|
|
378 |
// -----------------------------------------------------------------------------
|
|
379 |
// Handles view deactivation
|
|
380 |
// -----------------------------------------------------------------------------
|
|
381 |
//
|
|
382 |
void CAlfPerfAppTestCaseSelectionView::DoDeactivate()
|
|
383 |
{
|
|
384 |
if ( iContainer )
|
|
385 |
{
|
|
386 |
AppUi()->RemoveFromStack( iContainer );
|
|
387 |
delete iContainer;
|
|
388 |
iContainer = NULL;
|
|
389 |
}
|
|
390 |
}
|
|
391 |
|
|
392 |
|
|
393 |
// -----------------------------------------------------------------------------
|
|
394 |
// Display test results on screen. The text is wrapped.
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
void CAlfPerfAppTestCaseSelectionView::DisplayResultsL()
|
|
398 |
{
|
|
399 |
if (iContainer)
|
|
400 |
{
|
|
401 |
TBuf<KAlfPerfAppMaxCharsInLine> line;
|
|
402 |
iContainer->ClearOutputWindowL();
|
|
403 |
|
|
404 |
const TInt errorCount = iModel.ErrorArrayCount();
|
|
405 |
if ( !errorCount )
|
|
406 |
{
|
|
407 |
iContainer->PrintText( KAlfPerfAppNoErrors );
|
|
408 |
}
|
|
409 |
else
|
|
410 |
{
|
|
411 |
iContainer->PrintText( KAlfPerfAppErrorHeader );
|
|
412 |
for ( TInt ii = 0; ii < errorCount; ii++ )
|
|
413 |
{
|
|
414 |
TPtrC message;
|
|
415 |
iModel.GetFromErrorArray( ii, message );
|
|
416 |
if ( message.Length() )
|
|
417 |
{
|
|
418 |
line.Zero();
|
|
419 |
TPtrC item = message.Left( 64 );
|
|
420 |
line.Format( KAlfPerfappErrorItem, &item );
|
|
421 |
iContainer->PrintText( line );
|
|
422 |
}
|
|
423 |
}
|
|
424 |
iContainer->PrintText( KAlfPerfAppErrorFooter );
|
|
425 |
}
|
|
426 |
|
|
427 |
if (iModel.ResultsNotAddedToFile())
|
|
428 |
{
|
|
429 |
iContainer->PrintText( KAlfPerfAppResultsNone );
|
|
430 |
iContainer->PrintText( KAlfPerfAppInfoNote );
|
|
431 |
}
|
|
432 |
else
|
|
433 |
{
|
|
434 |
line.Zero();
|
|
435 |
line.Format( KAlfPerfAppResultsHeader );
|
|
436 |
iContainer->PrintText(line);
|
|
437 |
|
|
438 |
// Prepare to read lines
|
|
439 |
TFileText LineFromFile;
|
|
440 |
LineFromFile.Set(*iModel.ResultFile());
|
|
441 |
LineFromFile.Seek(ESeekStart);
|
|
442 |
|
|
443 |
// Read the first line and forget it (header info only)
|
|
444 |
line.Copy(getLineFromTargetFile());
|
|
445 |
|
|
446 |
TInt currentCase = 0;
|
|
447 |
TBool startTimeNotRecorded = ETrue;
|
|
448 |
TUint32 timeStampAtStart = 0;
|
|
449 |
TInt framesSinceCase = 0;
|
|
450 |
CAlfPerfAppModel::TTestCaseResultItem itemAtCase;
|
|
451 |
CAlfPerfAppModel::TTestCaseResultItem itemAtPhase;
|
|
452 |
TBuf8<KAlfPerfAppMaxCharsInSpecificResultText> specificResultStorage;
|
|
453 |
for(TInt i=0; ; i++) // i = line number in result file
|
|
454 |
{
|
|
455 |
line.Zero();
|
|
456 |
|
|
457 |
// Read a line from file and convert it to an TTestCaseResultItem
|
|
458 |
line.Copy(getLineFromTargetFile());
|
|
459 |
if(line.Length() == 0)
|
|
460 |
{
|
|
461 |
// If the line is empty, end this loop
|
|
462 |
break;
|
|
463 |
}
|
|
464 |
CAlfPerfAppModel::TTestCaseResultItem item;
|
|
465 |
item = ResultItemFromLine(line);
|
|
466 |
line.Zero();
|
|
467 |
|
|
468 |
if(startTimeNotRecorded)
|
|
469 |
{
|
|
470 |
timeStampAtStart = item.iTimeStamp;
|
|
471 |
startTimeNotRecorded = EFalse;
|
|
472 |
}
|
|
473 |
|
|
474 |
TUint32 timeFromStart =
|
|
475 |
DeltaFromCurrentToPrevious(
|
|
476 |
item.iTimeStamp, timeStampAtStart );
|
|
477 |
|
|
478 |
TBool changedCase = EFalse;
|
|
479 |
if ( !i || currentCase != item.iCaseId )
|
|
480 |
{
|
|
481 |
currentCase = item.iCaseId;
|
|
482 |
itemAtCase = item;
|
|
483 |
framesSinceCase = 0;
|
|
484 |
changedCase = ETrue;
|
|
485 |
//specificResultStorage.Zero();
|
|
486 |
}
|
|
487 |
|
|
488 |
if(changedCase || itemAtPhase.iPhase != item.iPhase)
|
|
489 |
{
|
|
490 |
itemAtPhase = item;
|
|
491 |
}
|
|
492 |
|
|
493 |
if ( changedCase )
|
|
494 |
{
|
|
495 |
// Name
|
|
496 |
TBuf<100> suiteName;
|
|
497 |
suiteName.Copy(item.iSuiteName);
|
|
498 |
TBuf<100> caseName;
|
|
499 |
caseName.Copy(item.iCaseName);
|
|
500 |
line.Format(
|
|
501 |
KAlfPerfAppResultsCaseTitle,
|
|
502 |
&suiteName,
|
|
503 |
&caseName,
|
|
504 |
item.iCaseId);
|
|
505 |
if(!iContainer->PrintText(line))break;
|
|
506 |
line.Zero();
|
|
507 |
|
|
508 |
// Start time
|
|
509 |
line.AppendFormat( KAlfPerfAppResultsCaseStart,
|
|
510 |
((TReal32)timeFromStart/1000));
|
|
511 |
if(!iContainer->PrintText(line))break;
|
|
512 |
line.Zero();
|
|
513 |
}
|
|
514 |
|
|
515 |
if(item.specificResult8.Length() != 0)
|
|
516 |
{
|
|
517 |
specificResultStorage.Zero();
|
|
518 |
specificResultStorage.Append(item.specificResult8);
|
|
519 |
}
|
|
520 |
|
|
521 |
if(i&0x1) // Skip even lines
|
|
522 |
{
|
|
523 |
// Print phase data
|
|
524 |
if (item.iPhase == 0)
|
|
525 |
{
|
|
526 |
line.AppendFormat(KAlfPerfAppResultsPhaseTitle0);
|
|
527 |
}
|
|
528 |
else if (item.iPhase == 1)
|
|
529 |
{
|
|
530 |
line.AppendFormat(KAlfPerfAppResultsPhaseTitle1);
|
|
531 |
}
|
|
532 |
else
|
|
533 |
{
|
|
534 |
line.AppendFormat(KAlfPerfAppResultsPhaseTitle2);
|
|
535 |
}
|
|
536 |
|
|
537 |
line.AppendFormat( KAlfPerfAppResultsCaseItem,
|
|
538 |
// duration
|
|
539 |
((TReal32)item.imsSincePhase)/1000,
|
|
540 |
// memory consumption delta
|
|
541 |
( item.iAppMemory - itemAtPhase.iAppMemory )/ 1024,
|
|
542 |
( item.iServerMemory - itemAtPhase.iServerMemory )/ 1024,
|
|
543 |
( item.iSystemMemory - itemAtPhase.iSystemMemory )/ 1024,
|
|
544 |
// frame info
|
|
545 |
item.iFrameCount,
|
|
546 |
item.iFPS );
|
|
547 |
if(!iContainer->PrintText(line))break;
|
|
548 |
line.Zero();
|
|
549 |
|
|
550 |
// Testcase specific results
|
|
551 |
if(specificResultStorage.Length() != 0)
|
|
552 |
{
|
|
553 |
TBuf<KAlfPerfAppMaxCharsInSpecificResultText> specificResult16;
|
|
554 |
specificResult16.Copy(specificResultStorage);
|
|
555 |
line.Append(specificResult16);
|
|
556 |
line.Append(KAlfPerfAppSpecificResultFooter);
|
|
557 |
if(!iContainer->PrintText(line))break;
|
|
558 |
specificResultStorage.Zero();
|
|
559 |
line.Zero();
|
|
560 |
}
|
|
561 |
|
|
562 |
|
|
563 |
framesSinceCase += item.iFrameCount;
|
|
564 |
if (item.iPhase == 2)
|
|
565 |
{
|
|
566 |
// Print case data
|
|
567 |
// need to be done like this because of fpsSinceCase is not
|
|
568 |
// recorded to file
|
|
569 |
TUint32 timeFromCase = item.imsSinceCase;
|
|
570 |
|
|
571 |
TReal32 fpsSinceCase = 0.f;
|
|
572 |
if ( timeFromCase != 0 )
|
|
573 |
{
|
|
574 |
fpsSinceCase = ((TReal32)framesSinceCase*1000)/timeFromCase;
|
|
575 |
}
|
|
576 |
|
|
577 |
line.AppendFormat(KAlfPerfAppResultsCaseTotalTitle);
|
|
578 |
if(!iContainer->PrintText(line))break;
|
|
579 |
|
|
580 |
line.Format( KAlfPerfAppResultsCaseItem,
|
|
581 |
// duration
|
|
582 |
((TReal32)timeFromCase/1000),
|
|
583 |
// memory consumption delta
|
|
584 |
( item.iAppMemory - itemAtCase.iAppMemory )/ 1024,
|
|
585 |
( item.iServerMemory - itemAtCase.iServerMemory )/ 1024,
|
|
586 |
( item.iSystemMemory - itemAtCase.iSystemMemory )/ 1024,
|
|
587 |
// frame info
|
|
588 |
framesSinceCase,
|
|
589 |
fpsSinceCase );
|
|
590 |
|
|
591 |
if(!iContainer->PrintText(line))break;
|
|
592 |
line.Zero();
|
|
593 |
}
|
|
594 |
|
|
595 |
}
|
|
596 |
}
|
|
597 |
}
|
|
598 |
|
|
599 |
TBuf<KAlfPerfAppMaxCharsInLine> temp = iModel.TargetPath();
|
|
600 |
line.Format( KAlfPerfAppPrintOutputFormat, &temp);
|
|
601 |
iContainer->PrintText(line);
|
|
602 |
|
|
603 |
// Finally update results to screen
|
|
604 |
iContainer->UpdateVisualContentL(ETrue);
|
|
605 |
}
|
|
606 |
}
|
|
607 |
|
|
608 |
|
|
609 |
// -----------------------------------------------------------------------------
|
|
610 |
// Handles test case selection view specific commands.
|
|
611 |
// -----------------------------------------------------------------------------
|
|
612 |
//
|
|
613 |
void CAlfPerfAppTestCaseSelectionView::HandleCommandL( TInt aCommand )
|
|
614 |
{
|
|
615 |
switch ( aCommand )
|
|
616 |
{
|
|
617 |
case EAlfPerfAppCmdRunAll:
|
|
618 |
CmdRunAllL();
|
|
619 |
break;
|
|
620 |
|
|
621 |
case EAlfPerfAppCmdRunAllContinuously:
|
|
622 |
CmdRunAllContinuouslyL();
|
|
623 |
break;
|
|
624 |
|
|
625 |
case EAlfPerfAppCmdClearFiles:
|
|
626 |
|
|
627 |
TBuf<1> empty;
|
|
628 |
if(CEikonEnv::Static()->QueryWinL(KAlfPerfAppClearFilesQueryLine2,empty))
|
|
629 |
{
|
|
630 |
// Clear the files
|
|
631 |
iModel.OpenFilesL(true);
|
|
632 |
ResetContainerL();
|
|
633 |
DisplayResultsL();
|
|
634 |
}
|
|
635 |
|
|
636 |
break;
|
|
637 |
|
|
638 |
|
|
639 |
default:
|
|
640 |
{
|
|
641 |
if ( ( aCommand & ~0xFFFF ) == EAlfPerfAppCmdTestCase )
|
|
642 |
{
|
|
643 |
const TInt testSuiteIndex = ( aCommand & 0xFF00 ) >> 8;
|
|
644 |
TInt testCaseIndex = aCommand & 0xFF;
|
|
645 |
|
|
646 |
if ( !testCaseIndex )
|
|
647 |
{
|
|
648 |
CmdRunAllFromSuiteL( testSuiteIndex );
|
|
649 |
}
|
|
650 |
else
|
|
651 |
{
|
|
652 |
// Run one specific test case
|
|
653 |
testCaseIndex--;
|
|
654 |
CmdRunTestCaseL( testSuiteIndex, testCaseIndex );
|
|
655 |
}
|
|
656 |
}
|
|
657 |
else
|
|
658 |
{
|
|
659 |
AppUi()->HandleCommandL( aCommand );
|
|
660 |
}
|
|
661 |
}
|
|
662 |
break;
|
|
663 |
}
|
|
664 |
}
|
|
665 |
|
|
666 |
|
|
667 |
// -----------------------------------------------------------------------------
|
|
668 |
// -----------------------------------------------------------------------------
|
|
669 |
//
|
|
670 |
void CAlfPerfAppTestCaseSelectionView::RestoreMenuL(
|
|
671 |
CCoeControl* aMenuControl, TInt aResourceId, TMenuType aType )
|
|
672 |
{
|
|
673 |
// Override resource in case of test suite menu
|
|
674 |
iResourceId = 0;
|
|
675 |
|
|
676 |
if ( ( aResourceId & ~0xFFFF ) == KAlfPerfAppMenuPaneResourceId )
|
|
677 |
{
|
|
678 |
iResourceId = aResourceId;
|
|
679 |
aResourceId = R_ALFPERFAPP_TEST_CASE_SELECTION_SUITE_MENUPANE;
|
|
680 |
}
|
|
681 |
|
|
682 |
CAknView::RestoreMenuL(
|
|
683 |
aMenuControl,
|
|
684 |
aResourceId,
|
|
685 |
aType );
|
|
686 |
}
|
|
687 |
|
|
688 |
// -----------------------------------------------------------------------------
|
|
689 |
// -----------------------------------------------------------------------------
|
|
690 |
//
|
|
691 |
void CAlfPerfAppTestCaseSelectionView::DynInitMenuPaneL(
|
|
692 |
TInt aResourceId,
|
|
693 |
CEikMenuPane* aMenuPane )
|
|
694 |
{
|
|
695 |
if ( aResourceId == R_ALFPERFAPP_TEST_CASE_SELECTION_MENUPANE )
|
|
696 |
{
|
|
697 |
// Add all suites to top level options menu.
|
|
698 |
const TInt suiteCount = iModel.SuiteCount();
|
|
699 |
for ( TInt ii = suiteCount - 1; ii >= 0; ii-- )
|
|
700 |
{
|
|
701 |
CEikMenuPaneItem::SData data;
|
|
702 |
data.iCommandId = 0;
|
|
703 |
data.iCascadeId = KAlfPerfAppMenuPaneResourceId + (ii << 8);
|
|
704 |
data.iFlags = 0;
|
|
705 |
data.iText.Copy( iModel.SuiteName( ii ) );
|
|
706 |
data.iExtraText.Zero();
|
|
707 |
|
|
708 |
aMenuPane->AddMenuItemL( data, EAlfPerfAppCmdRunAllContinuously );
|
|
709 |
}
|
|
710 |
}
|
|
711 |
|
|
712 |
if ( aResourceId == R_ALFPERFAPP_TEST_CASE_SELECTION_SUITE_MENUPANE )
|
|
713 |
{
|
|
714 |
const TInt suiteIndex = ( iResourceId & 0xFF00 ) >> 8;
|
|
715 |
const TInt testCaseCount = iModel.TestCaseCount( suiteIndex );
|
|
716 |
|
|
717 |
// Add 'Run All' option
|
|
718 |
HBufC* runAllText = StringLoader::LoadLC( R_ALFPERFAPP_TEXT_RUNALL );
|
|
719 |
CEikMenuPaneItem::SData runAll;
|
|
720 |
runAll.iCommandId = EAlfPerfAppCmdTestCase + (suiteIndex << 8);
|
|
721 |
runAll.iCascadeId = 0;
|
|
722 |
runAll.iFlags = 0;
|
|
723 |
runAll.iText.Copy( *runAllText );
|
|
724 |
runAll.iExtraText.Zero();
|
|
725 |
aMenuPane->AddMenuItemL( runAll );
|
|
726 |
CleanupStack::PopAndDestroy( runAllText );
|
|
727 |
|
|
728 |
// Add options menu items for all test cases of this suite
|
|
729 |
for ( TInt ii = 0; ii < testCaseCount; ii++ )
|
|
730 |
{
|
|
731 |
CEikMenuPaneItem::SData data;
|
|
732 |
data.iCommandId = EAlfPerfAppCmdTestCase + (suiteIndex << 8) + ii + 1;
|
|
733 |
data.iCascadeId = 0;
|
|
734 |
data.iFlags = 0;
|
|
735 |
|
|
736 |
TPtrC testCaseName;
|
|
737 |
TInt testCaseId;
|
|
738 |
TInt flags;
|
|
739 |
TInt sequenceLength;
|
|
740 |
|
|
741 |
iModel.GetTestCase(
|
|
742 |
suiteIndex,
|
|
743 |
ii,
|
|
744 |
testCaseName,
|
|
745 |
testCaseId,
|
|
746 |
flags,
|
|
747 |
sequenceLength);
|
|
748 |
|
|
749 |
data.iText.Copy( testCaseName );
|
|
750 |
data.iExtraText.Zero();
|
|
751 |
|
|
752 |
aMenuPane->AddMenuItemL( data );
|
|
753 |
}
|
|
754 |
}
|
|
755 |
}
|
|
756 |
|
|
757 |
TBuf8<KAlfPerfAppMaxCharsInLine> CAlfPerfAppTestCaseSelectionView::getLineFromTargetFile()
|
|
758 |
{
|
|
759 |
TBuf8<KAlfPerfAppMaxCharsInLine> line;
|
|
760 |
TBuf8<1> character;
|
|
761 |
iModel.ResultFile()->Read(character,1);
|
|
762 |
if(character.Length() == 0)
|
|
763 |
{
|
|
764 |
// File was empty --> return empty line
|
|
765 |
return line;
|
|
766 |
}
|
|
767 |
while(character[0] != '\n')
|
|
768 |
{
|
|
769 |
line.Append(character);
|
|
770 |
iModel.ResultFile()->Read(character,1);
|
|
771 |
}
|
|
772 |
return line;
|
|
773 |
}
|
|
774 |
|
|
775 |
void CAlfPerfAppTestCaseSelectionView::ResetContainerL()
|
|
776 |
{
|
|
777 |
// Reset the container
|
|
778 |
if ( iContainer )
|
|
779 |
{
|
|
780 |
AppUi()->RemoveFromStack( iContainer );
|
|
781 |
delete iContainer;
|
|
782 |
iContainer = NULL;
|
|
783 |
}
|
|
784 |
CContainer* container = new (ELeave) CContainer(&iModel);
|
|
785 |
CleanupStack::PushL( container );
|
|
786 |
container->ConstructL();
|
|
787 |
AppUi()->AddToStackL( *this, container );
|
|
788 |
CleanupStack::Pop( container );
|
|
789 |
iContainer = container;
|
|
790 |
}
|
|
791 |
|
|
792 |
|
|
793 |
// Let's create a function template for extracting items from lexer
|
|
794 |
TBuf<KAlfPerfAppMaxCharsInLine>& ProcessLexer(TLex& aLexer, TChar aSeparator,TBuf<KAlfPerfAppMaxCharsInLine>& aToken)
|
|
795 |
{
|
|
796 |
aToken.Zero();
|
|
797 |
TChar ch;
|
|
798 |
aLexer.SkipAndMark(0);
|
|
799 |
while (!aLexer.Eos())
|
|
800 |
{
|
|
801 |
ch = aLexer.Get();
|
|
802 |
if(ch == aSeparator)
|
|
803 |
{
|
|
804 |
aLexer.UnGet();
|
|
805 |
aToken.Append(aLexer.MarkedToken());
|
|
806 |
aLexer.SkipAndMark(1);
|
|
807 |
break;
|
|
808 |
}
|
|
809 |
}
|
|
810 |
return aToken;
|
|
811 |
}
|
|
812 |
|
|
813 |
CAlfPerfAppModel::TTestCaseResultItem CAlfPerfAppTestCaseSelectionView::ResultItemFromLine(TBuf<KAlfPerfAppMaxCharsInLine>& aLine)
|
|
814 |
{
|
|
815 |
CAlfPerfAppModel::TTestCaseResultItem item;
|
|
816 |
|
|
817 |
TBuf<KAlfPerfAppMaxCharsInLine> temp;
|
|
818 |
TLex lexer(aLine);
|
|
819 |
TLex tempLex;
|
|
820 |
|
|
821 |
item.iSuiteName.Copy(ProcessLexer(lexer,'/',temp));
|
|
822 |
item.iSuiteName.Trim();
|
|
823 |
item.iCaseName.Copy(ProcessLexer(lexer,',',temp));
|
|
824 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
825 |
item.iCaseName.Trim();
|
|
826 |
tempLex.Val(item.iCaseId);
|
|
827 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
828 |
tempLex.Val(item.iPhase);
|
|
829 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
830 |
tempLex.Val(item.iTimeStamp,EDecimal);
|
|
831 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
832 |
tempLex.Val(item.iAppCells);
|
|
833 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
834 |
tempLex.Val(item.iAppMemory);
|
|
835 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
836 |
tempLex.Val(item.iAppFree);
|
|
837 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
838 |
tempLex.Val(item.iServerCells);
|
|
839 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
840 |
tempLex.Val(item.iServerMemory);
|
|
841 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
842 |
tempLex.Val(item.iServerFree);
|
|
843 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
844 |
tempLex.Val(item.iSystemMemory);
|
|
845 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
846 |
tempLex.Val(item.iSystemFree);
|
|
847 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
848 |
tempLex.Val(item.iFrameCount,EDecimal);
|
|
849 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
850 |
tempLex.Val(item.imsSinceCase,EDecimal);
|
|
851 |
tempLex.Assign(ProcessLexer(lexer,',',temp));
|
|
852 |
tempLex.Val(item.imsSincePhase,EDecimal);
|
|
853 |
TBuf<15> fpsBuffer (ProcessLexer(lexer,',',temp));
|
|
854 |
tempLex.Assign(fpsBuffer);
|
|
855 |
tempLex.Val(item.iFPS);
|
|
856 |
item.specificResult8.Copy(lexer.Remainder());
|
|
857 |
item.specificResult8.Delete(item.specificResult8.Length()-1,1);
|
|
858 |
|
|
859 |
return item;
|
|
860 |
}
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
// Implementation of DeltaFromCurrentToPrevious
|
|
865 |
TUint32 CAlfPerfAppTestCaseSelectionView::DeltaFromCurrentToPrevious(
|
|
866 |
TUint32 aCurrent, TUint32 aPrevious )
|
|
867 |
{
|
|
868 |
// It's expected that execution of all test suites take less
|
|
869 |
// than KMaxTInt ms (so that it fits to TInt).
|
|
870 |
|
|
871 |
TUint64 delta = 0;
|
|
872 |
if ( aPrevious <= aCurrent )
|
|
873 |
{
|
|
874 |
// aPrevious .. aCurrent
|
|
875 |
delta = aCurrent - aPrevious;
|
|
876 |
}
|
|
877 |
else
|
|
878 |
{
|
|
879 |
// Overflow has occurred.
|
|
880 |
// aPrevious .. 2**32 + aCurrent
|
|
881 |
|
|
882 |
delta = 0xFFFFFFFF;
|
|
883 |
delta -= aPrevious;
|
|
884 |
delta++;
|
|
885 |
delta += aCurrent;
|
|
886 |
}
|
|
887 |
|
|
888 |
if ( delta >= KMaxTInt )
|
|
889 |
{
|
|
890 |
delta = KMaxTInt;
|
|
891 |
}
|
|
892 |
|
|
893 |
return I64LOW( delta );
|
|
894 |
}
|
|
895 |
|
|
896 |
|
|
897 |
// Implementation of CAlfPerfAppTestCaseSelectionView::CContainer:
|
|
898 |
// -----------------------------------------------------------------------------
|
|
899 |
//
|
|
900 |
CAlfPerfAppTestCaseSelectionView::CContainer::CContainer(CAlfPerfAppModel* aModel)
|
|
901 |
{
|
|
902 |
iModel = aModel;
|
|
903 |
}
|
|
904 |
|
|
905 |
// -----------------------------------------------------------------------------
|
|
906 |
//
|
|
907 |
void CAlfPerfAppTestCaseSelectionView::CContainer::ConstructL()
|
|
908 |
{
|
|
909 |
CreateWindowL();
|
|
910 |
|
|
911 |
TRect rect;
|
|
912 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect );
|
|
913 |
SetRect( rect );
|
|
914 |
|
|
915 |
iText = HBufC::NewL(KAlfPerfScreenTextBufferSize);
|
|
916 |
iCurrentLine = 0;
|
|
917 |
iLineCount = 0;
|
|
918 |
iNumberOfLinesFitsScreen = 0;
|
|
919 |
iX_factor = 1;
|
|
920 |
iY_factor = 1;
|
|
921 |
iLeftDrawingPosition = KAlfPerfAppLeftMargin;
|
|
922 |
|
|
923 |
TFontSpec myFontSpec(KAlfPerfAppFontName,KAlfPerfAppFontSizeInTwips);
|
|
924 |
CGraphicsDevice* screenDevice=iCoeEnv->ScreenDevice();
|
|
925 |
screenDevice->GetNearestFontInTwips(iFont,myFontSpec);
|
|
926 |
|
|
927 |
iWrappedArray = new(ELeave) CArrayFixFlat<TPtrC>(KAlfPerfScreenWrappedArraySize);
|
|
928 |
|
|
929 |
iNotPrintedResultDisplayBufferExceeded = ETrue;
|
|
930 |
|
|
931 |
ActivateL();
|
|
932 |
}
|
|
933 |
|
|
934 |
|
|
935 |
|
|
936 |
// -----------------------------------------------------------------------------
|
|
937 |
// -----------------------------------------------------------------------------
|
|
938 |
//
|
|
939 |
CAlfPerfAppTestCaseSelectionView::CContainer::~CContainer()
|
|
940 |
{
|
|
941 |
// Destroy the font
|
|
942 |
iCoeEnv->ScreenDevice()->ReleaseFont(iFont);
|
|
943 |
|
|
944 |
if (iWrappedArray)
|
|
945 |
{
|
|
946 |
iWrappedArray->Reset();
|
|
947 |
delete iWrappedArray;
|
|
948 |
}
|
|
949 |
|
|
950 |
if (iText)
|
|
951 |
delete iText;
|
|
952 |
|
|
953 |
if (iScrollBarFrame)
|
|
954 |
delete iScrollBarFrame;
|
|
955 |
|
|
956 |
if (iWrapperString)
|
|
957 |
delete iWrapperString;
|
|
958 |
}
|
|
959 |
|
|
960 |
|
|
961 |
// -----------------------------------------------------------------------------
|
|
962 |
// -----------------------------------------------------------------------------
|
|
963 |
//
|
|
964 |
TKeyResponse CAlfPerfAppTestCaseSelectionView::CContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
|
|
965 |
{
|
|
966 |
if(aType != EEventKey)
|
|
967 |
return EKeyWasConsumed;
|
|
968 |
|
|
969 |
if(aKeyEvent.iCode == EKeyUpArrow)
|
|
970 |
{
|
|
971 |
if (iCurrentLine > 0)
|
|
972 |
{
|
|
973 |
iCurrentLine--;
|
|
974 |
UpdateVisualContentL(EFalse);
|
|
975 |
}
|
|
976 |
|
|
977 |
return EKeyWasConsumed;
|
|
978 |
}
|
|
979 |
|
|
980 |
else if(aKeyEvent.iCode == EKeyDownArrow)
|
|
981 |
{
|
|
982 |
if (iCurrentLine < iLineCount - iNumberOfLinesFitsScreen)
|
|
983 |
{
|
|
984 |
iCurrentLine++;
|
|
985 |
UpdateVisualContentL(EFalse);
|
|
986 |
}
|
|
987 |
|
|
988 |
return EKeyWasConsumed;
|
|
989 |
}
|
|
990 |
|
|
991 |
return EKeyWasConsumed;
|
|
992 |
}
|
|
993 |
|
|
994 |
|
|
995 |
// -----------------------------------------------------------------------------
|
|
996 |
// -----------------------------------------------------------------------------
|
|
997 |
//
|
|
998 |
void CAlfPerfAppTestCaseSelectionView::CContainer::HandleResourceChange(TInt aType)
|
|
999 |
{
|
|
1000 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
1001 |
{
|
|
1002 |
TRect mainPaneRect;
|
|
1003 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
|
|
1004 |
SetRect(mainPaneRect);
|
|
1005 |
|
|
1006 |
iCurrentLine = 0; // scroll to top
|
|
1007 |
|
|
1008 |
// update font
|
|
1009 |
// Discard and destroy the font
|
|
1010 |
iCoeEnv->ScreenDevice()->ReleaseFont(iFont);
|
|
1011 |
|
|
1012 |
// Create the font
|
|
1013 |
TFontSpec myFontSpec(KAlfPerfAppFontName,KAlfPerfAppFontSizeInTwips);
|
|
1014 |
CGraphicsDevice* screenDevice=iCoeEnv->ScreenDevice();
|
|
1015 |
screenDevice->GetNearestFontInTwips(iFont,myFontSpec);
|
|
1016 |
|
|
1017 |
// delete the scroll and update screen
|
|
1018 |
if (iScrollBarFrame)
|
|
1019 |
{
|
|
1020 |
delete iScrollBarFrame;
|
|
1021 |
iScrollBarFrame = NULL;
|
|
1022 |
}
|
|
1023 |
TRAP_IGNORE(UpdateVisualContentL(EFalse));
|
|
1024 |
}
|
|
1025 |
else
|
|
1026 |
{
|
|
1027 |
CCoeControl::HandleResourceChange(aType);
|
|
1028 |
}
|
|
1029 |
}
|
|
1030 |
|
|
1031 |
|
|
1032 |
// -----------------------------------------------------------------------------
|
|
1033 |
// -----------------------------------------------------------------------------
|
|
1034 |
//
|
|
1035 |
void CAlfPerfAppTestCaseSelectionView::CContainer::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType)
|
|
1036 |
{
|
|
1037 |
// only on page up/down,scroll up/down and drag events
|
|
1038 |
if ((aEventType == EEikScrollPageDown) || (aEventType == EEikScrollPageUp) ||
|
|
1039 |
(aEventType == EEikScrollThumbDragVert) || (aEventType == EEikScrollUp) ||
|
|
1040 |
(aEventType == EEikScrollDown))
|
|
1041 |
{
|
|
1042 |
// get the current position from the scroll bar
|
|
1043 |
iCurrentLine = aScrollBar->ThumbPosition();
|
|
1044 |
|
|
1045 |
// refresh now
|
|
1046 |
UpdateVisualContentL(EFalse);
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
// -----------------------------------------------------------------------------
|
|
1051 |
// -----------------------------------------------------------------------------
|
|
1052 |
//
|
|
1053 |
void CAlfPerfAppTestCaseSelectionView::CContainer::HandleControlEventL(
|
|
1054 |
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
|
|
1055 |
{
|
|
1056 |
// TODO: Add your control event handler code here
|
|
1057 |
}
|
|
1058 |
|
|
1059 |
|
|
1060 |
// -----------------------------------------------------------------------------
|
|
1061 |
// -----------------------------------------------------------------------------
|
|
1062 |
//
|
|
1063 |
void CAlfPerfAppTestCaseSelectionView::CContainer::UpdateVisualContentL(TBool aScrollToBottom)
|
|
1064 |
{
|
|
1065 |
TSize rectSize;
|
|
1066 |
AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, rectSize);
|
|
1067 |
TRect rect(rectSize);
|
|
1068 |
|
|
1069 |
// init scroll bar if not yet done
|
|
1070 |
if (!iScrollBarFrame)
|
|
1071 |
{
|
|
1072 |
iScrollBarFrame = new(ELeave) CEikScrollBarFrame(this, this, ETrue);
|
|
1073 |
|
|
1074 |
CAknAppUi* appUi = iAvkonAppUi;
|
|
1075 |
|
|
1076 |
if (AknLayoutUtils::DefaultScrollBarType(appUi) == CEikScrollBarFrame::EDoubleSpan)
|
|
1077 |
{
|
|
1078 |
iScrollBarFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse);
|
|
1079 |
iScrollBarFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan);
|
|
1080 |
}
|
|
1081 |
else
|
|
1082 |
{
|
|
1083 |
iScrollBarFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EArrowHead);
|
|
1084 |
}
|
|
1085 |
iScrollBarFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
// drawing positions, needed for scalable ui
|
|
1089 |
iX_factor = TReal(rect.Width()) / 176;
|
|
1090 |
iY_factor = TReal(rect.Height()) / 144;
|
|
1091 |
|
|
1092 |
iWrappedArray->Reset();
|
|
1093 |
|
|
1094 |
if (iWrapperString)
|
|
1095 |
{
|
|
1096 |
delete iWrapperString;
|
|
1097 |
iWrapperString = NULL;
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
// define drawing width, some extra space needed if using double span scrolling bar
|
|
1101 |
TUint drawingWidth(0);
|
|
1102 |
if (iScrollBarFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
|
|
1103 |
{
|
|
1104 |
if (AknLayoutUtils::LayoutMirrored()) // scroll bar on 'left'
|
|
1105 |
{
|
|
1106 |
iLeftDrawingPosition = KAlfPerfAppLeftMargin + 12;
|
|
1107 |
drawingWidth = TInt( rect.Width() - iLeftDrawingPosition*iX_factor - (KAlfPerfAppRightMargin*iX_factor));
|
|
1108 |
}
|
|
1109 |
else // scroll bar on 'right'
|
|
1110 |
{
|
|
1111 |
iLeftDrawingPosition = KAlfPerfAppLeftMargin;
|
|
1112 |
drawingWidth = TInt( rect.Width() - iLeftDrawingPosition*iX_factor - (KAlfPerfAppRightMargin*iX_factor + 7*iX_factor));
|
|
1113 |
}
|
|
1114 |
}
|
|
1115 |
else
|
|
1116 |
drawingWidth = TInt( rect.Width() - KAlfPerfAppLeftMargin*iX_factor - KAlfPerfAppRightMargin*iX_factor);
|
|
1117 |
|
|
1118 |
// wrap the text
|
|
1119 |
iWrapperString = AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
|
|
1120 |
iText->Des(),
|
|
1121 |
drawingWidth,
|
|
1122 |
*iFont,
|
|
1123 |
*iWrappedArray
|
|
1124 |
);
|
|
1125 |
|
|
1126 |
iLineCount = iWrappedArray->Count();
|
|
1127 |
|
|
1128 |
// count amount of lines fits to screen
|
|
1129 |
iNumberOfLinesFitsScreen = TInt(rect.Height() / (iFont->HeightInPixels()));
|
|
1130 |
|
|
1131 |
// check if needed to scroll to the bottom
|
|
1132 |
if (aScrollToBottom && iCurrentLine < iLineCount - iNumberOfLinesFitsScreen)
|
|
1133 |
{
|
|
1134 |
iCurrentLine = iLineCount-iNumberOfLinesFitsScreen;
|
|
1135 |
}
|
|
1136 |
|
|
1137 |
// update the scroll bars
|
|
1138 |
TEikScrollBarModel horizontalBar;
|
|
1139 |
TEikScrollBarModel verticalBar;
|
|
1140 |
verticalBar.iThumbPosition = iCurrentLine;
|
|
1141 |
verticalBar.iScrollSpan = iLineCount - iNumberOfLinesFitsScreen + 1;
|
|
1142 |
verticalBar.iThumbSpan = 1;
|
|
1143 |
|
|
1144 |
TEikScrollBarFrameLayout layout;
|
|
1145 |
layout.iTilingMode = TEikScrollBarFrameLayout::EInclusiveRectConstant;
|
|
1146 |
|
|
1147 |
if (iScrollBarFrame->TypeOfVScrollBar() == CEikScrollBarFrame::EDoubleSpan)
|
|
1148 |
{
|
|
1149 |
// do not let scrollbar values overflow
|
|
1150 |
if (verticalBar.iThumbPosition + verticalBar.iThumbSpan > verticalBar.iScrollSpan)
|
|
1151 |
verticalBar.iThumbPosition = verticalBar.iScrollSpan - verticalBar.iThumbSpan;
|
|
1152 |
|
|
1153 |
TAknDoubleSpanScrollBarModel horizontalDSBar(horizontalBar);
|
|
1154 |
TAknDoubleSpanScrollBarModel verticalDSBar(verticalBar);
|
|
1155 |
|
|
1156 |
iScrollBarFrame->TileL(&horizontalDSBar, &verticalDSBar, rect, rect, layout);
|
|
1157 |
iScrollBarFrame->SetVFocusPosToThumbPos(verticalDSBar.FocusPosition());
|
|
1158 |
}
|
|
1159 |
else
|
|
1160 |
{
|
|
1161 |
iScrollBarFrame->TileL( &horizontalBar, &verticalBar, rect, rect, layout );
|
|
1162 |
iScrollBarFrame->SetVFocusPosToThumbPos( verticalBar.iThumbPosition );
|
|
1163 |
}
|
|
1164 |
|
|
1165 |
|
|
1166 |
// update the screen
|
|
1167 |
DrawNow();
|
|
1168 |
}
|
|
1169 |
|
|
1170 |
// -----------------------------------------------------------------------------
|
|
1171 |
// -----------------------------------------------------------------------------
|
|
1172 |
//
|
|
1173 |
TBool CAlfPerfAppTestCaseSelectionView::CContainer::PrintText(const TDesC& aDes)
|
|
1174 |
{
|
|
1175 |
// This doesn't guarantee that iText length actually remains below KAlfPerfAppDisplayResultMaxChars
|
|
1176 |
// but it won't exceed it that much. Approximation can be used for the limiting value.
|
|
1177 |
if(iText->Length() < KAlfPerfAppDisplayResultMaxChars)
|
|
1178 |
{
|
|
1179 |
iText->Des().Append( aDes );
|
|
1180 |
return ETrue;
|
|
1181 |
}
|
|
1182 |
else
|
|
1183 |
{
|
|
1184 |
if(iNotPrintedResultDisplayBufferExceeded)
|
|
1185 |
{
|
|
1186 |
iText->Des().Append( KAlfPerfAppDisplayBufferFull);
|
|
1187 |
TBuf<KAlfPerfAppMaxCharsInLine> line;
|
|
1188 |
TBuf<KAlfPerfAppMaxCharsInLine> temp = iModel->TargetPath();
|
|
1189 |
line.Format(KAlfPerfAppPrintOutputFormat, &temp);
|
|
1190 |
iText->Des().Append(line);
|
|
1191 |
iNotPrintedResultDisplayBufferExceeded = EFalse;
|
|
1192 |
}
|
|
1193 |
return EFalse;
|
|
1194 |
}
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
// -----------------------------------------------------------------------------
|
|
1198 |
// -----------------------------------------------------------------------------
|
|
1199 |
//
|
|
1200 |
void CAlfPerfAppTestCaseSelectionView::CContainer::ClearOutputWindowL()
|
|
1201 |
{
|
|
1202 |
iText->Des().Zero();
|
|
1203 |
iNotPrintedResultDisplayBufferExceeded = ETrue;
|
|
1204 |
UpdateVisualContentL(ETrue);
|
|
1205 |
}
|
|
1206 |
|
|
1207 |
|
|
1208 |
// -----------------------------------------------------------------------------
|
|
1209 |
// -----------------------------------------------------------------------------
|
|
1210 |
//
|
|
1211 |
void CAlfPerfAppTestCaseSelectionView::CContainer::Draw(
|
|
1212 |
const TRect& aRect ) const
|
|
1213 |
{
|
|
1214 |
CWindowGc& gc = SystemGc();
|
|
1215 |
gc.Clear(aRect);
|
|
1216 |
gc.SetPenColor(KRgbBlack);
|
|
1217 |
gc.UseFont(iFont);
|
|
1218 |
|
|
1219 |
// draw the text
|
|
1220 |
for (TInt i=0; i<iNumberOfLinesFitsScreen; i++)
|
|
1221 |
{
|
|
1222 |
// index out of bounds check and then draw text
|
|
1223 |
if (i+iCurrentLine < iWrappedArray->Count())
|
|
1224 |
gc.DrawText(iWrappedArray->At(i+iCurrentLine),
|
|
1225 |
TPoint(TInt(iLeftDrawingPosition*iX_factor), TInt(iFont->HeightInPixels()*(i+1))));
|
|
1226 |
}
|
|
1227 |
gc.DiscardFont();
|
|
1228 |
}
|