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 );
114 // ReleasePolicy is deprecated. Only set, but not used internally.
115 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::UNUSED, TEST_LOCATION );
117 // initialise handle with NEVER release policy
119 DALI_TEST_CHECK( !image );
121 image = FrameBufferImage::New(*(nativeImage.Get()), Image::NEVER);
123 DALI_TEST_CHECK( image );
125 // ReleasePolicy is deprecated. Only set, but not used internally.
126 DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
131 int UtcDaliFrameBufferImageAttachments01(void)
133 TestApplication application;
135 tet_infoline("UtcDaliFrameBufferImageAttachments01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
137 // invoke default handle constructor
138 FrameBufferImage image;
141 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR); // create framebuffer with Color buffer
142 ImageActor actor=ImageActor::New(image);
143 Stage::GetCurrent().Add(actor);
145 application.SendNotification();
146 application.Render();
147 application.Render();
148 application.SendNotification();
150 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
151 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
152 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
157 int UtcDaliFrameBufferImageAttachments02(void)
159 TestApplication application;
161 tet_infoline("UtcDaliFrameBufferImageAttachments02 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
163 // invoke default handle constructor
164 FrameBufferImage image;
167 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH); // create framebuffer with Color and Depth buffer
168 ImageActor actor=ImageActor::New(image);
169 Stage::GetCurrent().Add(actor);
171 application.SendNotification();
172 application.Render();
173 application.Render();
174 application.SendNotification();
176 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
177 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
178 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
183 int UtcDaliFrameBufferImageAttachments03(void)
185 TestApplication application;
187 tet_infoline("UtcDaliFrameBufferImageAttachments03 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
189 // invoke default handle constructor
190 FrameBufferImage image;
193 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_STENCIL); // create framebuffer with Color and Stencil
194 ImageActor actor=ImageActor::New(image);
195 Stage::GetCurrent().Add(actor);
197 application.SendNotification();
198 application.Render();
199 application.Render();
200 application.SendNotification();
202 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
203 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
204 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
209 int UtcDaliFrameBufferImageAttachments04(void)
211 TestApplication application;
213 tet_infoline("UtcDaliFrameBufferImageAttachments04 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
215 // invoke default handle constructor
216 FrameBufferImage image;
219 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH_STENCIL); // create framebuffer with Color, Depth and Stencil buffers
220 ImageActor actor=ImageActor::New(image);
221 Stage::GetCurrent().Add(actor);
223 application.SendNotification();
224 application.Render();
225 application.Render();
226 application.SendNotification();
228 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
229 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
230 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
235 int UtcDaliFrameBufferImageDownCast(void)
237 TestApplication application;
238 tet_infoline("Testing Dali::FrameBufferImage::DownCast()");
240 FrameBufferImage image = FrameBufferImage::New();
242 BaseHandle object(image);
244 FrameBufferImage image2 = FrameBufferImage::DownCast(object);
245 DALI_TEST_CHECK(image2);
247 FrameBufferImage image3 = DownCast< FrameBufferImage >(object);
248 DALI_TEST_CHECK(image3);
250 BaseHandle unInitializedObject;
251 FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject);
252 DALI_TEST_CHECK(!image4);
254 FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject);
255 DALI_TEST_CHECK(!image5);
257 Image image6 = FrameBufferImage::New();
258 FrameBufferImage image7 = FrameBufferImage::DownCast(image6);
259 DALI_TEST_CHECK(image7);