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.
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 );
104 image = FrameBufferImage::New(*(nativeImage.Get()));
106 DALI_TEST_CHECK( image );
111 int UtcDaliFrameBufferImageAttachments01(void)
113 TestApplication application;
115 tet_infoline("UtcDaliFrameBufferImageAttachments01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
117 // invoke default handle constructor
118 FrameBufferImage image;
121 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR); // create framebuffer with Color buffer
122 Actor actor = CreateRenderableActor(image);
123 Stage::GetCurrent().Add(actor);
125 application.SendNotification();
126 application.Render();
127 application.Render();
128 application.SendNotification();
130 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
131 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
132 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
137 int UtcDaliFrameBufferImageAttachments02(void)
139 TestApplication application;
141 tet_infoline("UtcDaliFrameBufferImageAttachments02 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
143 // invoke default handle constructor
144 FrameBufferImage image;
147 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH); // create framebuffer with Color and Depth buffer
148 Actor actor = CreateRenderableActor(image);
149 Stage::GetCurrent().Add(actor);
151 application.SendNotification();
152 application.Render();
153 application.Render();
154 application.SendNotification();
156 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
157 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
158 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
163 int UtcDaliFrameBufferImageAttachments03(void)
165 TestApplication application;
167 tet_infoline("UtcDaliFrameBufferImageAttachments03 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
169 // invoke default handle constructor
170 FrameBufferImage image;
173 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_STENCIL); // create framebuffer with Color and Stencil
174 Actor actor = CreateRenderableActor(image);
175 Stage::GetCurrent().Add(actor);
177 application.SendNotification();
178 application.Render();
179 application.Render();
180 application.SendNotification();
182 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
183 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
184 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
189 int UtcDaliFrameBufferImageAttachments04(void)
191 TestApplication application;
193 tet_infoline("UtcDaliFrameBufferImageAttachments04 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
195 // invoke default handle constructor
196 FrameBufferImage image;
199 image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH_STENCIL); // create framebuffer with Color, Depth and Stencil buffers
200 Actor actor = CreateRenderableActor(image);
201 Stage::GetCurrent().Add(actor);
203 application.SendNotification();
204 application.Render();
205 application.Render();
206 application.SendNotification();
208 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
209 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
210 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
215 int UtcDaliFrameBufferImageDownCast(void)
217 TestApplication application;
218 tet_infoline("Testing Dali::FrameBufferImage::DownCast()");
220 FrameBufferImage image = FrameBufferImage::New();
222 BaseHandle object(image);
224 FrameBufferImage image2 = FrameBufferImage::DownCast(object);
225 DALI_TEST_CHECK(image2);
227 FrameBufferImage image3 = DownCast< FrameBufferImage >(object);
228 DALI_TEST_CHECK(image3);
230 BaseHandle unInitializedObject;
231 FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject);
232 DALI_TEST_CHECK(!image4);
234 FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject);
235 DALI_TEST_CHECK(!image5);
237 Image image6 = FrameBufferImage::New();
238 FrameBufferImage image7 = FrameBufferImage::DownCast(image6);
239 DALI_TEST_CHECK(image7);