|
1 // Copyright (c) 2005-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 // Test accessing window group name.\n |
|
15 // Tests accessing & modifier functionality of CApaWindowGroupName API.\n |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include <e32test.h> |
|
25 #include <apgwgnam.h> |
|
26 #include <w32std.h> |
|
27 #include "T_WgnamStep.h" |
|
28 |
|
29 /** |
|
30 Auxiliary Fn for Test Case ID T-WgnamStep-testWgNamesL |
|
31 |
|
32 This function accepts current window group name as descriptor and prints it.\n |
|
33 |
|
34 */ |
|
35 void CT_WgnamStep::PrintWindowGroupName(const TPtrC& aWndGroupName) |
|
36 { |
|
37 _LIT(KWindowGroupName, "Current name=\"%S\"\n"); |
|
38 TFileName buffer; |
|
39 buffer.Format(KWindowGroupName, &aWndGroupName); |
|
40 INFO_PRINTF1(buffer); |
|
41 } |
|
42 |
|
43 |
|
44 /** |
|
45 @SYMTestCaseID T-WgnamStep-testWgNamesL |
|
46 |
|
47 @SYMPREQ |
|
48 |
|
49 @SYMTestCaseDesc Test setting and accessing functionality of Window group name. |
|
50 |
|
51 @SYMTestPriority High |
|
52 |
|
53 @SYMTestStatus Implemented |
|
54 |
|
55 @SYMTestActions The test checks the following functionality of CApaWindowGroupName\n |
|
56 (1) Creation of window group name object.\n |
|
57 (2) Setting the task to be a System task.\n |
|
58 (3) Setting the task to be Busy.\n |
|
59 (4) Setting document name as filename.\n |
|
60 (5) Setting the task's capability to shutdown.\n |
|
61 (6) Setting the task's capability to switch between files.\n |
|
62 (7) Setting the tasks Uid.\n |
|
63 (8) Setting the tasks caption.\n |
|
64 (9) Setting the tasks Document name.\n |
|
65 (10) Setting the task to be ready.\n |
|
66 (11) Setting a name to a window group name.\n |
|
67 \n |
|
68 In each of the cases the setter function is called to set a particular |
|
69 attribute. The attribute is cross checked by verifying with its |
|
70 corresponding getter / accessor function. After setting each of the attributes |
|
71 the test tries to analyze the impact of the attribute changed, on the windows |
|
72 group name.\n |
|
73 API Calls:\n |
|
74 CApaWindowGroupName::NewL(const RWsSession& aWsSession)\n |
|
75 CApaWindowGroupName::SetSystem(TBool aSystem)\n |
|
76 CApaWindowGroupName::IsSystem() const\n |
|
77 CApaWindowGroupName::SetBusy(TBool aBusy)\n |
|
78 CApaWindowGroupName::IsBusy() const\n |
|
79 CApaWindowGroupName::SetDocNameIsAFile(TBool aDocNameIsAFile)\n |
|
80 CApaWindowGroupName::DocNameIsAFile() const\n |
|
81 CApaWindowGroupName::SetRespondsToShutdownEvent(TBool aRespondsToShutdownEvent)\n |
|
82 CApaWindowGroupName::RespondsToShutdownEvent() const\n |
|
83 CApaWindowGroupName::SetRespondsToSwitchFilesEvent(TBool aRespondsToSwitchFilesEvent)\n |
|
84 CApaWindowGroupName::RespondsToSwitchFilesEvent() const\n |
|
85 CApaWindowGroupName::SetAppUid(TUid aAppUid);\n |
|
86 CApaWindowGroupName::AppUid() const\n |
|
87 CApaWindowGroupName::SetCaptionL(const TDesC& aCaption)\n |
|
88 CApaWindowGroupName::Caption() const\n |
|
89 CApaWindowGroupName::SetDocNameL(const TDesC& aDocName);\n |
|
90 CApaWindowGroupName::DocName() const\n |
|
91 CApaWindowGroupName::SetAppReady(TBool aIsReady)\n |
|
92 CApaWindowGroupName::IsAppReady()\n |
|
93 CApaWindowGroupName::SetWindowGroupName(HBufC* aWgName)\n |
|
94 CApaWindowGroupName::WindowGroupName() const\n |
|
95 CApaWindowGroupName::FindByCaption(const TDesC& aCaption, RWsSession& aWsSession, TInt& aPrevWgId) const\n |
|
96 |
|
97 @SYMTestExpectedResults Test checks results against expected values. |
|
98 |
|
99 */ |
|
100 void CT_WgnamStep::testWgNamesL() |
|
101 { |
|
102 _LIT(KWindowGroupName1, "WindowGroupName 1"); |
|
103 _LIT(KWindowGroupName2, "WindowGroupName 2"); |
|
104 _LIT(KBadName,"00\x00\x31\x31\x31\x31\x31\x31\x31\x31x31\x0\x0"); |
|
105 |
|
106 INFO_PRINTF1(_L("Starting testWgNamesL()")); |
|
107 // |
|
108 // Instantiate a blank name |
|
109 CApaWindowGroupName* apaWindowGroupName=NULL; |
|
110 TRAPD(ret, apaWindowGroupName=CApaWindowGroupName::NewL(iWsSession)); |
|
111 TEST(ret==KErrNone); |
|
112 User::LeaveIfError(iWsSession.Connect()); |
|
113 TEST(apaWindowGroupName!=NULL); |
|
114 |
|
115 // test setting system |
|
116 INFO_PRINTF1(_L("Block 1")); |
|
117 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
118 TEST(!apaWindowGroupName->IsSystem()); |
|
119 INFO_PRINTF1(_L("Setting system\n")); |
|
120 apaWindowGroupName->SetSystem(ETrue); |
|
121 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
122 TEST(apaWindowGroupName->IsSystem()); |
|
123 INFO_PRINTF1(_L("Setting not system\n")); |
|
124 apaWindowGroupName->SetSystem(EFalse); |
|
125 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
126 TEST(!apaWindowGroupName->IsSystem()); |
|
127 INFO_PRINTF1(_L("\n")); |
|
128 // User::After(2000000); |
|
129 |
|
130 // test setting busy |
|
131 INFO_PRINTF1(_L("Block 2")); |
|
132 INFO_PRINTF1(_L("Test setting busy")); |
|
133 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
134 TEST(!apaWindowGroupName->IsBusy()); |
|
135 INFO_PRINTF1(_L("Setting busy\n")); |
|
136 apaWindowGroupName->SetBusy(ETrue); |
|
137 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
138 TEST(apaWindowGroupName->IsBusy()); |
|
139 INFO_PRINTF1(_L("Setting not busy\n")); |
|
140 apaWindowGroupName->SetBusy(EFalse); |
|
141 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
142 TEST(!apaWindowGroupName->IsBusy()); |
|
143 INFO_PRINTF1(_L("\n")); |
|
144 // User::After(2000000); |
|
145 |
|
146 // test setting docname not a file |
|
147 INFO_PRINTF1(_L("Block 3")); |
|
148 INFO_PRINTF1(_L("Test setting doc name is not a file")); |
|
149 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
150 TEST(apaWindowGroupName->DocNameIsAFile()); |
|
151 INFO_PRINTF1(_L("Setting doc name not a file\n")); |
|
152 apaWindowGroupName->SetDocNameIsAFile(EFalse); |
|
153 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
154 TEST(!apaWindowGroupName->DocNameIsAFile()); |
|
155 INFO_PRINTF1(_L("Setting doc name is a file\n")); |
|
156 apaWindowGroupName->SetDocNameIsAFile(ETrue); |
|
157 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
158 TEST(apaWindowGroupName->DocNameIsAFile()); |
|
159 INFO_PRINTF1(_L("\n")); |
|
160 // User::After(2000000); |
|
161 |
|
162 // RDebug::Print(_L("Block 3")); |
|
163 INFO_PRINTF1(_L("Test setting does not respond to shutdown event")); |
|
164 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
165 TEST(apaWindowGroupName->RespondsToShutdownEvent()); |
|
166 INFO_PRINTF1(_L("Setting does not respond to shutdown event\n")); |
|
167 apaWindowGroupName->SetRespondsToShutdownEvent(EFalse); |
|
168 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
169 TEST(!apaWindowGroupName->RespondsToShutdownEvent()); |
|
170 INFO_PRINTF1(_L("Setting does respond to shutdown event\n")); |
|
171 apaWindowGroupName->SetRespondsToShutdownEvent(ETrue); |
|
172 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
173 TEST(apaWindowGroupName->RespondsToShutdownEvent()); |
|
174 INFO_PRINTF1(_L("\n")); |
|
175 // User::After(2000000); |
|
176 |
|
177 // test setting does not respond to switch files event |
|
178 // RDebug::Print(_L("Block 3")); |
|
179 INFO_PRINTF1(_L("Test setting does not respond to switch files event")); |
|
180 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
181 TEST(apaWindowGroupName->RespondsToSwitchFilesEvent()); |
|
182 INFO_PRINTF1(_L("Setting does not respond to switch files event\n")); |
|
183 apaWindowGroupName->SetRespondsToSwitchFilesEvent(EFalse); |
|
184 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
185 TEST(!apaWindowGroupName->RespondsToSwitchFilesEvent()); |
|
186 INFO_PRINTF1(_L("Setting does respond to switch files event\n")); |
|
187 apaWindowGroupName->SetRespondsToSwitchFilesEvent(ETrue); |
|
188 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
189 TEST(apaWindowGroupName->RespondsToSwitchFilesEvent()); |
|
190 INFO_PRINTF1(_L("\n")); |
|
191 // User::After(2000000); |
|
192 |
|
193 // test setting app uid |
|
194 // RDebug::Print(_L("Block 5")); |
|
195 INFO_PRINTF1(_L("Test setting appUid")); |
|
196 const TUid uid={ 0x10000111 }; |
|
197 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
198 INFO_PRINTF2(_L("Setting app uid to %x\n"), uid.iUid); |
|
199 apaWindowGroupName->SetAppUid(uid); |
|
200 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
201 TEST(apaWindowGroupName->AppUid()==uid); |
|
202 INFO_PRINTF1(_L("\n")); |
|
203 // User::After(2000000); |
|
204 |
|
205 // test setting caption |
|
206 // RDebug::Print(_L("Block 6")); |
|
207 INFO_PRINTF1(_L("Test setting caption")); |
|
208 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
209 TPtrC caption=_L("App caption"); |
|
210 INFO_PRINTF2(_L("Setting app caption to %S\n"), &caption); |
|
211 apaWindowGroupName->SetCaptionL(caption); |
|
212 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
213 TEST(!(apaWindowGroupName->Caption().Compare(caption))); |
|
214 INFO_PRINTF1(_L("\n")); |
|
215 // User::After(2000000); |
|
216 |
|
217 // testing FindByCaption |
|
218 INFO_PRINTF1(_L("Test Window group ID")); |
|
219 _LIT(KCaption, "App caption"); |
|
220 TInt aWgId=0; |
|
221 apaWindowGroupName->FindByCaption(KCaption, iWsSession, aWgId); |
|
222 TEST(aWgId==KErrNotFound); |
|
223 INFO_PRINTF3(_L("Expected value is KErrNotfound : %d ,Value Obtained is : %d \n"),KErrNotFound, aWgId); |
|
224 |
|
225 // test setting document name |
|
226 // RDebug::Print(_L("Block 7")); |
|
227 INFO_PRINTF1(_L("Test setting document name")); |
|
228 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
229 TPtrC docName=_L("Doc name"); |
|
230 INFO_PRINTF2(_L("Setting doc name to %S\n"), &docName); |
|
231 apaWindowGroupName->SetDocNameL(docName); |
|
232 PrintWindowGroupName(apaWindowGroupName->WindowGroupName()); |
|
233 TEST(!(apaWindowGroupName->DocName().Compare(docName))); |
|
234 INFO_PRINTF1(_L("\n")); |
|
235 |
|
236 // test AppReady flag |
|
237 INFO_PRINTF1(_L("Testing AppReady flag")); |
|
238 INFO_PRINTF1(_L("Setting AppReady flag to false")); |
|
239 apaWindowGroupName->SetAppReady(EFalse); |
|
240 TEST(apaWindowGroupName->IsAppReady()==EFalse); |
|
241 INFO_PRINTF1(_L("Setting AppReady flag to true")); |
|
242 apaWindowGroupName->SetAppReady(ETrue); |
|
243 TEST(!apaWindowGroupName->IsAppReady()==EFalse); |
|
244 INFO_PRINTF1(_L("\n")); |
|
245 |
|
246 |
|
247 // Testing SetWindowGroup Name |
|
248 INFO_PRINTF1(_L("Testing SetWindowGroupName")); |
|
249 CApaWindowGroupName* apaWindGroupName = NULL; |
|
250 |
|
251 TRAP(ret, apaWindGroupName=CApaWindowGroupName::NewL(iWsSession, apaWindowGroupName->WindowGroupName())); |
|
252 TEST(ret==KErrNone); |
|
253 apaWindGroupName->SetWindowGroupNameL(KWindowGroupName1); |
|
254 TEST(apaWindGroupName->WindowGroupName().Compare(KWindowGroupName1)==0); |
|
255 HBufC* windGroupName = KWindowGroupName2().AllocLC(); |
|
256 apaWindGroupName->SetWindowGroupName(windGroupName); |
|
257 TEST(apaWindGroupName->WindowGroupName().Compare(KWindowGroupName2)==0); |
|
258 |
|
259 apaWindGroupName->SetWindowGroupNameL(KBadName); |
|
260 const TUid retUid = apaWindGroupName->AppUid(); |
|
261 TEST(retUid == KNullUid); |
|
262 INFO_PRINTF2(_L("Expected Uid: 0, Actual uid = %d\n"), retUid); |
|
263 delete apaWindGroupName; |
|
264 |
|
265 INFO_PRINTF1(_L("Cleaning up")); |
|
266 delete apaWindowGroupName; // apaWindowGroupName |
|
267 |
|
268 CleanupStack::Pop(); // windGroupName |
|
269 iWsSession.Close(); |
|
270 |
|
271 INFO_PRINTF1(_L("Finished testWgNamesL()")); |
|
272 } |
|
273 |
|
274 |
|
275 |
|
276 CT_WgnamStep::~CT_WgnamStep() |
|
277 /** |
|
278 Destructor |
|
279 */ |
|
280 { |
|
281 } |
|
282 |
|
283 CT_WgnamStep::CT_WgnamStep() |
|
284 /** |
|
285 Constructor |
|
286 */ |
|
287 { |
|
288 // Call base class method to set up the human readable name for logging |
|
289 SetTestStepName(KT_WgnamStep); |
|
290 } |
|
291 |
|
292 TVerdict CT_WgnamStep::doTestStepPreambleL() |
|
293 /** |
|
294 @return - TVerdict code |
|
295 Override of base class virtual |
|
296 */ |
|
297 { |
|
298 SetTestStepResult(EPass); |
|
299 return TestStepResult(); |
|
300 } |
|
301 |
|
302 TVerdict CT_WgnamStep::doTestStepPostambleL() |
|
303 /** |
|
304 @return - TVerdict code |
|
305 Override of base class virtual |
|
306 */ |
|
307 { |
|
308 return TestStepResult(); |
|
309 } |
|
310 |
|
311 |
|
312 TVerdict CT_WgnamStep::doTestStepL() |
|
313 /** |
|
314 @return - TVerdict code |
|
315 Override of base class virtual |
|
316 */ |
|
317 { |
|
318 INFO_PRINTF1(_L("Testing window group names")); |
|
319 // |
|
320 // run the testcode (inside an alloc heaven harness) |
|
321 |
|
322 __UHEAP_MARK; |
|
323 TRAPD(r,testWgNamesL()); |
|
324 TEST(r==KErrNone); |
|
325 __UHEAP_MARKEND; |
|
326 |
|
327 return TestStepResult(); |
|
328 } |
|
329 |
|
330 |