1043cdc05feaf2d53c7f8e90866ddcadba7aa7c3
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Texture.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/devel-api/rendering/texture-devel.h>
20 #include <dali/integration-api/texture-integ.h>
21 #include <dali/public-api/dali-core.h>
22 #include <test-native-image.h>
23
24 using namespace Dali;
25
26 #include <mesh-builder.h>
27
28 void texture_set_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void texture_set_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 int UtcDaliTextureNew01(void)
39 {
40   TestApplication application;
41
42   unsigned int width(64);
43   unsigned int height(64);
44   Texture      texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
45
46   DALI_TEST_CHECK(texture);
47   END_TEST;
48 }
49
50 int UtcDaliTextureNew02(void)
51 {
52   TestApplication application;
53   Texture         texture;
54   DALI_TEST_CHECK(!texture);
55   END_TEST;
56 }
57
58 int UtcDaliTextureNew03(void)
59 {
60   TestApplication application;
61
62   // Create a native image source.
63   TestNativeImagePointer testNativeImage = TestNativeImage::New(64u, 64u);
64
65   // Create a texture from the native image source.
66   Texture nativeTexture = Texture::New(*testNativeImage);
67
68   // Check the texture was created OK.
69   DALI_TEST_CHECK(nativeTexture);
70
71   END_TEST;
72 }
73
74 int UtcDaliTextureNew04(void)
75 {
76   TestApplication application;
77
78   Texture texture = Texture::New(TextureType::TEXTURE_2D);
79
80   DALI_TEST_CHECK(texture);
81   END_TEST;
82 }
83
84 int UtcDaliTextureNew05(void)
85 {
86   TestApplication application;
87
88   uint32_t expectResourceId = 11u;
89
90   Texture texture = Integration::NewTextureWithResourceId(TextureType::TEXTURE_2D, expectResourceId);
91
92   DALI_TEST_CHECK(texture);
93
94   uint32_t currentResourceId = Integration::GetTextureResourceId(texture);
95
96   DALI_TEST_EQUALS(currentResourceId, expectResourceId, TEST_LOCATION);
97
98   END_TEST;
99 }
100
101 int UtcDaliTextureCopyConstructor(void)
102 {
103   TestApplication application;
104
105   unsigned int width(64);
106   unsigned int height(64);
107   Texture      texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
108
109   Texture textureCopy(texture);
110
111   DALI_TEST_CHECK(textureCopy);
112
113   END_TEST;
114 }
115
116 int UtcDaliTextureAssignmentOperator(void)
117 {
118   TestApplication application;
119   unsigned int    width(64);
120   unsigned int    height(64);
121   Texture         texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
122
123   Texture texture2;
124   DALI_TEST_CHECK(!texture2);
125
126   texture2 = texture;
127   DALI_TEST_CHECK(texture2);
128
129   END_TEST;
130 }
131
132 int UtcDaliTextureMoveConstructor(void)
133 {
134   TestApplication application;
135
136   uint32_t width   = 64;
137   uint32_t height  = 64;
138   Texture  texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
139   DALI_TEST_CHECK(texture);
140   DALI_TEST_EQUALS(1, texture.GetBaseObject().ReferenceCount(), TEST_LOCATION);
141   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
142   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
143
144   Texture move = std::move(texture);
145   DALI_TEST_CHECK(move);
146   DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
147   DALI_TEST_EQUALS(move.GetWidth(), width, TEST_LOCATION);
148   DALI_TEST_EQUALS(move.GetHeight(), height, TEST_LOCATION);
149   DALI_TEST_CHECK(!texture);
150
151   END_TEST;
152 }
153
154 int UtcDaliTextureMoveAssignment(void)
155 {
156   TestApplication application;
157
158   uint32_t width   = 64;
159   uint32_t height  = 64;
160   Texture  texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
161   DALI_TEST_CHECK(texture);
162   DALI_TEST_EQUALS(1, texture.GetBaseObject().ReferenceCount(), TEST_LOCATION);
163   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
164   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
165
166   Texture move;
167   move = std::move(texture);
168   DALI_TEST_CHECK(move);
169   DALI_TEST_EQUALS(1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
170   DALI_TEST_EQUALS(move.GetWidth(), width, TEST_LOCATION);
171   DALI_TEST_EQUALS(move.GetHeight(), height, TEST_LOCATION);
172   DALI_TEST_CHECK(!texture);
173
174   END_TEST;
175 }
176
177 int UtcDaliTextureDownCast01(void)
178 {
179   TestApplication application;
180   unsigned int    width(64);
181   unsigned int    height(64);
182   Texture         texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
183
184   BaseHandle handle(texture);
185   Texture    texture2 = Texture::DownCast(handle);
186   DALI_TEST_CHECK(texture2);
187
188   END_TEST;
189 }
190
191 int UtcDaliTextureDownCast02(void)
192 {
193   TestApplication application;
194
195   Handle  handle  = Handle::New(); // Create a custom object
196   Texture texture = Texture::DownCast(handle);
197   DALI_TEST_CHECK(!texture);
198   END_TEST;
199 }
200
201 int UtcDaliTextureUpload01(void)
202 {
203   TestApplication application;
204
205   //Create the texture
206   unsigned int width(64);
207   unsigned int height(64);
208   Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
209
210   application.GetGlAbstraction().EnableTextureCallTrace(true);
211
212   application.SendNotification();
213   application.Render();
214
215   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
216
217   //Upload data to the texture
218   callStack.Reset();
219
220   unsigned int   bufferSize(width * height * 4);
221   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
222   PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
223   texture.Upload(pixelData);
224   application.SendNotification();
225   application.Render();
226
227   //TexImage2D should be called to upload the data
228   {
229     std::stringstream out;
230     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
231     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
232   }
233
234   //Upload part of the texture
235   callStack.Reset();
236   bufferSize                  = width * height;
237   buffer                      = reinterpret_cast<unsigned char*>(malloc(bufferSize));
238   PixelData pixelDataSubImage = PixelData::New(buffer, bufferSize, width / 2, height / 2, Pixel::RGBA8888, PixelData::FREE);
239   texture.Upload(pixelDataSubImage, 0u, 0u, width / 2, height / 2, width / 2, height / 2);
240   application.SendNotification();
241   application.Render();
242
243   //TexSubImage2D should be called to upload the data
244   {
245     std::stringstream out;
246     out << GL_TEXTURE_2D << ", " << 0u << ", " << width / 2 << ", " << height / 2 << ", " << width / 2 << ", " << height / 2;
247     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str()));
248   }
249
250   END_TEST;
251 }
252
253 int UtcDaliTextureUpload02(void)
254 {
255   TestApplication application;
256
257   //Create the texture
258   unsigned int width(64);
259   unsigned int height(64);
260   Texture      texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
261
262   application.GetGlAbstraction().EnableTextureCallTrace(true);
263
264   application.SendNotification();
265   application.Render();
266
267   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
268
269   tet_infoline("TexImage2D should be called six times with a null pointer to reserve storage for the six textures of the cube map");
270   for(unsigned int i(0); i < 6; ++i)
271   {
272     std::stringstream out;
273     out << GL_TEXTURE_CUBE_MAP_POSITIVE_X + i << ", " << 0u << ", " << width << ", " << height;
274     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
275   }
276
277   unsigned int   bufferSize(width * height * 4);
278   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
279   PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
280
281   //Upload data to the POSITIVE_X face of the texture
282   {
283     callStack.Reset();
284
285     texture.Upload(pixelData, CubeMapLayer::POSITIVE_X, 0u, 0u, 0u, width, height);
286     application.SendNotification();
287     application.Render();
288
289     //TexImage2D should be called to upload the data to the POSITIVE_X face
290     {
291       std::stringstream out;
292       out << GL_TEXTURE_CUBE_MAP_POSITIVE_X << ", " << 0u << ", " << width << ", " << height;
293       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
294     }
295   }
296
297   //Upload data to the NEGATIVE_X face of the texture
298   {
299     callStack.Reset();
300
301     texture.Upload(pixelData, CubeMapLayer::NEGATIVE_X, 0u, 0u, 0u, width, height);
302     application.SendNotification();
303     application.Render();
304
305     //TexImage2D should be called to upload the data to the NEGATIVE_X face
306     {
307       std::stringstream out;
308       out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X << ", " << 0u << ", " << width << ", " << height;
309       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
310     }
311   }
312
313   //Upload data to the POSITIVE_Y face of the texture
314   {
315     callStack.Reset();
316     texture.Upload(pixelData, CubeMapLayer::POSITIVE_Y, 0u, 0u, 0u, width, height);
317     application.SendNotification();
318     application.Render();
319
320     //TexImage2D should be called to upload the data to the POSITIVE_Y face
321     {
322       std::stringstream out;
323       out << GL_TEXTURE_CUBE_MAP_POSITIVE_Y << ", " << 0u << ", " << width << ", " << height;
324       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
325     }
326   }
327
328   //Upload data to the NEGATIVE_Y face of the texture
329   {
330     callStack.Reset();
331     texture.Upload(pixelData, CubeMapLayer::NEGATIVE_Y, 0u, 0u, 0u, width, height);
332     application.SendNotification();
333     application.Render();
334
335     //TexImage2D should be called to upload the data to the NEGATIVE_Y face
336     {
337       std::stringstream out;
338       out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Y << ", " << 0u << ", " << width << ", " << height;
339       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
340     }
341   }
342
343   //Upload data to the POSITIVE_Z face of the texture
344   {
345     callStack.Reset();
346     texture.Upload(pixelData, CubeMapLayer::POSITIVE_Z, 0u, 0u, 0u, width, height);
347     application.SendNotification();
348     application.Render();
349
350     //TexImage2D should be called to upload the data to the POSITIVE_Z face
351     {
352       std::stringstream out;
353       out << GL_TEXTURE_CUBE_MAP_POSITIVE_Z << ", " << 0u << ", " << width << ", " << height;
354       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
355     }
356   }
357
358   //Upload data to the NEGATIVE_Z face of the texture
359   {
360     callStack.Reset();
361     texture.Upload(pixelData, CubeMapLayer::NEGATIVE_Z, 0u, 0u, 0u, width, height);
362     application.SendNotification();
363     application.Render();
364
365     //TexImage2D should be called to upload the data to the NEGATIVE_Z face
366     {
367       std::stringstream out;
368       out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Z << ", " << 0u << ", " << width << ", " << height;
369       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
370     }
371   }
372
373   END_TEST;
374 }
375
376 int UtcDaliTextureUpload03(void)
377 {
378   TestApplication application;
379
380   //Create the texture
381   unsigned int width(64);
382   unsigned int height(64);
383   unsigned int widthMipmap1(32);
384   unsigned int heightMipmap1(32);
385
386   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
387
388   application.GetGlAbstraction().EnableTextureCallTrace(true);
389
390   application.SendNotification();
391   application.Render();
392
393   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
394
395   tet_infoline("TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
396   {
397     std::stringstream out;
398     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
399     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
400   }
401
402   //Upload data to the texture mipmap 0 and mipmap 1
403   callStack.Reset();
404
405   unsigned int   bufferSize(width * height * 4);
406   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
407   PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
408   texture.Upload(pixelData, 0u, 0u, 0u, 0u, width, height);
409
410   bufferSize                 = widthMipmap1 * heightMipmap1 * 4;
411   buffer                     = reinterpret_cast<unsigned char*>(malloc(bufferSize));
412   PixelData pixelDataMipmap1 = PixelData::New(buffer, bufferSize, widthMipmap1, heightMipmap1, Pixel::RGBA8888, PixelData::FREE);
413   texture.Upload(pixelDataMipmap1, 0u, 1u, 0u, 0u, widthMipmap1, heightMipmap1);
414   application.SendNotification();
415   application.Render();
416
417   //TexImage2D should be called to upload the data to mipmaps 0 and 1
418   {
419     std::stringstream out;
420     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
421     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
422   }
423   {
424     std::stringstream out;
425     out << GL_TEXTURE_2D << ", " << 1u << ", " << widthMipmap1 << ", " << heightMipmap1;
426     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
427   }
428
429   END_TEST;
430 }
431
432 int UtcDaliTextureUpload04(void)
433 {
434   TestApplication application;
435
436   //Create the texture
437   unsigned int width(64);
438   unsigned int height(64);
439   unsigned int widthMipmap1(32);
440   unsigned int heightMipmap1(32);
441
442   Texture texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
443
444   application.GetGlAbstraction().EnableTextureCallTrace(true);
445   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
446
447   //Upload data to the NEGATIVE_X face mipmap 0 and mipmap 1
448   unsigned int   bufferSize(width * height * 4);
449   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
450   PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
451   texture.Upload(pixelData, CubeMapLayer::NEGATIVE_X, 0u, 0u, 0u, width, height);
452
453   bufferSize                 = widthMipmap1 * heightMipmap1 * 4;
454   buffer                     = reinterpret_cast<unsigned char*>(malloc(bufferSize));
455   PixelData pixelDataMipmap1 = PixelData::New(buffer, bufferSize, widthMipmap1, heightMipmap1, Pixel::RGBA8888, PixelData::FREE);
456   texture.Upload(pixelDataMipmap1, CubeMapLayer::NEGATIVE_X, 1u, 0u, 0u, widthMipmap1, heightMipmap1);
457   application.SendNotification();
458   application.Render();
459
460   //TexImage2D should be called to upload the data to mipmaps 0 and 1
461   {
462     std::stringstream out;
463     out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X << ", " << 0u << ", " << width << ", " << height;
464     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
465   }
466   {
467     std::stringstream out;
468     out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X << ", " << 1u << ", " << widthMipmap1 << ", " << heightMipmap1;
469     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
470   }
471
472   END_TEST;
473 }
474
475 int UtcDaliTextureUpload05(void)
476 {
477   Pixel::Format COMPRESSED_PIXEL_FORMATS[] =
478     {
479       Pixel::COMPRESSED_R11_EAC,
480       Pixel::COMPRESSED_SIGNED_R11_EAC,
481       Pixel::COMPRESSED_RG11_EAC,
482       Pixel::COMPRESSED_SIGNED_RG11_EAC,
483       Pixel::COMPRESSED_RGB8_ETC2,
484       Pixel::COMPRESSED_SRGB8_ETC2,
485       Pixel::COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
486       Pixel::COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
487       Pixel::COMPRESSED_RGBA8_ETC2_EAC,
488       Pixel::COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
489       Pixel::COMPRESSED_RGB8_ETC1,
490       Pixel::COMPRESSED_RGB_PVRTC_4BPPV1,
491       Pixel::COMPRESSED_RGBA_ASTC_4x4_KHR,
492       Pixel::COMPRESSED_RGBA_ASTC_5x4_KHR,
493       Pixel::COMPRESSED_RGBA_ASTC_5x5_KHR,
494       Pixel::COMPRESSED_RGBA_ASTC_6x5_KHR,
495       Pixel::COMPRESSED_RGBA_ASTC_6x6_KHR,
496       Pixel::COMPRESSED_RGBA_ASTC_8x5_KHR,
497       Pixel::COMPRESSED_RGBA_ASTC_8x6_KHR,
498       Pixel::COMPRESSED_RGBA_ASTC_8x8_KHR,
499       Pixel::COMPRESSED_RGBA_ASTC_10x5_KHR,
500       Pixel::COMPRESSED_RGBA_ASTC_10x6_KHR,
501       Pixel::COMPRESSED_RGBA_ASTC_10x8_KHR,
502       Pixel::COMPRESSED_RGBA_ASTC_10x10_KHR,
503       Pixel::COMPRESSED_RGBA_ASTC_12x10_KHR,
504       Pixel::COMPRESSED_RGBA_ASTC_12x12_KHR,
505       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
506       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
507       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
508       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
509       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
510       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
511       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
512       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
513       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
514       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
515       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
516       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
517       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
518       Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
519     };
520   const unsigned int NUMBER_OF_COMPRESSED_PIXEL_FORMATS = sizeof(COMPRESSED_PIXEL_FORMATS) / sizeof(Pixel::Format);
521
522   for(unsigned int index = 0; index < NUMBER_OF_COMPRESSED_PIXEL_FORMATS; ++index)
523   {
524     TestApplication application;
525
526     //Create a texture with a compressed format
527     unsigned int width(64);
528     unsigned int height(64);
529     Texture      texture = CreateTexture(TextureType::TEXTURE_2D, COMPRESSED_PIXEL_FORMATS[index], width, height);
530
531     application.GetGlAbstraction().EnableTextureCallTrace(true);
532
533     application.SendNotification();
534     application.Render();
535
536     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
537
538     tet_infoline("CompressedTexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
539     {
540       std::stringstream out;
541       out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
542       DALI_TEST_CHECK(callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str()));
543     }
544
545     //Upload data to the texture
546     callStack.Reset();
547
548     unsigned int   bufferSize(width * height * 4);
549     unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
550     PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, COMPRESSED_PIXEL_FORMATS[index], PixelData::FREE);
551     texture.Upload(pixelData);
552     application.SendNotification();
553     application.Render();
554
555     //CompressedTexImage2D should be called to upload the data
556     {
557       std::stringstream out;
558       out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
559       DALI_TEST_CHECK(callStack.FindMethodAndParams("CompressedTexImage2D", out.str().c_str()));
560     }
561
562     //Upload part of the texture
563     callStack.Reset();
564     bufferSize                  = width * height;
565     buffer                      = reinterpret_cast<unsigned char*>(malloc(bufferSize));
566     PixelData pixelDataSubImage = PixelData::New(buffer, bufferSize, width / 2, height / 2, COMPRESSED_PIXEL_FORMATS[index], PixelData::FREE);
567     texture.Upload(pixelDataSubImage, 0u, 0u, width / 2, height / 2, width / 2, height / 2);
568     application.SendNotification();
569     application.Render();
570
571     //CompressedTexSubImage2D should be called to upload the data
572     {
573       std::stringstream out;
574       out << GL_TEXTURE_2D << ", " << 0u << ", " << width / 2 << ", " << height / 2 << ", " << width / 2 << ", " << height / 2;
575       DALI_TEST_CHECK(callStack.FindMethodAndParams("CompressedTexSubImage2D", out.str().c_str()));
576     }
577
578     application.GetGlAbstraction().ResetTextureCallStack();
579   }
580
581   END_TEST;
582 }
583
584 int UtcDaliTextureUpload06(void)
585 {
586   TestApplication application;
587
588   //Create the texture
589   unsigned int width(64);
590   unsigned int height(64);
591   tet_infoline("Creating a Texure with an alpha channel");
592   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
593
594   application.GetGlAbstraction().EnableTextureCallTrace(true);
595
596   application.SendNotification();
597   application.Render();
598
599   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
600
601   tet_infoline("TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
602   {
603     std::stringstream out;
604     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
605     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
606   }
607
608   tet_infoline("Upload data to the texture");
609   callStack.Reset();
610
611   tet_infoline("Creating a RGB pixel buffer and adding that to the texture to ensure it is handled correctly");
612   unsigned int   bufferSize(width * height * 3);
613   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
614   PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE);
615   texture.Upload(pixelData);
616   application.SendNotification();
617   application.Render();
618
619   tet_infoline("TexImage2D should be called to upload the data");
620   {
621     std::stringstream out;
622     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
623     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
624   }
625
626   END_TEST;
627 }
628
629 int UtcDaliTextureUpload07(void)
630 {
631   Pixel::Format FLOATING_POINT_PIXEL_FORMATS[] =
632     {
633       Pixel::RGB16F,
634       Pixel::RGB32F,
635     };
636   const unsigned int NUMBER_OF_FLOATING_POINT_PIXEL_FORMATS = sizeof(FLOATING_POINT_PIXEL_FORMATS) / sizeof(Pixel::Format);
637
638   for(unsigned int index = 0; index < NUMBER_OF_FLOATING_POINT_PIXEL_FORMATS; ++index)
639   {
640     TestApplication application;
641
642     //Create the texture
643     unsigned int width(64);
644     unsigned int height(64);
645     tet_infoline("Creating a floating point texture");
646     Texture texture = CreateTexture(TextureType::TEXTURE_2D, FLOATING_POINT_PIXEL_FORMATS[index], width, height);
647
648     application.GetGlAbstraction().EnableTextureCallTrace(true);
649
650     application.SendNotification();
651     application.Render();
652
653     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
654
655     tet_infoline("TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
656     {
657       std::stringstream out;
658       out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
659       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
660     }
661
662     tet_infoline("Upload data to the texture");
663     callStack.Reset();
664
665     tet_infoline("Creating a RGB pixel buffer and adding that to the texture to ensure it is handled correctly");
666     unsigned int   bufferSize(width * height * 3);
667     unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
668     PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, FLOATING_POINT_PIXEL_FORMATS[index], PixelData::FREE);
669     texture.Upload(pixelData);
670     application.SendNotification();
671     application.Render();
672
673     tet_infoline("TexImage2D should be called to upload the data");
674     {
675       std::stringstream out;
676       out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
677       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
678     }
679   }
680
681   END_TEST;
682 }
683
684 int UtcDaliTextureUpload08(void)
685 {
686   TestApplication application;
687
688   //Create the texture without pixel information
689   tet_infoline("Creating a Texure without any size/format information");
690   Texture texture = Texture::New(TextureType::TEXTURE_2D);
691
692   application.GetGlAbstraction().EnableTextureCallTrace(true);
693
694   application.SendNotification();
695   application.Render();
696
697   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
698
699   tet_infoline("TexImage2D should not be called with a null pointer to reserve storage for the texture in the gpu");
700   DALI_TEST_CHECK(!callStack.FindMethod("GenTextures"));
701   DALI_TEST_CHECK(!callStack.FindMethod("TexImage2D"));
702
703   tet_infoline("Upload data to the texture");
704   unsigned int width(64);
705   unsigned int height(64);
706   callStack.Reset();
707
708   tet_infoline("Creating a RGB pixel buffer and adding that to the texture to ensure it is handled correctly");
709   unsigned int   bufferSize(width * height * 3);
710   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
711   PixelData      pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGB888, PixelData::FREE);
712   texture.Upload(pixelData);
713   application.SendNotification();
714   application.Render();
715
716   tet_infoline("GetWidth / GetHeight / GetPixelFormat will return uploaded value");
717   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
718   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
719   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
720
721   tet_infoline("TexImage2D should be called to upload the data");
722   DALI_TEST_CHECK(callStack.FindMethod("GenTextures"));
723   {
724     std::stringstream out;
725     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
726     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
727   }
728
729   tet_infoline("Upload another data to the texture");
730   width  = 40;
731   height = 73;
732   callStack.Reset();
733
734   tet_infoline("Creating a RGB pixel buffer and adding that to the texture to ensure it is handled correctly");
735   bufferSize = width * height * 4;
736   buffer     = reinterpret_cast<unsigned char*>(malloc(bufferSize));
737   pixelData  = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
738   texture.Upload(pixelData);
739   application.SendNotification();
740   application.Render();
741
742   tet_infoline("TexImage2D should be generate new graphics, and be called to upload the data");
743   DALI_TEST_CHECK(callStack.FindMethod("GenTextures"));
744   {
745     std::stringstream out;
746     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
747     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
748   }
749
750   tet_infoline("GetWidth / GetHeight / GetPixelFormat will return uploaded value");
751   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
752   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
753   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
754
755   END_TEST;
756 }
757
758 int UtcDaliTextureUploadSubPixelData01(void)
759 {
760   TestApplication application;
761
762   //Create the texture
763   unsigned int width(64);
764   unsigned int height(64);
765   Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
766
767   application.GetGlAbstraction().EnableTextureCallTrace(true);
768
769   application.SendNotification();
770   application.Render();
771
772   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
773
774   //Upload data to the texture
775   callStack.Reset();
776
777   uint32_t bufferWidth   = width * 2;
778   uint32_t bufferHeight  = height * 2;
779   uint32_t bufferXOffset = width;
780   uint32_t bufferYOffset = height;
781
782   unsigned int   bufferSize(bufferWidth * bufferHeight * 4);
783   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
784   PixelData      pixelData = PixelData::New(buffer, bufferSize, bufferWidth, bufferHeight, Pixel::RGBA8888, PixelData::FREE);
785   DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height);
786   application.SendNotification();
787   application.Render();
788
789   //TexImage2D should be called to upload the data
790   {
791     std::stringstream out;
792     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
793     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
794   }
795
796   //Upload part of the texture
797   callStack.Reset();
798   DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width / 2, height / 2, 0u, 0u, width / 2, height / 2, width / 2, height / 2);
799   application.SendNotification();
800   application.Render();
801
802   //TexSubImage2D should be called to upload the data
803   {
804     std::stringstream out;
805     out << GL_TEXTURE_2D << ", " << 0u << ", " << width / 2 << ", " << height / 2 << ", " << width / 2 << ", " << height / 2;
806     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str()));
807   }
808
809   END_TEST;
810 }
811
812 int UtcDaliTextureUploadSubPixelData02(void)
813 {
814   TestApplication application;
815
816   //Create the texture
817   unsigned int width(64);
818   unsigned int height(64);
819   Texture      texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
820
821   application.GetGlAbstraction().EnableTextureCallTrace(true);
822
823   application.SendNotification();
824   application.Render();
825
826   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
827
828   tet_infoline("TexImage2D should be called six times with a null pointer to reserve storage for the six textures of the cube map");
829   for(unsigned int i(0); i < 6; ++i)
830   {
831     std::stringstream out;
832     out << GL_TEXTURE_CUBE_MAP_POSITIVE_X + i << ", " << 0u << ", " << width << ", " << height;
833     DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
834   }
835
836   uint32_t bufferWidth   = width * 2;
837   uint32_t bufferHeight  = height * 2;
838   uint32_t bufferXOffset = width;
839   uint32_t bufferYOffset = height;
840
841   unsigned int   bufferSize(bufferWidth * bufferHeight * 4);
842   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
843   PixelData      pixelData = PixelData::New(buffer, bufferSize, bufferWidth, bufferHeight, Pixel::RGBA8888, PixelData::FREE);
844
845   //Upload data to the POSITIVE_X face of the texture
846   {
847     callStack.Reset();
848
849     DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::POSITIVE_X, 0u, 0u, 0u, width, height);
850     application.SendNotification();
851     application.Render();
852
853     //TexImage2D should be called to upload the data to the POSITIVE_X face
854     {
855       std::stringstream out;
856       out << GL_TEXTURE_CUBE_MAP_POSITIVE_X << ", " << 0u << ", " << width << ", " << height;
857       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
858     }
859   }
860
861   //Upload data to the NEGATIVE_X face of the texture
862   {
863     callStack.Reset();
864
865     DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::NEGATIVE_X, 0u, 0u, 0u, width, height);
866     application.SendNotification();
867     application.Render();
868
869     //TexImage2D should be called to upload the data to the NEGATIVE_X face
870     {
871       std::stringstream out;
872       out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X << ", " << 0u << ", " << width << ", " << height;
873       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
874     }
875   }
876
877   //Upload data to the POSITIVE_Y face of the texture
878   {
879     callStack.Reset();
880     DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::POSITIVE_Y, 0u, 0u, 0u, width, height);
881     application.SendNotification();
882     application.Render();
883
884     //TexImage2D should be called to upload the data to the POSITIVE_Y face
885     {
886       std::stringstream out;
887       out << GL_TEXTURE_CUBE_MAP_POSITIVE_Y << ", " << 0u << ", " << width << ", " << height;
888       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
889     }
890   }
891
892   //Upload data to the NEGATIVE_Y face of the texture
893   {
894     callStack.Reset();
895     DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::NEGATIVE_Y, 0u, 0u, 0u, width, height);
896     application.SendNotification();
897     application.Render();
898
899     //TexImage2D should be called to upload the data to the NEGATIVE_Y face
900     {
901       std::stringstream out;
902       out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Y << ", " << 0u << ", " << width << ", " << height;
903       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
904     }
905   }
906
907   //Upload data to the POSITIVE_Z face of the texture
908   {
909     callStack.Reset();
910     DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::POSITIVE_Z, 0u, 0u, 0u, width, height);
911     application.SendNotification();
912     application.Render();
913
914     //TexImage2D should be called to upload the data to the POSITIVE_Z face
915     {
916       std::stringstream out;
917       out << GL_TEXTURE_CUBE_MAP_POSITIVE_Z << ", " << 0u << ", " << width << ", " << height;
918       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
919     }
920   }
921
922   //Upload data to the NEGATIVE_Z face of the texture
923   {
924     callStack.Reset();
925     DevelTexture::UploadSubPixelData(texture, pixelData, bufferXOffset, bufferYOffset, width, height, CubeMapLayer::NEGATIVE_Z, 0u, 0u, 0u, width, height);
926     application.SendNotification();
927     application.Render();
928
929     //TexImage2D should be called to upload the data to the NEGATIVE_Z face
930     {
931       std::stringstream out;
932       out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Z << ", " << 0u << ", " << width << ", " << height;
933       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
934     }
935   }
936
937   END_TEST;
938 }
939
940 int UtcDaliTextureUploadPixelFormats(void)
941 {
942   TestApplication application;
943   application.GetGlAbstraction().EnableTextureCallTrace(true);
944
945   //Create the texture
946   unsigned int width(64);
947   unsigned int height(64);
948
949   std::vector<Pixel::Format> formats =
950     {
951       Pixel::A8,
952       Pixel::L8,
953       Pixel::LA88,
954       Pixel::RGB565,
955       Pixel::BGR565,
956       Pixel::RGBA4444,
957       Pixel::BGRA4444,
958       Pixel::RGBA5551,
959       Pixel::BGRA5551,
960       Pixel::RGB888,
961       Pixel::RGB8888,
962       Pixel::BGR8888,
963       Pixel::RGBA8888,
964       Pixel::BGRA8888,
965       Pixel::DEPTH_UNSIGNED_INT,
966       Pixel::DEPTH_FLOAT,
967       Pixel::DEPTH_STENCIL,
968       Pixel::RGB16F,
969       Pixel::RGB32F,
970       Pixel::R11G11B10F,
971       Pixel::CHROMINANCE_U,
972       Pixel::CHROMINANCE_V};
973
974   for(auto format : formats)
975   {
976     tet_infoline("Creating a Texure with a new or recent format");
977     Texture texture = CreateTexture(TextureType::TEXTURE_2D, format, width, height);
978
979     application.SendNotification();
980     application.Render();
981
982     TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
983
984     tet_infoline("TexImage2D should be called twice per texture");
985     DALI_TEST_EQUALS(callStack.CountMethod("TexImage2D"), 2, TEST_LOCATION);
986     {
987       std::stringstream out;
988       out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
989       DALI_TEST_CHECK(callStack.FindMethodAndParams("TexImage2D", out.str().c_str()));
990     }
991     callStack.Reset();
992   }
993
994   END_TEST;
995 }
996
997 int UtcDaliTextureUploadSmallerThanSize(void)
998 {
999   TestApplication application;
1000
1001   //Create the texture
1002   unsigned int width(64);
1003   unsigned int height(64);
1004   Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1005
1006   application.GetGlAbstraction().EnableTextureCallTrace(true);
1007
1008   application.SendNotification();
1009   application.Render();
1010
1011   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
1012   callStack.EnableLogging(true);
1013   TraceCallStack& texParamCallStack = application.GetGlAbstraction().GetTexParameterTrace();
1014   texParamCallStack.EnableLogging(true);
1015
1016   tet_infoline("TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu");
1017   {
1018     std::stringstream out;
1019     out << GL_TEXTURE_2D << ", " << 0u << ", " << width << ", " << height;
1020     std::string params;
1021     DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("TexImage2D", params));
1022     DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
1023   }
1024
1025   //Upload data to the texture
1026   callStack.Reset();
1027
1028   unsigned int   bufferSize(width * height * 4);
1029   unsigned char* buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
1030   PixelData      pixelData = PixelData::New(buffer, bufferSize, width / 2, height / 2, Pixel::RGBA8888, PixelData::FREE);
1031   texture.Upload(pixelData);
1032   application.SendNotification();
1033   application.Render();
1034
1035   //TexSubImage2D should be called to upload the data
1036   {
1037     std::stringstream out;
1038     out << GL_TEXTURE_2D << ", " << 0u << ", " << 0u << ", " << 0u << ", " << width / 2 << ", " << height / 2;
1039     std::string params;
1040     DALI_TEST_CHECK(callStack.FindMethodAndGetParameters("TexSubImage2D", params));
1041     DALI_TEST_EQUALS(out.str(), params, TEST_LOCATION);
1042   }
1043   END_TEST;
1044 }
1045
1046 int UtcDaliTextureGenerateMipmaps(void)
1047 {
1048   TestApplication application;
1049   unsigned int    width(64);
1050   unsigned int    height(64);
1051
1052   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1053   texture.GenerateMipmaps();
1054
1055   Texture textureCubemap = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
1056   textureCubemap.GenerateMipmaps();
1057
1058   application.GetGlAbstraction().EnableTextureCallTrace(true);
1059   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
1060   application.SendNotification();
1061   application.Render();
1062
1063   {
1064     std::stringstream out;
1065     out << GL_TEXTURE_2D;
1066     DALI_TEST_CHECK(callStack.FindMethodAndParams("GenerateMipmap", out.str().c_str()));
1067   }
1068   {
1069     std::stringstream out;
1070     out << GL_TEXTURE_CUBE_MAP;
1071     DALI_TEST_CHECK(callStack.FindMethodAndParams("GenerateMipmap", out.str().c_str()));
1072   }
1073
1074   END_TEST;
1075 }
1076
1077 int UtcDaliTextureGenerateMipmapsCompressedFormat(void)
1078 {
1079   TestApplication application;
1080   unsigned int    width(64);
1081   unsigned int    height(64);
1082
1083   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::COMPRESSED_RGBA8_ETC2_EAC, width, height);
1084   texture.GenerateMipmaps();
1085
1086   application.GetGlAbstraction().EnableTextureCallTrace(true);
1087   TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
1088   application.SendNotification();
1089   application.Render();
1090
1091   // Check generate mipmap didn't called when we use compressed pixel format.
1092   DALI_TEST_CHECK(!callStack.FindMethod("GenerateMipmap"));
1093
1094   END_TEST;
1095 }
1096
1097 int UtcDaliTextureGetWidth(void)
1098 {
1099   TestApplication application;
1100   unsigned int    width(64);
1101   unsigned int    height(64);
1102
1103   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1104   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
1105   END_TEST;
1106 }
1107
1108 int UtcDaliTextureGetHeight(void)
1109 {
1110   TestApplication application;
1111   unsigned int    width(64);
1112   unsigned int    height(64);
1113
1114   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1115   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
1116
1117   END_TEST;
1118 }
1119
1120 int UtcDaliTextureGetTextureType(void)
1121 {
1122   TestApplication application;
1123   unsigned int    width(64);
1124   unsigned int    height(64);
1125
1126   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1127   DALI_TEST_EQUALS(Integration::GetTextureType(texture), TextureType::TEXTURE_2D, TEST_LOCATION);
1128
1129   texture = CreateTexture(TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height);
1130   DALI_TEST_EQUALS(Integration::GetTextureType(texture), TextureType::TEXTURE_CUBE, TEST_LOCATION);
1131
1132   END_TEST;
1133 }
1134
1135 int UtcDaliTextureSetSize(void)
1136 {
1137   TestApplication application;
1138   unsigned int    width(64);
1139   unsigned int    height(64);
1140
1141   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1142   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
1143   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
1144   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
1145
1146   width += 11u;
1147   height += 22u;
1148
1149   Integration::SetTextureSize(texture, ImageDimensions(width, height));
1150   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
1151   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
1152   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
1153
1154   application.SendNotification();
1155   application.Render();
1156
1157   END_TEST;
1158 }
1159
1160 int UtcDaliTextureSetPixelFormat(void)
1161 {
1162   TestApplication application;
1163   unsigned int    width(64);
1164   unsigned int    height(64);
1165
1166   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1167   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
1168   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
1169   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
1170
1171   Integration::SetTexturePixelFormat(texture, Pixel::BGRA5551);
1172   DALI_TEST_EQUALS(texture.GetWidth(), width, TEST_LOCATION);
1173   DALI_TEST_EQUALS(texture.GetHeight(), height, TEST_LOCATION);
1174   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::BGRA5551, TEST_LOCATION);
1175
1176   application.SendNotification();
1177   application.Render();
1178
1179   END_TEST;
1180 }
1181
1182 int UtcDaliTextureContextLoss(void)
1183 {
1184   tet_infoline("UtcDaliTextureContextLoss\n");
1185   TestApplication application;
1186
1187   //Create the texture
1188   unsigned int width(64);
1189   unsigned int height(64);
1190   Texture      texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1191   DALI_TEST_CHECK(texture);
1192
1193   application.SendNotification();
1194   application.Render(16);
1195
1196   // Lose & regain context (in render 'thread')
1197   application.ResetContext();
1198   DALI_TEST_CHECK(texture);
1199
1200   END_TEST;
1201 }
1202
1203 int UtcDaliNativeImageTexture01(void)
1204 {
1205   TestApplication application;
1206   tet_infoline("UtcDaliNativeImageTexture01");
1207
1208   TestNativeImagePointer imageInterface = TestNativeImage::New(16, 16);
1209   {
1210     Texture texture = Texture::New(*(imageInterface.Get()));
1211     Actor   actor   = CreateRenderableActor(texture, "", "");
1212     application.GetScene().Add(actor);
1213
1214     DALI_TEST_CHECK(texture);
1215
1216     application.SendNotification();
1217     application.Render(16);
1218
1219     DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION);
1220     DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 0, TEST_LOCATION);
1221     DALI_TEST_EQUALS(actor.GetProperty(Actor::Property::SIZE), Property::Value(Vector3(16, 16, 0)), TEST_LOCATION);
1222
1223     UnparentAndReset(actor);
1224
1225     application.SendNotification();
1226     application.Render(16);
1227   }
1228   application.SendNotification();
1229   application.Render(16);
1230
1231   DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION);
1232   DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION);
1233
1234   END_TEST;
1235 }
1236
1237 int UtcDaliNativeImageTexture02(void)
1238 {
1239   TestApplication application;
1240   tet_infoline("UtcDaliNativeImageTexture02 - test error on TargetTexture");
1241
1242   TestNativeImagePointer imageInterface = TestNativeImage::New(16, 16);
1243   imageInterface->mTargetTextureError   = 1u;
1244   {
1245     Texture texture = Texture::New(*(imageInterface.Get()));
1246     Actor   actor   = CreateRenderableActor(texture, "", "");
1247     application.GetScene().Add(actor);
1248
1249     DALI_TEST_CHECK(texture);
1250
1251     application.SendNotification();
1252     application.Render(16);
1253
1254     // Expect 2 attempts to create the texture - once when adding the texture
1255     // to the scene-graph, and again since that failed, during the Bind.
1256     // The second one succeeds (TargetTexture only errors once)
1257     DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 2, TEST_LOCATION);
1258     DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION);
1259
1260     UnparentAndReset(actor);
1261
1262     application.SendNotification();
1263     application.Render(16);
1264   }
1265   application.SendNotification();
1266   application.Render(16);
1267
1268   // Expect that there are no further calls to create/destroy resource
1269   DALI_TEST_EQUALS(imageInterface->mExtensionCreateCalls, 2, TEST_LOCATION);
1270   DALI_TEST_EQUALS(imageInterface->mExtensionDestroyCalls, 2, TEST_LOCATION);
1271
1272   END_TEST;
1273 }
1274
1275 int UtcDaliTextureGenerateMipmapsNegative(void)
1276 {
1277   TestApplication application;
1278   Dali::Texture   instance;
1279   try
1280   {
1281     instance.GenerateMipmaps();
1282     DALI_TEST_CHECK(false); // Should not get here
1283   }
1284   catch(...)
1285   {
1286     DALI_TEST_CHECK(true); // We expect an assert
1287   }
1288   END_TEST;
1289 }
1290
1291 int UtcDaliTextureUploadNegative01(void)
1292 {
1293   TestApplication application;
1294   Dali::Texture   instance;
1295   try
1296   {
1297     Dali::PixelData arg1;
1298     instance.Upload(arg1);
1299     DALI_TEST_CHECK(false); // Should not get here
1300   }
1301   catch(...)
1302   {
1303     DALI_TEST_CHECK(true); // We expect an assert
1304   }
1305   END_TEST;
1306 }
1307
1308 int UtcDaliTextureUploadNegative02(void)
1309 {
1310   TestApplication application;
1311   Dali::Texture   instance;
1312   try
1313   {
1314     Dali::PixelData arg1;
1315     unsigned int    arg2(0u);
1316     unsigned int    arg3(0u);
1317     unsigned int    arg4(0u);
1318     unsigned int    arg5(0u);
1319     unsigned int    arg6(0u);
1320     unsigned int    arg7(0u);
1321     instance.Upload(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
1322     DALI_TEST_CHECK(false); // Should not get here
1323   }
1324   catch(...)
1325   {
1326     DALI_TEST_CHECK(true); // We expect an assert
1327   }
1328   END_TEST;
1329 }
1330
1331 int UtcDaliTextureGetWidthNegative(void)
1332 {
1333   TestApplication application;
1334   Dali::Texture   instance;
1335   try
1336   {
1337     instance.GetWidth();
1338     DALI_TEST_CHECK(false); // Should not get here
1339   }
1340   catch(...)
1341   {
1342     DALI_TEST_CHECK(true); // We expect an assert
1343   }
1344   END_TEST;
1345 }
1346
1347 int UtcDaliTextureGetHeightNegative(void)
1348 {
1349   TestApplication application;
1350   Dali::Texture   instance;
1351   try
1352   {
1353     instance.GetHeight();
1354     DALI_TEST_CHECK(false); // Should not get here
1355   }
1356   catch(...)
1357   {
1358     DALI_TEST_CHECK(true); // We expect an assert
1359   }
1360   END_TEST;
1361 }
1362
1363 int UtcDaliTextureCheckNativeP(void)
1364 {
1365   TestApplication        application;
1366   TestNativeImagePointer testNativeImage = TestNativeImage::New(64u, 64u);
1367   Texture                nativeTexture   = Texture::New(*testNativeImage);
1368
1369   DALI_TEST_CHECK(nativeTexture);
1370   DALI_TEST_CHECK(DevelTexture::IsNative(nativeTexture));
1371   END_TEST;
1372 }
1373
1374 int UtcDaliTextureCheckNativeN1(void)
1375 {
1376   TestApplication application;
1377   unsigned int    width(64);
1378   unsigned int    height(64);
1379   Texture         texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1380
1381   DALI_TEST_CHECK(texture);
1382   DALI_TEST_CHECK(!DevelTexture::IsNative(texture));
1383   END_TEST;
1384 }
1385
1386 int UtcDaliTextureCheckNativeN2(void)
1387 {
1388   TestApplication application;
1389   Texture         texture;
1390   try
1391   {
1392     bool native = DevelTexture::IsNative(texture);
1393     DALI_TEST_CHECK(native != native);
1394   }
1395   catch(...)
1396   {
1397     DALI_TEST_CHECK(true);
1398   }
1399   END_TEST;
1400 }
1401
1402 int UtcDaliTextureApplyFragShaderP1(void)
1403 {
1404   TestApplication        application;
1405   TestNativeImagePointer testNativeImage = TestNativeImage::New(64u, 64u);
1406   Texture                nativeTexture   = Texture::New(*testNativeImage);
1407   DALI_TEST_CHECK(nativeTexture);
1408
1409   const std::string baseFragShader =
1410     "varying mediump vec4 uColor;\n"
1411     "void main(){\n"
1412     "  gl_FragColor=uColor;\n"
1413     "}\n";
1414   std::string fragShader = baseFragShader;
1415   bool        applied    = DevelTexture::ApplyNativeFragmentShader(nativeTexture, fragShader);
1416
1417   std::string fragPrefix = "#extension GL_OES_EGL_image_external:require\n";
1418
1419   DALI_TEST_CHECK(applied);
1420   DALI_TEST_CHECK(baseFragShader.compare(fragShader));
1421   DALI_TEST_CHECK(fragShader.compare(fragPrefix + baseFragShader) == 0);
1422   DALI_TEST_CHECK(!fragShader.empty());
1423   END_TEST;
1424 }
1425
1426 int UtcDaliTextureApplyFragShaderP2(void)
1427 {
1428   TestApplication        application;
1429   TestNativeImagePointer testNativeImage = TestNativeImage::New(64u, 64u);
1430   Texture                nativeTexture   = Texture::New(*testNativeImage);
1431   DALI_TEST_CHECK(nativeTexture);
1432
1433   const std::string baseFragShader =
1434     "varying mediump vec4 uColor;\n"
1435     "varying vec2 vTexCoord;\n"
1436     "uniform sampler2D uNative;\n"
1437     "void main(){\n"
1438     "  gl_FragColor=uColor*texture2D(uNative, vTexCoord);\n"
1439     "}\n";
1440   std::string fragShader = baseFragShader;
1441   bool        applied    = DevelTexture::ApplyNativeFragmentShader(nativeTexture, fragShader);
1442
1443   DALI_TEST_CHECK(applied);
1444   DALI_TEST_CHECK(baseFragShader.compare(fragShader));
1445   DALI_TEST_CHECK(!fragShader.empty());
1446   DALI_TEST_CHECK(fragShader.find("samplerExternalOES") < fragShader.length());
1447   END_TEST;
1448 }
1449
1450 int UtcDaliTextureApplyFragShaderN1(void)
1451 {
1452   TestApplication        application;
1453   TestNativeImagePointer testNativeImage = TestNativeImage::New(64u, 64u);
1454   Texture                nativeTexture   = Texture::New(*testNativeImage);
1455   DALI_TEST_CHECK(nativeTexture);
1456
1457   std::string fragShader;
1458   bool        applied = DevelTexture::ApplyNativeFragmentShader(nativeTexture, fragShader);
1459
1460   DALI_TEST_CHECK(!applied);
1461   DALI_TEST_CHECK(fragShader.empty());
1462   END_TEST;
1463 }
1464
1465 int UtcDaliTextureApplyFragShaderN2(void)
1466 {
1467   TestApplication application;
1468   unsigned int    width(64);
1469   unsigned int    height(64);
1470   Texture         texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1471
1472   const std::string baseFragShader =
1473     "varying mediump vec4 uColor;\n"
1474     "void main(){\n"
1475     "  gl_FragColor=uColor;\n"
1476     "}\n";
1477   std::string fragShader = baseFragShader;
1478   bool        applied    = DevelTexture::ApplyNativeFragmentShader(texture, fragShader);
1479
1480   DALI_TEST_CHECK(!applied);
1481   DALI_TEST_CHECK(!baseFragShader.compare(fragShader));
1482   END_TEST;
1483 }
1484
1485 int UtcDaliTextureGetPixelFormat(void)
1486 {
1487   TestApplication application;
1488   uint32_t        width(64);
1489   uint32_t        height(64);
1490
1491   Texture texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1492   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION);
1493
1494   texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, width, height);
1495   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION);
1496
1497   texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::L8, width, height);
1498   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::L8, TEST_LOCATION);
1499
1500   texture = CreateTexture(TextureType::TEXTURE_2D, Pixel::CHROMINANCE_U, width, height);
1501   DALI_TEST_EQUALS(texture.GetPixelFormat(), Pixel::CHROMINANCE_U, TEST_LOCATION);
1502
1503   END_TEST;
1504 }
1505
1506 int utcDaliTexturePartialUpdate01(void)
1507 {
1508   TestApplication application(
1509     TestApplication::DEFAULT_SURFACE_WIDTH,
1510     TestApplication::DEFAULT_SURFACE_HEIGHT,
1511     TestApplication::DEFAULT_HORIZONTAL_DPI,
1512     TestApplication::DEFAULT_VERTICAL_DPI,
1513     true,
1514     true);
1515
1516   tet_infoline("Check the damaged rect with partial update and texture change");
1517
1518   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1519
1520   std::vector<Rect<int32_t>> damagedRects;
1521   Rect<int32_t>              clippingRect;
1522
1523   Geometry geometry = CreateQuadGeometry();
1524   Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
1525   Renderer renderer = Renderer::New(geometry, shader);
1526
1527   uint32_t   width(4);
1528   uint32_t   height(4);
1529   Texture    texture    = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1530   TextureSet textureSet = TextureSet::New();
1531   textureSet.SetTexture(0u, texture);
1532   renderer.SetTextures(textureSet);
1533
1534   Actor actor = Actor::New();
1535   actor.AddRenderer(renderer);
1536
1537   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1538   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
1539   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
1540   application.GetScene().Add(actor);
1541
1542   damagedRects.clear();
1543   application.SendNotification();
1544   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1545   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1546
1547   // Aligned by 16
1548   clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates
1549   DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
1550   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1551   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1552   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1553   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1554   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1555
1556   damagedRects.clear();
1557   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1558   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1559
1560   // Ensure the damaged rect is empty
1561   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1562
1563   // Upload texture
1564   uint32_t  bufferSize(width * height * 4);
1565   uint8_t*  buffer    = reinterpret_cast<unsigned char*>(malloc(bufferSize));
1566   PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
1567   texture.Upload(pixelData);
1568
1569   damagedRects.clear();
1570   application.SendNotification();
1571   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1572   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1573
1574   // Aligned by 16
1575   clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates
1576   DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
1577   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1578   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1579   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1580   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1581   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1582
1583   damagedRects.clear();
1584   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1585   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1586
1587   // Ensure the damaged rect is empty
1588   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1589
1590   END_TEST;
1591 }
1592
1593 int utcDaliTexturePartialUpdate02(void)
1594 {
1595   TestApplication application(
1596     TestApplication::DEFAULT_SURFACE_WIDTH,
1597     TestApplication::DEFAULT_SURFACE_HEIGHT,
1598     TestApplication::DEFAULT_HORIZONTAL_DPI,
1599     TestApplication::DEFAULT_VERTICAL_DPI,
1600     true,
1601     true);
1602
1603   tet_infoline("Check the damaged rect with partial update and texture change");
1604
1605   const TestGlAbstraction::ScissorParams& glScissorParams(application.GetGlAbstraction().GetScissorParams());
1606
1607   std::vector<Rect<int32_t>> damagedRects;
1608   Rect<int32_t>              clippingRect;
1609
1610   Geometry geometry = CreateQuadGeometry();
1611   Shader   shader   = Shader::New("vertexSrc", "fragmentSrc");
1612   Renderer renderer = Renderer::New(geometry, shader);
1613
1614   uint32_t   width(4);
1615   uint32_t   height(4);
1616   Texture    texture1   = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1617   Texture    texture2   = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
1618   TextureSet textureSet = TextureSet::New();
1619   textureSet.SetTexture(0u, texture1);
1620   renderer.SetTextures(textureSet);
1621
1622   Actor actor = Actor::New();
1623   actor.AddRenderer(renderer);
1624
1625   actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1626   actor.SetProperty(Actor::Property::POSITION, Vector3(16.0f, 16.0f, 0.0f));
1627   actor.SetProperty(Actor::Property::SIZE, Vector3(16.0f, 16.0f, 0.0f));
1628   application.GetScene().Add(actor);
1629
1630   damagedRects.clear();
1631   application.SendNotification();
1632   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1633   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1634
1635   // Aligned by 16
1636   clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
1637   DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
1638   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1639   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1640   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1641   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1642   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1643
1644   damagedRects.clear();
1645   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1646   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1647
1648   // Ensure the damaged rect is empty
1649   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1650
1651   // Set another texture
1652   textureSet.SetTexture(0u, texture2);
1653
1654   damagedRects.clear();
1655   application.SendNotification();
1656   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1657   DALI_TEST_EQUALS(damagedRects.size(), 1, TEST_LOCATION);
1658
1659   // Aligned by 16
1660   clippingRect = Rect<int32_t>(16, 768, 32, 32); // in screen coordinates, includes 3 last frames updates
1661   DALI_TEST_EQUALS<Rect<int32_t>>(clippingRect, damagedRects[0], TEST_LOCATION);
1662   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1663   DALI_TEST_EQUALS(clippingRect.x, glScissorParams.x, TEST_LOCATION);
1664   DALI_TEST_EQUALS(clippingRect.y, glScissorParams.y, TEST_LOCATION);
1665   DALI_TEST_EQUALS(clippingRect.width, glScissorParams.width, TEST_LOCATION);
1666   DALI_TEST_EQUALS(clippingRect.height, glScissorParams.height, TEST_LOCATION);
1667
1668   damagedRects.clear();
1669   application.PreRenderWithPartialUpdate(TestApplication::RENDER_FRAME_INTERVAL, nullptr, damagedRects);
1670   application.RenderWithPartialUpdate(damagedRects, clippingRect);
1671
1672   // Ensure the damaged rect is empty
1673   DALI_TEST_EQUALS(damagedRects.size(), 0, TEST_LOCATION);
1674
1675   END_TEST;
1676 }