os/mm/mmlibs/mmfw/tsrc/mmfunittest/videorenderer/src/testrupdatesession.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/videorenderer/src/testrupdatesession.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,128 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <graphics/surfaceupdateclient.h>
    1.20 +#include <graphics/surface.h>
    1.21 +#include <graphics/suerror.h>
    1.22 +#include "testgceharness.h"
    1.23 +
    1.24 +inline void SurfaceUpdateAssert(TInt aCond)	{__ASSERT_ALWAYS(aCond, User::Panic(_L("surfaceupdateclient.cpp; assertion failed"), __LINE__));}
    1.25 +
    1.26 +EXPORT_C RSurfaceUpdateSession::RSurfaceUpdateSession() :
    1.27 +	RSessionBase(), 
    1.28 +	iStatusAvailable(NULL), iStatusDisplayed(NULL), iStatusDisplayedXTimes(NULL)
    1.29 +	{
    1.30 +	}
    1.31 +
    1.32 +EXPORT_C TInt RSurfaceUpdateSession::Connect(TInt /*aMessageSlots*/)
    1.33 +	{
    1.34 +	iStatusAvailable = NULL;
    1.35 +	iStatusDisplayed = NULL;
    1.36 +	iStatusDisplayedXTimes = NULL;
    1.37 +
    1.38 +	CTestGCEHarness* gceHarness = NULL;
    1.39 +	TRAPD(err, gceHarness = CTestGCEHarness::RetrieveL());
    1.40 +	if(err != KErrNone)
    1.41 +		{
    1.42 +		return err;
    1.43 +		}
    1.44 +	return gceHarness->Connect();
    1.45 +	}
    1.46 +
    1.47 +EXPORT_C void RSurfaceUpdateSession::Close()	
    1.48 +	{
    1.49 +	iStatusAvailable = NULL;
    1.50 +	iStatusDisplayed = NULL;
    1.51 +	iStatusDisplayedXTimes = NULL;
    1.52 +	
    1.53 +	CTestGCEHarness* gceHarness = NULL;
    1.54 +	TRAPD(err, gceHarness = CTestGCEHarness::RetrieveL());
    1.55 +	if(err != KErrNone)
    1.56 +		{
    1.57 +		return;
    1.58 +		}
    1.59 +	gceHarness->Close();
    1.60 +	}
    1.61 +
    1.62 +EXPORT_C TInt RSurfaceUpdateSession::SubmitUpdate(TInt aScreen, const TSurfaceId& aSurfaceId, 
    1.63 +									TInt aBuffer, const TRegion* /*aDirtyRegion*/)
    1.64 +	{
    1.65 +	if(aScreen != KAllScreens || aBuffer < 0 || aSurfaceId.IsNull())
    1.66 +		{
    1.67 +		IssueRequestComplete(KErrArgument);
    1.68 +        return KErrArgument;
    1.69 +        }
    1.70 +
    1.71 +	CTestGCEHarness* gceHarness = NULL;
    1.72 +	TRAPD(err, gceHarness = CTestGCEHarness::RetrieveL());
    1.73 +	if(err != KErrNone)
    1.74 +		{
    1.75 +		return err;
    1.76 +		}
    1.77 +	return gceHarness->SubmitUpdate(aBuffer);
    1.78 +	}
    1.79 +
    1.80 +EXPORT_C void RSurfaceUpdateSession::NotifyWhenAvailable(TRequestStatus& aStatus)
    1.81 +	{
    1.82 +	CTestGCEHarness* gceHarness = NULL;
    1.83 +	TRAPD(err, gceHarness = CTestGCEHarness::RetrieveL());
    1.84 +
    1.85 +	if(err != KErrNone)
    1.86 +		{
    1.87 +		return;
    1.88 +		}
    1.89 +	
    1.90 +	gceHarness->NotifyWhenAvailable(aStatus);
    1.91 +	}
    1.92 +	
    1.93 +EXPORT_C void RSurfaceUpdateSession::NotifyWhenDisplayed(TRequestStatus& aStatus, TTimeStamp& aTimeStamp)
    1.94 +	{
    1.95 +	CTestGCEHarness* gceHarness = NULL;
    1.96 +	TRAPD(err, gceHarness = CTestGCEHarness::RetrieveL());
    1.97 +
    1.98 +	if(err != KErrNone)
    1.99 +		{
   1.100 +		return;
   1.101 +		}
   1.102 +
   1.103 +	gceHarness->NotifyWhenDisplayed(aStatus, aTimeStamp);
   1.104 +	}
   1.105 +
   1.106 +EXPORT_C void RSurfaceUpdateSession::NotifyWhenDisplayedXTimes(TInt aCount, TRequestStatus &aStatus)
   1.107 +	{
   1.108 +	iStatusDisplayedXTimes = &aStatus;
   1.109 +	//we will check aCount validity at submission time (in SubmitUpdate)
   1.110 +	iCount = aCount;
   1.111 +	}
   1.112 +
   1.113 +EXPORT_C void RSurfaceUpdateSession::CancelAllUpdateNotifications()
   1.114 +	{
   1.115 +	CTestGCEHarness* gceHarness = NULL;
   1.116 +	TRAPD(err, gceHarness = CTestGCEHarness::RetrieveL());
   1.117 +	if(err != KErrNone)
   1.118 +		{
   1.119 +		return;
   1.120 +		}
   1.121 +	gceHarness->CancelAllNotifications();
   1.122 +	}
   1.123 +	
   1.124 +TVersion RSurfaceUpdateSession::Version() const
   1.125 +	{
   1.126 +	return (TVersion(1, 1, 1));
   1.127 +	}
   1.128 +
   1.129 +void RSurfaceUpdateSession::IssueRequestComplete(TInt /*aErr*/)
   1.130 +	{
   1.131 +	}