|
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 // Tests for Object provider mechanism.\n |
|
15 // An interface that allows an object to be part of a network of object providers. |
|
16 // The object provider mechanism can be used to find and access objects of a |
|
17 // given type, where the type is defined by a TTypeUid object. Object providers |
|
18 // may be arranged in a hierarchy, i.e. an object provider may have a parent-child |
|
19 // relationship with another object provider. |
|
20 // An object provider must provide an implementation for the MopSupplyObject() |
|
21 // function and can choose to provide an implementation for the MopNext() function. |
|
22 // Typically, it will also have functionality to define who its parent is. |
|
23 // |
|
24 // |
|
25 |
|
26 /** |
|
27 @file |
|
28 @internalComponent - Internal Symbian test code |
|
29 @test |
|
30 */ |
|
31 |
|
32 #include <e32std.h> |
|
33 #include <coeaui.h> |
|
34 #include <coemop.h> |
|
35 #include "TCone3Step.h" |
|
36 #include "statecon.h" |
|
37 |
|
38 |
|
39 // Object Tree |
|
40 |
|
41 /** |
|
42 A |
|
43 / \ |
|
44 / \ |
|
45 / \ |
|
46 / \ |
|
47 B E |
|
48 / \ / \ |
|
49 C D F G |
|
50 |
|
51 */ |
|
52 |
|
53 |
|
54 |
|
55 /** Destructor for Class CSquareObj.\n */ |
|
56 |
|
57 CSquareObj::~CSquareObj() |
|
58 {} |
|
59 |
|
60 /** Sets the parent object provider's class name.\n */ |
|
61 |
|
62 void CSquareObj::SetParentClassName(TDesC& aName) |
|
63 { |
|
64 iName.Set( aName ); |
|
65 } |
|
66 |
|
67 TPtrC CSquareObj::GetParentClassName() const |
|
68 { |
|
69 return iName; |
|
70 } |
|
71 //! A CBase Derived Class.\n |
|
72 |
|
73 /** The class is used to test the object provider mechanism.\n */ |
|
74 |
|
75 class CTriangleObj : public CBase |
|
76 { |
|
77 public: |
|
78 DECLARE_TYPE_ID(0x10004C75) |
|
79 ~CTriangleObj(); |
|
80 void SetParentClassName(TDesC& aName); |
|
81 TPtrC GetParentClassName() const; |
|
82 private: |
|
83 TPtrC iName; |
|
84 }; |
|
85 |
|
86 /** Destructor for class CTriangleObj.\n */ |
|
87 |
|
88 CTriangleObj::~CTriangleObj() |
|
89 {} |
|
90 |
|
91 /** Sets the Parent class name of CTriangleObj class to aName.\n */ |
|
92 |
|
93 void CTriangleObj::SetParentClassName(TDesC& aName) |
|
94 { |
|
95 iName.Set( aName ); |
|
96 } |
|
97 /** Returns the Parent class name of CTriangleObj class.\n */ |
|
98 |
|
99 TPtrC CTriangleObj::GetParentClassName() const |
|
100 { |
|
101 return iName; |
|
102 } |
|
103 |
|
104 /** Destructor for class COctagonObj.\n */ |
|
105 |
|
106 COctagonObj::~COctagonObj() |
|
107 {} |
|
108 |
|
109 /** Sets the Parent class name of COctagonObj class to aName.\n */ |
|
110 void COctagonObj::SetParentClassName(TDesC& aName) |
|
111 { |
|
112 iName.Set( aName ); |
|
113 } |
|
114 /** Returns the Parent class name of COctagonObj class.\n */ |
|
115 TPtrC COctagonObj::GetParentClassName() const |
|
116 { |
|
117 return iName; |
|
118 } |
|
119 //! A Class derived from CBase and MObjectProvider.\n |
|
120 |
|
121 /** |
|
122 CObjectNode is an object provider implementing the MObjectProvider interface.\n |
|
123 MObjectProvider interface that allows an object to be part of a network of object providers.\n |
|
124 This class contains objects of classes CTriangleObj,CSquareObj and COctagonObj.\n |
|
125 */ |
|
126 class CObjectNode : public CBase, public MObjectProvider |
|
127 { |
|
128 public: |
|
129 CObjectNode(); |
|
130 CObjectNode(CTriangleObj* aTriangleObj, CSquareObj* aSquareObj, COctagonObj* aOctagonObj); |
|
131 ~CObjectNode(); |
|
132 void SetMopParent(MObjectProvider* aParent); |
|
133 |
|
134 CTriangleObj* GetTriangleObject(); |
|
135 CTriangleObj* GetTriangleObjNoChaining(); |
|
136 |
|
137 CSquareObj* GetSquareObject(); |
|
138 CSquareObj* GetSquareObjNoChaining(); |
|
139 |
|
140 COctagonObj* GetOctagonObject(); |
|
141 COctagonObj* GetOctagonObjNoChaining(); |
|
142 |
|
143 protected: // from MObjectProvider |
|
144 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
145 MObjectProvider* MopNext(); |
|
146 private: |
|
147 inline TTypeUid::Ptr SupplyMopObject(const TTypeUid aId); |
|
148 public: |
|
149 //! Array to store objects linked through object provider mechanism.\n |
|
150 RPointerArray<CObjectNode> iArray; |
|
151 private: |
|
152 //! Parent object provider.\n |
|
153 MObjectProvider* iMopParent; |
|
154 //! Pointer to the CTriangleObj returned searched by object provider mechanism.\n |
|
155 CTriangleObj* iTriangleObj; |
|
156 //! Pointer to the CSquareObj returned searched by object provider mechanism.\n |
|
157 CSquareObj* iSquareObj; |
|
158 //! Pointer to the COctagonObj returned searched by object provider mechanism.\n |
|
159 COctagonObj* iOctagonObj; |
|
160 }; |
|
161 /** Default Constructor for CObjectNode class.\n */ |
|
162 |
|
163 CObjectNode::CObjectNode() |
|
164 {} |
|
165 /** |
|
166 Three argument constructor for CObjectNode class.\n |
|
167 Initializes iTriangleObj,iSquareObj and iOctagonObj member objects.\n |
|
168 */ |
|
169 CObjectNode::CObjectNode(CTriangleObj* aTriangleObj, CSquareObj* aSquareObj, COctagonObj* aOctagonObj) |
|
170 : iTriangleObj(aTriangleObj), iSquareObj(aSquareObj), iOctagonObj(aOctagonObj) |
|
171 {} |
|
172 /** |
|
173 Destructor for CObjectNode class.\n |
|
174 Deletes the member objects of CTriangleObj,CSquareObj and COctagonObj classes.\n |
|
175 */ |
|
176 CObjectNode::~CObjectNode() |
|
177 { |
|
178 delete iTriangleObj; |
|
179 delete iSquareObj; |
|
180 delete iOctagonObj; |
|
181 |
|
182 iArray.ResetAndDestroy(); |
|
183 iArray.Close(); |
|
184 } |
|
185 |
|
186 /** |
|
187 |
|
188 Support for the object provider mechanism is in the construction of |
|
189 top-level controls in an application or view.\n |
|
190 Top level controls must have the view or app UI set as their object provider.\n |
|
191 The view or app UI does this by calling the control's SetMopParent() function.\n |
|
192 */ |
|
193 void CObjectNode::SetMopParent(MObjectProvider* aParent) |
|
194 { |
|
195 iMopParent = aParent; |
|
196 } |
|
197 /** |
|
198 Gets the parent object provider.\n |
|
199 This is called by the private function MopGetById() when a call to MopGetObject() |
|
200 returns NULL.\n |
|
201 |
|
202 */ |
|
203 MObjectProvider* CObjectNode::MopNext() |
|
204 { |
|
205 return iMopParent; |
|
206 } |
|
207 /** |
|
208 Gets an object whose type is encapsulated by the specified TTypeUid object.\n |
|
209 Calls the inline function SupplyMopObject .\n |
|
210 */ |
|
211 TTypeUid::Ptr CObjectNode::MopSupplyObject(TTypeUid aId) |
|
212 { |
|
213 return SupplyMopObject(aId); |
|
214 } |
|
215 /** |
|
216 This function is called by the MopSupplyObject when there is a request |
|
217 to get an object whose type is encapsulated by the specified TTypeUid object.\n |
|
218 The type uid is compared with the Uids of the three component objects namely |
|
219 aTriangleObj,aSquareObj and aOctagonObj.\n |
|
220 If the Uid matches,pointer to the matched object is returned.\n |
|
221 */ |
|
222 inline TTypeUid::Ptr CObjectNode::SupplyMopObject(const TTypeUid aId) |
|
223 { |
|
224 if (iTriangleObj) |
|
225 { |
|
226 if(aId.iUid == CTriangleObj::ETypeId) |
|
227 { |
|
228 return aId.MakePtr(iTriangleObj); |
|
229 } |
|
230 } |
|
231 |
|
232 if (iSquareObj) |
|
233 { |
|
234 if(aId.iUid == CSquareObj::ETypeId) |
|
235 { |
|
236 return aId.MakePtr(iSquareObj); |
|
237 } |
|
238 } |
|
239 |
|
240 if (iOctagonObj) |
|
241 { |
|
242 if(aId.iUid == COctagonObj::ETypeId) |
|
243 { |
|
244 return aId.MakePtr(iOctagonObj); |
|
245 } |
|
246 } |
|
247 |
|
248 return TTypeUid::Null(); |
|
249 } |
|
250 /** |
|
251 The function tests the ability to get the triangle object pointer |
|
252 using the Object provider mechanism.\n |
|
253 The function calls MopGetObject passing a pointer reference.\n |
|
254 */ |
|
255 CTriangleObj* CObjectNode::GetTriangleObject() |
|
256 { |
|
257 CTriangleObj* triangle = MopGetObject(triangle); |
|
258 return triangle; |
|
259 } |
|
260 |
|
261 /** |
|
262 The function tests the ability to get the square object pointer |
|
263 using the Object provider mechanism.\n |
|
264 The function calls MopGetObject passing a pointer reference.\n |
|
265 */ |
|
266 CSquareObj* CObjectNode::GetSquareObject() |
|
267 { |
|
268 CSquareObj* square = MopGetObject(square); |
|
269 return square; |
|
270 } |
|
271 /** |
|
272 The function tests the ability to get the octagon object pointer |
|
273 using the Object provider mechanism.\n |
|
274 The function calls MopGetObject passing a pointer reference.\n |
|
275 */ |
|
276 COctagonObj* CObjectNode::GetOctagonObject() |
|
277 { |
|
278 COctagonObj* octagon = MopGetObject(octagon); |
|
279 return octagon; |
|
280 } |
|
281 |
|
282 /** |
|
283 The function tests the ability to get the triangle object pointer |
|
284 using the Object provider mechanism without chaining.\n |
|
285 The object will be supplied directly by this object provider, or NULL |
|
286 will be returned, this function does not recurse through the object chain.\n |
|
287 The function calls MopGetObject passing a pointer reference.\n |
|
288 */ |
|
289 CTriangleObj* CObjectNode::GetTriangleObjNoChaining() |
|
290 { |
|
291 CTriangleObj* triangle = MopGetObjectNoChaining(triangle); |
|
292 return triangle; |
|
293 } |
|
294 |
|
295 /** |
|
296 The function tests the ability to get the square object pointer |
|
297 using the Object provider mechanism without chaining.\n |
|
298 The object will be supplied directly by this object provider, or NULL |
|
299 will be returned, this function does not recurse through the object chain.\n |
|
300 The function calls MopGetObject passing a pointer reference.\n |
|
301 */ |
|
302 CSquareObj* CObjectNode::GetSquareObjNoChaining() |
|
303 { |
|
304 CSquareObj* square = MopGetObjectNoChaining(square); |
|
305 return square; |
|
306 } |
|
307 /** |
|
308 The function tests the ability to get the octagon object pointer |
|
309 using the Object provider mechanism without chaining.\n |
|
310 The object will be supplied directly by this object provider, or NULL |
|
311 will be returned, this function does not recurse through the object chain.\n |
|
312 The function calls MopGetObject passing a pointer reference.\n |
|
313 */ |
|
314 COctagonObj* CObjectNode::GetOctagonObjNoChaining() |
|
315 { |
|
316 COctagonObj* octagon = MopGetObjectNoChaining(octagon); |
|
317 return octagon; |
|
318 } |
|
319 |
|
320 |
|
321 |
|
322 //! A class derived from CBase and MObjectProvider interface.\n |
|
323 /** |
|
324 The CObjectNodeConst tests the object provider mechanism by providing |
|
325 a constant interface. All the Get functions are constant to ensure that no changes |
|
326 are made to the objects.\n |
|
327 */ |
|
328 class CObjectNodeConst : public CBase, public MObjectProvider |
|
329 { |
|
330 public: |
|
331 CObjectNodeConst(); |
|
332 CObjectNodeConst(const CTriangleObj* aTriangleObj, const CSquareObj* aSquareObj, const COctagonObj* aOctagonObj); |
|
333 ~CObjectNodeConst(); |
|
334 void SetMopParent(MObjectProvider* aParent); |
|
335 |
|
336 const CTriangleObj* GetTriangleObject(); |
|
337 const CTriangleObj* GetTriangleObjNoChaining(); |
|
338 |
|
339 const CSquareObj* GetSquareObject(); |
|
340 const CSquareObj* GetSquareObjNoChaining(); |
|
341 |
|
342 const COctagonObj* GetOctagonObject(); |
|
343 const COctagonObj* GetOctagonObjNoChaining(); |
|
344 |
|
345 protected: // from MObjectProvider |
|
346 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
347 MObjectProvider* MopNext(); |
|
348 private: |
|
349 inline const TTypeUid::Ptr SupplyMopObject(TTypeUid aId); |
|
350 |
|
351 public: |
|
352 //! Array to store objects linked through object provider mechanism.\n |
|
353 RPointerArray<CObjectNodeConst> iArray; |
|
354 private: |
|
355 //! Parent object provider.\n |
|
356 MObjectProvider* iMopParent; |
|
357 //! Pointer to the CTriangleObj returned searched by object provider mechanism.\n |
|
358 const CTriangleObj* iTriangleObj; |
|
359 //! Pointer to the CSquareObj returned searched by object provider mechanism.\n |
|
360 const CSquareObj* iSquareObj; |
|
361 //! Pointer to the COctagonObj returned searched by object provider mechanism.\n |
|
362 const COctagonObj* iOctagonObj; |
|
363 }; |
|
364 |
|
365 /** Default constructor for CObjectNodeConst class.\n */ |
|
366 |
|
367 CObjectNodeConst::CObjectNodeConst() |
|
368 {} |
|
369 /** |
|
370 Three argument constructor for CObjectNodeConst class.\n |
|
371 Initializes iTriangleObj,iSquareObj and iOctagonObj member objects.\n |
|
372 */ |
|
373 CObjectNodeConst::CObjectNodeConst(const CTriangleObj* aTriangleObj, |
|
374 const CSquareObj* aSquareObj, |
|
375 const COctagonObj* aOctagonObj) |
|
376 : iTriangleObj(aTriangleObj), iSquareObj(aSquareObj), iOctagonObj(aOctagonObj) |
|
377 {} |
|
378 /** |
|
379 Destructor for CObjectNodeConst class.\n |
|
380 Deletes the iTriangleObj,iSquareObj and iOctagonObj objects.\n |
|
381 */ |
|
382 CObjectNodeConst::~CObjectNodeConst() |
|
383 { |
|
384 delete iTriangleObj; |
|
385 delete iSquareObj; |
|
386 delete iOctagonObj; |
|
387 |
|
388 iArray.ResetAndDestroy(); |
|
389 iArray.Close(); |
|
390 } |
|
391 |
|
392 /** |
|
393 Sets the context - that is, the enclosing parent object - for this object.\n |
|
394 */ |
|
395 void CObjectNodeConst::SetMopParent(MObjectProvider* aParent) |
|
396 { |
|
397 iMopParent = aParent; |
|
398 } |
|
399 /** |
|
400 Retrieves the parent object provider.\n |
|
401 This function may be overridden to continue the chain of object providers |
|
402 which are to be asked to supply an object.\n |
|
403 This is called by the private function MopGetById() when a call to MopGetObject() |
|
404 returns NULL.\n |
|
405 */ |
|
406 MObjectProvider* CObjectNodeConst::MopNext() |
|
407 { |
|
408 return iMopParent; |
|
409 } |
|
410 /** |
|
411 Gets an object whose type is encapsulated by the specified TTypeUid object.\n |
|
412 Calls the inline function SupplyMopObject .\n |
|
413 */ |
|
414 TTypeUid::Ptr CObjectNodeConst::MopSupplyObject(TTypeUid aId) |
|
415 { |
|
416 return SupplyMopObject(aId); |
|
417 } |
|
418 |
|
419 /** |
|
420 This function is called by the MopSupplyObject when there is a request |
|
421 to get an object whose type is encapsulated by the specified TTypeUid object.\n |
|
422 The type uid is compared with the Uids of the three component objects namely |
|
423 aTriangleObj,aSquareObj and aOctagonObj.\n |
|
424 If the Uid matches,pointer to the matched object is returned.\n |
|
425 */ |
|
426 inline const TTypeUid::Ptr CObjectNodeConst::SupplyMopObject(TTypeUid aId) |
|
427 { |
|
428 if (iTriangleObj) |
|
429 { |
|
430 if(aId.iUid == CTriangleObj::ETypeId) |
|
431 { |
|
432 return aId.MakePtr(const_cast<CTriangleObj*>(iTriangleObj)); |
|
433 } |
|
434 } |
|
435 |
|
436 if (iSquareObj) |
|
437 { |
|
438 if(aId.iUid == CSquareObj::ETypeId) |
|
439 { |
|
440 return aId.MakePtr(const_cast<CSquareObj*>(iSquareObj)); |
|
441 } |
|
442 } |
|
443 |
|
444 if (iOctagonObj) |
|
445 { |
|
446 if(aId.iUid == COctagonObj::ETypeId) |
|
447 { |
|
448 return aId.MakePtr(const_cast<COctagonObj*>(iOctagonObj)); |
|
449 } |
|
450 } |
|
451 |
|
452 return TTypeUid::Null(); |
|
453 } |
|
454 |
|
455 /** |
|
456 The function tests the ability to get the triangle object pointer |
|
457 using the Object provider mechanism.\n |
|
458 The function calls MopGetObject passing a pointer reference.\n |
|
459 */ |
|
460 const CTriangleObj* CObjectNodeConst::GetTriangleObject() |
|
461 { |
|
462 const CTriangleObj* triangle = MopGetObject(triangle); |
|
463 return triangle; |
|
464 } |
|
465 /** |
|
466 The function tests the ability to get the square object pointer |
|
467 using the Object provider mechanism.\n |
|
468 The function calls MopGetObject passing a pointer reference.\n |
|
469 */ |
|
470 const CSquareObj* CObjectNodeConst::GetSquareObject() |
|
471 { |
|
472 const CSquareObj* square = MopGetObject(square); |
|
473 return square; |
|
474 } |
|
475 /** |
|
476 The function tests the ability to get the octagon object pointer |
|
477 using the Object provider mechanism.\n |
|
478 The function calls MopGetObject passing a pointer reference.\n |
|
479 */ |
|
480 const COctagonObj* CObjectNodeConst::GetOctagonObject() |
|
481 { |
|
482 const COctagonObj* octagon = MopGetObject(octagon); |
|
483 return octagon; |
|
484 } |
|
485 /** |
|
486 The function tests the ability to get the triangle object pointer |
|
487 using the Object provider mechanism without chaining for constant functions.\n |
|
488 The object will be supplied directly by this object provider, or NULL |
|
489 will be returned, this function does not recurse through the object chain.\n |
|
490 The function calls MopGetObject passing a pointer reference.\n |
|
491 */ |
|
492 const CTriangleObj* CObjectNodeConst::GetTriangleObjNoChaining() |
|
493 { |
|
494 const CTriangleObj* triangle = MopGetObjectNoChaining(triangle); |
|
495 return triangle; |
|
496 } |
|
497 /** |
|
498 The function tests the ability to get the square object pointer |
|
499 using the Object provider mechanism without chaining for constant functions.\n |
|
500 The object will be supplied directly by this object provider, or NULL |
|
501 will be returned, this function does not recurse through the object chain.\n |
|
502 The function calls MopGetObject passing a pointer reference.\n |
|
503 */ |
|
504 const CSquareObj* CObjectNodeConst::GetSquareObjNoChaining() |
|
505 { |
|
506 const CSquareObj* square = MopGetObjectNoChaining(square); |
|
507 return square; |
|
508 } |
|
509 /** |
|
510 The function tests the ability to get the octagon object pointer |
|
511 using the Object provider mechanism without chaining for constant functions.\n |
|
512 The object will be supplied directly by this object provider, or NULL |
|
513 will be returned, this function does not recurse through the object chain.\n |
|
514 The function calls MopGetObject passing a pointer reference.\n |
|
515 */ |
|
516 const COctagonObj* CObjectNodeConst::GetOctagonObjNoChaining() |
|
517 { |
|
518 const COctagonObj* octagon = MopGetObjectNoChaining(octagon); |
|
519 return octagon; |
|
520 } |
|
521 |
|
522 /** Single Argument Constructor for CCone3TestAppUi class.\n */ |
|
523 |
|
524 CCone3TestAppUi::CCone3TestAppUi(CTmsTestStep* aStep) : |
|
525 CTestCoeAppUi(aStep) |
|
526 {} |
|
527 |
|
528 /** Destructor for CCone3TestAppUi class.\n */ |
|
529 |
|
530 CCone3TestAppUi::~CCone3TestAppUi() |
|
531 {} |
|
532 |
|
533 /** |
|
534 Second phase Constructor for CCone3TestAppUi class.\n |
|
535 Invokes the base class CTestCoeAppUi second phase constructor.\n |
|
536 Executes the testcases asynchronously using Autotest Manager.\n |
|
537 */ |
|
538 void CCone3TestAppUi::ConstructL() |
|
539 { |
|
540 CTestCoeAppUi::ConstructL(); |
|
541 AutoTestManager().StartAutoTest(); |
|
542 } |
|
543 |
|
544 /** |
|
545 @SYMTestCaseID UIF-TCone3Step-DoTestsL |
|
546 |
|
547 @SYMPREQ |
|
548 |
|
549 @SYMTestCaseDesc Tests the object provider mechanism |
|
550 |
|
551 @SYMTestPriority High |
|
552 |
|
553 @SYMTestStatus Implemented |
|
554 |
|
555 @SYMTestActions : Three types of component objects are created.\n |
|
556 a. Triangle object.\n |
|
557 b. Square Object.\n |
|
558 c. Octagon Object.\n |
|
559 Node objects instantiated from CObjectNode are created and a network |
|
560 is created using object provider mechanism.\n |
|
561 The details of the network are as follows.\n |
|
562 0. Node A - Contains Triangle A.\n |
|
563 1. Node B - Contains Square B.\n |
|
564 2. Node C - Contains Triangle C.\n |
|
565 3. Node D - Contains no component objects.\n |
|
566 4. Node E - Contains Triangle E and Octogen E as component objects.\n |
|
567 5. Node F - Contains Square F.\n |
|
568 6. Node G - Contains Triangle G.\n |
|
569 Parent-child relationships are set using SetMopParent at each node.\n |
|
570 Adds the pointers to above six object providers to iArray.\n |
|
571 Component objects are retrieved using GetMopObject() at every node.\n |
|
572 If the node does not have an object of particular type a search is made |
|
573 at the parent object provider also.\n |
|
574 These pointers are verified.\n |
|
575 |
|
576 @SYMTestExpectedResults The pointers of component objects obtained should match |
|
577 with the original objects.\n |
|
578 |
|
579 @SYMTestType : CIT |
|
580 */ |
|
581 void CCone3TestAppUi::DoTestsL() |
|
582 { |
|
583 __UHEAP_MARK; |
|
584 |
|
585 TPtrC nodeA(_L("A")); |
|
586 TPtrC nodeB(_L("B")); |
|
587 TPtrC nodeC(_L("C")); |
|
588 TPtrC nodeE(_L("E")); |
|
589 TPtrC nodeF(_L("F")); |
|
590 TPtrC nodeG(_L("G")); |
|
591 |
|
592 CTriangleObj* triangleA = new(ELeave) CTriangleObj(); |
|
593 triangleA->SetParentClassName(nodeA); |
|
594 |
|
595 CSquareObj* squareB = new(ELeave) CSquareObj(); |
|
596 squareB->SetParentClassName(nodeB); |
|
597 |
|
598 CTriangleObj* triangleC = new(ELeave) CTriangleObj(); |
|
599 triangleC->SetParentClassName(nodeC); |
|
600 |
|
601 CTriangleObj* triangleE = new(ELeave) CTriangleObj(); |
|
602 triangleE->SetParentClassName(nodeE); |
|
603 |
|
604 COctagonObj* octagonE = new(ELeave) COctagonObj() ; |
|
605 octagonE->SetParentClassName(nodeE); |
|
606 |
|
607 CSquareObj* squareF = new(ELeave) CSquareObj(); |
|
608 squareF->SetParentClassName(nodeF); |
|
609 |
|
610 CTriangleObj* triangleG = new(ELeave) CTriangleObj(); |
|
611 triangleG->SetParentClassName(nodeG); |
|
612 |
|
613 CObjectNode* node = new (ELeave) CObjectNode(); |
|
614 CleanupStack::PushL(node); |
|
615 |
|
616 node->iArray.Append(new (ELeave) CObjectNode(triangleA, NULL, NULL)); |
|
617 node->iArray.Append(new (ELeave) CObjectNode(NULL, squareB, NULL)); |
|
618 node->iArray.Append(new (ELeave) CObjectNode(triangleE, NULL, octagonE)); |
|
619 |
|
620 node->iArray.Append(new (ELeave) CObjectNode(triangleC, NULL, NULL)); |
|
621 node->iArray.Append(new (ELeave) CObjectNode(NULL, NULL, NULL)); |
|
622 |
|
623 node->iArray.Append(new (ELeave) CObjectNode(NULL, squareF, NULL)); |
|
624 node->iArray.Append(new (ELeave) CObjectNode(triangleG, NULL, NULL)); |
|
625 |
|
626 node->iArray[1]->SetMopParent(node->iArray[0]); |
|
627 node->iArray[2]->SetMopParent(node->iArray[0]); |
|
628 |
|
629 node->iArray[3]->SetMopParent(node->iArray[1]); |
|
630 node->iArray[4]->SetMopParent(node->iArray[1]); |
|
631 |
|
632 node->iArray[5]->SetMopParent(node->iArray[2]); |
|
633 node->iArray[6]->SetMopParent(node->iArray[2]); |
|
634 |
|
635 |
|
636 //Node0 - A |
|
637 CTriangleObj* getTriangle = NULL; |
|
638 CSquareObj* getSquare = NULL; |
|
639 COctagonObj* getOctagon = NULL; |
|
640 INFO_PRINTF1(_L("Testing Node A")); |
|
641 getTriangle = node->iArray[0]->GetTriangleObject(); |
|
642 getSquare = node->iArray[0]->GetSquareObject(); |
|
643 getOctagon = node->iArray[0]->GetOctagonObject(); |
|
644 |
|
645 TEST(getTriangle != NULL); |
|
646 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
647 TEST(getSquare == NULL); |
|
648 TEST(getOctagon == NULL); |
|
649 |
|
650 INFO_PRINTF1(_L("Testing Node B")); |
|
651 //Node1 - B |
|
652 getTriangle = NULL; |
|
653 getSquare = NULL; |
|
654 getOctagon = NULL; |
|
655 |
|
656 getTriangle = node->iArray[1]->GetTriangleObject(); |
|
657 getSquare = node->iArray[1]->GetSquareObject(); |
|
658 getOctagon = node->iArray[1]->GetOctagonObject(); |
|
659 |
|
660 TEST(getSquare != NULL); |
|
661 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
662 TEST(getTriangle != NULL); |
|
663 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
664 TEST(getOctagon == NULL); |
|
665 |
|
666 INFO_PRINTF1(_L("Testing Node C")); |
|
667 //Node3 - C |
|
668 getTriangle = NULL; |
|
669 getSquare = NULL; |
|
670 getOctagon = NULL; |
|
671 |
|
672 getTriangle = node->iArray[3]->GetTriangleObject(); |
|
673 getSquare = node->iArray[3]->GetSquareObject(); |
|
674 getOctagon = node->iArray[3]->GetOctagonObject(); |
|
675 |
|
676 TEST(getTriangle != NULL); |
|
677 TEST(getTriangle->GetParentClassName().Compare(nodeC) == KErrNone); |
|
678 TEST(getSquare != NULL); |
|
679 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
680 TEST(getOctagon == NULL); |
|
681 |
|
682 INFO_PRINTF1(_L("Testing Node D")); |
|
683 //Node4 - D |
|
684 getTriangle = NULL; |
|
685 getSquare = NULL; |
|
686 getOctagon = NULL; |
|
687 |
|
688 getTriangle = node->iArray[4]->GetTriangleObject(); |
|
689 getSquare = node->iArray[4]->GetSquareObject(); |
|
690 getOctagon = node->iArray[4]->GetOctagonObject(); |
|
691 |
|
692 TEST(getSquare != NULL); |
|
693 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
694 TEST(getTriangle != NULL); |
|
695 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
696 TEST(getOctagon == NULL); |
|
697 |
|
698 INFO_PRINTF1(_L("Testing Node E")); |
|
699 //Node2 - E |
|
700 getTriangle = NULL; |
|
701 getSquare = NULL; |
|
702 getOctagon = NULL; |
|
703 |
|
704 getTriangle = node->iArray[2]->GetTriangleObject(); |
|
705 getSquare = node->iArray[2]->GetSquareObject(); |
|
706 getOctagon = node->iArray[2]->GetOctagonObject(); |
|
707 |
|
708 TEST(getTriangle != NULL); |
|
709 TEST(getTriangle->GetParentClassName().Compare(nodeE) == KErrNone); |
|
710 TEST(getOctagon != NULL); |
|
711 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
712 TEST(getSquare == NULL); |
|
713 |
|
714 INFO_PRINTF1(_L("Testing Node F")); |
|
715 //Node5 - F |
|
716 getTriangle = NULL; |
|
717 getSquare = NULL; |
|
718 getOctagon = NULL; |
|
719 |
|
720 getTriangle = node->iArray[5]->GetTriangleObject(); |
|
721 getSquare = node->iArray[5]->GetSquareObject(); |
|
722 getOctagon = node->iArray[5]->GetOctagonObject(); |
|
723 |
|
724 TEST(getSquare != NULL); |
|
725 TEST(getSquare->GetParentClassName().Compare(nodeF) == KErrNone); |
|
726 TEST(getTriangle != NULL); |
|
727 TEST(getTriangle->GetParentClassName().Compare(nodeE) == KErrNone); |
|
728 TEST(getOctagon != NULL); |
|
729 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
730 |
|
731 INFO_PRINTF1(_L("Testing Node G")); |
|
732 //Node6 - G |
|
733 getTriangle = NULL; |
|
734 getSquare = NULL; |
|
735 getOctagon = NULL; |
|
736 |
|
737 getTriangle = node->iArray[6]->GetTriangleObject(); |
|
738 getSquare = node->iArray[6]->GetSquareObject(); |
|
739 getOctagon = node->iArray[6]->GetOctagonObject(); |
|
740 |
|
741 TEST(getTriangle != NULL); |
|
742 TEST(getTriangle->GetParentClassName().Compare(nodeG) == KErrNone); |
|
743 TEST(getOctagon != NULL); |
|
744 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
745 TEST(getSquare == NULL); |
|
746 |
|
747 CleanupStack::PopAndDestroy(); // node |
|
748 |
|
749 // test.Printf(_L("TEST COMPLETE [Press any key]")); |
|
750 __UHEAP_MARKEND; |
|
751 } |
|
752 /** |
|
753 @SYMTestCaseID UIF-TCone3Step-DoMopConstTestsL |
|
754 |
|
755 @SYMPREQ |
|
756 |
|
757 @SYMTestCaseDesc Tests the object provider mechanism using constant Mop functions.\n |
|
758 |
|
759 @SYMTestPriority High |
|
760 |
|
761 @SYMTestStatus Implemented |
|
762 |
|
763 @SYMTestActions : Three types of component objects are created.\n |
|
764 a. Triangle object.\n |
|
765 b. Square Object.\n |
|
766 c. Octagon Object.\n |
|
767 Node objects instantiated from CObjectNode are created and a network |
|
768 is created using object provider mechanism.\n |
|
769 The details of the network are as follows.\n |
|
770 0. Node A - Contains Triangle A.\n |
|
771 1. Node B - Contains Square B.\n |
|
772 2. Node C - Contains Triangle C.\n |
|
773 3. Node D - Contains no component objects.\n |
|
774 4. Node E - Contains Triangle E and Octogen E as component objects.\n |
|
775 5. Node F - Contains Square F.\n |
|
776 6. Node G - Contains Triangle G.\n |
|
777 Parent-child relationships are set using SetMopParent at each node.\n |
|
778 Adds the pointers to above six object providers to iArray.\n |
|
779 Component objects are retrieved using GetMopObject() at every node.\n |
|
780 If the node does not have an object of particular type a search is made |
|
781 at the parent object provider also.\n |
|
782 These pointers are verified.\n |
|
783 |
|
784 @SYMTestExpectedResults The pointers of component objects obtained should match |
|
785 with the original objects.\n |
|
786 |
|
787 */ |
|
788 |
|
789 void CCone3TestAppUi::DoMopConstTestsL() |
|
790 { |
|
791 __UHEAP_MARK; |
|
792 |
|
793 TPtrC nodeA(_L("A")); |
|
794 TPtrC nodeB(_L("B")); |
|
795 TPtrC nodeC(_L("C")); |
|
796 TPtrC nodeE(_L("E")); |
|
797 TPtrC nodeF(_L("F")); |
|
798 TPtrC nodeG(_L("G")); |
|
799 |
|
800 CObjectNodeConst* node = new (ELeave) CObjectNodeConst(); |
|
801 CleanupStack::PushL(node); |
|
802 |
|
803 const CTriangleObj* triangleA = new(ELeave) CTriangleObj(); |
|
804 (const_cast<CTriangleObj*>(triangleA))->SetParentClassName(nodeA); |
|
805 CleanupStack::PushL(const_cast<CTriangleObj*>(triangleA)); |
|
806 |
|
807 const CSquareObj* squareB = new(ELeave) CSquareObj(); |
|
808 (const_cast<CSquareObj*>(squareB))->SetParentClassName(nodeB); |
|
809 CleanupStack::PushL(const_cast<CSquareObj*>(squareB)); |
|
810 |
|
811 const CTriangleObj* triangleC = new(ELeave) CTriangleObj(); |
|
812 (const_cast<CTriangleObj*>(triangleC))->SetParentClassName(nodeC); |
|
813 CleanupStack::PushL(const_cast<CTriangleObj*>(triangleC)); |
|
814 |
|
815 const CTriangleObj* triangleE = new(ELeave) CTriangleObj(); |
|
816 (const_cast<CTriangleObj*>(triangleE))->SetParentClassName(nodeE); |
|
817 CleanupStack::PushL(const_cast<CTriangleObj*>(triangleE)); |
|
818 |
|
819 |
|
820 const COctagonObj* octagonE = new(ELeave) COctagonObj() ; |
|
821 (const_cast<COctagonObj*>(octagonE))->SetParentClassName(nodeE); |
|
822 CleanupStack::PushL(const_cast<COctagonObj*>(octagonE)); |
|
823 |
|
824 const CSquareObj* squareF = new(ELeave) CSquareObj(); |
|
825 (const_cast<CSquareObj*>(squareF))->SetParentClassName(nodeF); |
|
826 CleanupStack::PushL(const_cast<CSquareObj*>(squareF)); |
|
827 |
|
828 const CTriangleObj* triangleG = new(ELeave) CTriangleObj(); |
|
829 (const_cast<CTriangleObj*>(triangleG))->SetParentClassName(nodeG); |
|
830 |
|
831 CleanupStack::Pop(6); |
|
832 |
|
833 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleA, NULL, NULL)); |
|
834 node->iArray.Append(new (ELeave) CObjectNodeConst(NULL, squareB, NULL)); |
|
835 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleE, NULL, octagonE)); |
|
836 |
|
837 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleC, NULL, NULL)); |
|
838 node->iArray.Append(new (ELeave) CObjectNodeConst(NULL, NULL, NULL)); |
|
839 |
|
840 node->iArray.Append(new (ELeave) CObjectNodeConst(NULL, squareF, NULL)); |
|
841 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleG, NULL, NULL)); |
|
842 |
|
843 node->iArray[1]->SetMopParent(node->iArray[0]); |
|
844 node->iArray[2]->SetMopParent(node->iArray[0]); |
|
845 |
|
846 node->iArray[3]->SetMopParent(node->iArray[1]); |
|
847 node->iArray[4]->SetMopParent(node->iArray[1]); |
|
848 |
|
849 node->iArray[5]->SetMopParent(node->iArray[2]); |
|
850 node->iArray[6]->SetMopParent(node->iArray[2]); |
|
851 |
|
852 |
|
853 //Node0 - A |
|
854 const CTriangleObj* getTriangle = NULL; |
|
855 const CSquareObj* getSquare = NULL; |
|
856 const COctagonObj* getOctagon = NULL; |
|
857 INFO_PRINTF1(_L("Testing Node A Const")); |
|
858 getTriangle = node->iArray[0]->GetTriangleObject(); |
|
859 getSquare = node->iArray[0]->GetSquareObject(); |
|
860 getOctagon = node->iArray[0]->GetOctagonObject(); |
|
861 |
|
862 TEST(getTriangle != NULL); |
|
863 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
864 TEST(getSquare == NULL); |
|
865 TEST(getOctagon == NULL); |
|
866 |
|
867 INFO_PRINTF1(_L("Testing Node B Const")); |
|
868 //Node1 - B |
|
869 getTriangle = NULL; |
|
870 getSquare = NULL; |
|
871 getOctagon = NULL; |
|
872 |
|
873 getTriangle = node->iArray[1]->GetTriangleObject(); |
|
874 getSquare = node->iArray[1]->GetSquareObject(); |
|
875 getOctagon = node->iArray[1]->GetOctagonObject(); |
|
876 |
|
877 TEST(getSquare != NULL); |
|
878 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
879 TEST(getTriangle != NULL); |
|
880 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
881 TEST(getOctagon == NULL); |
|
882 |
|
883 INFO_PRINTF1(_L("Testing Node C Const")); |
|
884 //Node3 - C |
|
885 getTriangle = NULL; |
|
886 getSquare = NULL; |
|
887 getOctagon = NULL; |
|
888 |
|
889 getTriangle = node->iArray[3]->GetTriangleObject(); |
|
890 getSquare = node->iArray[3]->GetSquareObject(); |
|
891 getOctagon = node->iArray[3]->GetOctagonObject(); |
|
892 |
|
893 TEST(getTriangle != NULL); |
|
894 TEST(getTriangle->GetParentClassName().Compare(nodeC) == KErrNone); |
|
895 TEST(getSquare != NULL); |
|
896 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
897 TEST(getOctagon == NULL); |
|
898 |
|
899 INFO_PRINTF1(_L("Testing Node D Const")); |
|
900 //Node4 - D |
|
901 getTriangle = NULL; |
|
902 getSquare = NULL; |
|
903 getOctagon = NULL; |
|
904 |
|
905 getTriangle = node->iArray[4]->GetTriangleObject(); |
|
906 getSquare = node->iArray[4]->GetSquareObject(); |
|
907 getOctagon = node->iArray[4]->GetOctagonObject(); |
|
908 |
|
909 TEST(getSquare != NULL); |
|
910 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
911 TEST(getTriangle != NULL); |
|
912 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
913 TEST(getOctagon == NULL); |
|
914 |
|
915 INFO_PRINTF1(_L("Testing Node E Const")); |
|
916 //Node2 - E |
|
917 getTriangle = NULL; |
|
918 getSquare = NULL; |
|
919 getOctagon = NULL; |
|
920 |
|
921 getTriangle = node->iArray[2]->GetTriangleObject(); |
|
922 getSquare = node->iArray[2]->GetSquareObject(); |
|
923 getOctagon = node->iArray[2]->GetOctagonObject(); |
|
924 |
|
925 TEST(getTriangle != NULL); |
|
926 TEST(getTriangle->GetParentClassName().Compare(nodeE) == KErrNone); |
|
927 TEST(getOctagon != NULL); |
|
928 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
929 TEST(getSquare == NULL); |
|
930 |
|
931 INFO_PRINTF1(_L("Testing Node F Const")); |
|
932 //Node5 - F |
|
933 getTriangle = NULL; |
|
934 getSquare = NULL; |
|
935 getOctagon = NULL; |
|
936 |
|
937 getTriangle = node->iArray[5]->GetTriangleObject(); |
|
938 getSquare = node->iArray[5]->GetSquareObject(); |
|
939 getOctagon = node->iArray[5]->GetOctagonObject(); |
|
940 |
|
941 TEST(getSquare != NULL); |
|
942 TEST(getSquare->GetParentClassName().Compare(nodeF) == KErrNone); |
|
943 TEST(getTriangle != NULL); |
|
944 TEST(getTriangle->GetParentClassName().Compare(nodeE) == KErrNone); |
|
945 TEST(getOctagon != NULL); |
|
946 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
947 |
|
948 INFO_PRINTF1(_L("Testing Node G Const")); |
|
949 //Node6 - G |
|
950 getTriangle = NULL; |
|
951 getSquare = NULL; |
|
952 getOctagon = NULL; |
|
953 |
|
954 getTriangle = node->iArray[6]->GetTriangleObject(); |
|
955 getSquare = node->iArray[6]->GetSquareObject(); |
|
956 getOctagon = node->iArray[6]->GetOctagonObject(); |
|
957 |
|
958 TEST(getTriangle != NULL); |
|
959 TEST(getTriangle->GetParentClassName().Compare(nodeG) == KErrNone); |
|
960 TEST(getOctagon != NULL); |
|
961 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
962 TEST(getSquare == NULL); |
|
963 |
|
964 CleanupStack::PopAndDestroy(); // node |
|
965 |
|
966 // test.Printf(_L("TEST COMPLETE [Press any key]")); |
|
967 __UHEAP_MARKEND; |
|
968 } |
|
969 |
|
970 /** |
|
971 @SYMTestCaseID UIF-TCone3Step-DoMopNoChainingTestsL |
|
972 |
|
973 @SYMPREQ |
|
974 |
|
975 @SYMTestCaseDesc Tests the object provider mechanism without no chaining.\n |
|
976 |
|
977 @SYMTestPriority High |
|
978 |
|
979 @SYMTestStatus Implemented |
|
980 |
|
981 @SYMTestActions : Three types of component objects are created.\n |
|
982 a. Triangle object.\n |
|
983 b. Square Object.\n |
|
984 c. Octagon Object.\n |
|
985 Node objects instantiated from CObjectNode are created and a network |
|
986 is created using object provider mechanism.\n |
|
987 The details of the network are as follows.\n |
|
988 0. Node A - Contains Triangle A.\n |
|
989 1. Node B - Contains Square B.\n |
|
990 2. Node C - Contains Triangle C.\n |
|
991 3. Node D - Contains no component objects.\n |
|
992 4. Node E - Contains Triangle E and Octogen E as component objects.\n |
|
993 5. Node F - Contains Square F.\n |
|
994 6. Node G - Contains Triangle G.\n |
|
995 Parent-child relationships are set using SetMopParent at each node.\n |
|
996 Adds the pointers to above six object providers to iArray.\n |
|
997 Component objects are retrieved using GetMopObject() at every node.\n |
|
998 If the node does not have an object of particular type a search is made |
|
999 at the parent object provider also.\n |
|
1000 These pointers are verified.\n |
|
1001 |
|
1002 @SYMTestExpectedResults The pointers of component objects obtained should match |
|
1003 with the original objects.\n |
|
1004 |
|
1005 @SYMTestType : CIT |
|
1006 */ |
|
1007 void CCone3TestAppUi::DoMopNoChainingTestsL() |
|
1008 { |
|
1009 __UHEAP_MARK; |
|
1010 |
|
1011 TPtrC nodeA(_L("A")); |
|
1012 TPtrC nodeB(_L("B")); |
|
1013 TPtrC nodeC(_L("C")); |
|
1014 TPtrC nodeE(_L("E")); |
|
1015 TPtrC nodeF(_L("F")); |
|
1016 TPtrC nodeG(_L("G")); |
|
1017 |
|
1018 CObjectNode* node = new (ELeave) CObjectNode(); |
|
1019 CleanupStack::PushL(node); |
|
1020 |
|
1021 CTriangleObj* triangleA = new(ELeave) CTriangleObj(); |
|
1022 triangleA->SetParentClassName(nodeA); |
|
1023 CleanupStack::PushL(triangleA); |
|
1024 |
|
1025 CSquareObj* squareB = new(ELeave) CSquareObj(); |
|
1026 squareB->SetParentClassName(nodeB); |
|
1027 CleanupStack::PushL(squareB); |
|
1028 |
|
1029 CTriangleObj* triangleC = new(ELeave) CTriangleObj(); |
|
1030 triangleC->SetParentClassName(nodeC); |
|
1031 CleanupStack::PushL(triangleC); |
|
1032 |
|
1033 CTriangleObj* triangleE = new(ELeave) CTriangleObj(); |
|
1034 triangleE->SetParentClassName(nodeE); |
|
1035 CleanupStack::PushL(triangleE); |
|
1036 |
|
1037 |
|
1038 COctagonObj* octagonE = new(ELeave) COctagonObj() ; |
|
1039 octagonE->SetParentClassName(nodeE); |
|
1040 CleanupStack::PushL(octagonE); |
|
1041 |
|
1042 CSquareObj* squareF = new(ELeave) CSquareObj(); |
|
1043 squareF->SetParentClassName(nodeF); |
|
1044 CleanupStack::PushL(squareF); |
|
1045 |
|
1046 CTriangleObj* triangleG = new(ELeave) CTriangleObj(); |
|
1047 triangleG->SetParentClassName(nodeG); |
|
1048 |
|
1049 CleanupStack::Pop(6, triangleA); |
|
1050 node->iArray.Append(new (ELeave) CObjectNode(triangleA, NULL, NULL)); |
|
1051 node->iArray.Append(new (ELeave) CObjectNode(NULL, squareB, NULL)); |
|
1052 node->iArray.Append(new (ELeave) CObjectNode(triangleE, NULL, octagonE)); |
|
1053 |
|
1054 node->iArray.Append(new (ELeave) CObjectNode(triangleC, NULL, NULL)); |
|
1055 node->iArray.Append(new (ELeave) CObjectNode(NULL, NULL, NULL)); |
|
1056 |
|
1057 node->iArray.Append(new (ELeave) CObjectNode(NULL, squareF, NULL)); |
|
1058 node->iArray.Append(new (ELeave) CObjectNode(triangleG, NULL, NULL)); |
|
1059 |
|
1060 node->iArray[1]->SetMopParent(node->iArray[0]); |
|
1061 node->iArray[2]->SetMopParent(node->iArray[0]); |
|
1062 |
|
1063 node->iArray[3]->SetMopParent(node->iArray[1]); |
|
1064 node->iArray[4]->SetMopParent(node->iArray[1]); |
|
1065 |
|
1066 node->iArray[5]->SetMopParent(node->iArray[2]); |
|
1067 node->iArray[6]->SetMopParent(node->iArray[2]); |
|
1068 |
|
1069 //Node0 - A |
|
1070 CTriangleObj* getTriangle = NULL; |
|
1071 CSquareObj* getSquare = NULL; |
|
1072 COctagonObj* getOctagon = NULL; |
|
1073 INFO_PRINTF1(_L("Testing Node A No Chaining")); |
|
1074 getTriangle = node->iArray[0]->GetTriangleObjNoChaining(); |
|
1075 getSquare = node->iArray[0]->GetSquareObjNoChaining(); |
|
1076 getOctagon = node->iArray[0]->GetOctagonObjNoChaining(); |
|
1077 |
|
1078 TEST(getTriangle != NULL); |
|
1079 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
1080 TEST(getSquare == NULL); |
|
1081 TEST(getOctagon == NULL); |
|
1082 |
|
1083 INFO_PRINTF1(_L("Testing Node B No Chaining")); |
|
1084 //Node1 - B |
|
1085 getTriangle = NULL; |
|
1086 getSquare = NULL; |
|
1087 getOctagon = NULL; |
|
1088 |
|
1089 getTriangle = node->iArray[1]->GetTriangleObjNoChaining(); |
|
1090 getSquare = node->iArray[1]->GetSquareObjNoChaining(); |
|
1091 getOctagon = node->iArray[1]->GetOctagonObjNoChaining(); |
|
1092 |
|
1093 TEST(getSquare != NULL); |
|
1094 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
1095 TEST(getTriangle == NULL); |
|
1096 TEST(getOctagon == NULL); |
|
1097 |
|
1098 INFO_PRINTF1(_L("Testing Node C No Chaining")); |
|
1099 //Node3 - C |
|
1100 getTriangle = NULL; |
|
1101 getSquare = NULL; |
|
1102 getOctagon = NULL; |
|
1103 |
|
1104 getTriangle = node->iArray[3]->GetTriangleObjNoChaining(); |
|
1105 getSquare = node->iArray[3]->GetSquareObjNoChaining(); |
|
1106 getOctagon = node->iArray[3]->GetOctagonObjNoChaining(); |
|
1107 |
|
1108 TEST(getTriangle != NULL); |
|
1109 TEST(getTriangle->GetParentClassName().Compare(nodeC) == KErrNone); |
|
1110 TEST(getSquare == NULL); |
|
1111 TEST(getOctagon == NULL); |
|
1112 |
|
1113 INFO_PRINTF1(_L("Testing Node D No Chaining")); |
|
1114 //Node4 - D |
|
1115 getTriangle = NULL; |
|
1116 getSquare = NULL; |
|
1117 getOctagon = NULL; |
|
1118 |
|
1119 getTriangle = node->iArray[4]->GetTriangleObjNoChaining(); |
|
1120 getSquare = node->iArray[4]->GetSquareObjNoChaining(); |
|
1121 getOctagon = node->iArray[4]->GetOctagonObjNoChaining(); |
|
1122 |
|
1123 TEST(getSquare == NULL); |
|
1124 TEST(getTriangle == NULL); |
|
1125 TEST(getOctagon == NULL); |
|
1126 |
|
1127 INFO_PRINTF1(_L("Testing Node E No Chaining")); |
|
1128 //Node2 - E |
|
1129 getTriangle = NULL; |
|
1130 getSquare = NULL; |
|
1131 getOctagon = NULL; |
|
1132 |
|
1133 getTriangle = node->iArray[2]->GetTriangleObjNoChaining(); |
|
1134 getSquare = node->iArray[2]->GetSquareObjNoChaining(); |
|
1135 getOctagon = node->iArray[2]->GetOctagonObjNoChaining(); |
|
1136 |
|
1137 TEST(getTriangle != NULL); |
|
1138 TEST(getTriangle->GetParentClassName().Compare(nodeE) == KErrNone); |
|
1139 TEST(getOctagon != NULL); |
|
1140 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
1141 TEST(getSquare == NULL); |
|
1142 |
|
1143 INFO_PRINTF1(_L("Testing Node F No Chaining")); |
|
1144 //Node5 - F |
|
1145 getTriangle = NULL; |
|
1146 getSquare = NULL; |
|
1147 getOctagon = NULL; |
|
1148 |
|
1149 getTriangle = node->iArray[5]->GetTriangleObjNoChaining(); |
|
1150 getSquare = node->iArray[5]->GetSquareObjNoChaining(); |
|
1151 getOctagon = node->iArray[5]->GetOctagonObjNoChaining(); |
|
1152 |
|
1153 TEST(getSquare != NULL); |
|
1154 TEST(getSquare->GetParentClassName().Compare(nodeF) == KErrNone); |
|
1155 TEST(getTriangle == NULL); |
|
1156 TEST(getOctagon == NULL); |
|
1157 |
|
1158 INFO_PRINTF1(_L("Testing Node G No Chaining")); |
|
1159 //Node6 - G |
|
1160 getTriangle = NULL; |
|
1161 getSquare = NULL; |
|
1162 getOctagon = NULL; |
|
1163 |
|
1164 getTriangle = node->iArray[6]->GetTriangleObjNoChaining(); |
|
1165 getSquare = node->iArray[6]->GetSquareObjNoChaining(); |
|
1166 getOctagon = node->iArray[6]->GetOctagonObjNoChaining(); |
|
1167 |
|
1168 TEST(getTriangle != NULL); |
|
1169 TEST(getTriangle->GetParentClassName().Compare(nodeG) == KErrNone); |
|
1170 TEST(getOctagon == NULL); |
|
1171 TEST(getSquare == NULL); |
|
1172 |
|
1173 CleanupStack::PopAndDestroy(node); |
|
1174 |
|
1175 __UHEAP_MARKEND; |
|
1176 |
|
1177 } |
|
1178 |
|
1179 /** |
|
1180 @SYMTestCaseID UIF-TCone3Step-DoMopNoChainingConstTestsL |
|
1181 |
|
1182 @SYMPREQ |
|
1183 |
|
1184 @SYMTestCaseDesc Tests the object provider mechanism without no chaining |
|
1185 and using constant functions only.\n |
|
1186 |
|
1187 @SYMTestPriority High |
|
1188 |
|
1189 @SYMTestStatus Implemented |
|
1190 |
|
1191 @SYMTestActions : Three types of component objects are created.\n |
|
1192 a. Triangle object.\n |
|
1193 b. Square Object.\n |
|
1194 c. Octagon Object.\n |
|
1195 Node objects instantiated from CObjectNode are created and a network |
|
1196 is created using object provider mechanism.\n |
|
1197 The details of the network are as follows.\n |
|
1198 0. Node A - Contains Triangle A.\n |
|
1199 1. Node B - Contains Square B.\n |
|
1200 2. Node C - Contains Triangle C.\n |
|
1201 3. Node D - Contains no component objects.\n |
|
1202 4. Node E - Contains Triangle E and Octogen E as component objects.\n |
|
1203 5. Node F - Contains Square F.\n |
|
1204 6. Node G - Contains Triangle G.\n |
|
1205 Parent-child relationships are set using SetMopParent at each node.\n |
|
1206 Adds the pointers to above six object providers to iArray.\n |
|
1207 Component objects are retrieved using GetMopObject() at every node.\n |
|
1208 If the node does not have an object of particular type a search is made |
|
1209 at the parent object provider also.\n |
|
1210 These pointers are verified.\n |
|
1211 |
|
1212 @SYMTestExpectedResults The pointers of component objects obtained should match |
|
1213 with the original objects.\n |
|
1214 |
|
1215 @SYMTestType : CIT |
|
1216 */ |
|
1217 void CCone3TestAppUi::DoMopNoChainingConstTestsL() |
|
1218 { |
|
1219 __UHEAP_MARK; |
|
1220 |
|
1221 TPtrC nodeA(_L("A")); |
|
1222 TPtrC nodeB(_L("B")); |
|
1223 TPtrC nodeC(_L("C")); |
|
1224 TPtrC nodeE(_L("E")); |
|
1225 TPtrC nodeF(_L("F")); |
|
1226 TPtrC nodeG(_L("G")); |
|
1227 |
|
1228 CObjectNodeConst* node = new (ELeave) CObjectNodeConst(); |
|
1229 CleanupStack::PushL(node); |
|
1230 |
|
1231 const CTriangleObj* triangleA = new(ELeave) CTriangleObj(); |
|
1232 (const_cast<CTriangleObj*>(triangleA))->SetParentClassName(nodeA); |
|
1233 CleanupStack::PushL(const_cast<CTriangleObj*>(triangleA)); |
|
1234 |
|
1235 const CSquareObj* squareB = new(ELeave) CSquareObj(); |
|
1236 (const_cast<CSquareObj*>(squareB))->SetParentClassName(nodeB); |
|
1237 CleanupStack::PushL(const_cast<CSquareObj*>(squareB)); |
|
1238 |
|
1239 const CTriangleObj* triangleC = new(ELeave) CTriangleObj(); |
|
1240 (const_cast<CTriangleObj*>(triangleC))->SetParentClassName(nodeC); |
|
1241 CleanupStack::PushL(const_cast<CTriangleObj*>(triangleC)); |
|
1242 |
|
1243 const CTriangleObj* triangleE = new(ELeave) CTriangleObj(); |
|
1244 (const_cast<CTriangleObj*>(triangleE))->SetParentClassName(nodeE); |
|
1245 CleanupStack::PushL(const_cast<CTriangleObj*>(triangleE)); |
|
1246 |
|
1247 |
|
1248 const COctagonObj* octagonE = new(ELeave) COctagonObj() ; |
|
1249 (const_cast<COctagonObj*>(octagonE))->SetParentClassName(nodeE); |
|
1250 CleanupStack::PushL(const_cast<COctagonObj*>(octagonE)); |
|
1251 |
|
1252 const CSquareObj* squareF = new(ELeave) CSquareObj(); |
|
1253 (const_cast<CSquareObj*>(squareF))->SetParentClassName(nodeF); |
|
1254 CleanupStack::PushL(const_cast<CSquareObj*>(squareF)); |
|
1255 |
|
1256 const CTriangleObj* triangleG = new(ELeave) CTriangleObj(); |
|
1257 (const_cast<CTriangleObj*>(triangleG))->SetParentClassName(nodeG); |
|
1258 |
|
1259 CleanupStack::Pop(6); |
|
1260 |
|
1261 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleA, NULL, NULL)); |
|
1262 node->iArray.Append(new (ELeave) CObjectNodeConst(NULL, squareB, NULL)); |
|
1263 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleE, NULL, octagonE)); |
|
1264 |
|
1265 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleC, NULL, NULL)); |
|
1266 node->iArray.Append(new (ELeave) CObjectNodeConst(NULL, NULL, NULL)); |
|
1267 |
|
1268 node->iArray.Append(new (ELeave) CObjectNodeConst(NULL, squareF, NULL)); |
|
1269 node->iArray.Append(new (ELeave) CObjectNodeConst(triangleG, NULL, NULL)); |
|
1270 |
|
1271 node->iArray[1]->SetMopParent(node->iArray[0]); |
|
1272 node->iArray[2]->SetMopParent(node->iArray[0]); |
|
1273 |
|
1274 node->iArray[3]->SetMopParent(node->iArray[1]); |
|
1275 node->iArray[4]->SetMopParent(node->iArray[1]); |
|
1276 |
|
1277 node->iArray[5]->SetMopParent(node->iArray[2]); |
|
1278 node->iArray[6]->SetMopParent(node->iArray[2]); |
|
1279 |
|
1280 //Node0 - A |
|
1281 const CTriangleObj* getTriangle = NULL; |
|
1282 const CSquareObj* getSquare = NULL; |
|
1283 const COctagonObj* getOctagon = NULL; |
|
1284 INFO_PRINTF1(_L("Testing Node A No Chaining Const")); |
|
1285 getTriangle = node->iArray[0]->GetTriangleObjNoChaining(); |
|
1286 getSquare = node->iArray[0]->GetSquareObjNoChaining(); |
|
1287 getOctagon = node->iArray[0]->GetOctagonObjNoChaining(); |
|
1288 |
|
1289 TEST(getTriangle != NULL); |
|
1290 TEST(getTriangle->GetParentClassName().Compare(nodeA) == KErrNone); |
|
1291 TEST(getSquare == NULL); |
|
1292 TEST(getOctagon == NULL); |
|
1293 |
|
1294 INFO_PRINTF1(_L("Testing Node B No Chaining Const")); |
|
1295 //Node1 - B |
|
1296 getTriangle = NULL; |
|
1297 getSquare = NULL; |
|
1298 getOctagon = NULL; |
|
1299 |
|
1300 getTriangle = node->iArray[1]->GetTriangleObjNoChaining(); |
|
1301 getSquare = node->iArray[1]->GetSquareObjNoChaining(); |
|
1302 getOctagon = node->iArray[1]->GetOctagonObjNoChaining(); |
|
1303 |
|
1304 TEST(getSquare != NULL); |
|
1305 TEST(getSquare->GetParentClassName().Compare(nodeB) == KErrNone); |
|
1306 TEST(getTriangle == NULL); |
|
1307 TEST(getOctagon == NULL); |
|
1308 |
|
1309 INFO_PRINTF1(_L("Testing Node C No Chaining Const")); |
|
1310 //Node3 - C |
|
1311 getTriangle = NULL; |
|
1312 getSquare = NULL; |
|
1313 getOctagon = NULL; |
|
1314 |
|
1315 getTriangle = node->iArray[3]->GetTriangleObjNoChaining(); |
|
1316 getSquare = node->iArray[3]->GetSquareObjNoChaining(); |
|
1317 getOctagon = node->iArray[3]->GetOctagonObjNoChaining(); |
|
1318 |
|
1319 TEST(getTriangle != NULL); |
|
1320 TEST(getTriangle->GetParentClassName().Compare(nodeC) == KErrNone); |
|
1321 TEST(getSquare == NULL); |
|
1322 TEST(getOctagon == NULL); |
|
1323 |
|
1324 INFO_PRINTF1(_L("Testing Node D No Chaining Const")); |
|
1325 //Node4 - D |
|
1326 getTriangle = NULL; |
|
1327 getSquare = NULL; |
|
1328 getOctagon = NULL; |
|
1329 |
|
1330 getTriangle = node->iArray[4]->GetTriangleObjNoChaining(); |
|
1331 getSquare = node->iArray[4]->GetSquareObjNoChaining(); |
|
1332 getOctagon = node->iArray[4]->GetOctagonObjNoChaining(); |
|
1333 |
|
1334 TEST(getSquare == NULL); |
|
1335 TEST(getTriangle == NULL); |
|
1336 TEST(getOctagon == NULL); |
|
1337 |
|
1338 INFO_PRINTF1(_L("Testing Node E No Chaining Const")); |
|
1339 //Node2 - E |
|
1340 getTriangle = NULL; |
|
1341 getSquare = NULL; |
|
1342 getOctagon = NULL; |
|
1343 |
|
1344 getTriangle = node->iArray[2]->GetTriangleObjNoChaining(); |
|
1345 getSquare = node->iArray[2]->GetSquareObjNoChaining(); |
|
1346 getOctagon = node->iArray[2]->GetOctagonObjNoChaining(); |
|
1347 |
|
1348 TEST(getTriangle != NULL); |
|
1349 TEST(getTriangle->GetParentClassName().Compare(nodeE) == KErrNone); |
|
1350 TEST(getOctagon != NULL); |
|
1351 TEST(getOctagon->GetParentClassName().Compare(nodeE) == KErrNone); |
|
1352 TEST(getSquare == NULL); |
|
1353 |
|
1354 INFO_PRINTF1(_L("Testing Node F No Chaining Const")); |
|
1355 //Node5 - F |
|
1356 getTriangle = NULL; |
|
1357 getSquare = NULL; |
|
1358 getOctagon = NULL; |
|
1359 |
|
1360 getTriangle = node->iArray[5]->GetTriangleObjNoChaining(); |
|
1361 getSquare = node->iArray[5]->GetSquareObjNoChaining(); |
|
1362 getOctagon = node->iArray[5]->GetOctagonObjNoChaining(); |
|
1363 |
|
1364 TEST(getSquare != NULL); |
|
1365 TEST(getSquare->GetParentClassName().Compare(nodeF) == KErrNone); |
|
1366 TEST(getTriangle == NULL); |
|
1367 TEST(getOctagon == NULL); |
|
1368 |
|
1369 INFO_PRINTF1(_L("Testing Node G No Chaining Const")); |
|
1370 //Node6 - G |
|
1371 getTriangle = NULL; |
|
1372 getSquare = NULL; |
|
1373 getOctagon = NULL; |
|
1374 |
|
1375 getTriangle = node->iArray[6]->GetTriangleObjNoChaining(); |
|
1376 getSquare = node->iArray[6]->GetSquareObjNoChaining(); |
|
1377 getOctagon = node->iArray[6]->GetOctagonObjNoChaining(); |
|
1378 |
|
1379 TEST(getTriangle != NULL); |
|
1380 TEST(getTriangle->GetParentClassName().Compare(nodeG) == KErrNone); |
|
1381 TEST(getOctagon == NULL); |
|
1382 TEST(getSquare == NULL); |
|
1383 |
|
1384 CleanupStack::PopAndDestroy(node); |
|
1385 |
|
1386 __UHEAP_MARKEND; |
|
1387 |
|
1388 } |
|
1389 |
|
1390 /** |
|
1391 @SYMTestCaseID UIF-CONE-DoStateObserverTestL |
|
1392 |
|
1393 @SYMCR CR1251 |
|
1394 |
|
1395 @SYMTestCaseDesc Tests calling MakeVisible or SetDimmed calls the new Mop interface |
|
1396 when only the control itself provides the relevant Mop interface |
|
1397 |
|
1398 @SYMTestPriority High |
|
1399 |
|
1400 @SYMTestStatus Implemented |
|
1401 |
|
1402 @SYMTestActions Makes many calls to MakeVisible or SetDimmed in different situations |
|
1403 and checks if the new Mop interface is called or not on each time. |
|
1404 |
|
1405 @SYMTestExpectedResults The new interface is called if there is a change in the controls state |
|
1406 |
|
1407 @SYMTestType : Unit Test |
|
1408 */ |
|
1409 void CCone3TestAppUi::DoStateObserverTestL() |
|
1410 { |
|
1411 //Creating the first font allocates memory that is never deleted so must do this outside heap checks |
|
1412 CFbsFont* font=iCoeEnv->CreateScreenFontL(CStateObserverControl::iFontSpec); |
|
1413 iCoeEnv->ReleaseScreenFont(font); |
|
1414 __UHEAP_MARK; |
|
1415 CStateObserverControl* stateObCnt=new(ELeave) CStateObserverControl(); |
|
1416 CleanupStack::PushL(stateObCnt); |
|
1417 stateObCnt->ConstructL(); |
|
1418 stateObCnt->SetReturnObserver(CStateObserverControl::EObserver); |
|
1419 stateObCnt->SetRecievers(ETrue,EFalse); |
|
1420 TInt failAt=stateObCnt->DoTest(); |
|
1421 CleanupStack::PopAndDestroy(stateObCnt); |
|
1422 if (failAt>0) |
|
1423 { |
|
1424 TEST(EFalse); |
|
1425 _LIT(KLog,"StateObserverTest failed on subtest: %d"); |
|
1426 INFO_PRINTF2(KLog,failAt); |
|
1427 } |
|
1428 __UHEAP_MARKEND; |
|
1429 } |
|
1430 |
|
1431 /** |
|
1432 Auxiliary Function for all Test Cases.\n |
|
1433 |
|
1434 The method is an override from CTestCoeAppUi.\n |
|
1435 This function is called asynchronously by RunL function of the |
|
1436 AutotestManager after previous test case is executed.\n |
|
1437 Calls the following functions one by one.\n |
|
1438 1. DoTestsL().\n |
|
1439 2. DoMopConstTestsL().\n |
|
1440 3. DoMopNoChainingTestsL().\n |
|
1441 4. DoMopNoChainingConstTestsL().\n |
|
1442 5. DoStateObserverTestL(). |
|
1443 */ |
|
1444 void CCone3TestAppUi::RunTestStepL(TInt aStepNum) |
|
1445 { |
|
1446 _LIT(KTest1,"Tests Mop interface returns right object"); |
|
1447 _LIT(KTest2,"Tests MCoeControlStateObserver is called at the right times"); |
|
1448 switch(aStepNum) |
|
1449 { |
|
1450 case 1: |
|
1451 SetTestStepID(_L("UIF-TCone3Step-DoMopNoChainingConstTestsL")); |
|
1452 INFO_PRINTF1(KTest1); |
|
1453 DoTestsL(); |
|
1454 DoMopConstTestsL(); |
|
1455 DoMopNoChainingTestsL(); |
|
1456 DoMopNoChainingConstTestsL(); |
|
1457 RecordTestResultL(); |
|
1458 break; |
|
1459 case 2: |
|
1460 SetTestStepID(_L("UIF-CONE-DoStateObserverTestL")); |
|
1461 INFO_PRINTF1(KTest2); |
|
1462 DoStateObserverTestL(); |
|
1463 RecordTestResultL(); |
|
1464 CloseTMSGraphicsStep(); |
|
1465 break; |
|
1466 default: |
|
1467 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
1468 break; |
|
1469 } |
|
1470 } |
|
1471 |
|
1472 /** |
|
1473 Completes the construction of the Control Environment(CCoeEnv object).\n |
|
1474 Instantiates the CCone3TestAppUi class which serves as a AppUi class.\n |
|
1475 Sets the CCone3TestAppUi object as the application's user interface object.\n |
|
1476 Invokes the second phase constructor of the application's UI.\n |
|
1477 */ |
|
1478 void CTCone3Step::ConstructCone3AppL(CCoeEnv* aCoe) |
|
1479 { // runs inside a TRAP harness |
|
1480 aCoe->ConstructL(); |
|
1481 CCone3TestAppUi* appUi=new(ELeave) CCone3TestAppUi(this); |
|
1482 aCoe->SetAppUi(appUi); |
|
1483 appUi->ConstructL(); |
|
1484 } |
|
1485 /** |
|
1486 Constructor for CTCone3Step class.\n |
|
1487 Sets the test step name.\n |
|
1488 */ |
|
1489 CTCone3Step::CTCone3Step() |
|
1490 { |
|
1491 SetTestStepName(KTCone3Step); |
|
1492 } |
|
1493 |
|
1494 /** Destructor for CTCone3Step class.\n */ |
|
1495 |
|
1496 CTCone3Step::~CTCone3Step() |
|
1497 {} |
|
1498 |
|
1499 /** |
|
1500 Entry function for CTCone3 Test Step.\n |
|
1501 Sets up the control environment.\n |
|
1502 Constructs and Launches the CTCone3 Test application.\n |
|
1503 */ |
|
1504 TVerdict CTCone3Step::doTestStepL() |
|
1505 { |
|
1506 INFO_PRINTF1(_L("Test Started")); |
|
1507 CCoeEnv* coe=new(ELeave) CCoeEnv; |
|
1508 TRAPD(err,ConstructCone3AppL(coe)); |
|
1509 if (!err) |
|
1510 coe->ExecuteD(); |
|
1511 else |
|
1512 { |
|
1513 SetTestStepResult(EFail); |
|
1514 delete coe; |
|
1515 } |
|
1516 |
|
1517 INFO_PRINTF1(_L("Test Finished")); |
|
1518 return TestStepResult(); |
|
1519 } |
|
1520 |
|
1521 |