2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/bitmap.h>
23 #include <dali-test-suite-utils.h>
24 #include <test-native-image.h>
28 void utc_dali_image_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_image_cleanup(void)
35 test_return_value = TET_PASS;
38 static const char* gTestImageFilename = "icon_wrt.png";
45 int UtcDaliImageDownCast(void)
47 TestApplication application;
48 tet_infoline("Testing Dali::Image::DownCast()");
50 Image image = ResourceImage::New(gTestImageFilename);
52 BaseHandle object(image);
54 Image image2 = Image::DownCast(object);
55 DALI_TEST_CHECK(image2);
57 Image image3 = DownCast< Image >(object);
58 DALI_TEST_CHECK(image3);
60 BaseHandle unInitializedObject;
61 Image image4 = Image::DownCast(unInitializedObject);
62 DALI_TEST_CHECK(!image4);
64 Image image5 = DownCast< Image >(unInitializedObject);
65 DALI_TEST_CHECK(!image5);
69 int UtcDaliImageGetWidthHeight(void)
71 TestApplication application;
73 tet_infoline("UtcDaliImageGetWidthHeight - Image::GetWidth() & Image::GetHeight");
75 Vector2 testSize(8.0f, 16.0f);
76 application.GetPlatform().SetClosestImageSize(testSize);
77 PrepareResourceImage( application, testSize.x, testSize.y, Pixel::RGBA8888 );
78 Image image1 = ResourceImage::New(gTestImageFilename);
79 DALI_TEST_EQUALS( image1.GetWidth(), testSize.x, TEST_LOCATION );
80 DALI_TEST_EQUALS( image1.GetHeight(), testSize.y, TEST_LOCATION );
82 testSize = Vector2(128.0f, 256.0f);
83 PrepareResourceImage( application, testSize.x, testSize.y, Pixel::RGBA8888 );
84 Image image2 = ResourceImage::New( gTestImageFilename, ImageDimensions(testSize.x, testSize.y), FittingMode::SCALE_TO_FILL, SamplingMode::DEFAULT );
85 DALI_TEST_EQUALS( image2.GetWidth(), testSize.x, TEST_LOCATION );
86 DALI_TEST_EQUALS( image2.GetHeight(), testSize.y, TEST_LOCATION );
88 testSize = Vector2(16.0f, 32.0f);
89 Image image3 = FrameBufferImage::New(testSize.x, testSize.y);
90 DALI_TEST_EQUALS(image3.GetWidth(), testSize.x, TEST_LOCATION);
91 DALI_TEST_EQUALS(image3.GetHeight(), testSize.y, TEST_LOCATION);
93 testSize = Vector2(32.0f, 64.0f);
94 PrepareResourceImage( application, testSize.x, testSize.y, Pixel::RGBA8888 );
95 TestNativeImagePointer nativeImage = TestNativeImage::New(testSize.x, testSize.y);
96 Image image4 = NativeImage::New(*(nativeImage.Get()));
97 DALI_TEST_EQUALS(image4.GetWidth(), testSize.x, TEST_LOCATION);
98 DALI_TEST_EQUALS(image4.GetHeight(), testSize.y, TEST_LOCATION);
103 int UtcDaliImageDiscard01(void)
105 TestApplication application;
106 tet_infoline("UtcDaliImageDiscard01 - no actors");
109 Image image = ResourceImage::New(gTestImageFilename);
112 application.SendNotification();
113 application.Render(16);
114 std::vector<GLuint> ids;
116 application.GetGlAbstraction().SetNextTextureIds( ids );
117 application.Render(16);
118 application.SendNotification();
119 } // Drop image handle
121 application.SendNotification();
122 application.Render(16);
123 application.Render(16);
124 application.SendNotification();
126 // Shouldn't have been sent to GL...
127 const std::vector<GLuint>& texIds = application.GetGlAbstraction().GetNextTextureIds();
128 DALI_TEST_CHECK( texIds.size() == 1 );
129 DALI_TEST_CHECK( texIds[0] == 23 );