Merge remote-tracking branch 'origin/tizen' into new_text
[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/public-api/dali-core.h>
23 #include <dali-test-suite-utils.h>
24 #include <test-native-image.h>
25
26 using std::max;
27 using namespace Dali;
28
29 void utc_dali_framebuffer_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_framebuffer_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39 static const float ROTATION_EPSILON = 0.0001f;
40
41
42 int UtcDaliFrameBufferImageNew01(void)
43 {
44   TestApplication application;
45
46   tet_infoline("UtcDaliFrameBufferImageNew01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format)");
47
48   // invoke default handle constructor
49   FrameBufferImage image;
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   DALI_TEST_CHECK( image );
63   DALI_TEST_EQUALS((float)image.GetWidth(), stageSize.width, TEST_LOCATION);
64   DALI_TEST_EQUALS((float)image.GetHeight(), stageSize.height, TEST_LOCATION);
65
66   image = FrameBufferImage::New(16, 16);      // create framebuffer with dimensions of 16x16
67   actor.SetImage(image);
68
69   application.SendNotification();
70   application.Render();
71   application.Render();
72   application.SendNotification();
73
74   DALI_TEST_CHECK( image );
75   DALI_TEST_EQUALS(image.GetWidth(), 16u, TEST_LOCATION);
76   DALI_TEST_EQUALS(image.GetHeight(), 16u, TEST_LOCATION);
77   END_TEST;
78 }
79
80 int UtcDaliFrameBufferImageNew02(void)
81 {
82   TestApplication application;
83
84   tet_infoline("UtcDaliFrameBufferImageNew02 - FrameBufferImage::New(NativeImageInterface&)");
85
86   // invoke default handle constructor
87   FrameBufferImage image;
88   TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
89
90   DALI_TEST_CHECK( !image );
91
92   // initialise handle
93   image = FrameBufferImage::New(*(nativeImage.Get()));
94
95   DALI_TEST_CHECK( image );
96   END_TEST;
97 }
98
99 int UtcDaliFrameBufferImageDownCast(void)
100 {
101   TestApplication application;
102   tet_infoline("Testing Dali::FrameBufferImage::DownCast()");
103
104   FrameBufferImage image = FrameBufferImage::New();
105
106   BaseHandle object(image);
107
108   FrameBufferImage image2 = FrameBufferImage::DownCast(object);
109   DALI_TEST_CHECK(image2);
110
111   FrameBufferImage image3 = DownCast< FrameBufferImage >(object);
112   DALI_TEST_CHECK(image3);
113
114   BaseHandle unInitializedObject;
115   FrameBufferImage image4 = FrameBufferImage::DownCast(unInitializedObject);
116   DALI_TEST_CHECK(!image4);
117
118   FrameBufferImage image5 = DownCast< FrameBufferImage >(unInitializedObject);
119   DALI_TEST_CHECK(!image5);
120
121   Image image6 = FrameBufferImage::New();
122   FrameBufferImage image7 = FrameBufferImage::DownCast(image6);
123   DALI_TEST_CHECK(image7);
124   END_TEST;
125 }