Update contrib.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
24 #include "te_gesturegenerator.h"
28 _LIT(KSemaphore, "SemTPanSync"); // Name of the global semaphore
30 const TInt KGestureGenerationLimit = 50;
32 // Test bitmap file location
33 _LIT(KBigBitmap,"z:\\resource\\apps\\uibench_s60_big.mbm");
34 _LIT(KTestStep0001,"GRAPHICS-UI-BENCH-S60-0001");
38 SetTestStepName(KTPan);
41 TVerdict CTPan::doTestStepPreambleL()
43 // The semaphore has to be created before, otherwise the control can't open it.
44 TESTNOERRORL(iSemaphore.CreateGlobal(KSemaphore, 0));
45 return CTe_ConeStepBase::doTestStepPreambleL();
48 TVerdict CTPan::doTestStepPostambleL()
51 return CTe_ConeStepBase::doTestStepPostambleL();
55 Override of base class pure virtual
56 Our implementation only gets called if the base class doTestStepPreambleL() did
59 @return - TVerdict code
61 TVerdict CTPan::doTestStepL()
63 SetTestStepID(KTestStep0001);
65 //RecordTestResultL(); // not possible because of heap panic
66 return TestStepResult();
71 GRAPHICS-UI-BENCH-S60-0001
74 Tests how long it takes to pan a bitmap in reaction to pointer events.
77 Create the bitmap and generate the pointer events. Depending on the location of the
78 pointer the bitmap is drawn to the screen.
80 @SYMTestExpectedResults
81 Test should pass and display the average framerate for the whole test.
83 void CTPan::PanBitmapL()
85 iProfiler->InitResults();
87 // Simulate some horizontal drag pointer events
88 GestureGenerator::SimulateFlickGestureL(iSemaphore, TPoint(0, 0),
89 TPoint(KGestureGenerationLimit, 0));
90 // Simulate some vertical drag pointer events
91 GestureGenerator::SimulateFlickGestureL(iSemaphore, TPoint(KGestureGenerationLimit, 0),
92 TPoint(KGestureGenerationLimit, KGestureGenerationLimit));
94 iProfiler->MarkResultSetL();
95 TSize screenSize = CTWindow::GetDisplaySizeInPixels();
96 iProfiler->ResultsAnalysisFrameRate(KTestStep0001, 0, 0, 0,
97 iAppUi->PanControl()->Iterations(), screenSize.iWidth * screenSize.iHeight);
100 void CTPan::InitUIL(CCoeEnv* aCoeEnv)
102 iAppUi = new(ELeave) CPanAppUi();
103 // iAppUi needs to be put on the cleanupstack until CCoeEnv takes ownership of iAppUi
104 CleanupStack::PushL(iAppUi);
105 iAppUi->ConstructL(TRect(CTWindow::GetDisplaySizeInPixels()));
106 CleanupStack::Pop(iAppUi);
107 aCoeEnv->SetAppUi(iAppUi);
110 //=============================================================================
112 CPanAppUi::CPanAppUi()
117 CPanAppUi::~CPanAppUi()
119 RemoveFromStack(iPanControl);
123 void CPanAppUi::ConstructL(const TRect& aRect)
125 BaseConstructL(ENoAppResourceFile);
126 iPanControl = CPanControl::NewL(aRect);
127 AddToStackL(iPanControl);
130 CPanControl* CPanAppUi::PanControl()
135 //=============================================================================
137 CPanControl* CPanControl::NewL(const TRect& aRect, const CCoeControl* aParent)
139 CPanControl* self = CPanControl::NewLC(aRect, aParent);
140 CleanupStack::Pop(self);
144 CPanControl* CPanControl::NewLC(const TRect& aRect, const CCoeControl* aParent)
146 CPanControl* self = new(ELeave) CPanControl();
147 CleanupStack::PushL(self);
148 self->ConstructL(aRect, aParent);
152 CPanControl::CPanControl() : iWsSession(CCoeEnv::Static()->WsSession())
157 CPanControl::~CPanControl()
159 delete iSourceBitmap;
163 void CPanControl::ConstructL(const TRect& aRect, const CCoeControl* aParent)
165 User::LeaveIfError(iSemaphore.OpenGlobal(KSemaphore));
166 iSourceBitmap = new(ELeave) CFbsBitmap;
167 User::LeaveIfError(iSourceBitmap->Load(KBigBitmap, 0));
169 // No owner, so create an own window
173 DrawableWindow()->PointerFilter(EPointerFilterDrag, 0);
179 // use parent window as compound control
180 SetContainerWindowL(*aParent);
185 void CPanControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
187 if((aPointerEvent.iType == TPointerEvent::EDrag) || (aPointerEvent.iType == TPointerEvent::EButton1Down))
189 iCurrentPointerPos = aPointerEvent.iPosition;
191 DrawNow(); // Draws the entire control
192 iWsSession.Finish(); // Wait until WServ has finished drawing
193 iIterations++; // Update frame counter
194 iSemaphore.Signal(); // Signal test that control was drawn
197 void CPanControl::Draw(const TRect& aRect) const
199 CWindowGc& gc = SystemGc();
200 TRect sourceRect = Rect();
201 sourceRect.Move(iCurrentPointerPos);
202 gc.DrawBitmap(aRect, iSourceBitmap, sourceRect);
205 TInt CPanControl::Iterations()
210 CFbsBitmap* CPanControl::Bitmap()
212 return iSourceBitmap;