sl@0
|
1 |
// Copyright (c) 2008-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 |
#include <bautils.h>
|
sl@0
|
17 |
#include <bitdev.h>
|
sl@0
|
18 |
#include <gulutil.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "srtdecoder.h"
|
sl@0
|
21 |
#include "srtreader.h"
|
sl@0
|
22 |
#include "testsrtdecoder.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
_LIT(KSampleSubtitleSRTFilepath1, "c:\\mm\\subtitle1.srt");
|
sl@0
|
25 |
_LIT(KSampleSubtitleSRTFilepath2, "c:\\mm\\subtitle2.srt");
|
sl@0
|
26 |
|
sl@0
|
27 |
// subtitlebmp0.mbm -- subtitlebmp9.mbm: bitmaps for comparison
|
sl@0
|
28 |
_LIT(KSubtitleTargetBitmapFilePathSpec, "c:\\mm\\subtitlebmp%d.mbm");
|
sl@0
|
29 |
// subtitlecurbmp0.mbm -- subtitlecurbmp9.mbm: runtime bitmaps for comparison,
|
sl@0
|
30 |
// will be removed unless MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA is defined
|
sl@0
|
31 |
_LIT(KSubtitleCurrentBitmapFilePathSpec, "c:\\mm\\subtitlecurbmp%d.mbm");
|
sl@0
|
32 |
|
sl@0
|
33 |
// defining MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA means re-creating the test data (bitmaps) for comparison, instead
|
sl@0
|
34 |
// of doing the comparison with the existing test data
|
sl@0
|
35 |
// at runtime with the spec of KSubtitleCurrentBitmapFilePathSpec
|
sl@0
|
36 |
#ifndef MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA
|
sl@0
|
37 |
// #define MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA
|
sl@0
|
38 |
#endif
|
sl@0
|
39 |
|
sl@0
|
40 |
void RTestSrtDecoderStep::InitializeTestStepL(TBool aCreateSrtReaderOnly, const TDesC& aSrtFilePath)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
__MM_HEAP_MARK;
|
sl@0
|
43 |
iSrtReader = CSrtReader::NewL(aSrtFilePath);
|
sl@0
|
44 |
|
sl@0
|
45 |
iCreateSrtReaderOnly = aCreateSrtReaderOnly;
|
sl@0
|
46 |
if (!iCreateSrtReaderOnly)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
User::LeaveIfError(iRbsSession.Connect());
|
sl@0
|
49 |
iSrtDecoder = CSrtSubtitleDecoder::NewL(*iSrtReader);
|
sl@0
|
50 |
}
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
void RTestSrtDecoderStep::UnInitializeTestStep()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
if (!iCreateSrtReaderOnly)
|
sl@0
|
56 |
{
|
sl@0
|
57 |
iRbsSession.Disconnect();
|
sl@0
|
58 |
delete iSrtDecoder;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
delete iSrtReader;
|
sl@0
|
61 |
__MM_HEAP_MARKEND;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
// Implementation of the generic test step
|
sl@0
|
65 |
TBool RTestSrtDecoderStep::CompareFilesL(RFs &aFs, const TDesC& aFilePath1, const TDesC& aFilePath2)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
TBool identical = EFalse;
|
sl@0
|
68 |
RFile file1;
|
sl@0
|
69 |
RFile file2;
|
sl@0
|
70 |
TInt file1Size = 0;
|
sl@0
|
71 |
TInt file2Size = 0;
|
sl@0
|
72 |
|
sl@0
|
73 |
if (aFilePath1 == aFilePath2)
|
sl@0
|
74 |
{
|
sl@0
|
75 |
identical = ETrue;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
else
|
sl@0
|
78 |
{
|
sl@0
|
79 |
User::LeaveIfError(file1.Open(aFs, aFilePath1, EFileRead));
|
sl@0
|
80 |
CleanupClosePushL(file1);
|
sl@0
|
81 |
User::LeaveIfError(file2.Open(aFs, aFilePath2, EFileRead));
|
sl@0
|
82 |
CleanupClosePushL(file2);
|
sl@0
|
83 |
|
sl@0
|
84 |
User::LeaveIfError(file1.Size(file1Size));
|
sl@0
|
85 |
User::LeaveIfError(file2.Size(file2Size));
|
sl@0
|
86 |
|
sl@0
|
87 |
if (file1Size == file2Size)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
TBuf8<256> buffer1;
|
sl@0
|
90 |
TBuf8<256> buffer2;
|
sl@0
|
91 |
|
sl@0
|
92 |
identical = ETrue;
|
sl@0
|
93 |
while(ETrue)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
User::LeaveIfError(file1.Read(buffer1));
|
sl@0
|
96 |
User::LeaveIfError(file2.Read(buffer2));
|
sl@0
|
97 |
|
sl@0
|
98 |
if (buffer1 != buffer2)
|
sl@0
|
99 |
{
|
sl@0
|
100 |
identical = EFalse;
|
sl@0
|
101 |
break;
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
if (0 == buffer1.Length())
|
sl@0
|
105 |
{
|
sl@0
|
106 |
break;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
}
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
CleanupStack::PopAndDestroy(&file2);
|
sl@0
|
112 |
CleanupStack::PopAndDestroy(&file1);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
return identical;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
TBool RTestSrtDecoderStep::IsFontAvailableL(const TDesC& aTypefaceName)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
TBool avail = EFalse;
|
sl@0
|
121 |
TSize bmpSize(100, 100);
|
sl@0
|
122 |
|
sl@0
|
123 |
CFbsBitmap* sampleBitmap = new (ELeave) CFbsBitmap();
|
sl@0
|
124 |
CleanupStack::PushL(sampleBitmap);
|
sl@0
|
125 |
|
sl@0
|
126 |
User::LeaveIfError(sampleBitmap->Create(bmpSize, EColor16MA));
|
sl@0
|
127 |
|
sl@0
|
128 |
CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL(sampleBitmap);
|
sl@0
|
129 |
CleanupStack::PushL(bmpDevice);
|
sl@0
|
130 |
|
sl@0
|
131 |
if (0 != FontUtils::TypefaceAttributes(*bmpDevice, aTypefaceName))
|
sl@0
|
132 |
{
|
sl@0
|
133 |
const TInt KSubtitleFontMaxSpecHeights = 128;
|
sl@0
|
134 |
CArrayFix<TInt> *listHeights = new (ELeave) CArrayFixFlat<TInt>(KSubtitleFontMaxSpecHeights);
|
sl@0
|
135 |
CleanupStack::PushL(listHeights);
|
sl@0
|
136 |
|
sl@0
|
137 |
FontUtils::GetAvailableHeightsInTwipsL(*bmpDevice, aTypefaceName, *listHeights);
|
sl@0
|
138 |
for (TInt i = 0; i < listHeights->Count(); i++)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
if (KSrtTargetTypefaceHeightInTwips == (*listHeights)[i])
|
sl@0
|
141 |
{
|
sl@0
|
142 |
avail = ETrue;
|
sl@0
|
143 |
break;
|
sl@0
|
144 |
}
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
CleanupStack::PopAndDestroy(listHeights);
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
CleanupStack::PopAndDestroy(bmpDevice);
|
sl@0
|
151 |
CleanupStack::PopAndDestroy(sampleBitmap);
|
sl@0
|
152 |
|
sl@0
|
153 |
return avail;
|
sl@0
|
154 |
}
|
sl@0
|
155 |
|
sl@0
|
156 |
TBool RTestSrtDecoderStep::CompareBmpFilesL(TInt aStartIndex, TInt aEndIndex, const TDesC& aSrcFilePathSpec, const TDesC& aDestFilePathSpec)
|
sl@0
|
157 |
{
|
sl@0
|
158 |
TBool identical = ETrue;
|
sl@0
|
159 |
TBuf <KMaxFullName> bitmapFilename1;
|
sl@0
|
160 |
TBuf <KMaxFullName> bitmapFilename2;
|
sl@0
|
161 |
RFs rfs;
|
sl@0
|
162 |
User::LeaveIfError(rfs.Connect());
|
sl@0
|
163 |
CleanupClosePushL(rfs);
|
sl@0
|
164 |
for (TInt i = aStartIndex; i <= aEndIndex; i++)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
bitmapFilename1.Format(aDestFilePathSpec, i);
|
sl@0
|
167 |
bitmapFilename2.Format(aSrcFilePathSpec, i);
|
sl@0
|
168 |
if (!CompareFilesL(rfs, bitmapFilename1, bitmapFilename2))
|
sl@0
|
169 |
{
|
sl@0
|
170 |
identical = EFalse;
|
sl@0
|
171 |
break;
|
sl@0
|
172 |
}
|
sl@0
|
173 |
}
|
sl@0
|
174 |
CleanupStack::PopAndDestroy(&rfs);
|
sl@0
|
175 |
|
sl@0
|
176 |
return identical;
|
sl@0
|
177 |
}
|
sl@0
|
178 |
|
sl@0
|
179 |
void RTestSrtDecoderStep::DeleteTempFiles(TInt aStartIndex, TInt aEndIndex, const TDesC& aFilePathSpec)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
TBuf <KMaxFullName> bitmapFilename;
|
sl@0
|
182 |
RFs rfs;
|
sl@0
|
183 |
|
sl@0
|
184 |
if (KErrNone == rfs.Connect())
|
sl@0
|
185 |
{
|
sl@0
|
186 |
for (TInt i = aStartIndex ; i <= aEndIndex; i++)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
bitmapFilename.Format(aFilePathSpec, i);
|
sl@0
|
189 |
BaflUtils::DeleteFile(rfs, bitmapFilename);
|
sl@0
|
190 |
}
|
sl@0
|
191 |
}
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
|
sl@0
|
195 |
// Implementation of RTestSrtDecoderStep0002
|
sl@0
|
196 |
|
sl@0
|
197 |
RTestSrtDecoderStep0002::RTestSrtDecoderStep0002()
|
sl@0
|
198 |
{
|
sl@0
|
199 |
iTestStepName = _L("MM-MMF-SUBTITLE-SRTDECODER-U-0002-HP");
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|
sl@0
|
202 |
TVerdict RTestSrtDecoderStep0002::DoTestStepPreambleL()
|
sl@0
|
203 |
{
|
sl@0
|
204 |
InitializeTestStepL(EFalse, KSampleSubtitleSRTFilepath1);
|
sl@0
|
205 |
|
sl@0
|
206 |
// Install the Active Scheduler
|
sl@0
|
207 |
iActiveScheduler = new(ELeave) CActiveScheduler;
|
sl@0
|
208 |
CActiveScheduler::Install(iActiveScheduler);
|
sl@0
|
209 |
iActiveSchedulerStarted = EFalse;
|
sl@0
|
210 |
|
sl@0
|
211 |
InitWservL();
|
sl@0
|
212 |
|
sl@0
|
213 |
return EPass;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
TVerdict RTestSrtDecoderStep0002::DoTestStepPostambleL()
|
sl@0
|
217 |
{
|
sl@0
|
218 |
UninitWserv();
|
sl@0
|
219 |
CActiveScheduler::Install(NULL);
|
sl@0
|
220 |
delete iActiveScheduler;
|
sl@0
|
221 |
iActiveScheduler = NULL;
|
sl@0
|
222 |
|
sl@0
|
223 |
UnInitializeTestStep();
|
sl@0
|
224 |
|
sl@0
|
225 |
return EPass;
|
sl@0
|
226 |
}
|
sl@0
|
227 |
|
sl@0
|
228 |
TVerdict RTestSrtDecoderStep0002::DoTestStepL()
|
sl@0
|
229 |
{
|
sl@0
|
230 |
INFO_PRINTF1(_L("Enter DoTestStepL"));
|
sl@0
|
231 |
TVerdict result = EPass;
|
sl@0
|
232 |
|
sl@0
|
233 |
TRAPD(err, TestGetNextFrameL());
|
sl@0
|
234 |
if (KErrNone != err)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
result = EFail;
|
sl@0
|
237 |
ERR_PRINTF2(_L("Error - RTestSrtDecoderStep0002::TestGetNextFrameL failed. error code %d. "), err);
|
sl@0
|
238 |
}
|
sl@0
|
239 |
|
sl@0
|
240 |
INFO_PRINTF1(_L("Exit DoTestStepL"));
|
sl@0
|
241 |
return result;
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
void RTestSrtDecoderStep0002::InitWservL()
|
sl@0
|
245 |
{
|
sl@0
|
246 |
TInt err = iWs.Connect();
|
sl@0
|
247 |
|
sl@0
|
248 |
if (err != KErrNone)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
// Access violation if ws is null
|
sl@0
|
251 |
ERR_PRINTF2(_L("Error - Failed to connect to RWsSession. error code %d. "), err);
|
sl@0
|
252 |
User::Leave(err);
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
iScreen = new (ELeave) CWsScreenDevice(iWs); // make device for this session
|
sl@0
|
256 |
User::LeaveIfError(iScreen->Construct()); // and complete its construction
|
sl@0
|
257 |
|
sl@0
|
258 |
iRootWindow = RWindowGroup(iWs);
|
sl@0
|
259 |
User::LeaveIfError(iRootWindow.Construct((TUint32)this, ETrue));
|
sl@0
|
260 |
|
sl@0
|
261 |
iWindow = new(ELeave) RWindow(iWs);
|
sl@0
|
262 |
User::LeaveIfError(((RWindow*)iWindow)->Construct(iRootWindow,((TUint32)(this)) + 1));
|
sl@0
|
263 |
iWindow->SetExtent(TPoint(0,0), iScreen->SizeInPixels());
|
sl@0
|
264 |
iWindow->SetVisible(ETrue);
|
sl@0
|
265 |
iWindow->SetRequiredDisplayMode(EColor16MA);
|
sl@0
|
266 |
|
sl@0
|
267 |
// Light Sky Blue 135-206-250
|
sl@0
|
268 |
TRgb backgroundColour = TRgb(135, 206, 250);
|
sl@0
|
269 |
iWindow->SetBackgroundColor(backgroundColour);
|
sl@0
|
270 |
|
sl@0
|
271 |
iGc = new(ELeave) CWindowGc(iScreen);
|
sl@0
|
272 |
User::LeaveIfError(iGc->Construct());
|
sl@0
|
273 |
|
sl@0
|
274 |
iWindow->Activate();
|
sl@0
|
275 |
iWs.Flush();
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
void RTestSrtDecoderStep0002::UninitWserv()
|
sl@0
|
279 |
{
|
sl@0
|
280 |
if (iWindow)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
iWindow->Close();
|
sl@0
|
283 |
delete iWindow;
|
sl@0
|
284 |
iWindow = NULL;
|
sl@0
|
285 |
}
|
sl@0
|
286 |
|
sl@0
|
287 |
iRootWindow.Close();
|
sl@0
|
288 |
delete iScreen;
|
sl@0
|
289 |
iScreen = NULL;
|
sl@0
|
290 |
|
sl@0
|
291 |
delete iGc;
|
sl@0
|
292 |
iGc = NULL;
|
sl@0
|
293 |
|
sl@0
|
294 |
iWs.Flush();
|
sl@0
|
295 |
iWs.Close();
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
void RTestSrtDecoderStep0002::PrepGc()
|
sl@0
|
299 |
{
|
sl@0
|
300 |
iGc->Activate(*iWindow);
|
sl@0
|
301 |
iWindow->Invalidate();
|
sl@0
|
302 |
iWindow->BeginRedraw();
|
sl@0
|
303 |
|
sl@0
|
304 |
iGc->Clear(TRect(iScreen->SizeInPixels()));
|
sl@0
|
305 |
iWs.Flush();
|
sl@0
|
306 |
}
|
sl@0
|
307 |
|
sl@0
|
308 |
void RTestSrtDecoderStep0002::RetireGc()
|
sl@0
|
309 |
{
|
sl@0
|
310 |
iGc->Deactivate();
|
sl@0
|
311 |
iWindow->EndRedraw();
|
sl@0
|
312 |
iWs.Flush();
|
sl@0
|
313 |
}
|
sl@0
|
314 |
|
sl@0
|
315 |
void RTestSrtDecoderStep0002::DrawBitmap(CFbsBitmap& aBitmap)
|
sl@0
|
316 |
{
|
sl@0
|
317 |
PrepGc();
|
sl@0
|
318 |
|
sl@0
|
319 |
TSize size = iScreen->SizeInPixels();
|
sl@0
|
320 |
TInt width = size.iWidth;
|
sl@0
|
321 |
TInt height = size.iHeight;
|
sl@0
|
322 |
TPoint pos(0, 0);
|
sl@0
|
323 |
|
sl@0
|
324 |
// Draw a square border
|
sl@0
|
325 |
iGc->SetPenColor(TRgb(255,0,0));
|
sl@0
|
326 |
iGc->DrawLine(TPoint(0,0),TPoint(0,height-1));
|
sl@0
|
327 |
iGc->DrawLine (TPoint (0, height-1), TPoint (width-1, height-1));
|
sl@0
|
328 |
iGc->DrawLine(TPoint(width-1,height-1),TPoint(width-1,0));
|
sl@0
|
329 |
iGc->DrawLine (TPoint (width-1, 0), TPoint (0, 0));
|
sl@0
|
330 |
|
sl@0
|
331 |
// Draw a line between the corners of the window
|
sl@0
|
332 |
iGc->DrawLine(TPoint(0,0),TPoint(width, height));
|
sl@0
|
333 |
iGc->DrawLine (TPoint (0, height), TPoint (width, 0));
|
sl@0
|
334 |
|
sl@0
|
335 |
// Draw bitmap
|
sl@0
|
336 |
iGc->BitBlt(pos, &aBitmap);
|
sl@0
|
337 |
|
sl@0
|
338 |
RetireGc();
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
void RTestSrtDecoderStep0002::TestGetNextFrameL()
|
sl@0
|
342 |
{
|
sl@0
|
343 |
// start/stop for multiple times is also tested.
|
sl@0
|
344 |
const TInt64 KSrtMicroSecondsInAMilliSecond = 1000;
|
sl@0
|
345 |
const TInt64 KSrtMicroSecondsInASecond = KSrtMicroSecondsInAMilliSecond * 1000;
|
sl@0
|
346 |
const TInt64 KSrtMicroSecondsInAMinute = KSrtMicroSecondsInASecond * 60;
|
sl@0
|
347 |
const TInt64 KSrtMicroSecondsInAnHour = KSrtMicroSecondsInAMinute * 60;
|
sl@0
|
348 |
const TInt KSrtSetPosTestCount = 6;
|
sl@0
|
349 |
const TInt KSrtNumOfFrames = 10;
|
sl@0
|
350 |
|
sl@0
|
351 |
TTimeIntervalMicroSeconds videoPos[KSrtSetPosTestCount] =
|
sl@0
|
352 |
{
|
sl@0
|
353 |
0,
|
sl@0
|
354 |
KSrtMicroSecondsInAMinute,
|
sl@0
|
355 |
1 * KSrtMicroSecondsInAMinute + 2 * KSrtMicroSecondsInASecond + 1 * KSrtMicroSecondsInAMilliSecond,
|
sl@0
|
356 |
1 * KSrtMicroSecondsInAMinute + 6 * KSrtMicroSecondsInASecond + 20 * KSrtMicroSecondsInAMilliSecond,
|
sl@0
|
357 |
1 * KSrtMicroSecondsInAnHour + 1 * KSrtMicroSecondsInAMinute + 20 * KSrtMicroSecondsInASecond + 1 * KSrtMicroSecondsInAMilliSecond,
|
sl@0
|
358 |
2 * KSrtMicroSecondsInAnHour
|
sl@0
|
359 |
};
|
sl@0
|
360 |
|
sl@0
|
361 |
TInt expectedNumOfFrames[KSrtSetPosTestCount] =
|
sl@0
|
362 |
{
|
sl@0
|
363 |
10,
|
sl@0
|
364 |
8,
|
sl@0
|
365 |
6,
|
sl@0
|
366 |
6,
|
sl@0
|
367 |
2,
|
sl@0
|
368 |
0
|
sl@0
|
369 |
};
|
sl@0
|
370 |
|
sl@0
|
371 |
// check if the required Font is available before do the bitmap file comparison
|
sl@0
|
372 |
TInt requiredFontAvailable = IsFontAvailableL(KSrtTargetTypefaceName);
|
sl@0
|
373 |
if (!requiredFontAvailable)
|
sl@0
|
374 |
{
|
sl@0
|
375 |
#ifdef MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA
|
sl@0
|
376 |
INFO_PRINTF1(_L("Required font is not available, cannot save bitmap data. "));
|
sl@0
|
377 |
User::Leave(KErrGeneral);
|
sl@0
|
378 |
#else
|
sl@0
|
379 |
INFO_PRINTF1(_L("Required font is not available, no bitmap comparison. "));
|
sl@0
|
380 |
#endif //MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA
|
sl@0
|
381 |
}
|
sl@0
|
382 |
|
sl@0
|
383 |
for (TInt i = 0; i < KSrtSetPosTestCount; i++)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
#ifdef __WINSCW__
|
sl@0
|
386 |
TBool compareBitmap = (0 == i) && requiredFontAvailable;
|
sl@0
|
387 |
#else
|
sl@0
|
388 |
TBool compareBitmap = EFalse;
|
sl@0
|
389 |
#endif //__WINSCW__
|
sl@0
|
390 |
|
sl@0
|
391 |
TestGetNextFrameByPositionsL(videoPos[i], expectedNumOfFrames[i], compareBitmap);
|
sl@0
|
392 |
|
sl@0
|
393 |
// verify the bitmaps
|
sl@0
|
394 |
if (compareBitmap)
|
sl@0
|
395 |
{
|
sl@0
|
396 |
#ifndef MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA
|
sl@0
|
397 |
TBool compResult = CompareBmpFilesL(KSrtNumOfFrames - expectedNumOfFrames[i], KSrtNumOfFrames - 1, KSubtitleCurrentBitmapFilePathSpec, KSubtitleTargetBitmapFilePathSpec);
|
sl@0
|
398 |
|
sl@0
|
399 |
DeleteTempFiles(KSrtNumOfFrames - expectedNumOfFrames[i], KSrtNumOfFrames - 1, KSubtitleCurrentBitmapFilePathSpec);
|
sl@0
|
400 |
|
sl@0
|
401 |
if (!compResult)
|
sl@0
|
402 |
{
|
sl@0
|
403 |
INFO_PRINTF1(_L("At least one bitmap file does not match the expected one. "));
|
sl@0
|
404 |
User::Leave(KErrGeneral);
|
sl@0
|
405 |
}
|
sl@0
|
406 |
#endif //MMF_SUBTITLE_SUPPORT_TEST_SAVEDATA
|
sl@0
|
407 |
}
|
sl@0
|
408 |
}
|
sl@0
|
409 |
}
|
sl@0
|
410 |
|
sl@0
|
411 |
void RTestSrtDecoderStep0002::TestGetNextFrameByPositionsL(const TTimeIntervalMicroSeconds& aPosition, TInt aExpectedNumOfFrames, TBool aSaveBitmap)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
TRect dirtyRegion;
|
sl@0
|
414 |
TTimeIntervalMicroSeconds displayTime = 0;
|
sl@0
|
415 |
TTimeIntervalMicroSeconds displayDuration = 0;
|
sl@0
|
416 |
TInt64 tDisplayTime = 0;
|
sl@0
|
417 |
TInt64 tDisplayDuration = 0;
|
sl@0
|
418 |
TSize bmpSize(600, 300);
|
sl@0
|
419 |
TInt numOfFrames = 0;
|
sl@0
|
420 |
TInt err = KErrNone;
|
sl@0
|
421 |
TBuf <KMaxFullName> bitmapFilename;
|
sl@0
|
422 |
|
sl@0
|
423 |
CFbsBitmap* sampleBitmap = new (ELeave) CFbsBitmap();
|
sl@0
|
424 |
CleanupStack::PushL(sampleBitmap);
|
sl@0
|
425 |
|
sl@0
|
426 |
User::LeaveIfError(sampleBitmap->Create(bmpSize, EColor16MA));
|
sl@0
|
427 |
|
sl@0
|
428 |
iSrtDecoder->SetVideoPosition(aPosition);
|
sl@0
|
429 |
iSrtDecoder->Start();
|
sl@0
|
430 |
|
sl@0
|
431 |
while (KErrNone == err)
|
sl@0
|
432 |
{
|
sl@0
|
433 |
TRAP(err, iSrtDecoder->GetNextFrameL(*sampleBitmap, dirtyRegion, displayTime, displayDuration));
|
sl@0
|
434 |
if (KErrNone == err)
|
sl@0
|
435 |
{
|
sl@0
|
436 |
// show bitmap
|
sl@0
|
437 |
DrawBitmap(*sampleBitmap);
|
sl@0
|
438 |
|
sl@0
|
439 |
// save bitmap for the possible comparison
|
sl@0
|
440 |
if (aSaveBitmap)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
bitmapFilename.Format(KSubtitleCurrentBitmapFilePathSpec, numOfFrames);
|
sl@0
|
443 |
User::LeaveIfError(sampleBitmap->Save(bitmapFilename));
|
sl@0
|
444 |
}
|
sl@0
|
445 |
|
sl@0
|
446 |
if ((dirtyRegion.iTl.iX >= dirtyRegion.iBr.iX) ||
|
sl@0
|
447 |
(dirtyRegion.iTl.iY >= dirtyRegion.iBr.iY))
|
sl@0
|
448 |
{
|
sl@0
|
449 |
INFO_PRINTF2(_L("Invalid dirty region received. (frame %d)"), numOfFrames);
|
sl@0
|
450 |
User::Leave(KErrGeneral);
|
sl@0
|
451 |
}
|
sl@0
|
452 |
|
sl@0
|
453 |
tDisplayTime = displayTime.Int64()/1000;
|
sl@0
|
454 |
tDisplayDuration = displayDuration.Int64()/1000;
|
sl@0
|
455 |
INFO_PRINTF4(_L("Frame[%d]: displayTime: %dms, displayDuration: %dms."),
|
sl@0
|
456 |
numOfFrames,
|
sl@0
|
457 |
I64LOW(tDisplayTime),
|
sl@0
|
458 |
I64LOW(tDisplayDuration));
|
sl@0
|
459 |
|
sl@0
|
460 |
numOfFrames++;
|
sl@0
|
461 |
}
|
sl@0
|
462 |
}
|
sl@0
|
463 |
|
sl@0
|
464 |
CleanupStack::PopAndDestroy(sampleBitmap);
|
sl@0
|
465 |
|
sl@0
|
466 |
iSrtDecoder->Stop();
|
sl@0
|
467 |
|
sl@0
|
468 |
if (KErrEof != err)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
User::Leave(err);
|
sl@0
|
471 |
}
|
sl@0
|
472 |
|
sl@0
|
473 |
if (aExpectedNumOfFrames != numOfFrames)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
INFO_PRINTF2(_L("The number of frame (%d) is unexpected. "), numOfFrames);
|
sl@0
|
476 |
User::Leave(KErrGeneral);
|
sl@0
|
477 |
}
|
sl@0
|
478 |
}
|
sl@0
|
479 |
|
sl@0
|
480 |
|
sl@0
|
481 |
// Implementation of RTestSrtDecoderStep0101
|
sl@0
|
482 |
|
sl@0
|
483 |
RTestSrtDecoderStep0101::RTestSrtDecoderStep0101()
|
sl@0
|
484 |
{
|
sl@0
|
485 |
iTestStepName = _L("MM-MMF-SUBTITLE-SRTDECODER-U-0101-HP");
|
sl@0
|
486 |
}
|
sl@0
|
487 |
|
sl@0
|
488 |
TVerdict RTestSrtDecoderStep0101::DoTestStepPreambleL()
|
sl@0
|
489 |
{
|
sl@0
|
490 |
InitializeTestStepL(EFalse, KSampleSubtitleSRTFilepath2);
|
sl@0
|
491 |
|
sl@0
|
492 |
return EPass;
|
sl@0
|
493 |
}
|
sl@0
|
494 |
|
sl@0
|
495 |
TVerdict RTestSrtDecoderStep0101::DoTestStepPostambleL()
|
sl@0
|
496 |
{
|
sl@0
|
497 |
UnInitializeTestStep();
|
sl@0
|
498 |
|
sl@0
|
499 |
return EPass;
|
sl@0
|
500 |
}
|
sl@0
|
501 |
|
sl@0
|
502 |
TVerdict RTestSrtDecoderStep0101::DoTestStepL()
|
sl@0
|
503 |
{
|
sl@0
|
504 |
INFO_PRINTF1(_L("Enter DoTestStepL"));
|
sl@0
|
505 |
TVerdict result = EPass;
|
sl@0
|
506 |
|
sl@0
|
507 |
TRAPD(err, TestGetNextFrameL());
|
sl@0
|
508 |
if (KErrNone != err)
|
sl@0
|
509 |
{
|
sl@0
|
510 |
result = EFail;
|
sl@0
|
511 |
ERR_PRINTF2(_L("Error - RTestSrtDecoderStep0101::TestGetNextFrameL failed. error code %d. "), err);
|
sl@0
|
512 |
INFO_PRINTF1(_L("Exit CSrtDecoder"));
|
sl@0
|
513 |
return result;
|
sl@0
|
514 |
}
|
sl@0
|
515 |
|
sl@0
|
516 |
INFO_PRINTF1(_L("Exit DoTestStepL"));
|
sl@0
|
517 |
return result;
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
void RTestSrtDecoderStep0101::TestGetNextFrameL()
|
sl@0
|
521 |
{
|
sl@0
|
522 |
TInt numOfValidFrame = 0;
|
sl@0
|
523 |
const TInt KSrtCase0101ExpectedValidFrame = 6;
|
sl@0
|
524 |
TRect dirtyRegion;
|
sl@0
|
525 |
TTimeIntervalMicroSeconds displayTime = 0;
|
sl@0
|
526 |
TTimeIntervalMicroSeconds displayDuration = 0;
|
sl@0
|
527 |
TSize bmpSize(320, 120);
|
sl@0
|
528 |
|
sl@0
|
529 |
CFbsBitmap* sampleBitmap = new (ELeave) CFbsBitmap();
|
sl@0
|
530 |
CleanupStack::PushL(sampleBitmap);
|
sl@0
|
531 |
|
sl@0
|
532 |
TInt err = sampleBitmap->Create(
|
sl@0
|
533 |
bmpSize,
|
sl@0
|
534 |
EColor16MA
|
sl@0
|
535 |
);
|
sl@0
|
536 |
User::LeaveIfError(err);
|
sl@0
|
537 |
|
sl@0
|
538 |
iSrtDecoder->SetVideoPosition(0);
|
sl@0
|
539 |
iSrtDecoder->Start();
|
sl@0
|
540 |
|
sl@0
|
541 |
while (KErrNone == err)
|
sl@0
|
542 |
{
|
sl@0
|
543 |
TRAP(err, iSrtDecoder->GetNextFrameL(*sampleBitmap, dirtyRegion, displayTime, displayDuration));
|
sl@0
|
544 |
if (KErrNone == err)
|
sl@0
|
545 |
{
|
sl@0
|
546 |
numOfValidFrame++;
|
sl@0
|
547 |
}
|
sl@0
|
548 |
else if (KErrArgument == err)
|
sl@0
|
549 |
{
|
sl@0
|
550 |
err = KErrNone;
|
sl@0
|
551 |
}
|
sl@0
|
552 |
}
|
sl@0
|
553 |
|
sl@0
|
554 |
CleanupStack::PopAndDestroy(sampleBitmap);
|
sl@0
|
555 |
|
sl@0
|
556 |
iSrtDecoder->Stop();
|
sl@0
|
557 |
|
sl@0
|
558 |
if (err != KErrEof)
|
sl@0
|
559 |
{
|
sl@0
|
560 |
User::Leave(err);
|
sl@0
|
561 |
}
|
sl@0
|
562 |
|
sl@0
|
563 |
if (KSrtCase0101ExpectedValidFrame != numOfValidFrame)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
INFO_PRINTF2(_L("The number of valid frame (%d) is unexpected. "), numOfValidFrame);
|
sl@0
|
566 |
User::Leave(KErrGeneral);
|
sl@0
|
567 |
}
|
sl@0
|
568 |
}
|
sl@0
|
569 |
|
sl@0
|
570 |
// Implementation of RTestSrtDecoderStep0103
|
sl@0
|
571 |
|
sl@0
|
572 |
RTestSrtDecoderStep0103::RTestSrtDecoderStep0103()
|
sl@0
|
573 |
{
|
sl@0
|
574 |
iTestStepName = _L("MM-MMF-SUBTITLE-SRTDECODER-U-0103-HP");
|
sl@0
|
575 |
}
|
sl@0
|
576 |
|
sl@0
|
577 |
TVerdict RTestSrtDecoderStep0103::DoTestStepPreambleL()
|
sl@0
|
578 |
{
|
sl@0
|
579 |
User::LeaveIfError(RFbsSession::Connect());
|
sl@0
|
580 |
|
sl@0
|
581 |
return EPass;
|
sl@0
|
582 |
}
|
sl@0
|
583 |
|
sl@0
|
584 |
TVerdict RTestSrtDecoderStep0103::DoTestStepPostambleL()
|
sl@0
|
585 |
{
|
sl@0
|
586 |
RFbsSession::Disconnect();
|
sl@0
|
587 |
|
sl@0
|
588 |
return EPass;
|
sl@0
|
589 |
}
|
sl@0
|
590 |
|
sl@0
|
591 |
TVerdict RTestSrtDecoderStep0103::DoTestStepL()
|
sl@0
|
592 |
{
|
sl@0
|
593 |
INFO_PRINTF1(_L("Enter DoTestStepL"));
|
sl@0
|
594 |
TVerdict result = EFail;
|
sl@0
|
595 |
TSize bmpSize(120, 320);
|
sl@0
|
596 |
|
sl@0
|
597 |
CFbsBitmap* sampleBitmap = new (ELeave) CFbsBitmap();
|
sl@0
|
598 |
CleanupStack::PushL(sampleBitmap);
|
sl@0
|
599 |
User::LeaveIfError(sampleBitmap->Create(bmpSize, EColor16MA));
|
sl@0
|
600 |
|
sl@0
|
601 |
for (TInt failRate = 1; ; ++failRate)
|
sl@0
|
602 |
{
|
sl@0
|
603 |
__UHEAP_SETFAIL(RHeap::EFailNext, failRate);
|
sl@0
|
604 |
__UHEAP_MARK;
|
sl@0
|
605 |
|
sl@0
|
606 |
TRAPD(error, TestGetNextFrameL(*sampleBitmap));
|
sl@0
|
607 |
RDebug::Printf("Ending iteration %d. Result = %d. Failures = %d", failRate, error, __UHEAP_CHECKFAILURE);
|
sl@0
|
608 |
|
sl@0
|
609 |
__UHEAP_MARKEND;
|
sl@0
|
610 |
|
sl@0
|
611 |
if ((error != KErrNone) && (error != KErrNoMemory))
|
sl@0
|
612 |
{
|
sl@0
|
613 |
ERR_PRINTF3(_L("RTestSrtDecoderStep0103: TESTS FAILED TO COMPLETE (failRate=%i) error code: %d\n"), failRate, error);
|
sl@0
|
614 |
break;
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
TAny* const pointer = User::Alloc(1);
|
sl@0
|
618 |
User::Free(pointer);
|
sl@0
|
619 |
if (!pointer)
|
sl@0
|
620 |
{
|
sl@0
|
621 |
result = EPass;
|
sl@0
|
622 |
break;
|
sl@0
|
623 |
}
|
sl@0
|
624 |
}
|
sl@0
|
625 |
|
sl@0
|
626 |
__UHEAP_RESET;
|
sl@0
|
627 |
|
sl@0
|
628 |
CleanupStack::PopAndDestroy(sampleBitmap);
|
sl@0
|
629 |
|
sl@0
|
630 |
INFO_PRINTF1(_L("Exit DoTestStepL"));
|
sl@0
|
631 |
return result;
|
sl@0
|
632 |
}
|
sl@0
|
633 |
|
sl@0
|
634 |
void RTestSrtDecoderStep0103::TestGetNextFrameL(CFbsBitmap& aBitmap)
|
sl@0
|
635 |
{
|
sl@0
|
636 |
TRect dirtyRegion;
|
sl@0
|
637 |
CSrtReader *srtReader = CSrtReader::NewL(KSampleSubtitleSRTFilepath1);
|
sl@0
|
638 |
CleanupStack::PushL(srtReader);
|
sl@0
|
639 |
|
sl@0
|
640 |
CSrtSubtitleDecoder *srtDecoder = CSrtSubtitleDecoder::NewL(*srtReader);
|
sl@0
|
641 |
CleanupStack::PushL(srtDecoder);
|
sl@0
|
642 |
|
sl@0
|
643 |
TInt err = KErrNone;
|
sl@0
|
644 |
TTimeIntervalMicroSeconds displayTime = 0;
|
sl@0
|
645 |
TTimeIntervalMicroSeconds displayDuration = 0;
|
sl@0
|
646 |
|
sl@0
|
647 |
srtDecoder->SetVideoPosition(0);
|
sl@0
|
648 |
srtDecoder->Start();
|
sl@0
|
649 |
|
sl@0
|
650 |
while (KErrNone == err)
|
sl@0
|
651 |
{
|
sl@0
|
652 |
TRAP(err, srtDecoder->GetNextFrameL(aBitmap, dirtyRegion, displayTime, displayDuration));
|
sl@0
|
653 |
}
|
sl@0
|
654 |
|
sl@0
|
655 |
if (err != KErrEof)
|
sl@0
|
656 |
{
|
sl@0
|
657 |
User::LeaveIfError(err);
|
sl@0
|
658 |
}
|
sl@0
|
659 |
|
sl@0
|
660 |
srtDecoder->Stop();
|
sl@0
|
661 |
|
sl@0
|
662 |
CleanupStack::PopAndDestroy(srtDecoder);
|
sl@0
|
663 |
CleanupStack::PopAndDestroy(srtReader);
|
sl@0
|
664 |
}
|
sl@0
|
665 |
|
sl@0
|
666 |
RTestSrtDecoderStep0105::RTestSrtDecoderStep0105()
|
sl@0
|
667 |
{
|
sl@0
|
668 |
iTestStepName = _L("MM-MMF-SUBTITLE-SRTDECODER-U-0105-HP");
|
sl@0
|
669 |
}
|
sl@0
|
670 |
|
sl@0
|
671 |
TVerdict RTestSrtDecoderStep0105::DoTestStepL()
|
sl@0
|
672 |
{
|
sl@0
|
673 |
iSrtDecoder->Start();
|
sl@0
|
674 |
iSrtDecoder->Start();
|
sl@0
|
675 |
|
sl@0
|
676 |
ERR_PRINTF1(_L("Panic expected, so failing"));
|
sl@0
|
677 |
return EFail;
|
sl@0
|
678 |
}
|
sl@0
|
679 |
|
sl@0
|
680 |
TVerdict RTestSrtDecoderStep0105::DoTestStepPreambleL()
|
sl@0
|
681 |
{
|
sl@0
|
682 |
InitializeTestStepL(EFalse, KSampleSubtitleSRTFilepath1);
|
sl@0
|
683 |
return EPass;
|
sl@0
|
684 |
}
|
sl@0
|
685 |
|
sl@0
|
686 |
TVerdict RTestSrtDecoderStep0105::DoTestStepPostambleL()
|
sl@0
|
687 |
{
|
sl@0
|
688 |
UnInitializeTestStep();
|
sl@0
|
689 |
return EPass;
|
sl@0
|
690 |
}
|