os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/teststepvclnt2crp.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2008-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 #include "teststepvclnt2crp.h"
    17 #include <graphics/surfaceconfiguration.h>
    18 
    19 const TInt KScreenNumber = 0;
    20 
    21 _LIT(KUseCRP, "UseCRP");
    22 _LIT(KAddDisplay, "AddDisplay");
    23 _LIT(KAddWindow, "AddWindow");
    24 _LIT(Kfilename, "filename");
    25 
    26 RTestStepVclnt2CRP* RTestStepVclnt2CRP::NewL(const TDesC& aName)
    27 	{
    28 	RTestStepVclnt2CRP* self = new (ELeave) RTestStepVclnt2CRP(aName);
    29 	return self;
    30 	}
    31 
    32 RTestStepVclnt2CRP::RTestStepVclnt2CRP(const TDesC& aName) :
    33 	RTestVclnt2PlayFile(aName, aName, Kfilename, KErrNone)
    34 	{
    35 	}
    36 
    37 RTestStepVclnt2CRP::~RTestStepVclnt2CRP()
    38 	{	
    39 	if (iSurfaceWindow)
    40 		{	
    41 		iSurfaceWindow->Close();
    42 		}
    43 
    44 	delete iSurfaceWindow;
    45 	}
    46 
    47 TVerdict RTestStepVclnt2CRP::DoTestStepPreambleL()
    48 	{
    49 	iTestStepResult = RTestVclnt2PlayFile::DoTestStepPreambleL();
    50 
    51 	if (iTestStepResult == EPass)
    52 		{
    53 		iTestStepResult = EFail;
    54 		// Assume if values are not set to revert to defaults
    55 		// e.g. EFalse default
    56 		GetBoolFromConfig(iTestStepName, KUseCRP, iUseCRP);
    57 		// EFalse default
    58 		GetBoolFromConfig(iTestStepName, KAddDisplay, iAddDisplay);
    59 		// EFalse default
    60 		GetBoolFromConfig(iTestStepName, KAddWindow, iAddWindow);
    61 
    62 		iSurfaceWindow = new (ELeave) RWindow(iWs);
    63 		// Don't use this but instead something 'unique' since this is used in the base class to
    64 		// construct a window
    65 		User::LeaveIfError(iSurfaceWindow->Construct(*iWindow, reinterpret_cast<TInt>(this + 3431)));
    66 		iTestStepResult = EPass;
    67 		}
    68 
    69 	return iTestStepResult;	
    70 	}
    71 
    72 TVerdict RTestStepVclnt2CRP::DoTestStepPostambleL()
    73 	{
    74 	if (iSurfaceWindow)
    75 		{
    76 		iSurfaceWindow->Close();
    77 		iSurfaceWindow = NULL;
    78 		}
    79 
    80 	return RTestVclnt2PlayFile::DoTestStepPostambleL();	
    81 	}
    82 
    83 void RTestStepVclnt2CRP::HandleOpenCompleteL()
    84 	{
    85 	if (!iAddWindow)
    86 		{
    87 		iVideoPlayer2->RemoveDisplayWindow(*iWindow);
    88 		}
    89 	
    90 	if (iAddDisplay)
    91 		{
    92 		iVideoPlayer2->AddDisplayL(iWs, KScreenNumber, *this);
    93 		}
    94 
    95 	RTestVclnt2PlayFile::HandleOpenCompleteL();
    96 	}
    97 
    98 void RTestStepVclnt2CRP::MmsehSurfaceCreated(TInt aDisplayId, const TSurfaceId& aId, const TRect& aCropRect, TVideoAspectRatio /*aAspectRatio*/)
    99 	{
   100 	if (aDisplayId != KScreenNumber)
   101 		{
   102 		FailTest(_L("Mismatching display id provided to MmsehSurfaceCreated"));
   103 		return;
   104 		}
   105 
   106 	iSurfaceId = aId;
   107 	iCropRect = aCropRect;	
   108 
   109 	const TRect windowSize(iSurfaceWindow->Size());
   110 
   111 	TSurfaceConfiguration config;
   112 	config.SetSurfaceId(iSurfaceId);
   113 	config.SetExtent(windowSize);
   114 	config.SetViewport(iCropRect);
   115 
   116 	iSurfaceWindow->SetVisible(ETrue);
   117 	iSurfaceWindow->SetBackgroundColor(TRgb(0, 0));
   118 
   119 	TRAP_IGNORE(iVideoPlayer2->SetRotationL(*iWindow, EVideoRotationClockwise90));
   120 	TRAP_IGNORE(iVideoPlayer2->RotationL(*iWindow));
   121 	TRAP_IGNORE(iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleBestFit));
   122 
   123 	iSurfaceWindow->SetBackgroundSurface(config, KScreenNumber);
   124 	iSurfaceWindow->BeginRedraw();
   125 	iSurfaceWindow->EndRedraw();
   126 	}
   127 
   128 void RTestStepVclnt2CRP::MmsehSurfaceParametersChanged(const TSurfaceId& /*aId*/, const TRect& /*aCropRect*/, TVideoAspectRatio /*aAspectRatio*/)
   129 	{
   130 	FailTest(_L("Unexpected call to MmsehSurfaceParametersChanged"));
   131 	}
   132 
   133 void RTestStepVclnt2CRP::MmsehRemoveSurface(const TSurfaceId& /*aId*/)
   134 	{
   135 	FailTest(_L("Unexpected call to MmsehRemoveSurface"));
   136 	}
   137 
   138 void RTestStepVclnt2CRP::FailTest(const TDesC& aMessage)
   139 	{
   140 	ERR_PRINTF2(_L("%S"), &aMessage);
   141 	iTestStepResult = EFail;
   142 	iActiveScheduler->Stop();
   143 	}
   144