|
1 // Copyright (c) 2006-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 plug-in provides the client side CWsGraphic instance CWsListen, which is used in |
|
15 // GRAPHICS-WSERV-0023 and GRAPHICS-WSERV-0024. |
|
16 // This is also used for Test Case GRAPHICS-WSERV-0058 for INC094118: CWsGraphicDrawer::SendMessage panics window server. |
|
17 // The customer incident "INC094118" reports the failure of CWsGraphicDrawer::SendMessage(const TDesC8& aData) |
|
18 // when the event message iEventMsg is not ready. The defect is reproduced by calling QueryPlugin(aInfo) |
|
19 // once again to wserv plug-in side in the CWsListen::HandleMessage(const TDesC8& aData), when the event |
|
20 // message has not yet been reset by CWsGraphic::CManager. Certainly in practice there are many other cases |
|
21 // which could trigger the defect. |
|
22 // The fix is added in CWsGraphicMessageQueue::Queue(CMessage* aMessage), where we check whether the iEventMsg |
|
23 // is empty or not. As a result, if iEventMsg is not ready we do not signal event but keep message untouched in queue. |
|
24 // nce the iEventMsg is set ready, an event is signaleed immediately if there is a waiting event and message |
|
25 // will be popped out of the queue. |
|
26 // The test of defect-fixing INC094118 can be enabled by initialising iTestFlag to ETrue. Setting iTestFlag to |
|
27 // EFalse will not trigger the defect. A new test case is written to trigger the defect only once. |
|
28 // |
|
29 // |
|
30 |
|
31 /** |
|
32 @file |
|
33 @test |
|
34 @internalComponent - Internal Symbian test code |
|
35 */ |
|
36 |
|
37 #include "wslisten.h" |
|
38 |
|
39 const TUid KListenerInterfaceId = {0x10281fb6}; |
|
40 const TUid KListenerImplId = {0x10281fb7}; |
|
41 const TUid KNotifierInterfaceId1 = {0x102754c3}; |
|
42 const TUid KNotifierImplId1 = {0x102754c4}; |
|
43 const TUid KNotifierInterfaceId2 = {0x102754c5}; |
|
44 const TUid KNotifierImplId2 = {0x102754c6}; |
|
45 |
|
46 const TUint8 KCmdDisable = 0; |
|
47 const TUint8 KCmdEnable = 1; |
|
48 const TUint8 KCmdQuery = 2; |
|
49 |
|
50 EXPORT_C CWsListen* CWsListen::NewL() |
|
51 { |
|
52 return NewL(EFalse); |
|
53 } |
|
54 |
|
55 EXPORT_C CWsListen* CWsListen::NewL(TBool aDisableWin) |
|
56 { |
|
57 CWsListen* self = new(ELeave) CWsListen; |
|
58 CleanupStack::PushL(self); |
|
59 TBuf8<1> data; |
|
60 data.Append((TUint8)aDisableWin); |
|
61 self->BaseConstructL(KListenerInterfaceId, KListenerImplId, data); |
|
62 CleanupStack::Pop(self); |
|
63 //Initialise the test flag to EFalse if dont want to reproduce the INC094118 and test the fix |
|
64 self->iTestFlag = EFalse; |
|
65 self->iIsReady = ETrue; |
|
66 return self; |
|
67 } |
|
68 |
|
69 EXPORT_C CWsListen::~CWsListen() |
|
70 { |
|
71 iIsReady = EFalse; |
|
72 } |
|
73 |
|
74 EXPORT_C void CWsListen::SetTestFlag() |
|
75 { |
|
76 //Set the test flag to ETrue if want to reproduce the INC094118 and test the fix |
|
77 iTestFlag = ETrue; |
|
78 } |
|
79 |
|
80 void CWsListen::HandleMessage(const TDesC8& aData) |
|
81 { |
|
82 if (aData[0]==KListenerInfoSig) |
|
83 Mem::Copy(iReq, aData.Ptr(), aData.Size()); |
|
84 //The if-statement allows to call QueryPlugin() in HandleMessage() only once to reproduce the defect INC094118. |
|
85 //Otherwise HandleMessage() will behave as normal. |
|
86 if (iTestFlag) |
|
87 { |
|
88 TListenerInfo aInfo; |
|
89 QueryPlugin(aInfo) ; |
|
90 iTestFlag = EFalse; |
|
91 } |
|
92 else |
|
93 { |
|
94 iCallBack.CallBack(); |
|
95 } |
|
96 } |
|
97 |
|
98 void CWsListen::OnReplace() |
|
99 { |
|
100 } |
|
101 |
|
102 EXPORT_C TInt CWsListen::Enable(TBool aEnabled) |
|
103 { |
|
104 if (!iIsReady) |
|
105 return KErrNotReady; |
|
106 |
|
107 TBuf8<1> cmd; |
|
108 cmd.Append(aEnabled? KCmdEnable : KCmdDisable); |
|
109 SendMessage(cmd); |
|
110 return Flush(); |
|
111 } |
|
112 |
|
113 EXPORT_C TInt CWsListen::QueryPlugin(TListenerInfo& aInfo) |
|
114 { |
|
115 TBuf8<1> cmd; |
|
116 cmd.Append(KCmdQuery); |
|
117 SendMessage(cmd); |
|
118 TInt err = Flush(); |
|
119 if (err!=KErrNone) |
|
120 return err; |
|
121 iReq = &aInfo; |
|
122 return KErrNone; |
|
123 } |
|
124 |
|
125 EXPORT_C void CWsListen::SetCallBack(TCallBack aCallBack) |
|
126 { |
|
127 iCallBack = aCallBack; |
|
128 } |
|
129 |
|
130 EXPORT_C CWsNotify* CWsNotify::NewL() |
|
131 { |
|
132 return NewL(EFalse); |
|
133 } |
|
134 |
|
135 EXPORT_C CWsNotify* CWsNotify::NewL(TBool aPluginOrder) |
|
136 { |
|
137 CWsNotify* self = new(ELeave) CWsNotify; |
|
138 CleanupStack::PushL(self); |
|
139 TBuf8<1> data; |
|
140 data.Append(8); |
|
141 if (!aPluginOrder) //Different IDs so 2 plugins may be registered at once |
|
142 self->BaseConstructL(KNotifierInterfaceId1, KNotifierImplId1, data); |
|
143 else |
|
144 self->BaseConstructL(KNotifierInterfaceId2, KNotifierImplId2, data); |
|
145 CleanupStack::Pop(self); |
|
146 self->iIsReady = ETrue; |
|
147 self->iResult = ETrue; |
|
148 return self; |
|
149 } |
|
150 |
|
151 EXPORT_C CWsNotify::~CWsNotify() |
|
152 { |
|
153 iIsReady = EFalse; |
|
154 } |
|
155 |
|
156 void CWsNotify::HandleMessage(const TDesC8& aData) |
|
157 { |
|
158 TBuf8<100> KTesting(_L8("Error:")); |
|
159 if(aData.Find(KTesting)!=KErrNotFound) |
|
160 { |
|
161 iError.Copy(aData); |
|
162 iResult = EFalse; |
|
163 } |
|
164 } |
|
165 |
|
166 void CWsNotify::OnReplace() |
|
167 { |
|
168 } |
|
169 |
|
170 EXPORT_C TInt CWsNotify::SetBehaviour(TInt aType) |
|
171 { |
|
172 if (!iIsReady) |
|
173 return KErrNotReady; |
|
174 TBuf8<1> cmd; |
|
175 cmd.Append(aType); |
|
176 SendMessage(cmd); |
|
177 return Flush(); |
|
178 } |