|
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 // This is a support executable used by "Cone\tef\TConeTestServer" (TCone4Step in particular) |
|
15 // This application covers the following tests for the static objects |
|
16 // Test 1 : Existing CCoeStatic derived objects using the 2 parameter |
|
17 // constructor must be destroyed before the app ui. |
|
18 // Way to test this, |
|
19 // Case 1: Get hold of a particular static using CCoeEnv::Static(TUid aUid) |
|
20 // in an application's override of CEikAppUi::PrepareToExit() and confirm the |
|
21 // returned pointer is not null. |
|
22 // Case 2: Then, the same thing is done in the app ui's destructor to check that |
|
23 // the pointer is now null. |
|
24 // Test 2: A static constructed with a negative priority should be accessible from the |
|
25 // app ui's destructor, but then destroyed before another static that has a lower priority value. |
|
26 // Way to test this, |
|
27 // Case 1: Construct a static (A) using the 3 parameter constructor, specifying a negative priority. |
|
28 // Then construct another static (B) specifying a priority (A's priority - 1). |
|
29 // Check that static A is still non-null when accessed from the app ui's destructor. |
|
30 // Case 2: Then check that static A is null when accessed from B's destructor. |
|
31 // Test 3: Given two statics with different positive priorities, |
|
32 // the higher priority one should be destroyed first. |
|
33 // Way to test this, |
|
34 // Case 1: If (for example) static A has priority EDefaultDestructionPriority, |
|
35 // and static B has EDefaultDestructionPriority-1, A's destructor should be able to access B, |
|
36 // Case 2: But B's destructor shouldn't be able to access A. |
|
37 // Test 4: Statics with priorities immediately either side of the pre/post-destroy app ui should be destroyed before/after the app ui. Should also test that |
|
38 // the first negative priority static is destroyed and not "skipped over" when the code calculates |
|
39 // which static should be destroyed next after the app ui has been destroyed. |
|
40 // Way to test this, |
|
41 // Case 1: We could create statics A, B and C with priority zero, -1 and -2 respectively. |
|
42 // Then check in the app ui destructor that A is null, and B and C are both non-null. |
|
43 // Case 2: Then in B's destructor check that C is still non-null. |
|
44 // Case 3: And in C's destructor check that B is now null. |
|
45 // |
|
46 // |
|
47 |
|
48 /** |
|
49 @file |
|
50 @internalComponent - Internal Symbian test code |
|
51 */ |
|
52 |
|
53 #include <coeccntx.h> |
|
54 #include <apgtask.h> |
|
55 #include <eikenv.h> |
|
56 #include <eikappui.h> |
|
57 #include <eikapp.h> |
|
58 #include <eikdoc.h> |
|
59 #include <techview/eikmenup.h> |
|
60 #include <f32file.h> |
|
61 #include <techview/eikon.hrh> |
|
62 #include <eikstart.h> //TKAS added for exe-app |
|
63 |
|
64 |
|
65 #include <tconetestexe.rsg> |
|
66 |
|
67 //! File which stores the test results.\n |
|
68 _LIT(KConeTestResultsFileName, "c:\\system\\conetest\\ConeTestResultsFile2.txt"); |
|
69 //! Cone Test Directory.\n |
|
70 _LIT(KConeTestDir, "c:\\system\\conetest\\"); |
|
71 //! Literal for Test Pass.\n |
|
72 _LIT8(KTestPass ,"PASS\r\n"); |
|
73 //! Literal for Test Fail.\n |
|
74 _LIT8(KTestFail,"FAIL\r\n"); |
|
75 //! Literal to indicate Test number one.\n |
|
76 _LIT8(KConeTest1,"Test1:"); |
|
77 //! Literal to indicate Test number two.\n |
|
78 _LIT8(KConeTest2,"Test2:"); |
|
79 //! Literal to indicate Test number three.\n |
|
80 _LIT8(KConeTest3,"Test3:"); |
|
81 //! Literal to indicate Test number four.\n |
|
82 _LIT8(KConeTest4,"Test4:"); |
|
83 //! Literal to indicate case number one.\n |
|
84 _LIT8(KConeTestCase1,"Case1:"); |
|
85 //! Literal to indicate case number Two.\n |
|
86 _LIT8(KConeTestCase2,"Case2:"); |
|
87 //! Literal to indicate Case number three.\n |
|
88 _LIT8(KConeTestCase3,"Case3:"); |
|
89 //! Uid for Cone Test Application.\n |
|
90 const TUid KUidConeTestApp = {0x10004C5A}; |
|
91 |
|
92 //! Uids for diffent classes for static |
|
93 //! Unique Uid for object of Singleton Class CTConeTestStatic.\n |
|
94 const TUid KUidTestStatic = {0x13003ACE}; |
|
95 //! Unique Uid for object of Singleton Class CTConeTestNegativePrioStaticA.\n |
|
96 const TUid KUidTestStaticNegativePrioA = {0x13004ACE}; |
|
97 //! Unique Uid for object of Singleton Class CTConeTestNegativePrioStaticB.\n |
|
98 const TUid KUidTestStaticNegativePrioB = {0x13005ACE}; |
|
99 //! Unique Uid for object of Singleton Class CTConeTestPosPrioStaticA.\n |
|
100 const TUid KUidTestStaticPosPriA = {0x13006ACE}; |
|
101 //! Unique Uid for object of Singleton Class CTConeTestPosPrioStaticB.\n |
|
102 const TUid KUidTestStaticPosPriB = {0x13007ACE}; |
|
103 //! Unique Uid for object of Singleton Class CTConeTestPrioZeroStaticA.\n |
|
104 const TUid KUidTestStaticPriZeroA= {0x13009ACE}; |
|
105 //! Unique Uid for object of Singleton Class CTConeTestPrioOneStaticB.\n |
|
106 const TUid KUidTestStaticPriOneB = {0x1300AACE}; |
|
107 //! Unique Uid for object of Singleton Class CTConeTestPrioTwoStaticC.\n |
|
108 const TUid KUidTestStaticPriTwoC = {0x1300BACE}; |
|
109 |
|
110 //! Priorities for static objects |
|
111 enum {ENegativePriortyStaticA = -3}; |
|
112 enum {EPriorityTwoStaticC= -2,EPriorityOneStaticB = -1,EPriorityZeroStaticA= 0}; |
|
113 |
|
114 |
|
115 //! A CCoeStatic derived class.\n |
|
116 /** |
|
117 Class used to test the deletion of a CCoeStatic members before deletion of appUi class.\n |
|
118 */ |
|
119 class CTConeTestStatic : public CCoeStatic |
|
120 { |
|
121 public: |
|
122 inline CTConeTestStatic(RFile& aFile); |
|
123 inline static CTConeTestStatic* Self(); |
|
124 ~CTConeTestStatic(); |
|
125 RFile iFile; |
|
126 }; |
|
127 /** |
|
128 Destructor for CTConeTestStatic Class.\n |
|
129 */ |
|
130 CTConeTestStatic::~CTConeTestStatic() |
|
131 { |
|
132 } |
|
133 |
|
134 //! A CCoeStatic derived class.\n |
|
135 /** |
|
136 A Static Class with Negative priority for Test Case 2.\n |
|
137 */ |
|
138 class CTConeTestNegativePrioStaticA : public CCoeStatic |
|
139 { |
|
140 public: |
|
141 inline CTConeTestNegativePrioStaticA(RFile& aFile); |
|
142 inline static CTConeTestNegativePrioStaticA* Self(); |
|
143 ~CTConeTestNegativePrioStaticA(); |
|
144 |
|
145 RFile& iFile; |
|
146 }; |
|
147 |
|
148 //! A CCoeStatic derived class.\n |
|
149 /** |
|
150 Static class with negative priority for Test case 2. (priority less than CTConeTestNegativePrioStaticA).\n |
|
151 */ |
|
152 class CTConeTestNegativePrioStaticB : public CCoeStatic |
|
153 { |
|
154 public: |
|
155 inline CTConeTestNegativePrioStaticB(); |
|
156 inline static CTConeTestNegativePrioStaticB* Self(); |
|
157 ~CTConeTestNegativePrioStaticB(); |
|
158 |
|
159 RFile iFile; |
|
160 RFs iFs; |
|
161 }; |
|
162 /** |
|
163 Destructor for CTConeTestNegativePrioStaticA Class.\n |
|
164 */ |
|
165 CTConeTestNegativePrioStaticA::~CTConeTestNegativePrioStaticA() |
|
166 { |
|
167 } |
|
168 /** |
|
169 @SYMTestCaseID UIF-TConeTestApp-Test2Case2 |
|
170 |
|
171 @SYMPREQ |
|
172 |
|
173 @SYMTestCaseDesc Check for the order of deletion of CCoeStatic objects with |
|
174 negative priorities.\n |
|
175 |
|
176 @SYMTestPriority High |
|
177 |
|
178 @SYMTestStatus Implemented |
|
179 |
|
180 @SYMTestActions : CTConeTestNegativePrioStaticA and CTConeTestNegativePrioStaticB objects |
|
181 have negative priorities.\n |
|
182 CTConeTestNegativePrioStaticB has lower negative priority than CTConeTestNegativePrioStaticA object.\n |
|
183 CTConeTestNegativePrioStaticA object should be deleted before CTConeTestNegativePrioStaticB object.\n |
|
184 Hence a pointer to CTConeTestNegativePrioStaticA is obtained in CTConeTestNegativePrioStaticB destructor.\n |
|
185 |
|
186 @SYMTestExpectedResults The CTConeTestNegativePrioStaticA object pointer should be NULL.\n |
|
187 |
|
188 @SYMTestType : CIT |
|
189 */ |
|
190 CTConeTestNegativePrioStaticB::~CTConeTestNegativePrioStaticB() |
|
191 { |
|
192 // Test 2, Case 2 |
|
193 CTConeTestNegativePrioStaticA* testCoeStaticA = CTConeTestNegativePrioStaticA::Self(); |
|
194 iFile.Write(KConeTest2); |
|
195 iFile.Write(KConeTestCase2); |
|
196 |
|
197 if(testCoeStaticA == NULL) |
|
198 iFile.Write(KTestPass); |
|
199 else |
|
200 iFile.Write(KTestFail); |
|
201 |
|
202 // CTConeTestNegativePrioStaticB class object is the most negative prioritised |
|
203 // static objects .Hence the file and session handles are closed here as no |
|
204 // more logging is required hereafter. |
|
205 iFile.Close(); |
|
206 iFs.Close(); |
|
207 } |
|
208 |
|
209 // Static class with positive priority for Test case 3: |
|
210 //! A CCoeStatic derived class.\n |
|
211 /** |
|
212 Static class with positive priority for Test case 3: |
|
213 */ |
|
214 class CTConeTestPosPrioStaticA : public CCoeStatic |
|
215 { |
|
216 public: |
|
217 inline CTConeTestPosPrioStaticA(RFile& aFile); |
|
218 inline static CTConeTestPosPrioStaticA* Self(); |
|
219 ~CTConeTestPosPrioStaticA(); |
|
220 |
|
221 RFile& iFile; |
|
222 }; |
|
223 |
|
224 // static class with positive priority less than CTConeTestPosPrioStaticA for Test case 3. |
|
225 //! A CCoeStatic derived class.\n |
|
226 /** |
|
227 Static class with positive priority less than CTConeTestPosPrioStaticA for Test case 3.\n |
|
228 */ |
|
229 class CTConeTestPosPrioStaticB : public CCoeStatic |
|
230 { |
|
231 public: |
|
232 inline CTConeTestPosPrioStaticB(RFile& aFile); |
|
233 inline static CTConeTestPosPrioStaticB* Self(); |
|
234 ~CTConeTestPosPrioStaticB(); |
|
235 |
|
236 RFile& iFile; |
|
237 }; |
|
238 /** |
|
239 @SYMTestCaseID UIF-TConeTestApp-Test3Case1 |
|
240 |
|
241 @SYMPREQ |
|
242 |
|
243 @SYMTestCaseDesc Check for the availabity of CCoeStatic object with |
|
244 lower positive priority in destructor of higher positive priority object.\n |
|
245 |
|
246 @SYMTestPriority High |
|
247 |
|
248 @SYMTestStatus Implemented |
|
249 |
|
250 @SYMTestActions : CTConeTestPosPrioStaticA and CTConeTestPosPrioStaticB objects |
|
251 have positive priorities.\n |
|
252 CTConeTestPosPrioStaticB has lower priority than CTConeTestPosPrioStaticA object.\n |
|
253 CTConeTestNegativePrioStaticB object should be available in CTConeTestPosPrioStaticA object's destructor.\n |
|
254 Hence a pointer to CTConeTestPosPrioStaticB is obtained in CTConeTestPosPrioStaticA's destructor.\n |
|
255 |
|
256 @SYMTestExpectedResults The CTConeTestPosPrioStaticB object pointer should not be NULL.\n |
|
257 |
|
258 @SYMTestType : CIT |
|
259 */ |
|
260 CTConeTestPosPrioStaticA::~CTConeTestPosPrioStaticA() |
|
261 { |
|
262 // Test 3 , Case 1 |
|
263 CTConeTestPosPrioStaticB* testPosPrioStaticB = CTConeTestPosPrioStaticB::Self(); |
|
264 iFile.Write(KConeTest3); |
|
265 iFile.Write(KConeTestCase1); |
|
266 |
|
267 if(testPosPrioStaticB != NULL) |
|
268 iFile.Write(KTestPass); |
|
269 else |
|
270 iFile.Write(KTestFail); |
|
271 } |
|
272 /** |
|
273 @SYMTestCaseID UIF-TConeTestApp-Test3Case2 |
|
274 |
|
275 @SYMPREQ |
|
276 |
|
277 @SYMTestCaseDesc Check for the order of deletion of CCoeStatics object with |
|
278 different positive priorities.\n |
|
279 |
|
280 @SYMTestPriority High |
|
281 |
|
282 @SYMTestStatus Implemented |
|
283 |
|
284 @SYMTestActions : CTConeTestPosPrioStaticA and CTConeTestPosPrioStaticB objects |
|
285 have positive priorities.\n |
|
286 CTConeTestPosPrioStaticB has lower priority than CTConeTestPosPrioStaticA object.\n |
|
287 CTConeTestNegativePrioStaticA object should be deleted before CTConeTestPosPrioStaticB object's destructor is called.\n |
|
288 Hence a pointer to CTConeTestPosPrioStaticA is obtained in CTConeTestPosPrioStaticB's destructor.\n |
|
289 |
|
290 @SYMTestExpectedResults The CTConeTestPosPrioStaticA object pointer should be NULL.\n |
|
291 |
|
292 @SYMTestType : CIT |
|
293 */ |
|
294 CTConeTestPosPrioStaticB::~CTConeTestPosPrioStaticB() |
|
295 { |
|
296 // Test 3 , Case 2 |
|
297 CTConeTestPosPrioStaticA* testPosPrioStaticA = CTConeTestPosPrioStaticA::Self(); |
|
298 iFile.Write(KConeTest3); |
|
299 iFile.Write(KConeTestCase2); |
|
300 |
|
301 if(testPosPrioStaticA == NULL) |
|
302 iFile.Write(KTestPass); |
|
303 else |
|
304 iFile.Write(KTestFail); |
|
305 } |
|
306 |
|
307 //! A CCoeStatic derived class.\n |
|
308 /** |
|
309 A static class with priority 0 for test case 4 |
|
310 */ |
|
311 class CTConeTestPrioZeroStaticA : public CCoeStatic |
|
312 { |
|
313 public: |
|
314 inline CTConeTestPrioZeroStaticA(RFile& aFile); |
|
315 inline static CTConeTestPrioZeroStaticA* Self(); |
|
316 ~CTConeTestPrioZeroStaticA(); |
|
317 |
|
318 RFile& iFile; |
|
319 }; |
|
320 |
|
321 //! A CCoeStatic derived class.\n |
|
322 /** |
|
323 A static class with priority -1 for test case 4 |
|
324 */ |
|
325 class CTConeTestPrioOneStaticB : public CCoeStatic |
|
326 { |
|
327 public: |
|
328 inline CTConeTestPrioOneStaticB(RFile& aFile); |
|
329 inline static CTConeTestPrioOneStaticB* Self(); |
|
330 ~CTConeTestPrioOneStaticB(); |
|
331 |
|
332 RFile& iFile; |
|
333 }; |
|
334 |
|
335 //! A CCoeStatic derived class.\n |
|
336 /** |
|
337 A static class with priority -2 for test case 4 |
|
338 */ |
|
339 class CTConeTestPrioTwoStaticC : public CCoeStatic |
|
340 { |
|
341 public: |
|
342 inline CTConeTestPrioTwoStaticC(RFile& aFile); |
|
343 inline static CTConeTestPrioTwoStaticC* Self(); |
|
344 ~CTConeTestPrioTwoStaticC(); |
|
345 |
|
346 RFile& iFile; |
|
347 }; |
|
348 /** |
|
349 Destructor for CTConeTestPrioZeroStaticA Class.\n |
|
350 */ |
|
351 CTConeTestPrioZeroStaticA::~CTConeTestPrioZeroStaticA() |
|
352 { |
|
353 } |
|
354 /** |
|
355 @SYMTestCaseID UIF-TConeTestApp-Test4Case2 |
|
356 |
|
357 @SYMPREQ |
|
358 |
|
359 @SYMTestCaseDesc Check for the availability of CTConeTestPrioTwoStaticC object in |
|
360 CTConeTestPrioOneStaticB's destructor.\n |
|
361 |
|
362 @SYMTestPriority High |
|
363 |
|
364 @SYMTestStatus Implemented |
|
365 |
|
366 @SYMTestActions : CTConeTestPrioOneStaticB and CTConeTestPrioTwoStaticC objects |
|
367 have negative priorities of -1 and -2 respectively.\n |
|
368 CTConeTestPrioTwoStaticC object should be available in CTConeTestPrioOneStaticB object's destructor is called.\n |
|
369 Hence a pointer to CTConeTestPrioTwoStaticC is obtained in CTConeTestPrioOneStaticB's destructor.\n |
|
370 |
|
371 @SYMTestExpectedResults The CTConeTestPosPrioStaticA object pointer should not be NULL.\n |
|
372 |
|
373 @SYMTestType : CIT |
|
374 */ |
|
375 CTConeTestPrioOneStaticB::~CTConeTestPrioOneStaticB() |
|
376 { |
|
377 // Test 4 , Case 2 |
|
378 CTConeTestPrioTwoStaticC* testPrioTwoCoeStaticC = CTConeTestPrioTwoStaticC::Self(); |
|
379 iFile.Write(KConeTest4); |
|
380 iFile.Write(KConeTestCase2); |
|
381 |
|
382 if(testPrioTwoCoeStaticC != NULL) |
|
383 iFile.Write(KTestPass); |
|
384 else |
|
385 iFile.Write(KTestFail); |
|
386 } |
|
387 |
|
388 /** |
|
389 @SYMTestCaseID UIF-TConeTestApp-Test4Case3 |
|
390 |
|
391 @SYMPREQ |
|
392 |
|
393 @SYMTestCaseDesc Check for the deletion of CTConeTestPrioOneStaticB object before |
|
394 CTConeTestPrioTwoStaticC's destructor is called.\n |
|
395 |
|
396 @SYMTestPriority High |
|
397 |
|
398 @SYMTestStatus Implemented |
|
399 |
|
400 @SYMTestActions : CTConeTestPrioOneStaticB and CTConeTestPrioTwoStaticC objects |
|
401 have negative priorities of -1 and -2 respectively.\n |
|
402 CTConeTestPrioOneStaticB object should be deleted before CTConeTestPrioTwoStaticC object's destructor is called.\n |
|
403 Hence a pointer to CTConeTestPrioOneStaticB is obtained in CTConeTestPrioTwoStaticC's destructor.\n |
|
404 |
|
405 @SYMTestExpectedResults The CTConeTestPosPrioStaticA object pointer should be NULL.\n |
|
406 |
|
407 @SYMTestType : CIT |
|
408 */ |
|
409 CTConeTestPrioTwoStaticC::~CTConeTestPrioTwoStaticC() |
|
410 { |
|
411 // Test 4 , Case 3 |
|
412 CTConeTestPrioOneStaticB* testPrioOneCoeStaticB = CTConeTestPrioOneStaticB::Self(); |
|
413 iFile.Write(KConeTest4); |
|
414 iFile.Write(KConeTestCase3); |
|
415 |
|
416 if(testPrioOneCoeStaticB == NULL) |
|
417 iFile.Write(KTestPass); |
|
418 else |
|
419 iFile.Write(KTestFail); |
|
420 } |
|
421 |
|
422 // |
|
423 // |
|
424 // CTConeTestAppView |
|
425 // |
|
426 // |
|
427 //! A CCoeControl derived class.\n |
|
428 /** |
|
429 View Class for TConeTestApp Application.\n |
|
430 */ |
|
431 class CTConeTestAppView : public CCoeControl |
|
432 { |
|
433 public: |
|
434 static CTConeTestAppView* NewL(const TRect& aRect); |
|
435 CTConeTestAppView(); |
|
436 ~CTConeTestAppView(); |
|
437 void ConstructL(const TRect& aRect); |
|
438 private: |
|
439 // Inherited from CCoeControl |
|
440 void Draw(const TRect& /*aRect*/) const; |
|
441 private: |
|
442 HBufC* iConeTestText; |
|
443 }; |
|
444 /** |
|
445 Constructor for the View Class.\n |
|
446 */ |
|
447 CTConeTestAppView::CTConeTestAppView() |
|
448 { |
|
449 } |
|
450 /** |
|
451 Static function used to instantiate the View Class.\n |
|
452 |
|
453 @return CTConeTestAppView*, Pointer to the newly created View.\n |
|
454 */ |
|
455 CTConeTestAppView* CTConeTestAppView::NewL(const TRect& aRect) |
|
456 { |
|
457 CTConeTestAppView* self = new(ELeave) CTConeTestAppView(); |
|
458 CleanupStack::PushL(self); |
|
459 self->ConstructL(aRect); |
|
460 CleanupStack::Pop(); |
|
461 return self; |
|
462 } |
|
463 /** |
|
464 Destructor for the View Class.\n |
|
465 */ |
|
466 CTConeTestAppView::~CTConeTestAppView() |
|
467 { |
|
468 delete iConeTestText; |
|
469 } |
|
470 /** |
|
471 Second phase constructor for CTConeTestAppView Class.\n |
|
472 */ |
|
473 void CTConeTestAppView::ConstructL(const TRect& aRect) |
|
474 { |
|
475 iConeTestText = iEikonEnv->AllocReadResourceL(R_TCONETEST_TEXT_TITLE); |
|
476 CreateWindowL(); |
|
477 SetRect(aRect); |
|
478 ActivateL(); |
|
479 } |
|
480 /** |
|
481 Draws the TConeTestApp Application's View.\n |
|
482 */ |
|
483 void CTConeTestAppView::Draw(const TRect& /*aRect*/) const |
|
484 { |
|
485 CWindowGc& gc = SystemGc(); |
|
486 TRect drawRect = Rect(); |
|
487 const CFont* fontUsed = iEikonEnv->TitleFont(); |
|
488 |
|
489 gc.Clear(); |
|
490 gc.UseFont(fontUsed); |
|
491 TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; |
|
492 gc.DrawText(*iConeTestText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); |
|
493 gc.DiscardFont(); |
|
494 } |
|
495 |
|
496 // |
|
497 // |
|
498 // CTConeTestAppUi |
|
499 // |
|
500 // |
|
501 //! A CEikAppUi derived class.\n |
|
502 /** |
|
503 The class is the AppUi class for the TCone4Step test case.\n |
|
504 */ |
|
505 class CTConeTestAppUi : public CEikAppUi |
|
506 { |
|
507 public: |
|
508 void ConstructL(); |
|
509 ~CTConeTestAppUi(); |
|
510 private: |
|
511 // Inherirted from class CEikAppUi |
|
512 void PrepareToExit(); |
|
513 void HandleCommandL(TInt aCommand); |
|
514 void TestSetLogicalToPixelFontSizesL(); |
|
515 |
|
516 private: |
|
517 CCoeControl* iAppView; |
|
518 }; |
|
519 |
|
520 /** |
|
521 Second phase constructor for CTConeTestAppUi Class.\n |
|
522 Creates the following singleton objects.\n |
|
523 1. CTConeTestStatic.\n |
|
524 2. CTConeTestNegativePrioStaticA.\n |
|
525 3. CTConeTestPrioTwoStaticC.\n |
|
526 4. CTConeTestPosPrioStaticA.\n |
|
527 5. CTConeTestPosPrioStaticB.\n |
|
528 6. CTConeTestPrioZeroStaticA.\n |
|
529 7. CTConeTestPrioOneStaticB.\n |
|
530 */ |
|
531 void CTConeTestAppUi::ConstructL() |
|
532 { |
|
533 BaseConstructL(); |
|
534 iAppView = CTConeTestAppView::NewL(ClientRect()); |
|
535 |
|
536 // Constructs the static object for tests |
|
537 CTConeTestNegativePrioStaticB* testCoeStaticB = new(ELeave)CTConeTestNegativePrioStaticB(); |
|
538 |
|
539 CTConeTestStatic* testCoeStatic = new (ELeave)CTConeTestStatic(testCoeStaticB->iFile); |
|
540 CTConeTestNegativePrioStaticA* testCoeStaticA = new(ELeave)CTConeTestNegativePrioStaticA(testCoeStaticB->iFile); |
|
541 CTConeTestPrioTwoStaticC* testPrioTwoStaticC = new(ELeave) CTConeTestPrioTwoStaticC(testCoeStaticB->iFile); |
|
542 CTConeTestPosPrioStaticA* testPosPriStaticA = new(ELeave) CTConeTestPosPrioStaticA(testCoeStaticB->iFile); |
|
543 CTConeTestPosPrioStaticB* testPosPriStaticB = new(ELeave) CTConeTestPosPrioStaticB(testCoeStaticB->iFile); |
|
544 CTConeTestPrioZeroStaticA* testPrioZeroStaticA = new(ELeave) CTConeTestPrioZeroStaticA(testCoeStaticB->iFile); |
|
545 CTConeTestPrioOneStaticB* testPrioOneStaticB = new(ELeave) CTConeTestPrioOneStaticB(testCoeStaticB->iFile); |
|
546 |
|
547 // to get rid of compiler warnings |
|
548 if(testCoeStatic==NULL || testCoeStaticA == NULL || testCoeStaticB == NULL|| testPosPriStaticA ==NULL || |
|
549 testPosPriStaticB == NULL || testPrioZeroStaticA == NULL || testPrioOneStaticB == NULL|| testPrioTwoStaticC == NULL) |
|
550 return; |
|
551 } |
|
552 /** |
|
553 @SYMTestCaseID UIF-TConeTestApp-Test1Case2-Test2Case1-Test4Case1 |
|
554 |
|
555 @SYMPREQ |
|
556 |
|
557 @SYMTestCaseDesc Following testcases are tested.\n |
|
558 1. Deletion of Static objects with positive priority before AppUi's destructor.\n |
|
559 2. Availability of Static objects with negative priority in AppUi's destructor.\n |
|
560 |
|
561 @SYMTestPriority High |
|
562 |
|
563 @SYMTestStatus Implemented |
|
564 |
|
565 @SYMTestActions : |
|
566 |
|
567 @SYMTestExpectedResults 1. Static objects with positive priority should be deleted before AppUi is deleted.\n |
|
568 2.Negative priority static objects should be available in AppUi's destructor.\n |
|
569 |
|
570 @SYMTestType : CIT |
|
571 */ |
|
572 CTConeTestAppUi::~CTConeTestAppUi() |
|
573 { |
|
574 CTConeTestNegativePrioStaticB* testNegStaticB = CTConeTestNegativePrioStaticB::Self(); |
|
575 // Test 1, Case 2 |
|
576 CTConeTestStatic* testCoeStatic = CTConeTestStatic::Self(); |
|
577 testNegStaticB->iFile.Write(KConeTest1); |
|
578 testNegStaticB->iFile.Write(KConeTestCase2); |
|
579 |
|
580 if(testCoeStatic == NULL) |
|
581 testNegStaticB->iFile.Write(KTestPass); |
|
582 else |
|
583 testNegStaticB->iFile.Write(KTestFail); |
|
584 |
|
585 // Test 2, Case 1 |
|
586 CTConeTestNegativePrioStaticA* testCoeStaticA = CTConeTestNegativePrioStaticA::Self(); |
|
587 testNegStaticB->iFile.Write(KConeTest2); |
|
588 testNegStaticB->iFile.Write(KConeTestCase1); |
|
589 |
|
590 if(testCoeStaticA != NULL) |
|
591 testNegStaticB->iFile.Write(KTestPass); |
|
592 else |
|
593 testNegStaticB->iFile.Write(KTestFail); |
|
594 |
|
595 // Test 4, Case 1 |
|
596 CTConeTestPrioZeroStaticA* testPrioZeroCoeStaticA = CTConeTestPrioZeroStaticA::Self(); |
|
597 CTConeTestPrioOneStaticB* testPrioOneCoeStaticB = CTConeTestPrioOneStaticB::Self(); |
|
598 CTConeTestPrioTwoStaticC* testPrioTwoCoeStaticC = CTConeTestPrioTwoStaticC::Self(); |
|
599 testNegStaticB->iFile.Write(KConeTest4); |
|
600 testNegStaticB->iFile.Write(KConeTestCase1); |
|
601 |
|
602 if(testPrioZeroCoeStaticA == NULL && testPrioOneCoeStaticB != NULL && testPrioTwoCoeStaticC != NULL) |
|
603 testNegStaticB->iFile.Write(KTestPass); |
|
604 else |
|
605 testNegStaticB->iFile.Write(KTestFail); |
|
606 |
|
607 delete iAppView; |
|
608 } |
|
609 /** |
|
610 Handles the user commands.\n |
|
611 Exits the application when EEikCmdExit command is generated.\n |
|
612 */ |
|
613 void CTConeTestAppUi::HandleCommandL(TInt aCommand) |
|
614 { |
|
615 switch (aCommand) |
|
616 { |
|
617 case EEikCmdExit: |
|
618 Exit(); |
|
619 break; |
|
620 } |
|
621 } |
|
622 /** |
|
623 @SYMTestCaseID UIF-TConeTestApp-Test1Case1 |
|
624 |
|
625 @SYMPREQ |
|
626 |
|
627 @SYMTestCaseDesc Availability of Positive priority static objects before AppUi is deleted.\n |
|
628 |
|
629 @SYMTestPriority High |
|
630 |
|
631 @SYMTestStatus Implemented |
|
632 |
|
633 @SYMTestActions : The PrepareToExit function performs pre-exit processing |
|
634 to ensure the application will exit cleanly.\n |
|
635 Static objects with positive priority should be available in this function.\n |
|
636 Pointer to CTConeTestStatic object is obtained.\n |
|
637 The validity of the pointer is checked.\n |
|
638 |
|
639 @SYMTestExpectedResults The pointer should be valid.\n |
|
640 |
|
641 @SYMTestType : CIT |
|
642 */ |
|
643 void CTConeTestAppUi::PrepareToExit() |
|
644 { |
|
645 CEikAppUi::PrepareToExit(); |
|
646 // Test 1, Case 1 |
|
647 CTConeTestStatic* testCoeStatic = CTConeTestStatic::Self(); |
|
648 |
|
649 testCoeStatic->iFile.Write(KConeTest1); |
|
650 testCoeStatic->iFile.Write(KConeTestCase1); |
|
651 |
|
652 if(testCoeStatic != NULL) |
|
653 testCoeStatic->iFile.Write(KTestPass); |
|
654 else |
|
655 testCoeStatic->iFile.Write(KTestFail); |
|
656 } |
|
657 |
|
658 |
|
659 // |
|
660 // |
|
661 // CTConeTestDocument |
|
662 // |
|
663 // |
|
664 //! A CEikDocument derived class.\n |
|
665 /** |
|
666 The base for all Uikon applications’ documents.\n |
|
667 A class derived from CEikDocument is used in each Uikon application.\n |
|
668 In file-based applications, the document provides an intermediate layer between the user interface, the model and the file the model will be stored in.\n |
|
669 Non-file-based applications will only use a document to create the application UI. |
|
670 */ |
|
671 class CTConeTestDocument : public CEikDocument |
|
672 { |
|
673 public: |
|
674 static CTConeTestDocument* NewL(CEikApplication& aApp); |
|
675 CTConeTestDocument(CEikApplication& aApp); |
|
676 void ConstructL(); |
|
677 private: |
|
678 // Inherited from CEikDocument |
|
679 CEikAppUi* CreateAppUiL(); |
|
680 }; |
|
681 /** |
|
682 Single argument constructor for CTConeTestDocument.\n |
|
683 Call base class's (CEikDocument) constructor.\n |
|
684 */ |
|
685 CTConeTestDocument::CTConeTestDocument(CEikApplication& aApp) |
|
686 : CEikDocument(aApp) |
|
687 { |
|
688 } |
|
689 /** |
|
690 Creates the AppUi for the application.\n |
|
691 Instantiates CTConeTestAppUi object.\n |
|
692 @return CTConeTestAppUi*, Pointer to AppUi object.\n |
|
693 */ |
|
694 CEikAppUi* CTConeTestDocument::CreateAppUiL() |
|
695 { |
|
696 return new(ELeave) CTConeTestAppUi; |
|
697 } |
|
698 |
|
699 // |
|
700 // |
|
701 // CTConeTestApplication |
|
702 // |
|
703 // |
|
704 //! A CEikApplication derived class.\n |
|
705 /** |
|
706 The root of all Uikon applications.\n |
|
707 CEikApplication builds on CApaApplication, providing a basis for applications |
|
708 working within the framework provided by Uikon.\n |
|
709 It also contains an interface to the resource file and the document. |
|
710 */ |
|
711 class CTConeTestApplication : public CEikApplication |
|
712 { |
|
713 private: |
|
714 // Inherited from class CApaApplication |
|
715 CApaDocument* CreateDocumentL(); |
|
716 TUid AppDllUid() const; |
|
717 private: |
|
718 CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); } |
|
719 }; |
|
720 /** |
|
721 Gets the application specific UID.\n |
|
722 The UID is used to differentiate between UI applications.\n |
|
723 An implementation of this function must be supplied by the UI application.\n |
|
724 |
|
725 @return TUid,Application specific Uid.\n |
|
726 */ |
|
727 TUid CTConeTestApplication::AppDllUid() const |
|
728 { |
|
729 return KUidConeTestApp; |
|
730 } |
|
731 /** |
|
732 Creates a document object.\n |
|
733 The function is called by the application process when a new document is required.\n |
|
734 The application process adds the new document to its list of documents.\n |
|
735 An implementation of this function is supplied by the UI framework.\n |
|
736 |
|
737 @return CApaDocument* , A pointer to the newly created document.\n |
|
738 |
|
739 */ |
|
740 CApaDocument* CTConeTestApplication::CreateDocumentL() |
|
741 { |
|
742 return new (ELeave) CTConeTestDocument(*this); |
|
743 } |
|
744 /** |
|
745 The only exported function.\n |
|
746 This function will be called by Application framework to create the application.\n |
|
747 |
|
748 @return CApaApplication*, A pointer to the newly created application.\n |
|
749 |
|
750 */ |
|
751 LOCAL_C CApaApplication* NewApplication() |
|
752 { |
|
753 return new CTConeTestApplication; |
|
754 } |
|
755 /** |
|
756 Entry Function.\n |
|
757 */ |
|
758 GLDEF_C TInt E32Main() |
|
759 { |
|
760 return EikStart::RunApplication( NewApplication ); |
|
761 } |
|
762 |
|
763 |
|
764 |
|
765 // |
|
766 // inline functions |
|
767 // |
|
768 |
|
769 // inline function for CTConeTestStatic |
|
770 /** |
|
771 Constructor for CTConeTestStatic Class.\n |
|
772 */ |
|
773 inline CTConeTestStatic::CTConeTestStatic(RFile& aFile) |
|
774 : CCoeStatic(KUidTestStatic),iFile(aFile) |
|
775 { |
|
776 } |
|
777 /** |
|
778 Returns pointer to CTConeTestStatic Object.\n |
|
779 */ |
|
780 inline CTConeTestStatic* CTConeTestStatic::Self() |
|
781 { |
|
782 return STATIC_CAST(CTConeTestStatic*,CCoeEnv::Static(KUidTestStatic)); |
|
783 } |
|
784 |
|
785 // inline functions for CTConeTestNegativePrioStaticA |
|
786 /** |
|
787 Constructor for CTConeTestNegativePrioStaticA Class.\n |
|
788 */ |
|
789 inline CTConeTestNegativePrioStaticA::CTConeTestNegativePrioStaticA(RFile& aFile) |
|
790 : CCoeStatic(KUidTestStaticNegativePrioA,ENegativePriortyStaticA),iFile(aFile) |
|
791 { |
|
792 } |
|
793 /** |
|
794 Returns pointer to CTConeTestNegativePrioStaticA Object.\n |
|
795 */ |
|
796 inline CTConeTestNegativePrioStaticA* CTConeTestNegativePrioStaticA::Self() |
|
797 { |
|
798 return STATIC_CAST(CTConeTestNegativePrioStaticA*,CCoeEnv::Static(KUidTestStaticNegativePrioA)); |
|
799 } |
|
800 |
|
801 // inline functions for CTConeTestNegativePrioStaticB |
|
802 /** |
|
803 Constructor for CTConeTestNegativePrioStaticB Class.\n |
|
804 */ |
|
805 inline CTConeTestNegativePrioStaticB::CTConeTestNegativePrioStaticB() |
|
806 : CCoeStatic(KUidTestStaticNegativePrioB,ENegativePriortyStaticA - 1) |
|
807 { |
|
808 User::LeaveIfError(iFs.Connect()); |
|
809 TInt err = iFs.MkDirAll(KConeTestDir); |
|
810 |
|
811 err = iFile.Create(iFs,KConeTestResultsFileName,EFileWrite | EFileShareAny); |
|
812 if(err == KErrAlreadyExists) |
|
813 iFile.Open(iFs,KConeTestResultsFileName,EFileWrite | EFileShareAny); |
|
814 } |
|
815 /** |
|
816 Returns pointer to CTConeTestNegativePrioStaticB object.\n |
|
817 */ |
|
818 inline CTConeTestNegativePrioStaticB* CTConeTestNegativePrioStaticB::Self() |
|
819 { |
|
820 return STATIC_CAST(CTConeTestNegativePrioStaticB*,CCoeEnv::Static(KUidTestStaticNegativePrioB)); |
|
821 } |
|
822 |
|
823 // inline functions for CTConeTestPosPrioStaticA |
|
824 /** |
|
825 Constructor for CTConeTestPosPrioStaticA Class.\n |
|
826 */ |
|
827 inline CTConeTestPosPrioStaticA::CTConeTestPosPrioStaticA(RFile& aFile) |
|
828 : CCoeStatic(KUidTestStaticPosPriA,EDefaultDestructionPriority),iFile(aFile) |
|
829 { |
|
830 } |
|
831 /** |
|
832 Returns pointer to CTConeTestPosPrioStaticA object.\n |
|
833 */ |
|
834 inline CTConeTestPosPrioStaticA* CTConeTestPosPrioStaticA::Self() |
|
835 { |
|
836 return STATIC_CAST(CTConeTestPosPrioStaticA*,CCoeEnv::Static(KUidTestStaticPosPriA)); |
|
837 } |
|
838 |
|
839 // inline functions for CTConeTestPosPrioStaticB |
|
840 /** |
|
841 Constructor for CTConeTestPosPrioStaticB Class.\n |
|
842 */ |
|
843 inline CTConeTestPosPrioStaticB::CTConeTestPosPrioStaticB(RFile& aFile) |
|
844 : CCoeStatic(KUidTestStaticPosPriB,EDefaultDestructionPriority-1),iFile(aFile) |
|
845 { |
|
846 } |
|
847 /** |
|
848 Returns pointer to CTConeTestPosPrioStaticB object.\n |
|
849 */ |
|
850 inline CTConeTestPosPrioStaticB* CTConeTestPosPrioStaticB::Self() |
|
851 { |
|
852 return STATIC_CAST(CTConeTestPosPrioStaticB*,CCoeEnv::Static(KUidTestStaticPosPriB)); |
|
853 } |
|
854 |
|
855 // inline functions for CTConeTestPrioZeroStaticA |
|
856 /** |
|
857 Constructor for CTConeTestPrioZeroStaticA Class.\n |
|
858 */ |
|
859 inline CTConeTestPrioZeroStaticA::CTConeTestPrioZeroStaticA(RFile& aFile) |
|
860 : CCoeStatic(KUidTestStaticPriZeroA,EPriorityZeroStaticA),iFile(aFile) |
|
861 { |
|
862 } |
|
863 /** |
|
864 Returns pointer to CTConeTestPrioZeroStaticA object.\n |
|
865 */ |
|
866 inline CTConeTestPrioZeroStaticA* CTConeTestPrioZeroStaticA::Self() |
|
867 { |
|
868 return STATIC_CAST(CTConeTestPrioZeroStaticA*,CCoeEnv::Static(KUidTestStaticPriZeroA)); |
|
869 } |
|
870 |
|
871 // inline functions for CTConeTestPrioOneStaticB |
|
872 /** |
|
873 Constructor for CTConeTestPrioOneStaticB Class.\n |
|
874 */ |
|
875 inline CTConeTestPrioOneStaticB::CTConeTestPrioOneStaticB(RFile& aFile) |
|
876 : CCoeStatic(KUidTestStaticPriOneB,EPriorityOneStaticB),iFile(aFile) |
|
877 { |
|
878 } |
|
879 /** |
|
880 Returns pointer to CTConeTestPrioOneStaticB object.\n |
|
881 */ |
|
882 inline CTConeTestPrioOneStaticB* CTConeTestPrioOneStaticB::Self() |
|
883 { |
|
884 return STATIC_CAST(CTConeTestPrioOneStaticB*,CCoeEnv::Static(KUidTestStaticPriOneB)); |
|
885 } |
|
886 |
|
887 // inline functions for CTConeTestPrioTwoStaticC |
|
888 /** |
|
889 Constructor for CTConeTestPrioTwoStaticC Class.\n |
|
890 */ |
|
891 inline CTConeTestPrioTwoStaticC::CTConeTestPrioTwoStaticC(RFile& aFile) |
|
892 : CCoeStatic(KUidTestStaticPriTwoC,EPriorityTwoStaticC),iFile(aFile) |
|
893 { |
|
894 } |
|
895 /** |
|
896 Returns pointer to CTConeTestPrioTwoStaticC object.\n |
|
897 */ |
|
898 inline CTConeTestPrioTwoStaticC* CTConeTestPrioTwoStaticC::Self() |
|
899 { |
|
900 return STATIC_CAST(CTConeTestPrioTwoStaticC*,CCoeEnv::Static(KUidTestStaticPriTwoC)); |
|
901 } |
|
902 |
|
903 |
|
904 |