sl@0
|
1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@test
|
sl@0
|
19 |
@internalComponent - Internal Symbian test code
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "cmultiplesurfaces.h"
|
sl@0
|
24 |
#include "tsmallwindowraster.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
const TInt KTimeBetweenFrames = 100000; // checks every 100 ms for a new message
|
sl@0
|
28 |
|
sl@0
|
29 |
// messages which are sent by the test step
|
sl@0
|
30 |
const TInt KBringToFront = 1;
|
sl@0
|
31 |
const TInt KTerminate = 2;
|
sl@0
|
32 |
|
sl@0
|
33 |
// defines number of windows on the screen
|
sl@0
|
34 |
const TInt KWindowsAcross = 1;
|
sl@0
|
35 |
const TInt KWindowsDown = 1;
|
sl@0
|
36 |
|
sl@0
|
37 |
_LIT(KSmallBitmap,"z:\\resource\\apps\\cover2.jpg"); // bitmap that is displayed by the windows
|
sl@0
|
38 |
|
sl@0
|
39 |
|
sl@0
|
40 |
CMultipleSurfaces* CMultipleSurfaces::NewL(RWsSession& aWs, RWindowGroup& aWindowGroup, TPtrC childQueueName, CMultipleSurfacesAppUi* aMultipleSurfacesAppUi, TPtrC aParentQueueName)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
CMultipleSurfaces* self = new (ELeave)CMultipleSurfaces(aWs, aWindowGroup, aMultipleSurfacesAppUi);
|
sl@0
|
43 |
self->ConstructL(childQueueName, aParentQueueName);
|
sl@0
|
44 |
return self;
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
CMultipleSurfaces::CMultipleSurfaces(RWsSession& aWs, RWindowGroup& aWindowGroup, CMultipleSurfacesAppUi* aMultipleSurfacesAppUi) :
|
sl@0
|
48 |
iWs(aWs), iWindowGroup(aWindowGroup), iMultipleSurfacesAppUi(aMultipleSurfacesAppUi)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
// empty
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
CMultipleSurfaces::~CMultipleSurfaces()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
delete iTimer;
|
sl@0
|
56 |
iParentMsgQueue.Send(KTerminate);
|
sl@0
|
57 |
iParentMsgQueue.Close();
|
sl@0
|
58 |
iMsgQueue.Close();
|
sl@0
|
59 |
for (TInt w = 0; w < iSmallWindows.Count(); w++)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
delete iSmallWindows[w];
|
sl@0
|
62 |
}
|
sl@0
|
63 |
iSmallWindows.Close();
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
void CMultipleSurfaces::ConstructL(TPtrC childQueueName, TPtrC aParentQueueName)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
iTimer = CPeriodic::NewL(CActive::EPriorityIdle);
|
sl@0
|
69 |
// available screensize is reduced by the menu bar
|
sl@0
|
70 |
TSize screenSize = iMultipleSurfacesAppUi->ClientRect().Size();
|
sl@0
|
71 |
|
sl@0
|
72 |
TSize windowSize;
|
sl@0
|
73 |
windowSize.iHeight = screenSize.iHeight/KWindowsDown;
|
sl@0
|
74 |
windowSize.iWidth = screenSize.iWidth/KWindowsAcross;
|
sl@0
|
75 |
// adjust window size to make square windows
|
sl@0
|
76 |
if (windowSize.iWidth > windowSize.iHeight)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
windowSize.iWidth = windowSize.iHeight;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
else
|
sl@0
|
81 |
{
|
sl@0
|
82 |
windowSize.iHeight = windowSize.iWidth;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
// available screensize is reduced by the menu bar
|
sl@0
|
86 |
TPoint initialPosition(iMultipleSurfacesAppUi->ClientRect().iTl);
|
sl@0
|
87 |
CSurfaceUtility* utility = CSurfaceUtility::NewL();
|
sl@0
|
88 |
CleanupStack::PushL(utility);
|
sl@0
|
89 |
CTWindow* smallWindow;
|
sl@0
|
90 |
for (TInt i = 0; i < KWindowsAcross; i++)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
initialPosition.iX = 0;
|
sl@0
|
93 |
for (TInt j = 0; j < KWindowsDown; j++)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
smallWindow = CTSmallWindowRaster::NewL(iWs, iWindowGroup, initialPosition, windowSize);
|
sl@0
|
96 |
CleanupStack::PushL(smallWindow);
|
sl@0
|
97 |
smallWindow->LoadL(utility, KSmallBitmap());
|
sl@0
|
98 |
iSmallWindows.AppendL(smallWindow);
|
sl@0
|
99 |
CleanupStack::Pop(smallWindow);
|
sl@0
|
100 |
initialPosition.iX += windowSize.iWidth;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
initialPosition.iY += windowSize.iHeight;
|
sl@0
|
103 |
}
|
sl@0
|
104 |
CleanupStack::PopAndDestroy(utility);
|
sl@0
|
105 |
User::LeaveIfError(iMsgQueue.OpenGlobal(childQueueName));
|
sl@0
|
106 |
User::LeaveIfError(iParentMsgQueue.OpenGlobal(aParentQueueName));
|
sl@0
|
107 |
// inform test app that the message queues are ready
|
sl@0
|
108 |
RProcess::Rendezvous(KErrNone);
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
* Starts a timer which redraws the screen periodically.
|
sl@0
|
115 |
*/
|
sl@0
|
116 |
void CMultipleSurfaces::Start()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
iTimer->Start(0, KTimeBetweenFrames, TCallBack(TimerCallBack, this));
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
TInt CMultipleSurfaces::TimerCallBack(TAny* MultipleSurfaces)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
TRAPD(err, static_cast<CMultipleSurfaces*>(MultipleSurfaces)->RenderL());
|
sl@0
|
124 |
return err;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
/**
|
sl@0
|
128 |
* Meassures the time it takes to bring this application to the foreground.
|
sl@0
|
129 |
* It receives a message from the test step which coordinates the switching.
|
sl@0
|
130 |
*/
|
sl@0
|
131 |
void CMultipleSurfaces::RenderL()
|
sl@0
|
132 |
{
|
sl@0
|
133 |
TInt msg = 0;
|
sl@0
|
134 |
iMsgQueue.ReceiveBlocking(msg);
|
sl@0
|
135 |
|
sl@0
|
136 |
for (TInt w = 0; w < iSmallWindows.Count(); w++)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
iSmallWindows[w]->Move(0, 1);
|
sl@0
|
139 |
iSmallWindows[w]->RenderL();
|
sl@0
|
140 |
}
|
sl@0
|
141 |
iWs.Flush();
|
sl@0
|
142 |
iWs.Finish();
|
sl@0
|
143 |
|
sl@0
|
144 |
switch (msg)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
case KBringToFront:
|
sl@0
|
147 |
{
|
sl@0
|
148 |
TUint32 timeStamp = User::FastCounter();
|
sl@0
|
149 |
iMultipleSurfacesAppUi->BringToFront();
|
sl@0
|
150 |
TUint32 time = User::FastCounter() - timeStamp;
|
sl@0
|
151 |
iParentMsgQueue.Send(time);
|
sl@0
|
152 |
break;
|
sl@0
|
153 |
}
|
sl@0
|
154 |
case KTerminate:
|
sl@0
|
155 |
{
|
sl@0
|
156 |
Stop();
|
sl@0
|
157 |
iMultipleSurfacesAppUi->Terminate();
|
sl@0
|
158 |
break;
|
sl@0
|
159 |
}
|
sl@0
|
160 |
}
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
/**
|
sl@0
|
164 |
* Stops the timer.
|
sl@0
|
165 |
*/
|
sl@0
|
166 |
void CMultipleSurfaces::Stop()
|
sl@0
|
167 |
{
|
sl@0
|
168 |
if(iTimer)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
iTimer->Cancel();
|
sl@0
|
171 |
}
|
sl@0
|
172 |
}
|