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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali-toolkit/dali-toolkit.h>
23 using namespace Dali::Toolkit;
26 void bloom_view_startup(void)
28 test_return_value = TET_UNDEF;
31 void bloom_view_cleanup(void)
33 test_return_value = TET_PASS;
36 // Negative test case for a method
37 int UtcDaliBloomViewUninitialized(void)
39 ToolkitTestApplication application;
40 tet_infoline(" UtcDaliBloomViewUninitialized");
42 Toolkit::BloomView view;
46 // New() must be called to create a BloomView or it wont be valid.
47 Actor a = Actor::New();
49 DALI_TEST_CHECK( false );
51 catch (Dali::DaliException& e)
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);
60 // Positive test case for a method
61 int UtcDaliBloomViewNew(void)
63 ToolkitTestApplication application;
64 tet_infoline(" UtcDaliBloomViewNew");
66 Toolkit::BloomView view = Toolkit::BloomView::New();
67 DALI_TEST_CHECK( view );
69 Toolkit::BloomView view2 = Toolkit::BloomView::New(10, 1.0f, Pixel::RGB888, 0.5f, 0.5f);
70 DALI_TEST_CHECK( view2 );
74 // Positive test case for a method
75 int UtcDaliBloomViewDownCast(void)
77 ToolkitTestApplication application;
78 tet_infoline(" UtcDaliBloomViewDownCast");
80 Toolkit::BloomView view = Toolkit::BloomView::New();
81 BaseHandle handle(view);
83 Toolkit::BloomView bloomView = Toolkit::BloomView::DownCast( handle );
84 DALI_TEST_CHECK( view );
85 DALI_TEST_CHECK( bloomView );
86 DALI_TEST_CHECK( bloomView == view );
91 // Positive test case for a method
92 int UtcDaliBloomViewPropertyNames(void)
94 ToolkitTestApplication application;
95 tet_infoline(" UtcDaliBloomViewPropertyNames");
97 Toolkit::BloomView view = Toolkit::BloomView::New();
98 DALI_TEST_CHECK( view );
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 );
111 // Positive test case for a method
112 int UtcDaliBloomViewAddRemove(void)
114 ToolkitTestApplication application;
115 tet_infoline(" UtcDaliBloomViewAddRemove");
117 Toolkit::BloomView view = Toolkit::BloomView::New();
118 DALI_TEST_CHECK( view );
120 Actor actor = Actor::New();
121 DALI_TEST_CHECK( !actor.OnStage() );
124 view.SetParentOrigin(ParentOrigin::CENTER);
125 view.SetSize(Stage::GetCurrent().GetSize());
127 Stage::GetCurrent().Add(view);
129 DALI_TEST_CHECK( actor.OnStage() );
133 DALI_TEST_CHECK( !actor.OnStage() );
137 // Positive test case for a method
138 int UtcDaliBloomActivateDeactivate(void)
140 ToolkitTestApplication application;
141 tet_infoline(" UtcDaliBloomActivateDeactivate");
143 Toolkit::BloomView view = Toolkit::BloomView::New();
144 DALI_TEST_CHECK( view );
146 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
147 DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
149 view.SetParentOrigin(ParentOrigin::CENTER);
150 view.SetSize(Stage::GetCurrent().GetSize());
151 view.Add(Actor::New());
152 Stage::GetCurrent().Add(view);
155 RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
156 DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
160 RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
161 DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );