Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-ImageActor.cpp
1 /*
2  * Copyright (c) 2014 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 <iostream>
19 #include <stdlib.h>
20 #include <dali/public-api/dali-core.h>
21 #include "dali-test-suite-utils/dali-test-suite-utils.h"
22
23 using namespace Dali;
24
25 static const char* TestImageFilename = "icon_wrt.png";
26
27 void image_actor_test_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void image_actor_test_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37
38 int UtcDaliImageActorConstructorVoid(void)
39 {
40   TestApplication application;
41   tet_infoline("Testing Dali::ImageActor::ImageActor()");
42
43   ImageActor actor;
44
45   DALI_TEST_CHECK(!actor);
46   END_TEST;
47 }
48
49 int UtcDaliImageActorDestructor(void)
50 {
51   TestApplication application;
52
53   ImageActor* actor = new ImageActor();
54   delete actor;
55
56   DALI_TEST_CHECK( true );
57   END_TEST;
58 }
59
60 int UtcDaliImageActorNew01(void)
61 {
62   TestApplication application;
63   tet_infoline("Positive test for Dali::ImageActor::New()");
64
65   Image image = ResourceImage::New(TestImageFilename);
66   ImageActor actor = ImageActor::New(image);
67   Stage::GetCurrent().Add(actor);
68
69   application.SendNotification();
70   application.Render();
71   application.Render();
72   application.SendNotification();
73
74   DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc));
75
76   DALI_TEST_CHECK(actor);
77   END_TEST;
78 }
79
80 int UtcDaliImageActorNew02(void)
81 {
82   TestApplication application;
83   tet_infoline("Negative test for Dali::ImageActor::New()");
84
85   Image image = ResourceImage::New("hopefully-this-image-file-does-not-exist");
86   ImageActor actor = ImageActor::New(image);
87
88   DALI_TEST_CHECK(actor);
89   END_TEST;
90 }
91
92 int UtcDaliImageActorDownCast(void)
93 {
94   TestApplication application;
95   tet_infoline("Testing Dali::ImageActor::DownCast()");
96
97   Image image = ResourceImage::New("IncorrectImageName");
98   ImageActor actor1 = ImageActor::New(image);
99   Actor anActor = Actor::New();
100   anActor.Add(actor1);
101
102   Actor child = anActor.GetChildAt(0);
103   ImageActor imageActor = DownCast< ImageActor >(child);
104
105   DALI_TEST_CHECK(imageActor);
106   END_TEST;
107 }
108
109 int UtcDaliImageActorDownCast2(void)
110 {
111   TestApplication application;
112   tet_infoline("Testing Dali::ImageActor::DownCast()");
113
114   Actor actor1 = Actor::New();
115   Actor anActor = Actor::New();
116   anActor.Add(actor1);
117
118   Actor child = anActor.GetChildAt(0);
119   ImageActor imageActor = ImageActor::DownCast(child);
120   DALI_TEST_CHECK(!imageActor);
121
122   Actor unInitialzedActor;
123   imageActor = ImageActor::DownCast( unInitialzedActor );
124   DALI_TEST_CHECK(!imageActor);
125   END_TEST;
126 }
127
128 int UtcDaliImageActor9Patch(void)
129 {
130   TestApplication application;
131   tet_infoline("Positive test for Dali::ImageActor:: 9 patch api");
132
133   Image image = ResourceImage::New(TestImageFilename);
134   ImageActor actor = ImageActor::New(image);
135
136   actor.SetStyle(ImageActor::STYLE_NINE_PATCH);
137   Vector4 border(0.1,0.2,0.3,0.4);
138   actor.SetNinePatchBorder(border);
139
140   DALI_TEST_EQUALS( 0.1f, actor.GetNinePatchBorder().x, TEST_LOCATION );
141   DALI_TEST_EQUALS( 0.2f, actor.GetNinePatchBorder().y, TEST_LOCATION );
142   DALI_TEST_EQUALS( 0.3f, actor.GetNinePatchBorder().z, TEST_LOCATION );
143   DALI_TEST_EQUALS( 0.4f, actor.GetNinePatchBorder().w, TEST_LOCATION );
144   END_TEST;
145 }
146
147 int UtcDaliImageActorPixelArea(void)
148 {
149   TestApplication application;
150   tet_infoline("Positive test for Dali::ImageActor::UtcDaliImageActorPixelArea");
151
152   BufferImage img = BufferImage::New( 10, 10 );
153   ImageActor actor = ImageActor::New( img );
154
155   DALI_TEST_CHECK( actor.IsPixelAreaSet() == false );
156
157   ImageActor::PixelArea area( 1, 2, 3, 4 );
158   actor.SetPixelArea( area );
159
160   DALI_TEST_CHECK( actor.IsPixelAreaSet() == true );
161
162   DALI_TEST_EQUALS( 1, actor.GetPixelArea().x, TEST_LOCATION );
163   DALI_TEST_EQUALS( 2, actor.GetPixelArea().y, TEST_LOCATION );
164   DALI_TEST_EQUALS( 3, actor.GetPixelArea().width, TEST_LOCATION );
165   DALI_TEST_EQUALS( 4, actor.GetPixelArea().height, TEST_LOCATION );
166
167   ImageActor actor2 = ImageActor::New( img, ImageActor::PixelArea( 5, 6, 7, 8 ) );
168   DALI_TEST_CHECK( actor2.IsPixelAreaSet() == true );
169
170   DALI_TEST_EQUALS( 5, actor2.GetPixelArea().x, TEST_LOCATION );
171   DALI_TEST_EQUALS( 6, actor2.GetPixelArea().y, TEST_LOCATION );
172   DALI_TEST_EQUALS( 7, actor2.GetPixelArea().width, TEST_LOCATION );
173   DALI_TEST_EQUALS( 8, actor2.GetPixelArea().height, TEST_LOCATION );
174   END_TEST;
175 }
176
177 // Set a size that is too large on an Image with a shader that requires grid
178 int UtcDaliImageActorSetSize01(void)
179 {
180   TestApplication application;
181
182   BufferImage img = BufferImage::New( 1,1 );
183   ImageActor actor = ImageActor::New( img );
184   actor.SetRelayoutEnabled( false );
185
186   ShaderEffect effect = ShaderEffect::New( " ", " ", GEOMETRY_TYPE_IMAGE, ShaderEffect::HINT_GRID );
187   actor.SetShaderEffect( effect );
188
189   const float INVALID_SIZE = float(1u<<31);
190   Vector3 vector( INVALID_SIZE, INVALID_SIZE, INVALID_SIZE );
191
192   DALI_TEST_CHECK(vector != actor.GetCurrentSize());
193
194   actor.SetSize(vector);
195   Stage::GetCurrent().Add(actor);
196
197   // flush the queue and render once
198   application.SendNotification();
199   application.Render();
200
201   DALI_TEST_EQUALS(vector, actor.GetCurrentSize(), TEST_LOCATION );
202   END_TEST;
203 }
204
205 int UtcDaliImageActorGetCurrentSize01(void)
206 {
207   TestApplication application;
208   tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize");
209
210   Vector2 initialImageSize(100, 50);
211   BufferImage image = BufferImage::New( initialImageSize.width, initialImageSize.height );
212   ImageActor actor = ImageActor::New( image );
213   actor.SetRelayoutEnabled( false );
214   Stage::GetCurrent().Add(actor);
215
216   application.SendNotification();
217   application.Render();
218
219   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
220
221   Vector2 size(200.0f, 200.0f);
222   actor.SetSize(size);
223
224   // flush the queue and render once
225   application.SendNotification();
226   application.Render();
227   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
228
229   size.x = 200.0f;
230   size.y = 200.0f;
231   actor.SetSize(size);
232   application.Render(8);
233
234   // Test when a pixel area is set
235   ImageActor::PixelArea area(0, 0, 10, 10);
236   actor.SetPixelArea(area);
237   application.Render(9);
238   // natural size is not used as setsize is called
239   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
240
241   actor.SetToNaturalSize();
242   application.SendNotification();
243   application.Render(9);
244   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2( area.width, area.height ), TEST_LOCATION );
245
246   END_TEST;
247 }
248
249
250 int UtcDaliImageActorGetCurrentSize02(void)
251 {
252   TestApplication application;
253   tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - Test that using an image resource sets the actor size with it's natural size immediately rather than on load");
254
255   Vector2 initialImageSize(100, 50);
256
257   application.GetPlatform().SetClosestImageSize(initialImageSize);
258
259   Image image = ResourceImage::New("image.jpg");
260   ImageActor actor = ImageActor::New( image );
261   actor.SetRelayoutEnabled( false );
262   Stage::GetCurrent().Add(actor);
263
264   application.SendNotification(); // Flush update messages
265   application.Render();           // Process resource request
266   application.SendNotification(); // Flush update messages
267   application.Render();           // Process resource request
268
269   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
270
271   // Now complete the image load
272   Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
273   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
274   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  initialImageSize.width,initialImageSize.height, initialImageSize.width,initialImageSize.height );
275
276   Integration::ResourcePointer resourcePtr(bitmap); // reference it
277   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
278   application.Render();           // Process LoadComplete
279   application.SendNotification(); // Process event messages
280   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
281   application.GetPlatform().ClearReadyResources(); //
282
283   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
284
285   Vector2 size(200.0f, 200.0f);
286   actor.SetSize(size);
287
288   // flush the queue and render once
289   application.SendNotification();
290   application.Render();
291   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
292
293   actor.SetToNaturalSize();
294   application.SendNotification();
295   application.Render();
296   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
297   END_TEST;
298 }
299
300
301 int UtcDaliImageActorGetCurrentSize03(void)
302 {
303   TestApplication application;
304   tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - Test that using an image resource with a requested size sets the actor size with it's nearest size immediately rather than on load");
305
306   const Vector2 closestImageSize( 80, 45);
307   application.GetPlatform().SetClosestImageSize(closestImageSize);
308
309   ImageAttributes attrs;
310   const Vector2 requestedSize( 40, 30 );
311   attrs.SetSize( requestedSize.width, requestedSize.height );
312   Image image = ResourceImage::New("image.jpg", attrs);
313   ImageActor actor = ImageActor::New( image );
314   actor.SetRelayoutEnabled( false );
315   Stage::GetCurrent().Add(actor);
316
317   application.SendNotification(); // Flush update messages
318   application.Render();           // Process resource request
319   application.SendNotification(); // Flush update messages
320   application.Render();           // Process resource request
321
322   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
323
324   // Now complete the image load
325   Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
326   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
327   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
328
329   Integration::ResourcePointer resourcePtr(bitmap); // reference it
330   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
331   application.Render();           // Process LoadComplete
332   application.SendNotification(); // Process event messages
333   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
334   application.GetPlatform().ClearReadyResources(); //
335
336   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
337
338   // Test that setting a size on the actor can be 'undone' with SetNaturalSize()
339   Vector2 size(200.0f, 200.0f);
340   actor.SetSize(size);
341
342   // flush the queue and render once
343   application.SendNotification();
344   application.Render();
345   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
346
347   actor.SetToNaturalSize();
348   application.SendNotification();
349   application.Render();
350   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
351   END_TEST;
352 }
353
354
355 int UtcDaliImageActorGetCurrentSize04(void)
356 {
357   TestApplication application;
358   tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - check a new image doesn't change a set actor size");
359
360   const Vector2 closestImageSize( 80, 45);
361   application.GetPlatform().SetClosestImageSize(closestImageSize);
362
363   const Vector2 requestedSize( 40, 30 );
364   ImageAttributes attrs;
365   attrs.SetSize( requestedSize.width, requestedSize.height );
366   Image image = ResourceImage::New("image.jpg", attrs);
367   ImageActor actor = ImageActor::New( image );
368   actor.SetRelayoutEnabled( false );
369   Stage::GetCurrent().Add(actor);
370
371   application.SendNotification(); // Flush update messages
372   application.Render();           // Process resource request
373
374   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
375
376   // Now complete the image load
377   Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
378   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
379   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
380
381   Integration::ResourcePointer resourcePtr(bitmap); // reference it
382   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
383   application.Render();           // Process LoadComplete
384   application.SendNotification(); // Process event messages
385   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
386   application.GetPlatform().ClearReadyResources(); //
387
388   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
389
390   Vector2 size(200.0f, 200.0f);
391   actor.SetSize(size);
392
393   // flush the queue and render once
394   application.SendNotification();
395   application.Render();
396   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
397
398   // Load a different image
399
400   Vector2 image2ClosestSize = Vector2(240, 150); // The actual size image loader will return for the request below
401   application.GetPlatform().SetClosestImageSize(image2ClosestSize);
402
403   const Vector2 request2Size( 100, 100 );
404   attrs.SetSize( request2Size.width, request2Size.height );
405   Image image2 = ResourceImage::New("image2.jpg", attrs);
406   actor.SetImage(image2);
407
408   application.SendNotification(); // Flush update messages
409   application.Render();           // Process resource request
410   application.SendNotification(); // Flush update messages
411   application.Render();           // Process resource request
412
413   // Ensure the actor size is kept
414   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
415
416   // Now complete the image load
417   req = application.GetPlatform().GetRequest();
418   Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
419   bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  image2ClosestSize.width, image2ClosestSize.height, image2ClosestSize.width, image2ClosestSize.height );
420
421   Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
422   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr2);
423   application.Render();           // Process LoadComplete
424   application.SendNotification(); // Process event messages
425   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
426   application.GetPlatform().ClearReadyResources(); //
427
428   // Ensure the actor size is kept
429   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
430
431   actor.SetToNaturalSize();
432   application.SendNotification();
433   application.Render();
434   // Ensure the actor size gets the new image's natural size
435   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), request2Size, TEST_LOCATION );
436   END_TEST;
437 }
438
439
440 int UtcDaliImageActorGetCurrentSize05(void)
441 {
442   TestApplication application;
443   tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - check a new image doens't change actor size until load complete");
444
445   Vector2 closestImageSize( 80, 45);
446   application.GetPlatform().SetClosestImageSize(closestImageSize);
447
448   ImageAttributes attrs;
449   const Vector2 requestedSize( 40, 30 );
450   attrs.SetSize( requestedSize.width, requestedSize.height );
451   Image image = ResourceImage::New("image.jpg", attrs);
452   ImageActor actor = ImageActor::New( image );
453   actor.SetRelayoutEnabled( false );
454   Stage::GetCurrent().Add(actor);
455
456   application.SendNotification(); // Flush update messages
457   application.Render();           // Process resource request
458
459   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
460
461   // Now complete the image load
462   Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
463   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
464   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
465
466   Integration::ResourcePointer resourcePtr(bitmap); // reference it
467   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
468   application.Render();           // Process LoadComplete
469   application.SendNotification(); // Process event messages
470   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
471   application.GetPlatform().ClearReadyResources(); //
472
473   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
474
475   // Load a different image
476
477   Vector2 image2ClosestSize = Vector2(240, 150);
478   application.GetPlatform().SetClosestImageSize(image2ClosestSize);
479
480   const Vector2 requestedSize2( 100, 100 );
481   attrs.SetSize( requestedSize2.width, requestedSize2.height );
482   Image image2 = ResourceImage::New("image2.jpg", attrs);
483   actor.SetImage(image2);
484
485   application.SendNotification(); // Flush update messages
486   application.Render();           // Process resource request
487   application.SendNotification(); // Flush update messages
488   application.Render();           // Process resource request
489
490   // Ensure the actor size is kept
491   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize2, TEST_LOCATION );
492
493   // Now complete the image load
494   req = application.GetPlatform().GetRequest();
495   Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
496   bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  image2ClosestSize.width, image2ClosestSize.height, image2ClosestSize.width, image2ClosestSize.height );
497
498   Integration::ResourcePointer resourcePtr2(bitmap2); // reference it
499   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr2);
500   application.Render();           // Process LoadComplete
501   application.SendNotification(); // Process event messages
502   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
503   application.GetPlatform().ClearReadyResources(); //
504
505   application.SendNotification(); // Process event messages
506   application.Render();           // Process LoadComplete
507
508   // Ensure the actor size gets the new image's natural size
509   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize2, TEST_LOCATION );
510   END_TEST;
511 }
512
513 int UtcDaliImageActorNaturalPixelAreaSize01(void)
514 {
515   TestApplication application;
516   tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - check a new image doens't change actor size until load complete");
517
518 //If an image is loaded without setting size, then the actor gets the natural size of the image
519 //Setting the pixel area will change the actor size to match the pixel area
520 //Setting the actor size will not change pixel area, and will cause the partial image to stretch
521 //to the new size.
522 //Clearing the pixel area will not change actor size, and the actor will show the whole image.
523
524
525   Vector2 closestImageSize( 80, 45);
526   application.GetPlatform().SetClosestImageSize(closestImageSize);
527
528   ImageAttributes attrs;
529   const Vector2 requestedSize( 40, 30 );
530   attrs.SetSize( requestedSize.width, requestedSize.height );
531   Image image = ResourceImage::New("image.jpg", attrs);
532   ImageActor actor = ImageActor::New( image );
533   actor.SetRelayoutEnabled( false );
534   Stage::GetCurrent().Add(actor);
535
536   application.SendNotification(); // Flush update messages
537   application.Render();           // Process resource request
538
539   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
540
541   // Now complete the image load
542   Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
543   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
544   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
545
546   Integration::ResourcePointer resourcePtr(bitmap); // reference it
547   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
548   application.Render();           // Process LoadComplete
549   application.SendNotification(); // Process event messages
550   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
551   application.GetPlatform().ClearReadyResources(); //
552
553   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
554
555   // Set a pixel area on a naturally sized actor - expect the actor to take the
556   // pixel area as size
557   actor.SetPixelArea(ImageActor::PixelArea(0, 0, 30, 30));
558   application.SendNotification(); // Process event messages
559   application.Render();           // Process LoadComplete
560   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(30, 30), TEST_LOCATION );
561
562   // Set a size. Expect the partial image to stretch to fill the new size
563   actor.SetSize(100, 100);
564   application.SendNotification(); // Process event messages
565   application.Render();           // Process LoadComplete
566   application.Render();           // Process LoadComplete
567   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
568
569   // Clear the pixel area. Expect the whole image to be shown, filling the set size.
570   actor.ClearPixelArea();
571   application.SendNotification(); // Process event messages
572   application.Render();           // Process LoadComplete
573   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
574   END_TEST;
575 }
576
577 int UtcDaliImageActorNaturalPixelAreaSize02(void)
578 {
579   TestApplication application;
580   tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - check a new image doens't change actor size until load complete");
581
582 //If an image is loaded without setting size, then the actor gets the natural size of the image
583 //Setting the pixel area will change the actor size to match the pixel area
584 //Setting the actor size will not change pixel area, and will cause the partial image to stretch
585 //to the new size.
586 //Clearing the pixel area will not change actor size, and the actor will show the whole image.
587
588
589   Vector2 closestImageSize( 80, 45);
590   application.GetPlatform().SetClosestImageSize(closestImageSize);
591
592   ImageAttributes attrs;
593   const Vector2 requestedSize( 40, 30 );
594   attrs.SetSize( requestedSize.width, requestedSize.height );
595   Image image = ResourceImage::New("image.jpg", attrs);
596   ImageActor actor = ImageActor::New( image );
597   actor.SetRelayoutEnabled( false );
598   Stage::GetCurrent().Add(actor);
599
600   application.SendNotification(); // Flush update messages
601   application.Render();           // Process resource request
602
603   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
604
605   // Now complete the image load
606   Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
607   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
608   bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height );
609
610   Integration::ResourcePointer resourcePtr(bitmap); // reference it
611   application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr);
612   application.Render();           // Process LoadComplete
613   application.SendNotification(); // Process event messages
614   application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
615   application.GetPlatform().ClearReadyResources(); //
616
617   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
618
619   // Set a pixel area on a naturally sized actor - expect the actor to take the
620   // pixel area as size
621   actor.SetPixelArea(ImageActor::PixelArea(0, 0, 30, 30));
622   application.SendNotification(); // Process event messages
623   application.Render();           // Process LoadComplete
624   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(30, 30), TEST_LOCATION );
625
626   // Clear the pixel area. Expect the whole image to be shown, changing actor size
627   actor.ClearPixelArea();
628   application.SendNotification(); // Process event messages
629   application.Render();           // Process LoadComplete
630   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
631
632   // Set a size. Expect the partial image to stretch to fill the new size
633   actor.SetSize(100, 100);
634   application.SendNotification(); // Process event messages
635   application.Render();           // Process LoadComplete
636   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
637
638   // Set a pixel area, don't expect size to change
639   actor.SetPixelArea(ImageActor::PixelArea(0, 0, 40, 40));
640   application.SendNotification(); // Process event messages
641   application.Render();           // Process LoadComplete
642   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
643
644   // Use natural size - expect actor to change to pixel area
645   actor.SetToNaturalSize();
646   application.SendNotification(); // Process event messages
647   application.Render();           // Process LoadComplete
648   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(40, 40), TEST_LOCATION );
649
650   // Clearing pixel area should change actor size to image size
651   actor.ClearPixelArea();
652   application.SendNotification(); // Process event messages
653   application.Render();           // Process LoadComplete
654   DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
655   END_TEST;
656 }
657
658
659
660 int UtcDaliImageActorDefaultProperties(void)
661 {
662   TestApplication application;
663   tet_infoline("Testing Dali::ImageActor DefaultProperties");
664
665   BufferImage img = BufferImage::New( 10, 10 );
666   ImageActor actor = ImageActor::New( img );
667
668   std::vector<Property::Index> indices;
669   indices.push_back(ImageActor::Property::PIXEL_AREA      );
670   indices.push_back(ImageActor::Property::STYLE           );
671   indices.push_back(ImageActor::Property::BORDER          );
672   indices.push_back(ImageActor::Property::IMAGE           );
673
674   DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
675
676   for(std::vector<Property::Index>::iterator iter = indices.begin(); iter != indices.end(); ++iter)
677   {
678     DALI_TEST_CHECK( *iter == actor.GetPropertyIndex(actor.GetPropertyName(*iter)) );
679     DALI_TEST_CHECK( actor.IsPropertyWritable(*iter) );
680     DALI_TEST_CHECK( !actor.IsPropertyAnimatable(*iter) );
681     DALI_TEST_CHECK( actor.GetPropertyType(*iter) == actor.GetPropertyType(*iter) );  // just checking call succeeds
682   }
683
684   // set/get one of them
685   actor.SetPixelArea(ImageActor::PixelArea( 0, 0, 0, 0 ));
686
687   ImageActor::PixelArea area( 1, 2, 3, 4 );
688   actor.SetProperty(ImageActor::Property::PIXEL_AREA, Property::Value(Rect<int>(area)));
689
690   DALI_TEST_CHECK(Property::RECTANGLE == actor.GetPropertyType(ImageActor::Property::PIXEL_AREA));
691
692   Property::Value v = actor.GetProperty(ImageActor::Property::PIXEL_AREA);
693
694   DALI_TEST_CHECK(v.Get<Rect<int> >() == area);
695
696   END_TEST;
697 }
698
699 int UtcDaliImageActorUseImageAlpha01(void)
700 {
701   TestApplication application;
702
703   tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
704
705   BufferImage image = BufferImage::New( 100, 50 );
706   ImageActor actor = ImageActor::New( image );
707   actor.SetBlendMode( BlendingMode::ON );
708   actor.SetSize(100, 50);
709   application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
710   Stage::GetCurrent().Add(actor);
711
712   application.SendNotification();
713   application.Render();
714
715   const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
716   DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
717   DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
718   END_TEST;
719 }
720
721 int UtcDaliImageActorUseImageAlpha02(void)
722 {
723   TestApplication application;
724
725   tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
726
727   BufferImage image = BufferImage::New( 100, 50 );
728   ImageActor actor = ImageActor::New( image );
729   actor.SetBlendMode( BlendingMode::OFF );
730   actor.SetSize(100, 50);
731   application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
732   Stage::GetCurrent().Add(actor);
733
734   application.SendNotification();
735   application.Render();
736
737   const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
738   DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
739   DALI_TEST_EQUALS( BlendEnabled( callTrace), false, TEST_LOCATION );
740   END_TEST;
741 }
742
743 int UtcDaliImageActorUseImageAlpha03(void)
744 {
745   TestApplication application;
746
747   tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
748
749   BufferImage image = BufferImage::New( 100, 50 );
750   ImageActor actor = ImageActor::New( image );
751   actor.SetBlendMode( BlendingMode::AUTO );
752   actor.SetColor(Vector4(1.0, 1.0, 1.0, 0.5));
753   actor.SetSize(100, 50);
754   application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
755   Stage::GetCurrent().Add(actor);
756
757   application.SendNotification();
758   application.Render();
759
760   const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
761   DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
762   DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
763   END_TEST;
764 }
765
766 int UtcDaliImageActorUseImageAlpha04(void)
767 {
768   TestApplication application;
769
770   tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
771
772   FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 );
773   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
774   RenderTask task = taskList.GetTask( 0u );
775   task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected
776   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
777   application.SendNotification();
778   application.Render(0);
779
780   ImageActor actor = ImageActor::New( image );
781   application.SendNotification();
782   application.Render(0);
783
784   actor.SetBlendMode( BlendingMode::ON );
785   actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0));
786   actor.SetSize(100, 50);
787   application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
788   Stage::GetCurrent().Add(actor);
789
790   application.SendNotification();
791   application.Render();
792
793   const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
794   DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
795   DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
796   END_TEST;
797 }
798
799 int UtcDaliImageActorUseImageAlpha05(void)
800 {
801   TestApplication application;
802
803   tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");
804
805   BufferImage image = BufferImage::New( 100, 50, Pixel::RGB888 );
806   ImageActor actor = ImageActor::New( image );
807   actor.SetBlendMode( BlendingMode::AUTO );
808   actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0));
809   actor.SetSize(100, 50);
810   application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
811   Stage::GetCurrent().Add(actor);
812
813   application.SendNotification();
814   application.Render();
815
816   const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
817   DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
818   DALI_TEST_EQUALS( BlendEnabled( callTrace), false, TEST_LOCATION );
819   END_TEST;
820 }
821
822 int UtcDaliImageActorClearPixelArea(void)
823 {
824   TestApplication application;
825
826   BufferImage img = BufferImage::New( 10, 10 );
827   ImageActor actor = ImageActor::New( img );
828
829   DALI_TEST_CHECK( actor.IsPixelAreaSet() == false );
830
831   ImageActor::PixelArea area( 1, 2, 3, 4 );
832   actor.SetPixelArea( area );
833
834   DALI_TEST_CHECK( actor.IsPixelAreaSet() == true );
835
836   actor.ClearPixelArea();
837
838   DALI_TEST_CHECK( actor.IsPixelAreaSet() == false );
839   END_TEST;
840 }
841
842 int UtcDaliImageGetStyle(void)
843 {
844   TestApplication application;
845
846   Image image = ResourceImage::New(TestImageFilename);
847   ImageActor actor = ImageActor::New(image);
848
849   actor.SetStyle(ImageActor::STYLE_NINE_PATCH);
850
851   // flush the queue and render once
852   application.SendNotification();
853   application.Render();
854
855   DALI_TEST_EQUALS( ImageActor::STYLE_NINE_PATCH, actor.GetStyle(), TEST_LOCATION );
856   END_TEST;
857 }
858
859 int UtcDaliImageSetNinePatchBorder(void)
860 {
861   TestApplication application;
862
863   Image image = ResourceImage::New(TestImageFilename);
864   ImageActor actor = ImageActor::New(image);
865
866   actor.SetStyle(ImageActor::STYLE_NINE_PATCH);
867   actor.SetNinePatchBorder(Vector4( 1.0f, 2.0f, 3.0f, 4.0f));
868
869   DALI_TEST_EQUALS( 1.0f, actor.GetNinePatchBorder().x, TEST_LOCATION );
870   DALI_TEST_EQUALS( 2.0f, actor.GetNinePatchBorder().y, TEST_LOCATION );
871   DALI_TEST_EQUALS( 3.0f, actor.GetNinePatchBorder().z, TEST_LOCATION );
872   DALI_TEST_EQUALS( 4.0f, actor.GetNinePatchBorder().w, TEST_LOCATION );
873   END_TEST;
874 }
875
876 int UtcDaliImageActorNewNull(void)
877 {
878   TestApplication application;
879
880   ImageActor actor = ImageActor::New(Image());
881
882   DALI_TEST_CHECK(actor);
883   END_TEST;
884 }
885
886 int UtcDaliImageActorNewNullWithArea(void)
887 {
888   TestApplication application;
889
890   ImageActor::PixelArea area( 1, 2, 3, 4 );
891
892   ImageActor actor = ImageActor::New(Image(), area);
893
894   DALI_TEST_CHECK(actor);
895   END_TEST;
896 }
897
898 int UtcDaliImageActorSetImage(void)
899 {
900   TestApplication application;
901
902   ImageActor actor = ImageActor::New(Image());
903
904   DALI_TEST_CHECK(actor);
905
906   actor.SetImage( Image() );
907
908   DALI_TEST_CHECK(!actor.GetImage());
909   END_TEST;
910 }
911
912 int UtcDaliImageActorPropertyIndices(void)
913 {
914   TestApplication application;
915   Actor basicActor = Actor::New();
916   ImageActor imageActor = ImageActor::New();
917
918   Property::IndexContainer indices;
919   imageActor.GetPropertyIndices( indices );
920   DALI_TEST_CHECK( indices.size() > basicActor.GetPropertyCount() );
921   DALI_TEST_EQUALS( indices.size(), imageActor.GetPropertyCount(), TEST_LOCATION );
922   END_TEST;
923 }
924
925 int UtcDaliImageActorImageProperty(void)
926 {
927   TestApplication application;
928   Image image = ResourceImage::New( "MY_PATH" );
929   ImageActor imageActor = ImageActor::New( image );
930
931   Stage::GetCurrent().Add( imageActor );
932   application.SendNotification();
933   application.Render();
934
935   Property::Value imageMap = imageActor.GetProperty( ImageActor::Property::IMAGE );
936   DALI_TEST_CHECK( imageMap.HasKey( "filename" ) );
937   DALI_TEST_EQUALS( imageMap.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION );
938   END_TEST;
939 }
940
941 int UtcDaliImageActorNinePatch01(void)
942 {
943   TestApplication application;
944   TestPlatformAbstraction& platform = application.GetPlatform();
945   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
946   TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
947   TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
948
949   tet_infoline("Test the successful loading of a nine-patch image\n");
950
951   platform.SetClosestImageSize(Vector2(4, 4));
952   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
953   Integration::PixelBuffer* pixels = bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  4,4,4,4 );
954   memset( pixels, 0, 64 );
955
956   Integration::ResourcePointer resourcePtr(bitmap); // reference it
957   platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
958
959   Image ninePatchImage = ResourceImage::New( "blah.#.png" );
960   DALI_TEST_CHECK( ninePatchImage );
961
962   ImageActor imageActor = ImageActor::New( ninePatchImage );
963   DALI_TEST_CHECK( imageActor );
964   Stage::GetCurrent().Add( imageActor );
965
966   drawTrace.Reset();
967   textureTrace.Reset();
968   drawTrace.Enable(true);
969   textureTrace.Enable(true);
970   glAbstraction.ClearBoundTextures();
971   std::vector<GLuint> ids;
972   ids.push_back( 23 );
973   glAbstraction.SetNextTextureIds( ids );
974
975   application.SendNotification();
976   application.Render();
977
978   DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
979   typedef std::vector<GLuint> TexVec;
980   const TexVec& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
981   DALI_TEST_CHECK( textures.size() > 0 );
982   if( textures.size() > 0 )
983   {
984     DALI_TEST_EQUALS( textures[0], 23u, TEST_LOCATION );
985   }
986
987   END_TEST;
988 }
989
990
991 int UtcDaliImageActorNinePatch02(void)
992 {
993   TestApplication application;
994   TestPlatformAbstraction& platform = application.GetPlatform();
995   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
996   TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
997   TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
998
999   tet_infoline("Test the failed loading of a nine-patch image\n");
1000
1001   platform.SetClosestImageSize(Vector2(0, 0));
1002   Integration::ResourcePointer resourcePtr;
1003   platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
1004
1005   Image ninePatchImage = ResourceImage::New( "blah.#.png" );
1006   DALI_TEST_CHECK( ninePatchImage );
1007
1008   ImageActor imageActor = ImageActor::New( ninePatchImage );
1009   DALI_TEST_CHECK( imageActor );
1010   Stage::GetCurrent().Add( imageActor );
1011
1012   drawTrace.Reset();
1013   textureTrace.Reset();
1014   drawTrace.Enable(true);
1015   textureTrace.Enable(true);
1016   glAbstraction.ClearBoundTextures();
1017   std::vector<GLuint> ids;
1018   ids.push_back( 23 );
1019   glAbstraction.SetNextTextureIds( ids );
1020
1021   application.SendNotification();
1022   application.Render();
1023
1024   // Check that nothing was drawn.
1025   DALI_TEST_CHECK( ! drawTrace.FindMethod( "DrawArrays" ) );
1026   typedef std::vector<GLuint> TexVec;
1027   const TexVec& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
1028   DALI_TEST_CHECK( textures.size() == 0u );
1029
1030   END_TEST;
1031 }
1032
1033
1034 int UtcDaliImageActorNinePatch03(void)
1035 {
1036   TestApplication application;
1037   TestPlatformAbstraction& platform = application.GetPlatform();
1038   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1039   TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
1040   TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
1041
1042   tet_infoline("Test the successful loading of a nine-patch image added using ImageActor::SetImage()\n");
1043
1044   platform.SetClosestImageSize(Vector2(4, 4));
1045   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::RETAIN );
1046   Integration::PixelBuffer* pixels = bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  4,4,4,4 );
1047   memset( pixels, 0, 64 );
1048
1049   Integration::ResourcePointer resourcePtr(bitmap); // reference it
1050   platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
1051
1052   Image ninePatchImage = ResourceImage::New( "blah.#.png" );
1053   DALI_TEST_CHECK( ninePatchImage );
1054
1055   ImageActor imageActor = ImageActor::New();
1056   DALI_TEST_CHECK( imageActor );
1057   Stage::GetCurrent().Add( imageActor );
1058
1059   imageActor.SetImage( ninePatchImage );
1060
1061   drawTrace.Reset();
1062   textureTrace.Reset();
1063   drawTrace.Enable(true);
1064   textureTrace.Enable(true);
1065   glAbstraction.ClearBoundTextures();
1066   std::vector<GLuint> ids;
1067   ids.push_back( 23 );
1068   glAbstraction.SetNextTextureIds( ids );
1069
1070   application.SendNotification();
1071   application.Render();
1072
1073   DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
1074   typedef std::vector<GLuint> TexVec;
1075   const TexVec& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
1076   DALI_TEST_CHECK( textures.size() > 0 );
1077   if( textures.size() > 0 )
1078   {
1079     DALI_TEST_EQUALS( textures[0], 23u, TEST_LOCATION );
1080   }
1081
1082   END_TEST;
1083 }
1084
1085
1086 int UtcDaliImageActorNinePatch04(void)
1087 {
1088   TestApplication application;
1089   TestPlatformAbstraction& platform = application.GetPlatform();
1090   TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1091   TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
1092   TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
1093
1094   tet_infoline("Test the failed loading of a nine-patch image using ImageActor::SetImage()\n");
1095
1096   platform.SetClosestImageSize(Vector2(0, 0));
1097   Integration::ResourcePointer resourcePtr;
1098   platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
1099
1100   Image ninePatchImage = ResourceImage::New( "blah.#.png" );
1101   DALI_TEST_CHECK( ninePatchImage );
1102
1103   ImageActor imageActor = ImageActor::New();
1104   DALI_TEST_CHECK( imageActor );
1105   Stage::GetCurrent().Add( imageActor );
1106
1107   imageActor.SetImage( ninePatchImage );
1108
1109   drawTrace.Reset();
1110   textureTrace.Reset();
1111   drawTrace.Enable(true);
1112   textureTrace.Enable(true);
1113   glAbstraction.ClearBoundTextures();
1114   std::vector<GLuint> ids;
1115   ids.push_back( 23 );
1116   glAbstraction.SetNextTextureIds( ids );
1117
1118   application.SendNotification();
1119   application.Render();
1120
1121   // Check that nothing was drawn.
1122   DALI_TEST_CHECK( ! drawTrace.FindMethod( "DrawArrays" ) );
1123   typedef std::vector<GLuint> TexVec;
1124   const TexVec& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
1125   DALI_TEST_CHECK( textures.size() == 0u );
1126
1127   END_TEST;
1128 }
1129
1130 int UtcDaliImageActorGetNaturalSize(void)
1131 {
1132   TestApplication application;
1133
1134   // Standard image
1135   BufferImage img = BufferImage::New( 10, 10 );
1136   ImageActor actor = ImageActor::New( img );
1137
1138   DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == Vector2( 10, 10 ) );
1139
1140   // Pixel area set
1141   ImageActor::PixelArea area( 1, 2, 3, 4 );
1142   actor.SetPixelArea( area );
1143
1144   DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == Vector2( 3, 4 ) );
1145
1146   END_TEST;
1147 }