sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\emul\d_guiconfig.cpp sl@0: // LDD for testing emulator GUI config API sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "d_guiconfig.h" sl@0: sl@0: const TInt KMajorVersionNumber=0; sl@0: const TInt KMinorVersionNumber=1; sl@0: const TInt KBuildVersionNumber=1; sl@0: sl@0: class DTest; sl@0: sl@0: class DTestFactory : public DLogicalDevice sl@0: // sl@0: // Test LDD factory sl@0: // sl@0: { sl@0: public: sl@0: DTestFactory(); sl@0: virtual TInt Install(); //overriding pure virtual sl@0: virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual sl@0: }; sl@0: sl@0: class DTest : public DLogicalChannelBase sl@0: // sl@0: // Test logical channel sl@0: // sl@0: { sl@0: public: sl@0: virtual ~DTest(); sl@0: protected: sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); sl@0: virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); sl@0: }; sl@0: sl@0: DECLARE_STANDARD_LDD() sl@0: { sl@0: return new DTestFactory; sl@0: } sl@0: sl@0: DTestFactory::DTestFactory() sl@0: // sl@0: // Constructor sl@0: // sl@0: { sl@0: iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); sl@0: //iParseMask=0;//No units, no info, no PDD sl@0: //iUnitsMask=0;//Only one thing sl@0: } sl@0: sl@0: TInt DTestFactory::Create(DLogicalChannelBase*& aChannel) sl@0: // sl@0: // Create a new DTest on this logical device sl@0: // sl@0: { sl@0: aChannel=new DTest; sl@0: return aChannel?KErrNone:KErrNoMemory; sl@0: } sl@0: sl@0: TInt DTestFactory::Install() sl@0: // sl@0: // Install the LDD - overriding pure virtual sl@0: // sl@0: { sl@0: return SetName(&KLddName); sl@0: } sl@0: sl@0: void DTestFactory::GetCaps(TDes8& aDes) const sl@0: // sl@0: // Get capabilities - overriding pure virtual sl@0: // sl@0: { sl@0: TCapsTestV01 b; sl@0: b.iVersion=TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber); sl@0: Kern::InfoCopy(aDes,(TUint8*)&b,sizeof(b)); sl@0: } sl@0: sl@0: TInt DTest::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& aVer) sl@0: // sl@0: // Create channel sl@0: // sl@0: { sl@0: sl@0: if (!Kern::QueryVersionSupported(TVersion(KMajorVersionNumber,KMinorVersionNumber,KBuildVersionNumber),aVer)) sl@0: return KErrNotSupported; sl@0: return KErrNone; sl@0: } sl@0: sl@0: DTest::~DTest() sl@0: // sl@0: // Destructor sl@0: // sl@0: { sl@0: } sl@0: sl@0: TInt DTest::Request(TInt aFunction, TAny* a1, TAny* a2) sl@0: { sl@0: (void)a1; sl@0: (void)a2; sl@0: TInt r=KErrNone; sl@0: switch (aFunction) sl@0: { sl@0: case RGuiConfigTest::EGetConfig: sl@0: { sl@0: r = WinsGui::CurrentConfiguration(); sl@0: break; sl@0: } sl@0: case RGuiConfigTest::EGenerateKeyEvent: sl@0: { sl@0: r = WinsGui::CurrentConfiguration(); sl@0: sl@0: TRawEvent eventDown, eventUp; sl@0: eventDown.Set(TRawEvent::EKeyDown, (EKeyScreenDimension0 + r)<<16); sl@0: eventUp.Set(TRawEvent::EKeyUp, (EKeyScreenDimension0 + r)<<16); sl@0: sl@0: NKern::ThreadEnterCS(); sl@0: r = Kern::AddEvent(eventDown); sl@0: if (r == KErrNone) sl@0: r = Kern::AddEvent(eventUp); sl@0: NKern::ThreadLeaveCS(); sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: r=KErrNotSupported; sl@0: break; sl@0: } sl@0: } sl@0: return r; sl@0: } sl@0: