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