License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-FrameBufferImage.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <algorithm>
20
21 #include <stdlib.h>
22 #include <dali/dali.h>
23 #include <dali-test-suite-utils.h>
24
25 using std::max;
26 using namespace Dali;
27
28 void utc_dali_framebuffer_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void utc_dali_framebuffer_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 static const float ROTATION_EPSILON = 0.0001f;
39
40
41 int UtcDaliFrameBufferImageNew01(void)
42 {
43   TestApplication application;
44
45   tet_infoline("UtcDaliFrameBufferImageNew01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format)");
46
47   // invoke default handle constructor
48   FrameBufferImage image;
49   Dali::ImageAttributes attributes;
50   Vector2 stageSize = Stage::GetCurrent().GetSize();
51
52   // initialise handle
53   image = FrameBufferImage::New();            // create framebuffer with the same dimensions as the stage
54   ImageActor actor=ImageActor::New(image);
55   Stage::GetCurrent().Add(actor);
56
57   application.SendNotification();
58   application.Render();
59   application.Render();
60   application.SendNotification();
61
62   attributes = image.GetAttributes();
63
64   DALI_TEST_CHECK( image );
65   DALI_TEST_EQUALS((float)attributes.GetWidth(), stageSize.width, TEST_LOCATION);
66   DALI_TEST_EQUALS((float)attributes.GetHeight(), stageSize.height, TEST_LOCATION);
67
68   image = FrameBufferImage::New(16, 16);      // create framebuffer with dimensions of 16x16
69   actor.SetImage(image);
70
71   application.SendNotification();
72   application.Render();
73   application.Render();
74   application.SendNotification();
75
76   attributes = image.GetAttributes();
77
78   DALI_TEST_CHECK( image );
79   DALI_TEST_EQUALS(attributes.GetWidth(), 16u, TEST_LOCATION);
80   DALI_TEST_EQUALS(attributes.GetHeight(), 16u, TEST_LOCATION);
81   END_TEST;
82 }
83
84 int UtcDaliFrameBufferImageDownCast(void)
85 {
86   TestApplication application;
87   tet_infoline("Testing Dali::FrameBufferImage::DownCast()");
88
89   FrameBufferImage image = FrameBufferImage::New();
90
91   BaseHandle object(image);
92
93   FrameBufferImage image2 = FrameBufferImage::DownCast(object);
94   DALI_TEST_CHECK(image2);
95
96   FrameBufferImage image3 = DownCast< FrameBufferImage >(object);
97   DALI_TEST_CHECK(image3);
98
99   BaseHandle unInitializedObject;
100   FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject);
101   DALI_TEST_CHECK(!image4);
102
103   FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject);
104   DALI_TEST_CHECK(!image5);
105
106   Image image6 = FrameBufferImage::New();
107   FrameBufferImage image7 = FrameBufferImage::DownCast(image6);
108   DALI_TEST_CHECK(image7);
109   END_TEST;
110 }