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 Actor actor = CreateRenderableActor( 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
66 DALI_TEST_CHECK( image );
67 DALI_TEST_EQUALS(image.GetWidth(), 16u, TEST_LOCATION);
68 DALI_TEST_EQUALS(image.GetHeight(), 16u, TEST_LOCATION);
72 int UtcDaliFrameBufferImageNew02(void)
74 TestApplication application;
76 tet_infoline("UtcDaliFrameBufferImageNew02 - FrameBufferImage::New(NativeImageInterface&)");
78 // invoke default handle constructor
79 FrameBufferImage image;
80 TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
82 DALI_TEST_CHECK( !image );
85 image = FrameBufferImage::New(*(nativeImage.Get()));
87 DALI_TEST_CHECK( image );
91 int UtcDaliFrameBufferImageNew03(void)
93 TestApplication application;
95 tet_infoline("UtcDaliFrameBufferImageNew03 - FrameBufferImage::New(NativeImageInterface&, ReleasePolicy)");
97 // invoke default handle constructor
98 FrameBufferImage image;
99 TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
101 DALI_TEST_CHECK( !image );
103 // initialise handle with UNUSED release policy
104 image = FrameBufferImage::New(*(nativeImage.Get()), Image::UNUSED);
106 DALI_TEST_CHECK( image );
108 // ReleasePolicy is deprecated. Only set, but not used internally.
109 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::UNUSED, TEST_LOCATION );
111 // initialise handle with NEVER release policy
113 DALI_TEST_CHECK( !image );
115 image = FrameBufferImage::New(*(nativeImage.Get()), Image::NEVER);
117 DALI_TEST_CHECK( image );
119 // ReleasePolicy is deprecated. Only set, but not used internally.
120 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
125 int UtcDaliFrameBufferImageAttachments01(void)
127 TestApplication application;
129 tet_infoline("UtcDaliFrameBufferImageAttachments01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
131 // invoke default handle constructor
132 FrameBufferImage image;
135 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR); // create framebuffer with Color buffer
136 Actor actor = CreateRenderableActor(image);
137 Stage::GetCurrent().Add(actor);
139 application.SendNotification();
140 application.Render();
141 application.Render();
142 application.SendNotification();
144 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
145 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
146 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
151 int UtcDaliFrameBufferImageAttachments02(void)
153 TestApplication application;
155 tet_infoline("UtcDaliFrameBufferImageAttachments02 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
157 // invoke default handle constructor
158 FrameBufferImage image;
161 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH); // create framebuffer with Color and Depth buffer
162 Actor actor = CreateRenderableActor(image);
163 Stage::GetCurrent().Add(actor);
165 application.SendNotification();
166 application.Render();
167 application.Render();
168 application.SendNotification();
170 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
171 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
172 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
177 int UtcDaliFrameBufferImageAttachments03(void)
179 TestApplication application;
181 tet_infoline("UtcDaliFrameBufferImageAttachments03 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
183 // invoke default handle constructor
184 FrameBufferImage image;
187 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_STENCIL); // create framebuffer with Color and Stencil
188 Actor actor = CreateRenderableActor(image);
189 Stage::GetCurrent().Add(actor);
191 application.SendNotification();
192 application.Render();
193 application.Render();
194 application.SendNotification();
196 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
197 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
198 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
203 int UtcDaliFrameBufferImageAttachments04(void)
205 TestApplication application;
207 tet_infoline("UtcDaliFrameBufferImageAttachments04 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
209 // invoke default handle constructor
210 FrameBufferImage image;
213 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH_STENCIL); // create framebuffer with Color, Depth and Stencil buffers
214 Actor actor = CreateRenderableActor(image);
215 Stage::GetCurrent().Add(actor);
217 application.SendNotification();
218 application.Render();
219 application.Render();
220 application.SendNotification();
222 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
223 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
224 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
229 int UtcDaliFrameBufferImageDownCast(void)
231 TestApplication application;
232 tet_infoline("Testing Dali::FrameBufferImage::DownCast()");
234 FrameBufferImage image = FrameBufferImage::New();
236 BaseHandle object(image);
238 FrameBufferImage image2 = FrameBufferImage::DownCast(object);
239 DALI_TEST_CHECK(image2);
241 FrameBufferImage image3 = DownCast< FrameBufferImage >(object);
242 DALI_TEST_CHECK(image3);
244 BaseHandle unInitializedObject;
245 FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject);
246 DALI_TEST_CHECK(!image4);
248 FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject);
249 DALI_TEST_CHECK(!image5);
251 Image image6 = FrameBufferImage::New();
252 FrameBufferImage image7 = FrameBufferImage::DownCast(image6);
253 DALI_TEST_CHECK(image7);