2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <dali/public-api/dali-core.h>
24 #include <dali-toolkit/dali-toolkit.h>
26 #include <dali-toolkit-test-suite-utils.h>
29 using namespace Dali::Toolkit;
31 static void Startup();
32 static void Cleanup();
35 void (*tet_startup)() = Startup;
36 void (*tet_cleanup)() = Cleanup;
39 static void UtcDaliBloomViewUninitialized();
40 static void UtcDaliBloomViewNew();
41 static void UtcDaliBloomViewDownCast();
42 static void UtcDaliBloomViewPropertyNames();
43 static void UtcDaliBloomViewAddRemove();
44 static void UtcDaliBloomActivateDeactivate();
47 POSITIVE_TC_IDX = 0x01,
51 // Add test functionality for all APIs in the class (Positive and Negative)
53 struct tet_testlist tet_testlist[] = {
54 { UtcDaliBloomViewUninitialized, NEGATIVE_TC_IDX },
55 { UtcDaliBloomViewNew, POSITIVE_TC_IDX },
56 { UtcDaliBloomViewDownCast, POSITIVE_TC_IDX },
57 { UtcDaliBloomViewPropertyNames, POSITIVE_TC_IDX },
58 { UtcDaliBloomViewAddRemove, POSITIVE_TC_IDX },
59 { UtcDaliBloomActivateDeactivate, POSITIVE_TC_IDX },
64 // Called only once before first test is run.
69 // Called only once after last test is run
74 // Negative test case for a method
75 static void UtcDaliBloomViewUninitialized()
77 ToolkitTestApplication application;
78 tet_infoline(" UtcDaliBloomViewUninitialized");
80 Toolkit::BloomView view;
84 // New() must be called to create a BloomView or it wont be valid.
85 Actor a = Actor::New();
87 DALI_TEST_CHECK( false );
89 catch (Dali::DaliException& e)
91 // Tests that a negative test of an assertion succeeds
92 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
93 DALI_TEST_CHECK(!view);
97 // Positive test case for a method
98 static void UtcDaliBloomViewNew()
100 ToolkitTestApplication application;
101 tet_infoline(" UtcDaliBloomViewNew");
103 Toolkit::BloomView view = Toolkit::BloomView::New();
104 DALI_TEST_CHECK( view );
106 Toolkit::BloomView view2 = Toolkit::BloomView::New(10, 1.0f, Pixel::RGB888, 0.5f, 0.5f);
107 DALI_TEST_CHECK( view2 );
110 // Positive test case for a method
111 static void UtcDaliBloomViewDownCast()
113 ToolkitTestApplication application;
114 tet_infoline(" UtcDaliBloomViewDownCast");
116 Toolkit::BloomView view = Toolkit::BloomView::New();
117 BaseHandle handle(view);
119 Toolkit::BloomView bloomView = Toolkit::BloomView::DownCast( handle );
120 DALI_TEST_CHECK( view );
121 DALI_TEST_CHECK( bloomView );
122 DALI_TEST_CHECK( bloomView == view );
126 // Positive test case for a method
127 static void UtcDaliBloomViewPropertyNames()
129 ToolkitTestApplication application;
130 tet_infoline(" UtcDaliBloomViewPropertyNames");
132 Toolkit::BloomView view = Toolkit::BloomView::New();
133 DALI_TEST_CHECK( view );
135 // Check the names, this names are used in the shader code,
136 // if they change in the shader code, then it has to be updated here.
137 DALI_TEST_EQUALS( view.GetBloomThresholdPropertyIndex(), view.GetPropertyIndex("uBloomThreshold"), TEST_LOCATION );
138 DALI_TEST_EQUALS( view.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
139 DALI_TEST_EQUALS( view.GetBloomIntensityPropertyIndex(), view.GetPropertyIndex("uBloomIntensity"), TEST_LOCATION );
140 DALI_TEST_EQUALS( view.GetBloomSaturationPropertyIndex(), view.GetPropertyIndex("uBloomSaturation"), TEST_LOCATION );
141 DALI_TEST_EQUALS( view.GetImageIntensityPropertyIndex(), view.GetPropertyIndex("uImageIntensity"), TEST_LOCATION );
142 DALI_TEST_EQUALS( view.GetImageSaturationPropertyIndex(), view.GetPropertyIndex("uImageSaturation"), TEST_LOCATION );
145 // Positive test case for a method
146 static void UtcDaliBloomViewAddRemove()
148 ToolkitTestApplication application;
149 tet_infoline(" UtcDaliBloomViewAddRemove");
151 Toolkit::BloomView view = Toolkit::BloomView::New();
152 DALI_TEST_CHECK( view );
154 Actor actor = Actor::New();
155 DALI_TEST_CHECK( !actor.OnStage() );
158 view.SetParentOrigin(ParentOrigin::CENTER);
159 view.SetSize(Stage::GetCurrent().GetSize());
161 Stage::GetCurrent().Add(view);
163 DALI_TEST_CHECK( actor.OnStage() );
167 DALI_TEST_CHECK( !actor.OnStage() );
170 // Positive test case for a method
171 static void UtcDaliBloomActivateDeactivate()
173 ToolkitTestApplication application;
174 tet_infoline(" UtcDaliBloomActivateDeactivate");
176 Toolkit::BloomView view = Toolkit::BloomView::New();
177 DALI_TEST_CHECK( view );
179 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
180 DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
182 view.SetParentOrigin(ParentOrigin::CENTER);
183 view.SetSize(Stage::GetCurrent().GetSize());
184 view.Add(Actor::New());
185 Stage::GetCurrent().Add(view);
188 RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
189 DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
193 RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
194 DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );