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;
32 static void Startup();
33 static void Cleanup();
36 void (*tet_startup)() = Startup;
37 void (*tet_cleanup)() = Cleanup;
40 static void UtcDaliShadowViewUninitialized();
41 static void UtcDaliShadowViewNew();
42 static void UtcDaliShadowViewDownCast();
43 static void UtcDaliShadowViewPropertyNames();
44 static void UtcDaliShadowViewAddRemove();
45 static void UtcDaliShadowViewActivateDeactivate();
49 POSITIVE_TC_IDX = 0x01,
53 // Add test functionality for all APIs in the class (Positive and Negative)
55 struct tet_testlist tet_testlist[] = {
56 { UtcDaliShadowViewUninitialized, NEGATIVE_TC_IDX },
57 { UtcDaliShadowViewNew, POSITIVE_TC_IDX },
58 { UtcDaliShadowViewDownCast, POSITIVE_TC_IDX },
59 { UtcDaliShadowViewPropertyNames, POSITIVE_TC_IDX },
60 { UtcDaliShadowViewAddRemove, POSITIVE_TC_IDX },
61 { UtcDaliShadowViewActivateDeactivate, POSITIVE_TC_IDX },
66 // Called only once before first test is run.
71 // Called only once after last test is run
76 // Negative test case for a method
77 static void UtcDaliShadowViewUninitialized()
79 ToolkitTestApplication application;
80 tet_infoline("UtcDaliShadowViewUninitialized");
82 Toolkit::ShadowView view;
85 // New() must be called to create a GaussianBlurView or it wont be valid.
86 Actor a = Actor::New();
88 DALI_TEST_CHECK( false );
90 catch (Dali::DaliException& e)
92 // Tests that a negative test of an assertion succeeds
93 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
94 DALI_TEST_CHECK(!view);
98 // Positive test case for a method
99 static void UtcDaliShadowViewNew()
101 ToolkitTestApplication application;
102 tet_infoline("UtcDaliShadowViewNew");
104 Toolkit::ShadowView view = Toolkit::ShadowView::New();
105 DALI_TEST_CHECK( view );
107 Toolkit::ShadowView view2 = Toolkit::ShadowView::New(1.0f, 1.0f);
108 DALI_TEST_CHECK( view2 );
111 // Positive test case for a method
112 static void UtcDaliShadowViewDownCast()
114 ToolkitTestApplication application;
115 tet_infoline("UtcDaliShadowViewDownCast");
117 Toolkit::ShadowView view = Toolkit::ShadowView::New();
118 BaseHandle handle(view);
120 Toolkit::ShadowView shadowView = Toolkit::ShadowView::DownCast( handle );
121 DALI_TEST_CHECK( view );
122 DALI_TEST_CHECK( shadowView );
123 DALI_TEST_CHECK( shadowView == view );
126 // Positive test case for a method
127 static void UtcDaliShadowViewPropertyNames()
129 ToolkitTestApplication application;
130 tet_infoline("UtcDaliShadowViewPropertyNames");
132 Toolkit::ShadowView view = Toolkit::ShadowView::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.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
138 DALI_TEST_EQUALS( view.GetShadowColorPropertyIndex(), view.GetPropertyIndex("ShadowColorProperty"), TEST_LOCATION );
141 // Positive test case for a method
142 static void UtcDaliShadowViewAddRemove()
144 ToolkitTestApplication application;
145 tet_infoline("UtcDaliShadowViewAddRemove");
147 Toolkit::ShadowView view = Toolkit::ShadowView::New();
148 DALI_TEST_CHECK( view );
150 Actor actor = Actor::New();
151 DALI_TEST_CHECK( !actor.OnStage() );
154 view.SetParentOrigin(ParentOrigin::CENTER);
155 view.SetSize(Stage::GetCurrent().GetSize());
157 Stage::GetCurrent().Add(view);
159 DALI_TEST_CHECK( actor.OnStage() );
163 DALI_TEST_CHECK( !actor.OnStage() );
166 // Positive test case for a method
167 static void UtcDaliShadowViewActivateDeactivate()
169 ToolkitTestApplication application;
170 tet_infoline("UtcDaliShadowViewActivateDeactivate");
172 Toolkit::ShadowView view = Toolkit::ShadowView::New();
173 DALI_TEST_CHECK( view );
175 RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
176 DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
178 view.SetParentOrigin(ParentOrigin::CENTER);
179 view.SetSize(Stage::GetCurrent().GetSize());
180 view.Add(Actor::New());
181 Stage::GetCurrent().Add(view);
184 RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
185 DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
189 RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
190 DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );