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;
31 static void Startup();
32 static void Cleanup();
35 void (*tet_startup)() = Startup;
36 void (*tet_cleanup)() = Cleanup;
39 static void UtcDaliShadowViewUninitialized();
40 static void UtcDaliShadowViewNew();
41 static void UtcDaliShadowViewDownCast();
42 static void UtcDaliShadowViewPropertyNames();
43 static void UtcDaliShadowViewAddRemove();
44 static void UtcDaliShadowViewActivateDeactivate();
48 POSITIVE_TC_IDX = 0x01,
52 // Add test functionality for all APIs in the class (Positive and Negative)
54 struct tet_testlist tet_testlist[] = {
55 { UtcDaliShadowViewUninitialized, NEGATIVE_TC_IDX },
56 { UtcDaliShadowViewNew, POSITIVE_TC_IDX },
57 { UtcDaliShadowViewDownCast, POSITIVE_TC_IDX },
58 { UtcDaliShadowViewPropertyNames, POSITIVE_TC_IDX },
59 { UtcDaliShadowViewAddRemove, POSITIVE_TC_IDX },
60 { UtcDaliShadowViewActivateDeactivate, POSITIVE_TC_IDX },
65 // Called only once before first test is run.
70 // Called only once after last test is run
75 // Negative test case for a method
76 static void UtcDaliShadowViewUninitialized()
78 ToolkitTestApplication application;
79 tet_infoline("UtcDaliShadowViewUninitialized");
81 Toolkit::ShadowView view;
84 // New() must be called to create a GaussianBlurView 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 UtcDaliShadowViewNew()
100 ToolkitTestApplication application;
101 tet_infoline("UtcDaliShadowViewNew");
103 Toolkit::ShadowView view = Toolkit::ShadowView::New();
104 DALI_TEST_CHECK( view );
106 Toolkit::ShadowView view2 = Toolkit::ShadowView::New(1.0f, 1.0f);
107 DALI_TEST_CHECK( view2 );
110 // Positive test case for a method
111 static void UtcDaliShadowViewDownCast()
113 ToolkitTestApplication application;
114 tet_infoline("UtcDaliShadowViewDownCast");
116 Toolkit::ShadowView view = Toolkit::ShadowView::New();
117 BaseHandle handle(view);
119 Toolkit::ShadowView shadowView = Toolkit::ShadowView::DownCast( handle );
120 DALI_TEST_CHECK( view );
121 DALI_TEST_CHECK( shadowView );
122 DALI_TEST_CHECK( shadowView == view );
125 // Positive test case for a method
126 static void UtcDaliShadowViewPropertyNames()
128 ToolkitTestApplication application;
129 tet_infoline("UtcDaliShadowViewPropertyNames");
131 Toolkit::ShadowView view = Toolkit::ShadowView::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.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
137 DALI_TEST_EQUALS( view.GetShadowColorPropertyIndex(), view.GetPropertyIndex("ShadowColorProperty"), TEST_LOCATION );
140 // Positive test case for a method
141 static void UtcDaliShadowViewAddRemove()
143 ToolkitTestApplication application;
144 tet_infoline("UtcDaliShadowViewAddRemove");
146 Toolkit::ShadowView view = Toolkit::ShadowView::New();
147 DALI_TEST_CHECK( view );
149 Actor actor = Actor::New();
150 DALI_TEST_CHECK( !actor.OnStage() );
153 view.SetParentOrigin(ParentOrigin::CENTER);
154 view.SetSize(Stage::GetCurrent().GetSize());
156 Stage::GetCurrent().Add(view);
158 DALI_TEST_CHECK( actor.OnStage() );
162 DALI_TEST_CHECK( !actor.OnStage() );
165 // Positive test case for a method
166 static void UtcDaliShadowViewActivateDeactivate()
168 ToolkitTestApplication application;
169 tet_infoline("UtcDaliShadowViewActivateDeactivate");
171 Toolkit::ShadowView view = Toolkit::ShadowView::New();
172 DALI_TEST_CHECK( view );
174 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
175 DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
177 view.SetParentOrigin(ParentOrigin::CENTER);
178 view.SetSize(Stage::GetCurrent().GetSize());
179 view.Add(Actor::New());
180 Stage::GetCurrent().Add(view);
183 RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
184 DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
188 RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
189 DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );