Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-unmanaged / utc-Dali-BloomView.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 <stdlib.h>
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali-toolkit/dali-toolkit.h>
21
22 using namespace Dali;
23 using namespace Dali::Toolkit;
24
25
26 void bloom_view_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void bloom_view_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 // Negative test case for a method
37 int UtcDaliBloomViewUninitialized(void)
38 {
39   ToolkitTestApplication application;
40   tet_infoline(" UtcDaliBloomViewUninitialized");
41
42   Toolkit::BloomView view;
43
44   try
45   {
46     // New() must be called to create a BloomView or it wont be valid.
47     Actor a = Actor::New();
48     view.Add( a );
49     DALI_TEST_CHECK( false );
50   }
51   catch (Dali::DaliException& e)
52   {
53     // Tests that a negative test of an assertion succeeds
54     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
55     DALI_TEST_CHECK(!view);
56   }
57   END_TEST;
58 }
59
60 // Positive test case for a method
61 int UtcDaliBloomViewNew(void)
62 {
63   ToolkitTestApplication application;
64   tet_infoline(" UtcDaliBloomViewNew");
65
66   Toolkit::BloomView view = Toolkit::BloomView::New();
67   DALI_TEST_CHECK( view );
68
69   Toolkit::BloomView view2 = Toolkit::BloomView::New(10, 1.0f, Pixel::RGB888, 0.5f, 0.5f);
70   DALI_TEST_CHECK( view2 );
71   END_TEST;
72 }
73
74 // Positive test case for a method
75 int UtcDaliBloomViewDownCast(void)
76 {
77   ToolkitTestApplication application;
78   tet_infoline(" UtcDaliBloomViewDownCast");
79
80   Toolkit::BloomView view = Toolkit::BloomView::New();
81   BaseHandle handle(view);
82
83   Toolkit::BloomView bloomView = Toolkit::BloomView::DownCast( handle );
84   DALI_TEST_CHECK( view );
85   DALI_TEST_CHECK( bloomView );
86   DALI_TEST_CHECK( bloomView == view );
87   END_TEST;
88 }
89
90
91 // Positive test case for a method
92 int UtcDaliBloomViewPropertyNames(void)
93 {
94   ToolkitTestApplication application;
95   tet_infoline(" UtcDaliBloomViewPropertyNames");
96
97   Toolkit::BloomView view = Toolkit::BloomView::New();
98   DALI_TEST_CHECK( view );
99
100   // Check the names, this names are used in the shader code,
101   // if they change in the shader code, then it has to be updated here.
102   DALI_TEST_EQUALS( view.GetBloomThresholdPropertyIndex(), view.GetPropertyIndex("uBloomThreshold"), TEST_LOCATION );
103   DALI_TEST_EQUALS( view.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
104   DALI_TEST_EQUALS( view.GetBloomIntensityPropertyIndex(), view.GetPropertyIndex("uBloomIntensity"), TEST_LOCATION );
105   DALI_TEST_EQUALS( view.GetBloomSaturationPropertyIndex(), view.GetPropertyIndex("uBloomSaturation"), TEST_LOCATION );
106   DALI_TEST_EQUALS( view.GetImageIntensityPropertyIndex(), view.GetPropertyIndex("uImageIntensity"), TEST_LOCATION );
107   DALI_TEST_EQUALS( view.GetImageSaturationPropertyIndex(), view.GetPropertyIndex("uImageSaturation"), TEST_LOCATION );
108   END_TEST;
109 }
110
111 // Positive test case for a method
112 int UtcDaliBloomViewAddRemove(void)
113 {
114   ToolkitTestApplication application;
115   tet_infoline(" UtcDaliBloomViewAddRemove");
116
117   Toolkit::BloomView view = Toolkit::BloomView::New();
118   DALI_TEST_CHECK( view );
119
120   Actor actor = Actor::New();
121   DALI_TEST_CHECK( !actor.OnStage() );
122
123
124   view.SetParentOrigin(ParentOrigin::CENTER);
125   view.SetSize(Stage::GetCurrent().GetSize());
126   view.Add(actor);
127   Stage::GetCurrent().Add(view);
128
129   DALI_TEST_CHECK( actor.OnStage() );
130
131   view.Remove(actor);
132
133   DALI_TEST_CHECK( !actor.OnStage() );
134   END_TEST;
135 }
136
137 // Positive test case for a method
138 int UtcDaliBloomActivateDeactivate(void)
139 {
140   ToolkitTestApplication application;
141   tet_infoline(" UtcDaliBloomActivateDeactivate");
142
143   Toolkit::BloomView view = Toolkit::BloomView::New();
144   DALI_TEST_CHECK( view );
145
146   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
147   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
148
149   view.SetParentOrigin(ParentOrigin::CENTER);
150   view.SetSize(Stage::GetCurrent().GetSize());
151   view.Add(Actor::New());
152   Stage::GetCurrent().Add(view);
153   view.Activate();
154
155   RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
156   DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
157
158   view.Deactivate();
159
160   RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
161   DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );
162   END_TEST;
163 }