lafagnosticuifoundation/animation/tef/TMng.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2006-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent - Internal Symbian test code  
       
    19 */
       
    20 
       
    21 #include  <fbs.h>
       
    22 #include "TMng.h"
       
    23 #include "ActiveWait.h"
       
    24 #include "ICLAnimationDataProvider.h"
       
    25 #include "AnimationEvents.h"
       
    26 
       
    27 _LIT(KMngFile, "Z:\\Private\\10204F5B\\simple_b.mng");
       
    28 const TInt KExpectedNumberOfFrames = 12; // must match number of frames in KMngFile
       
    29 
       
    30 CMng::CMng()
       
    31 	{
       
    32 	SetTestStepName(KMngStep);
       
    33 	}
       
    34 	
       
    35 CMng::~CMng()
       
    36 	{
       
    37 	iFs.Close();
       
    38 	RFbsSession::Disconnect();
       
    39 	delete iDataProvider;
       
    40 	if(iWaiter)
       
    41 		{
       
    42 		iWaiter->Cancel();
       
    43 		delete iWaiter;
       
    44 		}
       
    45 	}
       
    46 
       
    47 void CMng::StartTestL()
       
    48 	{
       
    49 	iWaiter = CActiveWait::NewL();
       
    50 	
       
    51 	User::LeaveIfError(iFs.Connect());
       
    52 	User::LeaveIfError(RFbsSession::Connect());
       
    53 	iDataProvider = new (ELeave) CICLAnimationDataProvider;
       
    54 	iDataProvider->SetObserver(this);
       
    55 	iDataProvider->SetFileL(iFs, KMngFile());
       
    56 	iDataProvider->StartL(); // decode all frames
       
    57 	}
       
    58 
       
    59 /**
       
    60 @SYMTestCaseID UIF-ANIMATION-0001
       
    61 @SYMDEF DEF084519
       
    62 @SYMTestCaseDesc This test verifies that CICLAnimationDataLoader manages to extract frames from image files encoded as multi image network graphics.
       
    63 @SYMTestPriority High
       
    64 @SYMTestStatus Implemented
       
    65 @SYMTestActions The test verifies that we receive EBitmapAnimationComplete and that the number of extracted frames at that point equals the expected number of frames.
       
    66 @SYMTestExpectedResults Test should complete without any leave, panic or error.
       
    67  */
       
    68 TVerdict CMng::doActiveTestStepL()
       
    69 	{
       
    70 	SetTestStepID(_L("UIF-ANIMATION-0001"));
       
    71 
       
    72 	StartTestL();
       
    73 			
       
    74 	const TInt KTimeOut = 5*1000000;
       
    75 	iWaiter->Wait(KTimeOut); // continue on timeout or EImageConvertComplete
       
    76 
       
    77 	TEST(iConvertionComplete);
       
    78 	TEST(iDecodedFrames == KExpectedNumberOfFrames);
       
    79 	
       
    80 	RecordTestResultL();
       
    81 	CloseTMSGraphicsStep();
       
    82 
       
    83 	return TestStepResult();
       
    84 	}
       
    85 
       
    86 // from MAnimationDataProviderObserver
       
    87 void CMng::DataProviderEventL(TInt aEvent, TAny* /*aData*/, TInt /*aDataSize*/)
       
    88 	{
       
    89 	switch(aEvent)
       
    90 		{
       
    91 		case EAnimationDataChanged:
       
    92 			break;
       
    93 		case EBitmapAnimationNewFrame:
       
    94 			++iDecodedFrames;
       
    95 			break;
       
    96 		case EBitmapAnimationComplete:
       
    97 			iConvertionComplete = ETrue;
       
    98 			iWaiter->Cancel();
       
    99 			break;
       
   100 		default:
       
   101 			TESTE(EFalse, aEvent);
       
   102 			break;
       
   103 		}
       
   104 	}