sl@0
|
1 |
|
sl@0
|
2 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
// All rights reserved.
|
sl@0
|
4 |
// This component and the accompanying materials are made available
|
sl@0
|
5 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
// which accompanies this distribution, and is available
|
sl@0
|
7 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
//
|
sl@0
|
9 |
// Initial Contributors:
|
sl@0
|
10 |
// Nokia Corporation - initial contribution.
|
sl@0
|
11 |
//
|
sl@0
|
12 |
// Contributors:
|
sl@0
|
13 |
//
|
sl@0
|
14 |
// Description:
|
sl@0
|
15 |
// This program is designed the test of the MMF_VCLNT.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file TSI_MMFVCLNT.cpp
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "TSI_MMFVCLNT.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
TInt CVideoCallbackHandler::ID()
|
sl@0
|
27 |
{
|
sl@0
|
28 |
return iID;
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
void CVideoCallbackHandler::MvpuoOpenComplete(TInt aError)
|
sl@0
|
32 |
{
|
sl@0
|
33 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
void CVideoCallbackHandler::MvpuoFrameReady(CFbsBitmap& /*aFrame*/)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
iMchObserver->MchoComplete(ID(),0);
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
void CVideoCallbackHandler::MvpuoPlayComplete(TInt aError)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
44 |
}
|
sl@0
|
45 |
|
sl@0
|
46 |
CVideoRecorderCallbackHandler::CVideoRecorderCallbackHandler(const TInt aID, MCallbackHandlerObserver* aMchObserver)
|
sl@0
|
47 |
: iMchObserver(aMchObserver)
|
sl@0
|
48 |
, iID(aID)
|
sl@0
|
49 |
{}
|
sl@0
|
50 |
|
sl@0
|
51 |
TInt CVideoRecorderCallbackHandler::ID()
|
sl@0
|
52 |
{
|
sl@0
|
53 |
return iID;
|
sl@0
|
54 |
}
|
sl@0
|
55 |
|
sl@0
|
56 |
void CVideoRecorderCallbackHandler::MvruoOpenComplete(TInt aError)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
void CVideoRecorderCallbackHandler::MvruoRecordComplete(TInt aError)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
* Timeout function
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
void CTestMmfVclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
TRequestStatus timerStatus;
|
sl@0
|
72 |
RTimer timer ;
|
sl@0
|
73 |
timer.CreateLocal() ;
|
sl@0
|
74 |
timer.After(timerStatus,aNumberOfMicroSeconds);
|
sl@0
|
75 |
|
sl@0
|
76 |
User::WaitForRequest(aStatus, timerStatus);
|
sl@0
|
77 |
if (timerStatus == KRequestPending)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
timer.Cancel();
|
sl@0
|
80 |
User::WaitForRequest(timerStatus);
|
sl@0
|
81 |
}
|
sl@0
|
82 |
else
|
sl@0
|
83 |
{
|
sl@0
|
84 |
INFO_PRINTF1(_L("Time is over!!!")) ;
|
sl@0
|
85 |
}
|
sl@0
|
86 |
timer.Close() ;
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
* Time comparison utility function
|
sl@0
|
91 |
*
|
sl@0
|
92 |
* @param "const TUint aActual"
|
sl@0
|
93 |
* The actual timer value produced
|
sl@0
|
94 |
* @param "const TUint aExpected"
|
sl@0
|
95 |
* Expected timer value
|
sl@0
|
96 |
* @param "const TUint aDeviation"
|
sl@0
|
97 |
* Allowed deviation of the expected value
|
sl@0
|
98 |
* from the actual value.
|
sl@0
|
99 |
* @return "TBool"
|
sl@0
|
100 |
* Did actual timed value fall within deviation limits
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
TBool CTestMmfVclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
// save unnessary conditions
|
sl@0
|
105 |
if(aActual == aExpected)
|
sl@0
|
106 |
return ETrue;
|
sl@0
|
107 |
|
sl@0
|
108 |
// Prevent unsigned wrapping errors
|
sl@0
|
109 |
TUint difference;
|
sl@0
|
110 |
if(aActual > aExpected)
|
sl@0
|
111 |
difference = aActual - aExpected;
|
sl@0
|
112 |
else
|
sl@0
|
113 |
difference = aExpected - aActual;
|
sl@0
|
114 |
|
sl@0
|
115 |
// comapare
|
sl@0
|
116 |
if(difference < aDeviation)
|
sl@0
|
117 |
return ETrue;
|
sl@0
|
118 |
return EFalse;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
/**
|
sl@0
|
122 |
* Test Preample routines.
|
sl@0
|
123 |
*
|
sl@0
|
124 |
* Creates our own Active Scheduler.
|
sl@0
|
125 |
*
|
sl@0
|
126 |
* @return "TVerdict"
|
sl@0
|
127 |
* Did Preamble complete.
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
TVerdict CTestMmfVclntStep::DoTestStepPreambleL()
|
sl@0
|
130 |
{
|
sl@0
|
131 |
iActiveScheduler = new(ELeave) CActiveScheduler;
|
sl@0
|
132 |
CActiveScheduler::Install(iActiveScheduler);
|
sl@0
|
133 |
|
sl@0
|
134 |
return EPass;
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
/**
|
sl@0
|
138 |
* Test Postample routines.
|
sl@0
|
139 |
*
|
sl@0
|
140 |
* Destroys our Active Scheduler.
|
sl@0
|
141 |
*
|
sl@0
|
142 |
* @return "TVerdict"
|
sl@0
|
143 |
* Did Postamble complete.
|
sl@0
|
144 |
*/
|
sl@0
|
145 |
TVerdict CTestMmfVclntStep::DoTestStepPostambleL()
|
sl@0
|
146 |
{
|
sl@0
|
147 |
delete iActiveScheduler;
|
sl@0
|
148 |
iActiveScheduler = NULL;
|
sl@0
|
149 |
|
sl@0
|
150 |
delete iScreen;
|
sl@0
|
151 |
delete iWindow;
|
sl@0
|
152 |
iWs.Close();
|
sl@0
|
153 |
|
sl@0
|
154 |
return EPass;
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
/**
|
sl@0
|
158 |
* CTestMMFVCLNTStep Implementation
|
sl@0
|
159 |
*/
|
sl@0
|
160 |
CTestMmfVclntStep::CTestMmfVclntStep()
|
sl@0
|
161 |
:iActiveScheduler( NULL )
|
sl@0
|
162 |
{}
|
sl@0
|
163 |
|
sl@0
|
164 |
CTestMmfVclntStep::~CTestMmfVclntStep()
|
sl@0
|
165 |
{
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
void CTestMmfVclntStep::InitWservL()
|
sl@0
|
169 |
{
|
sl@0
|
170 |
TInt err = iWs.Connect();
|
sl@0
|
171 |
if (err != KErrNone)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
// Access violation if ws is null
|
sl@0
|
174 |
INFO_PRINTF1(_L("Cannot test, no window server available"));
|
sl@0
|
175 |
User::Leave(err);
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
iScreen = new (ELeave) CWsScreenDevice(iWs); // make device for this session
|
sl@0
|
179 |
User::LeaveIfError(iScreen->Construct()); // and complete its construction
|
sl@0
|
180 |
|
sl@0
|
181 |
RWindowGroup rootWindow = RWindowGroup(iWs);
|
sl@0
|
182 |
User::LeaveIfError(rootWindow.Construct((TUint32)this, ETrue));
|
sl@0
|
183 |
|
sl@0
|
184 |
iWindow = new(ELeave) RWindow(iWs);
|
sl@0
|
185 |
User::LeaveIfError(((RWindow*)iWindow)->Construct(rootWindow,((TUint32)(this)) + 1));
|
sl@0
|
186 |
iWindow->SetExtent(TPoint(0,0), TSize(100,100));
|
sl@0
|
187 |
iWindow->SetVisible(ETrue);
|
sl@0
|
188 |
iWindow->Activate();
|
sl@0
|
189 |
iWs.Flush();
|
sl@0
|
190 |
}
|