103
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// The process to close all the panic window.
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@test
|
|
21 |
@internalComponent - Internal Symbian test code
|
|
22 |
*/
|
|
23 |
|
|
24 |
#include <e32base.h>
|
|
25 |
#include <e32cons.h>
|
|
26 |
#include <e32test.h>
|
|
27 |
#include <e32std.h>
|
|
28 |
#include <e32debug.h>
|
|
29 |
#include <w32debug.h>
|
|
30 |
#include <w32std.h>
|
|
31 |
|
|
32 |
// Simulate 50 escape-keys down to close all the panic window
|
|
33 |
static TInt CloseAllPanicWindows(RWsSession& aWs)
|
|
34 |
{
|
|
35 |
TInt idFocus = aWs.GetFocusWindowGroup();
|
|
36 |
TWsEvent event;
|
|
37 |
event.SetType(EEventKey);
|
|
38 |
TKeyEvent* keyEvent = event.Key();
|
|
39 |
keyEvent->iCode = EKeyEscape;
|
|
40 |
keyEvent->iScanCode = EStdKeyEscape;
|
|
41 |
keyEvent->iModifiers = 0;
|
|
42 |
TInt theLimit = 50;
|
|
43 |
TInt err = KErrNone;
|
|
44 |
while(idFocus != NULL && (theLimit-- > 0))
|
|
45 |
{
|
|
46 |
err = aWs.SendEventToAllWindowGroups(event);
|
|
47 |
if (err != KErrNone && err != KErrNoMemory)
|
|
48 |
{
|
|
49 |
return err;
|
|
50 |
}
|
|
51 |
User::After(1000); //give it time to process
|
|
52 |
idFocus = aWs.GetFocusWindowGroup();
|
|
53 |
}
|
|
54 |
return KErrNone;
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
// Real main function
|
|
59 |
void MainL()
|
|
60 |
{
|
|
61 |
// Open wserv session
|
|
62 |
RWsSession ws;
|
|
63 |
TInt err = ws.Connect();
|
|
64 |
if (err != KErrNone)
|
|
65 |
{
|
|
66 |
User::Leave(err);
|
|
67 |
}
|
|
68 |
|
|
69 |
CleanupClosePushL(ws);
|
|
70 |
|
|
71 |
User::LeaveIfError(CloseAllPanicWindows(ws));
|
|
72 |
|
|
73 |
CleanupStack::PopAndDestroy(&ws);
|
|
74 |
}
|
|
75 |
|
|
76 |
// Cleanup stack harness
|
|
77 |
GLDEF_C TInt E32Main()
|
|
78 |
{
|
|
79 |
__UHEAP_MARK;
|
|
80 |
CTrapCleanup* cleanupStack = CTrapCleanup::New();
|
|
81 |
TRAPD(error, MainL());
|
|
82 |
_LIT(KTCloseAllPanicWindowPanic,"tcloseallpanicwindow");
|
|
83 |
// Panic the current process
|
|
84 |
__ASSERT_ALWAYS(!error, User::Panic(KTCloseAllPanicWindowPanic, error));
|
|
85 |
delete cleanupStack;
|
|
86 |
__UHEAP_MARKEND;
|
|
87 |
return KErrNone;
|
|
88 |
}
|