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".
 
     8 // Initial Contributors:
 
     9 // Nokia Corporation - initial contribution.
 
    16 #include "teststepvclnt2crp.h"
 
    17 #include <graphics/surfaceconfiguration.h>
 
    19 const TInt KScreenNumber = 0;
 
    21 _LIT(KUseCRP, "UseCRP");
 
    22 _LIT(KAddDisplay, "AddDisplay");
 
    23 _LIT(KAddWindow, "AddWindow");
 
    24 _LIT(Kfilename, "filename");
 
    26 RTestStepVclnt2CRP* RTestStepVclnt2CRP::NewL(const TDesC& aName)
 
    28 	RTestStepVclnt2CRP* self = new (ELeave) RTestStepVclnt2CRP(aName);
 
    32 RTestStepVclnt2CRP::RTestStepVclnt2CRP(const TDesC& aName) :
 
    33 	RTestVclnt2PlayFile(aName, aName, Kfilename, KErrNone)
 
    37 RTestStepVclnt2CRP::~RTestStepVclnt2CRP()
 
    41 		iSurfaceWindow->Close();
 
    44 	delete iSurfaceWindow;
 
    47 TVerdict RTestStepVclnt2CRP::DoTestStepPreambleL()
 
    49 	iTestStepResult = RTestVclnt2PlayFile::DoTestStepPreambleL();
 
    51 	if (iTestStepResult == EPass)
 
    53 		iTestStepResult = EFail;
 
    54 		// Assume if values are not set to revert to defaults
 
    55 		// e.g. EFalse default
 
    56 		GetBoolFromConfig(iTestStepName, KUseCRP, iUseCRP);
 
    58 		GetBoolFromConfig(iTestStepName, KAddDisplay, iAddDisplay);
 
    60 		GetBoolFromConfig(iTestStepName, KAddWindow, iAddWindow);
 
    62 		iSurfaceWindow = new (ELeave) RWindow(iWs);
 
    63 		// Don't use this but instead something 'unique' since this is used in the base class to
 
    65 		User::LeaveIfError(iSurfaceWindow->Construct(*iWindow, reinterpret_cast<TInt>(this + 3431)));
 
    66 		iTestStepResult = EPass;
 
    69 	return iTestStepResult;	
 
    72 TVerdict RTestStepVclnt2CRP::DoTestStepPostambleL()
 
    76 		iSurfaceWindow->Close();
 
    77 		iSurfaceWindow = NULL;
 
    80 	return RTestVclnt2PlayFile::DoTestStepPostambleL();	
 
    83 void RTestStepVclnt2CRP::HandleOpenCompleteL()
 
    87 		iVideoPlayer2->RemoveDisplayWindow(*iWindow);
 
    92 		iVideoPlayer2->AddDisplayL(iWs, KScreenNumber, *this);
 
    95 	RTestVclnt2PlayFile::HandleOpenCompleteL();
 
    98 void RTestStepVclnt2CRP::MmsehSurfaceCreated(TInt aDisplayId, const TSurfaceId& aId, const TRect& aCropRect, TVideoAspectRatio /*aAspectRatio*/)
 
   100 	if (aDisplayId != KScreenNumber)
 
   102 		FailTest(_L("Mismatching display id provided to MmsehSurfaceCreated"));
 
   107 	iCropRect = aCropRect;	
 
   109 	const TRect windowSize(iSurfaceWindow->Size());
 
   111 	TSurfaceConfiguration config;
 
   112 	config.SetSurfaceId(iSurfaceId);
 
   113 	config.SetExtent(windowSize);
 
   114 	config.SetViewport(iCropRect);
 
   116 	iSurfaceWindow->SetVisible(ETrue);
 
   117 	iSurfaceWindow->SetBackgroundColor(TRgb(0, 0));
 
   119 	TRAP_IGNORE(iVideoPlayer2->SetRotationL(*iWindow, EVideoRotationClockwise90));
 
   120 	TRAP_IGNORE(iVideoPlayer2->RotationL(*iWindow));
 
   121 	TRAP_IGNORE(iVideoPlayer2->SetAutoScaleL(*iWindow, EAutoScaleBestFit));
 
   123 	iSurfaceWindow->SetBackgroundSurface(config, KScreenNumber);
 
   124 	iSurfaceWindow->BeginRedraw();
 
   125 	iSurfaceWindow->EndRedraw();
 
   128 void RTestStepVclnt2CRP::MmsehSurfaceParametersChanged(const TSurfaceId& /*aId*/, const TRect& /*aCropRect*/, TVideoAspectRatio /*aAspectRatio*/)
 
   130 	FailTest(_L("Unexpected call to MmsehSurfaceParametersChanged"));
 
   133 void RTestStepVclnt2CRP::MmsehRemoveSurface(const TSurfaceId& /*aId*/)
 
   135 	FailTest(_L("Unexpected call to MmsehRemoveSurface"));
 
   138 void RTestStepVclnt2CRP::FailTest(const TDesC& aMessage)
 
   140 	ERR_PRINTF2(_L("%S"), &aMessage);
 
   141 	iTestStepResult = EFail;
 
   142 	iActiveScheduler->Stop();