os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanualsecondprocess.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/src/tsggenericmanualsecondprocess.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,61 @@
     1.4 +// Copyright (c) 2010 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 <e32msgqueue.h>
    1.20 +#include <sgresource/sgimage.h>
    1.21 +#include "tgraphicsresourcemultiprocessthread.h"
    1.22 +
    1.23 +// The second process waits for image IDs sent by the main test process
    1.24 +// and opens and closes RSgImage handles to the corresponding images.
    1.25 +// Image IDs are received through a message queue and synchronisation
    1.26 +// with the main process is achieved by means of rendezvous objects.
    1.27 +// A null ID indicates the end of the test.
    1.28 +void MainL()
    1.29 +	{
    1.30 +	RSgDriver driver;
    1.31 +	User::LeaveIfError(driver.Open());
    1.32 +	CleanupClosePushL(driver);
    1.33 +	RMsgQueue<TSgDrawableId> msgQ;
    1.34 +	User::LeaveIfError(msgQ.OpenGlobal(KSgTestMultiprocessMsgQ));
    1.35 +	CleanupClosePushL(msgQ);
    1.36 +	for (;;)
    1.37 +		{
    1.38 +		TSgDrawableId id;
    1.39 +		msgQ.ReceiveBlocking(id);
    1.40 +		if (id == KSgNullDrawableId)
    1.41 +			{
    1.42 +			break;
    1.43 +			}
    1.44 +		RSgImage image;
    1.45 +		TInt err = image.Open(id);
    1.46 +		image.Close();
    1.47 +		RProcess::Rendezvous(err);
    1.48 +		}
    1.49 +	CleanupStack::PopAndDestroy(2);
    1.50 +	}
    1.51 +
    1.52 +GLDEF_C TInt E32Main()
    1.53 +	{
    1.54 +	__UHEAP_MARK;
    1.55 +	CTrapCleanup* cleanup = CTrapCleanup::New();
    1.56 +	if (!cleanup)
    1.57 +		{
    1.58 +		return KErrNoMemory;
    1.59 +		}
    1.60 +	TRAPD(ret, MainL());
    1.61 +	delete cleanup;
    1.62 +	__UHEAP_MARKEND;
    1.63 +	return ret;
    1.64 +	}