(Partial Update) Mark as not rendered if the node is transparent or culled
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-IntrusivePtr.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
20 #include <stdlib.h>
21
22 #include <iostream>
23
24 using namespace Dali;
25
26 namespace
27 {
28 const int REPEAT = 1000;
29
30 size_t g_creationCount             = 0;
31 size_t g_destructionCount          = 0;
32 size_t g_creationCountSubclass     = 0;
33 size_t g_destructionCountSubclass  = 0;
34 size_t g_creationCountUnrelated    = 0;
35 size_t g_destructionCountUnrelated = 0;
36
37 class Counted : public RefObject
38 {
39 public:
40   Counted()
41   {
42     ++g_creationCount;
43   }
44   ~Counted()
45   {
46     ++g_destructionCount;
47   }
48 };
49
50 class CountedSubclass : public Counted
51 {
52 public:
53   CountedSubclass()
54   {
55     ++g_creationCountSubclass;
56   }
57   ~CountedSubclass()
58   {
59     ++g_destructionCountSubclass;
60   }
61 };
62
63 class UnrelatedCounted : public RefObject
64 {
65 public:
66   UnrelatedCounted()
67   {
68     ++g_creationCountUnrelated;
69   }
70   ~UnrelatedCounted()
71   {
72     ++g_destructionCountUnrelated;
73   }
74 };
75
76 class TestObject : public RefObject
77 {
78 public:
79   TestObject()
80   : data(201)
81   {
82   }
83
84   TestObject(const TestObject& testObject)
85   : RefObject(testObject),
86     data(testObject.data)
87   {
88   }
89
90   TestObject& Assign(const TestObject& testObject)
91   {
92     RefObject::operator=(testObject);
93     data               = testObject.data;
94     return *this;
95   }
96
97   int data;
98 };
99
100 } // Anonymous namespace
101
102 /**
103  * Test that a default constructed pointer is null and harmless.
104  */
105 int UtcDaliIntrusivePtrIntrusivePtr(void)
106 {
107   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr()");
108
109   g_creationCount = g_destructionCount = 0;
110
111   IntrusivePtr<Counted> counted;
112   DALI_TEST_EQUALS(g_creationCount, 0u, TEST_LOCATION);
113   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
114   // Test the pointer is null
115   DALI_TEST_EQUALS(counted.Get(), (Counted*)0, TEST_LOCATION);
116   DALI_TEST_EQUALS(&(*counted), (Counted*)0, TEST_LOCATION);
117   // Check destruction of the null smart pointer does nothing:
118   counted = IntrusivePtr<Counted>();
119   DALI_TEST_EQUALS(g_creationCount, 0u, TEST_LOCATION);
120   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
121
122   END_TEST;
123 }
124
125 int UtcDaliIntrusivePtrIntrusivePtrTP(void)
126 {
127   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr(T*)");
128
129   g_creationCount = g_destructionCount = 0;
130
131   IntrusivePtr<Counted> counted(new Counted);
132   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
133   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
134   counted = 0;
135   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
136   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
137
138   END_TEST;
139 }
140
141 // Class is too simple for a negative case to be created: int UtcDaliIntrusiveIntrusivePtrTN(void)
142
143 int UtcDaliIntrusivePtrIntrusivePtrIntrusivePtrUP(void)
144 {
145   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr(IntrusivePtr<U> const &)");
146
147   g_creationCount = g_destructionCount = g_creationCountSubclass = g_destructionCountSubclass = 0;
148
149   IntrusivePtr<CountedSubclass> countedSubclass(new CountedSubclass);
150   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
151   DALI_TEST_EQUALS(g_creationCountSubclass, 1u, TEST_LOCATION);
152   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
153   DALI_TEST_EQUALS(g_destructionCountSubclass, 0u, TEST_LOCATION);
154
155   IntrusivePtr<Counted> counted(countedSubclass);
156   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
157
158   // Make loads more references:
159   std::vector<IntrusivePtr<Counted> > intrusivePtrs;
160   for(int i = 0; i < REPEAT; ++i)
161   {
162     intrusivePtrs.push_back(IntrusivePtr<Counted>(countedSubclass));
163   }
164   DALI_TEST_EQUALS(counted->ReferenceCount(), 2 + REPEAT, TEST_LOCATION);
165
166   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
167   DALI_TEST_EQUALS(g_creationCountSubclass, 1u, TEST_LOCATION);
168   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
169
170   END_TEST;
171 }
172
173 // The negative version of this test would fail at compile time:
174 // int UtcDaliIntrusivePtrIntrusivePtrIntrusivePtrUN(void)
175
176 int UtcDaliIntrusivePtrIntrusivePtrIntrusivePtrP(void)
177 {
178   tet_infoline("Testing Dali::IntrusivePtr::IntrusivePtr(IntrusivePtr const &)");
179
180   // Pass a pointer to a constructed second object:
181   // Pass a pointer to null:
182
183   g_creationCount = g_destructionCount = 0;
184
185   IntrusivePtr<Counted> counted(new Counted);
186   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
187   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
188   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
189
190   IntrusivePtr<Counted> counted2(counted);
191   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
192   DALI_TEST_EQUALS(counted.Get(), counted2.Get(), TEST_LOCATION);
193
194   // Make loads more references:
195   std::vector<IntrusivePtr<Counted> > intrusivePtrs;
196   for(int i = 0; i < REPEAT; ++i)
197   {
198     intrusivePtrs.push_back(IntrusivePtr<Counted>(counted));
199   }
200   DALI_TEST_EQUALS(counted->ReferenceCount(), 2 + REPEAT, TEST_LOCATION);
201
202   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
203   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
204
205   intrusivePtrs.clear();
206
207   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
208
209   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
210   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
211
212   counted.Reset();
213   DALI_TEST_EQUALS(counted2->ReferenceCount(), 1, TEST_LOCATION);
214   counted2.Reset();
215
216   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
217   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
218
219   END_TEST;
220 }
221
222 int UtcDaliIntrusivePtrGetP(void)
223 {
224   tet_infoline("Testing Dali::IntrusivePtr::Get()");
225
226   IntrusivePtr<Counted> counted(new Counted);
227   DALI_TEST_CHECK(counted.Get() != 0);
228   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
229   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
230
231   END_TEST;
232 }
233
234 int UtcDaliIntrusivePtrGetN(void)
235 {
236   tet_infoline("Testing Dali::IntrusivePtr::Get()");
237
238   g_creationCount = 0;
239
240   IntrusivePtr<Counted> counted(0);
241   DALI_TEST_CHECK(counted.Get() == 0);
242   DALI_TEST_EQUALS(g_creationCount, 0u, TEST_LOCATION);
243
244   END_TEST;
245 }
246
247 int UtcDaliIntrusivePtrArrowOperatorP(void)
248 {
249   tet_infoline("Positive Test for Dali::IntrusivePtr::operator->()");
250
251   IntrusivePtr<Counted> counted(new Counted);
252   DALI_TEST_CHECK((counted.operator->()) != 0);
253   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
254
255   END_TEST;
256 }
257
258 int UtcDaliIntrusivePtrArrowOperatorN(void)
259 {
260   tet_infoline("Negative Test for Dali::IntrusivePtr::operator->()");
261
262   IntrusivePtr<Counted> counted;
263   DALI_TEST_CHECK((counted.operator->()) == 0);
264
265   END_TEST;
266 }
267
268 int UtcDaliIntrusivePtrIndirectionOperatorP(void)
269 {
270   tet_infoline("Positive Test for Dali::IntrusivePtr::operator*()");
271
272   IntrusivePtr<Counted> counted(new Counted);
273   DALI_TEST_CHECK(&(counted.operator*()) != 0);
274   DALI_TEST_EQUALS((*counted).ReferenceCount(), 1, TEST_LOCATION);
275
276   END_TEST;
277 }
278
279 int UtcDaliIntrusivePtrIndirectionOperatorN(void)
280 {
281   tet_infoline("Negative Test for Dali::IntrusivePtr::operator*()");
282
283   IntrusivePtr<Counted> counted;
284   DALI_TEST_CHECK(&(counted.operator*()) == 0);
285
286   END_TEST;
287 }
288
289 int UtcDaliIntrusivePtrResetP(void)
290 {
291   tet_infoline("Positive Test for Dali::IntrusivePtr::Reset()");
292
293   IntrusivePtr<Counted> counted(new Counted);
294   DALI_TEST_CHECK(counted.Get() != 0);
295   counted.Reset();
296   DALI_TEST_CHECK(counted.Get() == 0);
297
298   END_TEST;
299 }
300
301 int UtcDaliIntrusivePtrResetN(void)
302 {
303   tet_infoline("Negative Test for Dali::IntrusivePtr::Reset()");
304
305   IntrusivePtr<Counted> counted;
306   Counted*              firstGet = counted.Get();
307   counted.Reset();
308   DALI_TEST_EQUALS(counted.Get(), firstGet, TEST_LOCATION);
309
310   END_TEST;
311 }
312
313 int UtcDaliIntrusivePtrResetTP(void)
314 {
315   tet_infoline("Positive Test for Dali::IntrusivePtr::Reset(T*)");
316
317   g_creationCount = g_destructionCount = 0;
318
319   IntrusivePtr<Counted> counted(new Counted);
320
321   IntrusivePtr<Counted> counted2(new Counted);
322
323   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
324   DALI_TEST_EQUALS(counted2->ReferenceCount(), 1, TEST_LOCATION);
325
326   counted.Reset(counted2.Get());
327
328   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
329   DALI_TEST_EQUALS(counted2->ReferenceCount(), 2, TEST_LOCATION);
330
331   DALI_TEST_EQUALS(counted.Get(), counted2.Get(), TEST_LOCATION);
332
333   DALI_TEST_EQUALS(g_creationCount, 2u, TEST_LOCATION);
334   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
335
336   counted2.Reset((Counted*)0);
337   counted.Reset(counted2.Get());
338   DALI_TEST_EQUALS(g_destructionCount, 2u, TEST_LOCATION);
339
340   // Check that reseting nulls is harmless:
341   counted2.Reset(counted.Get());
342   counted.Reset(counted2.Get());
343
344   DALI_TEST_EQUALS(g_destructionCount, 2u, TEST_LOCATION);
345
346   END_TEST;
347 }
348
349 int UtcDaliIntrusivePtrResetTN(void)
350 {
351   tet_infoline("Negative Test for Dali::IntrusivePtr::Reset(T*)");
352
353   g_creationCount = g_destructionCount = 0;
354
355   IntrusivePtr<Counted> counted(new Counted);
356
357   counted.Reset((Counted*)0);
358
359   DALI_TEST_EQUALS(counted.Get(), (Counted*)0, TEST_LOCATION);
360   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
361   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
362
363   END_TEST;
364 }
365
366 int UtcDaliIntrusivePtrOperatorBooleanTypeP(void)
367 {
368   tet_infoline("Positive Test for Dali::IntrusivePtr::operator Booleantype()");
369
370   IntrusivePtr<Counted> counted(new Counted);
371   DALI_TEST_CHECK(counted.operator BooleanType() != 0);
372   DALI_TEST_CHECK(counted);
373
374   typedef void (IntrusivePtr<Counted>::*BoolIdiomFunc)() const;
375   BoolIdiomFunc func = static_cast<BoolIdiomFunc>(counted.operator BooleanType());
376   ((counted).*func)(); // purely for test coverage
377
378   counted.Reset();
379   DALI_TEST_CHECK(counted.operator BooleanType() == 0);
380
381   END_TEST;
382 }
383
384 int UtcDaliIntrusivePtrOperatorBooleanTypeN(void)
385 {
386   tet_infoline("Negative Test for Dali::IntrusivePtr::operator Booleantype()");
387
388   IntrusivePtr<Counted> counted;
389   DALI_TEST_CHECK(counted.operator BooleanType() == 0);
390   DALI_TEST_CHECK(!counted);
391   END_TEST;
392 }
393
394 /** Equality of two different types*/
395 int UtcDaliIntrusivePtrOperatorEqualTU(void)
396 {
397   tet_infoline("Test for Dali::IntrusivePtr::operator ==(T, U)");
398
399   IntrusivePtr<Counted>         counted1(new Counted);
400   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
401   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
402   IntrusivePtr<Counted>         counted2(countedSubclass2);
403
404   DALI_TEST_EQUALS(operator==(counted1, countedSubclass1), false, TEST_LOCATION);
405   DALI_TEST_EQUALS(operator==(counted2, countedSubclass2), true, TEST_LOCATION);
406   END_TEST;
407 }
408
409 /** Inequality of two different types*/
410 int UtcDaliIntrusivePtrOperatorNotEqualTU(void)
411 {
412   tet_infoline("Test for Dali::IntrusivePtr::operator !=(T, U)");
413
414   IntrusivePtr<Counted>         counted1(new Counted);
415   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
416   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
417   IntrusivePtr<Counted>         counted2(countedSubclass2);
418
419   DALI_TEST_EQUALS(operator!=(counted1, countedSubclass1), true, TEST_LOCATION);
420   DALI_TEST_EQUALS(operator!=(counted2, countedSubclass2), false, TEST_LOCATION);
421   END_TEST;
422 }
423
424 /** Equality of two different types where right hand side is a raw pointer */
425 int UtcDaliIntrusivePtrOperatorEqualRightPointerTU(void)
426 {
427   tet_infoline("Test for Dali::IntrusivePtr::operator ==(T, U*)");
428
429   IntrusivePtr<Counted>         counted1(new Counted);
430   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
431   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
432   IntrusivePtr<Counted>         counted2(countedSubclass2);
433
434   DALI_TEST_EQUALS(operator==(counted1, countedSubclass1.Get()), false, TEST_LOCATION);
435   DALI_TEST_EQUALS(operator==(counted2, countedSubclass2.Get()), true, TEST_LOCATION);
436   END_TEST;
437 }
438
439 /** Inequality of two different types where the right hand side is a raw pointer */
440 int UtcDaliIntrusivePtrOperatorNotEqualRightPointerTU(void)
441 {
442   tet_infoline("Test for Dali::IntrusivePtr::operator !=(T, U*)");
443
444   IntrusivePtr<Counted>         counted1(new Counted);
445   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
446   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
447   IntrusivePtr<Counted>         counted2(countedSubclass2);
448
449   DALI_TEST_EQUALS(operator!=(counted1, countedSubclass1.Get()), true, TEST_LOCATION);
450   DALI_TEST_EQUALS(operator!=(counted2, countedSubclass2.Get()), false, TEST_LOCATION);
451   END_TEST;
452 }
453
454 /** Equality of two different types where left hand side is a raw pointer */
455 int UtcDaliIntrusivePtrOperatorEqualLeftPointerTU(void)
456 {
457   tet_infoline("Test for Dali::IntrusivePtr::operator ==(T*, U)");
458
459   IntrusivePtr<Counted>         counted1(new Counted);
460   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
461   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
462   IntrusivePtr<Counted>         counted2(countedSubclass2);
463
464   DALI_TEST_EQUALS(operator==(counted1.Get(), countedSubclass1), false, TEST_LOCATION);
465   DALI_TEST_EQUALS(operator==(counted2.Get(), countedSubclass2), true, TEST_LOCATION);
466   END_TEST;
467 }
468
469 /** Inequality of two different types where the left hand side is a raw pointer */
470 int UtcDaliIntrusivePtrOperatorNotEqualLeftPointerTU(void)
471 {
472   tet_infoline("Test for Dali::IntrusivePtr::operator !=(T*, U)");
473
474   IntrusivePtr<Counted>         counted1(new Counted);
475   IntrusivePtr<CountedSubclass> countedSubclass1(new CountedSubclass);
476   IntrusivePtr<CountedSubclass> countedSubclass2(new CountedSubclass);
477   IntrusivePtr<Counted>         counted2(countedSubclass2);
478
479   DALI_TEST_EQUALS(operator!=(counted1.Get(), countedSubclass1), true, TEST_LOCATION);
480   DALI_TEST_EQUALS(operator!=(counted2.Get(), countedSubclass2), false, TEST_LOCATION);
481   END_TEST;
482 }
483
484 int UtcDaliRefObjectCopyConstructor(void)
485 {
486   tet_infoline("Test for Dali::RefObject(const RefObject&)");
487
488   {
489     IntrusivePtr<TestObject> testPtr(new TestObject);
490     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
491
492     const TestObject& testObject = *testPtr.Get();
493     {
494       IntrusivePtr<TestObject> testPtr2(new TestObject(testObject));
495       DALI_TEST_EQUALS(testPtr2->ReferenceCount(), 1, TEST_LOCATION);
496     }
497     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
498   }
499   END_TEST;
500 }
501
502 int UtcDaliRefObjectAssignmentOperator(void)
503 {
504   tet_infoline("Test for Dali::RefObject::operator=(const RefObject&)");
505
506   {
507     IntrusivePtr<TestObject> testPtr(new TestObject);
508     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
509
510     const TestObject& testObject = *testPtr.Get();
511     {
512       IntrusivePtr<TestObject> testPtr2(new TestObject());
513       testPtr->data                     = 33;
514       IntrusivePtr<TestObject> testPtr3 = testPtr2;
515       DALI_TEST_EQUALS(testPtr2->ReferenceCount(), 2, TEST_LOCATION);
516       DALI_TEST_EQUALS(testPtr2->data, 201, TEST_LOCATION);
517
518       TestObject& testObject2 = *testPtr2.Get();
519       testObject2             = testObject;
520
521       DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
522       DALI_TEST_EQUALS(testPtr2->ReferenceCount(), 2, TEST_LOCATION);
523     }
524     DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
525   }
526
527   END_TEST;
528 }
529
530 int UtcDaliRefObjectAssignmentOperatorToNull(void)
531 {
532   tet_infoline("Testing Dali::IntrusivePtr = nullptr");
533
534   g_creationCount = g_destructionCount = 0;
535
536   IntrusivePtr<Counted> counted(new Counted);
537
538   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
539   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
540
541   IntrusivePtr<Counted> counted2 = counted;
542   DALI_TEST_EQUALS(g_creationCount, 1u, TEST_LOCATION);
543   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
544
545   DALI_TEST_EQUALS(counted->ReferenceCount(), 2, TEST_LOCATION);
546
547   counted2 = nullptr;
548   DALI_TEST_EQUALS(g_destructionCount, 0u, TEST_LOCATION);
549   DALI_TEST_EQUALS(counted->ReferenceCount(), 1, TEST_LOCATION);
550
551   counted = nullptr;
552   DALI_TEST_EQUALS(g_destructionCount, 1u, TEST_LOCATION);
553
554   END_TEST;
555 }
556
557 int UtcDaliIntrusivePtrMoveConstructor(void)
558 {
559   IntrusivePtr<TestObject> testPtr(new TestObject);
560   DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
561   DALI_TEST_EQUALS(testPtr->data, 201, TEST_LOCATION);
562
563   IntrusivePtr<TestObject> movePtr = std::move(testPtr);
564   DALI_TEST_EQUALS(movePtr->ReferenceCount(), 1, TEST_LOCATION);
565   DALI_TEST_EQUALS(movePtr->data, 201, TEST_LOCATION);
566   DALI_TEST_CHECK(!testPtr);
567
568   IntrusivePtr<TestObject> anotherTestPtr(new TestObject);
569   DALI_TEST_EQUALS(anotherTestPtr->ReferenceCount(), 1, TEST_LOCATION);
570   DALI_TEST_EQUALS(anotherTestPtr->data, 201, TEST_LOCATION);
571   IntrusivePtr<TestObject> anotherMovePtr = std::move(anotherTestPtr);
572   DALI_TEST_EQUALS(anotherMovePtr->ReferenceCount(), 1, TEST_LOCATION);
573   DALI_TEST_EQUALS(anotherMovePtr->data, 201, TEST_LOCATION);
574   DALI_TEST_CHECK(!anotherTestPtr.Get());
575
576   IntrusivePtr<CountedSubclass> countedSubclass(new CountedSubclass);
577   DALI_TEST_EQUALS(countedSubclass->ReferenceCount(), 1, TEST_LOCATION);
578
579   IntrusivePtr<Counted> countedMovePtr = std::move(countedSubclass);
580   DALI_TEST_EQUALS(countedMovePtr->ReferenceCount(), 1, TEST_LOCATION);
581   DALI_TEST_CHECK(!countedSubclass);
582
583   END_TEST;
584 }
585
586 int UtcDaliIntrusivePtrMoveAssignment(void)
587 {
588   IntrusivePtr<TestObject> testPtr(new TestObject);
589   DALI_TEST_EQUALS(testPtr->ReferenceCount(), 1, TEST_LOCATION);
590   DALI_TEST_EQUALS(testPtr->data, 201, TEST_LOCATION);
591
592   IntrusivePtr<TestObject> secondPtr(testPtr);
593   DALI_TEST_EQUALS(testPtr->ReferenceCount(), 2, TEST_LOCATION);
594
595   IntrusivePtr<TestObject> thirdPtr;
596   testPtr = std::move(thirdPtr);
597   DALI_TEST_EQUALS(secondPtr->ReferenceCount(), 1, TEST_LOCATION);
598   DALI_TEST_EQUALS(secondPtr->data, 201, TEST_LOCATION);
599   DALI_TEST_CHECK(!testPtr.Get());
600
601   IntrusivePtr<TestObject> fourthPtr(new TestObject);
602   testPtr = std::move(fourthPtr);
603   DALI_TEST_CHECK(!fourthPtr.Get());
604
605   IntrusivePtr<CountedSubclass> countedSubclassPtr(new CountedSubclass);
606   DALI_TEST_EQUALS(countedSubclassPtr->ReferenceCount(), 1, TEST_LOCATION);
607
608   IntrusivePtr<Counted> countedMovePtr;
609   countedMovePtr = std::move(countedSubclassPtr);
610   DALI_TEST_EQUALS(countedMovePtr->ReferenceCount(), 1, TEST_LOCATION);
611   DALI_TEST_CHECK(!countedSubclassPtr);
612
613   END_TEST;
614 }