2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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-toolkit/dali-toolkit.h>
25 #include <dali-toolkit-test-suite-utils.h>
28 using namespace Dali::Toolkit;
30 static void Startup();
31 static void Cleanup();
34 void (*tet_startup)() = Startup;
35 void (*tet_cleanup)() = Cleanup;
38 static void UtcDaliBloomViewUninitialized();
39 static void UtcDaliBloomViewNew();
40 static void UtcDaliBloomViewDownCast();
41 static void UtcDaliBloomViewPropertyNames();
42 static void UtcDaliBloomViewAddRemove();
43 static void UtcDaliBloomActivateDeactivate();
46 POSITIVE_TC_IDX = 0x01,
50 // Add test functionality for all APIs in the class (Positive and Negative)
52 struct tet_testlist tet_testlist[] = {
53 { UtcDaliBloomViewUninitialized, NEGATIVE_TC_IDX },
54 { UtcDaliBloomViewNew, POSITIVE_TC_IDX },
55 { UtcDaliBloomViewDownCast, POSITIVE_TC_IDX },
56 { UtcDaliBloomViewPropertyNames, POSITIVE_TC_IDX },
57 { UtcDaliBloomViewAddRemove, POSITIVE_TC_IDX },
58 { UtcDaliBloomActivateDeactivate, POSITIVE_TC_IDX },
63 // Called only once before first test is run.
68 // Called only once after last test is run
73 // Negative test case for a method
74 static void UtcDaliBloomViewUninitialized()
76 ToolkitTestApplication application;
77 tet_infoline(" UtcDaliBloomViewUninitialized");
79 Toolkit::BloomView view;
83 // New() must be called to create a BloomView or it wont be valid.
84 Actor a = Actor::New();
86 DALI_TEST_CHECK( false );
88 catch (Dali::DaliException& e)
90 // Tests that a negative test of an assertion succeeds
91 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
92 DALI_TEST_CHECK(!view);
96 // Positive test case for a method
97 static void UtcDaliBloomViewNew()
99 ToolkitTestApplication application;
100 tet_infoline(" UtcDaliBloomViewNew");
102 Toolkit::BloomView view = Toolkit::BloomView::New();
103 DALI_TEST_CHECK( view );
105 Toolkit::BloomView view2 = Toolkit::BloomView::New(10, 1.0f, Pixel::RGB888, 0.5f, 0.5f);
106 DALI_TEST_CHECK( view2 );
109 // Positive test case for a method
110 static void UtcDaliBloomViewDownCast()
112 ToolkitTestApplication application;
113 tet_infoline(" UtcDaliBloomViewDownCast");
115 Toolkit::BloomView view = Toolkit::BloomView::New();
116 BaseHandle handle(view);
118 Toolkit::BloomView bloomView = Toolkit::BloomView::DownCast( handle );
119 DALI_TEST_CHECK( view );
120 DALI_TEST_CHECK( bloomView );
121 DALI_TEST_CHECK( bloomView == view );
125 // Positive test case for a method
126 static void UtcDaliBloomViewPropertyNames()
128 ToolkitTestApplication application;
129 tet_infoline(" UtcDaliBloomViewPropertyNames");
131 Toolkit::BloomView view = Toolkit::BloomView::New();
132 DALI_TEST_CHECK( view );
134 // Check the names, this names are used in the shader code,
135 // if they change in the shader code, then it has to be updated here.
136 DALI_TEST_EQUALS( view.GetBloomThresholdPropertyIndex(), view.GetPropertyIndex("uBloomThreshold"), TEST_LOCATION );
137 DALI_TEST_EQUALS( view.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
138 DALI_TEST_EQUALS( view.GetBloomIntensityPropertyIndex(), view.GetPropertyIndex("uBloomIntensity"), TEST_LOCATION );
139 DALI_TEST_EQUALS( view.GetBloomSaturationPropertyIndex(), view.GetPropertyIndex("uBloomSaturation"), TEST_LOCATION );
140 DALI_TEST_EQUALS( view.GetImageIntensityPropertyIndex(), view.GetPropertyIndex("uImageIntensity"), TEST_LOCATION );
141 DALI_TEST_EQUALS( view.GetImageSaturationPropertyIndex(), view.GetPropertyIndex("uImageSaturation"), TEST_LOCATION );
144 // Positive test case for a method
145 static void UtcDaliBloomViewAddRemove()
147 ToolkitTestApplication application;
148 tet_infoline(" UtcDaliBloomViewAddRemove");
150 Toolkit::BloomView view = Toolkit::BloomView::New();
151 DALI_TEST_CHECK( view );
153 Actor actor = Actor::New();
154 DALI_TEST_CHECK( !actor.OnStage() );
157 view.SetParentOrigin(ParentOrigin::CENTER);
158 view.SetSize(Stage::GetCurrent().GetSize());
160 Stage::GetCurrent().Add(view);
162 DALI_TEST_CHECK( actor.OnStage() );
166 DALI_TEST_CHECK( !actor.OnStage() );
169 // Positive test case for a method
170 static void UtcDaliBloomActivateDeactivate()
172 ToolkitTestApplication application;
173 tet_infoline(" UtcDaliBloomActivateDeactivate");
175 Toolkit::BloomView view = Toolkit::BloomView::New();
176 DALI_TEST_CHECK( view );
178 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
179 DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
181 view.SetParentOrigin(ParentOrigin::CENTER);
182 view.SetSize(Stage::GetCurrent().GetSize());
183 view.Add(Actor::New());
184 Stage::GetCurrent().Add(view);
187 RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
188 DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
192 RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
193 DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );