diff -r 57c618273d5c -r bbf46f59e123 windowing/windowserver/test/tauto/tclosepanicwindowprocess.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/windowing/windowserver/test/tauto/tclosepanicwindowprocess.cpp Tue Aug 31 16:31:06 2010 +0300 @@ -0,0 +1,88 @@ +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// The process to close all the panic window. +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + +#include +#include +#include +#include +#include +#include +#include + +// Simulate 50 escape-keys down to close all the panic window +static TInt CloseAllPanicWindows(RWsSession& aWs) + { + TInt idFocus = aWs.GetFocusWindowGroup(); + TWsEvent event; + event.SetType(EEventKey); + TKeyEvent* keyEvent = event.Key(); + keyEvent->iCode = EKeyEscape; + keyEvent->iScanCode = EStdKeyEscape; + keyEvent->iModifiers = 0; + TInt theLimit = 50; + TInt err = KErrNone; + while(idFocus != NULL && (theLimit-- > 0)) + { + err = aWs.SendEventToAllWindowGroups(event); + if (err != KErrNone && err != KErrNoMemory) + { + return err; + } + User::After(1000); //give it time to process + idFocus = aWs.GetFocusWindowGroup(); + } + return KErrNone; + } + + +// Real main function +void MainL() + { + // Open wserv session + RWsSession ws; + TInt err = ws.Connect(); + if (err != KErrNone) + { + User::Leave(err); + } + + CleanupClosePushL(ws); + + User::LeaveIfError(CloseAllPanicWindows(ws)); + + CleanupStack::PopAndDestroy(&ws); + } + +// Cleanup stack harness +GLDEF_C TInt E32Main() + { + __UHEAP_MARK; + CTrapCleanup* cleanupStack = CTrapCleanup::New(); + TRAPD(error, MainL()); + _LIT(KTCloseAllPanicWindowPanic,"tcloseallpanicwindow"); + // Panic the current process + __ASSERT_ALWAYS(!error, User::Panic(KTCloseAllPanicWindowPanic, error)); + delete cleanupStack; + __UHEAP_MARKEND; + return KErrNone; + }