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