2 * Copyright (c) 2014 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.
22 #include <dali/public-api/dali-core.h>
23 #include <dali-test-suite-utils.h>
24 #include <test-native-image.h>
25 #include <dali/integration-api/gl-abstraction.h>
30 void utc_dali_framebuffer_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_framebuffer_cleanup(void)
37 test_return_value = TET_PASS;
40 int UtcDaliFrameBufferImageNew01(void)
42 TestApplication application;
44 tet_infoline("UtcDaliFrameBufferImageNew01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format)");
46 // invoke default handle constructor
47 FrameBufferImage image;
48 Vector2 stageSize = Stage::GetCurrent().GetSize();
51 image = FrameBufferImage::New(); // create framebuffer with the same dimensions as the stage
52 ImageActor actor=ImageActor::New(image);
53 Stage::GetCurrent().Add(actor);
55 application.SendNotification();
58 application.SendNotification();
60 DALI_TEST_CHECK( image );
61 DALI_TEST_EQUALS((float)image.GetWidth(), stageSize.width, TEST_LOCATION);
62 DALI_TEST_EQUALS((float)image.GetHeight(), stageSize.height, TEST_LOCATION);
64 image = FrameBufferImage::New(16, 16); // create framebuffer with dimensions of 16x16
65 actor.SetImage(image);
67 application.SendNotification();
70 application.SendNotification();
72 DALI_TEST_CHECK( image );
73 DALI_TEST_EQUALS(image.GetWidth(), 16u, TEST_LOCATION);
74 DALI_TEST_EQUALS(image.GetHeight(), 16u, TEST_LOCATION);
78 int UtcDaliFrameBufferImageNew02(void)
80 TestApplication application;
82 tet_infoline("UtcDaliFrameBufferImageNew02 - FrameBufferImage::New(NativeImageInterface&)");
84 // invoke default handle constructor
85 FrameBufferImage image;
86 TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
88 DALI_TEST_CHECK( !image );
91 image = FrameBufferImage::New(*(nativeImage.Get()));
93 DALI_TEST_CHECK( image );
97 int UtcDaliFrameBufferImageNew03(void)
99 TestApplication application;
101 tet_infoline("UtcDaliFrameBufferImageNew03 - FrameBufferImage::New(NativeImageInterface&, ReleasePolicy)");
103 // invoke default handle constructor
104 FrameBufferImage image;
105 TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
107 DALI_TEST_CHECK( !image );
109 // initialise handle with UNUSED release policy
110 image = FrameBufferImage::New(*(nativeImage.Get()), Image::UNUSED);
112 DALI_TEST_CHECK( image );
113 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::UNUSED, TEST_LOCATION );
115 // initialise handle with NEVER release policy
117 DALI_TEST_CHECK( !image );
119 image = FrameBufferImage::New(*(nativeImage.Get()), Image::NEVER);
121 DALI_TEST_CHECK( image );
122 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
127 int UtcDaliFrameBufferImageAttachments01(void)
129 TestApplication application;
131 tet_infoline("UtcDaliFrameBufferImageAttachments01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
133 // invoke default handle constructor
134 FrameBufferImage image;
137 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR); // create framebuffer with Color buffer
138 ImageActor actor=ImageActor::New(image);
139 Stage::GetCurrent().Add(actor);
141 application.SendNotification();
142 application.Render();
143 application.Render();
144 application.SendNotification();
146 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
147 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
148 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
153 int UtcDaliFrameBufferImageAttachments02(void)
155 TestApplication application;
157 tet_infoline("UtcDaliFrameBufferImageAttachments02 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
159 // invoke default handle constructor
160 FrameBufferImage image;
163 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH); // create framebuffer with Color and Depth buffer
164 ImageActor actor=ImageActor::New(image);
165 Stage::GetCurrent().Add(actor);
167 application.SendNotification();
168 application.Render();
169 application.Render();
170 application.SendNotification();
172 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
173 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
174 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
179 int UtcDaliFrameBufferImageAttachments03(void)
181 TestApplication application;
183 tet_infoline("UtcDaliFrameBufferImageAttachments03 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
185 // invoke default handle constructor
186 FrameBufferImage image;
189 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_STENCIL); // create framebuffer with Color and Stencil
190 ImageActor actor=ImageActor::New(image);
191 Stage::GetCurrent().Add(actor);
193 application.SendNotification();
194 application.Render();
195 application.Render();
196 application.SendNotification();
198 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
199 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
200 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
205 int UtcDaliFrameBufferImageAttachments04(void)
207 TestApplication application;
209 tet_infoline("UtcDaliFrameBufferImageAttachments04 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
211 // invoke default handle constructor
212 FrameBufferImage image;
215 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH_STENCIL); // create framebuffer with Color, Depth and Stencil buffers
216 ImageActor actor=ImageActor::New(image);
217 Stage::GetCurrent().Add(actor);
219 application.SendNotification();
220 application.Render();
221 application.Render();
222 application.SendNotification();
224 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
225 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
226 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
231 int UtcDaliFrameBufferImageDownCast(void)
233 TestApplication application;
234 tet_infoline("Testing Dali::FrameBufferImage::DownCast()");
236 FrameBufferImage image = FrameBufferImage::New();
238 BaseHandle object(image);
240 FrameBufferImage image2 = FrameBufferImage::DownCast(object);
241 DALI_TEST_CHECK(image2);
243 FrameBufferImage image3 = DownCast< FrameBufferImage >(object);
244 DALI_TEST_CHECK(image3);
246 BaseHandle unInitializedObject;
247 FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject);
248 DALI_TEST_CHECK(!image4);
250 FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject);
251 DALI_TEST_CHECK(!image5);
253 Image image6 = FrameBufferImage::New();
254 FrameBufferImage image7 = FrameBufferImage::DownCast(image6);
255 DALI_TEST_CHECK(image7);