os/kernelhwsrv/kerneltest/e32test/emul/d_guiconfig.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/emul/d_guiconfig.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,149 @@
     1.4 +// Copyright (c) 2005-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 the License "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 +// e32test\emul\d_guiconfig.cpp
    1.18 +// LDD for testing emulator GUI config API
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include <kernel/kernel.h>
    1.23 +#include <wins/winsgui.h>
    1.24 +#include <e32keys.h>
    1.25 +#include "d_guiconfig.h"
    1.26 +
    1.27 +const TInt KMajorVersionNumber=0;
    1.28 +const TInt KMinorVersionNumber=1;
    1.29 +const TInt KBuildVersionNumber=1;
    1.30 +
    1.31 +class DTest;
    1.32 +
    1.33 +class DTestFactory : public DLogicalDevice
    1.34 +//
    1.35 +// Test LDD factory
    1.36 +//
    1.37 +	{
    1.38 +public:
    1.39 +	DTestFactory();
    1.40 +	virtual TInt Install(); 					//overriding pure virtual
    1.41 +	virtual void GetCaps(TDes8& aDes) const;	//overriding pure virtual
    1.42 +	virtual TInt Create(DLogicalChannelBase*& aChannel); 	//overriding pure virtual
    1.43 +	};
    1.44 +
    1.45 +class DTest : public DLogicalChannelBase
    1.46 +//
    1.47 +// Test logical channel
    1.48 +//
    1.49 +	{
    1.50 +public:
    1.51 +	virtual ~DTest();
    1.52 +protected:
    1.53 +	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
    1.54 +	virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
    1.55 +	};
    1.56 +
    1.57 +DECLARE_STANDARD_LDD()
    1.58 +	{
    1.59 +	return new DTestFactory;
    1.60 +	}
    1.61 +
    1.62 +DTestFactory::DTestFactory()
    1.63 +//
    1.64 +// Constructor
    1.65 +//
    1.66 +	{
    1.67 +	iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
    1.68 +	//iParseMask=0;//No units, no info, no PDD
    1.69 +	//iUnitsMask=0;//Only one thing
    1.70 +	}
    1.71 +
    1.72 +TInt DTestFactory::Create(DLogicalChannelBase*& aChannel)
    1.73 +//
    1.74 +// Create a new DTest on this logical device
    1.75 +//
    1.76 +	{
    1.77 +	aChannel=new DTest;
    1.78 +	return aChannel?KErrNone:KErrNoMemory;
    1.79 +	}
    1.80 +
    1.81 +TInt DTestFactory::Install()
    1.82 +//
    1.83 +// Install the LDD - overriding pure virtual
    1.84 +//
    1.85 +	{
    1.86 +	return SetName(&KLddName);
    1.87 +	}
    1.88 +
    1.89 +void DTestFactory::GetCaps(TDes8& aDes) const
    1.90 +//
    1.91 +// Get capabilities - overriding pure virtual
    1.92 +//
    1.93 +	{
    1.94 +	TCapsTestV01 b;
    1.95 +	b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber);
    1.96 +    Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b));
    1.97 +	}
    1.98 +
    1.99 +TInt DTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer)
   1.100 +//
   1.101 +// Create channel
   1.102 +//
   1.103 +	{
   1.104 +
   1.105 +	if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer))
   1.106 +		return KErrNotSupported;
   1.107 +	return KErrNone;
   1.108 +	}
   1.109 +
   1.110 +DTest::~DTest()
   1.111 +//
   1.112 +// Destructor
   1.113 +//
   1.114 +	{
   1.115 +	}
   1.116 +
   1.117 +TInt DTest::Request(TInt aFunction, TAny* a1, TAny* a2)
   1.118 +	{
   1.119 +	(void)a1;
   1.120 +	(void)a2;
   1.121 +	TInt r=KErrNone;
   1.122 +	switch (aFunction)
   1.123 +		{
   1.124 +		case RGuiConfigTest::EGetConfig:
   1.125 +			{
   1.126 +			r = WinsGui::CurrentConfiguration();
   1.127 +			break;
   1.128 +			}
   1.129 +		case RGuiConfigTest::EGenerateKeyEvent:
   1.130 +			{
   1.131 +			r = WinsGui::CurrentConfiguration();
   1.132 +
   1.133 +			TRawEvent eventDown, eventUp;
   1.134 +			eventDown.Set(TRawEvent::EKeyDown, (EKeyScreenDimension0 + r)<<16);
   1.135 +			eventUp.Set(TRawEvent::EKeyUp, (EKeyScreenDimension0 + r)<<16);
   1.136 +
   1.137 +			NKern::ThreadEnterCS();
   1.138 +			r = Kern::AddEvent(eventDown);
   1.139 +			if (r == KErrNone)
   1.140 +				r = Kern::AddEvent(eventUp);
   1.141 +			NKern::ThreadLeaveCS();
   1.142 +			break;
   1.143 +			}
   1.144 +		default:
   1.145 +			{
   1.146 +			r=KErrNotSupported;
   1.147 +			break;
   1.148 +			}
   1.149 +		}
   1.150 +	return r;
   1.151 +	}
   1.152 +