5ed410feb78e0c34edd85ac6b5b3bb4c19856e8a
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-unmanaged / utc-Dali-ShadowView.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22
23 using namespace Dali;
24 using namespace Dali::Toolkit;
25
26 void shadow_view_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void shadow_view_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36
37 // Negative test case for a method
38 int UtcDaliShadowViewUninitialized(void)
39 {
40   ToolkitTestApplication application;
41   tet_infoline("UtcDaliShadowViewUninitialized");
42
43   Toolkit::ShadowView view;
44   try
45   {
46     // New() must be called to create a GaussianBlurView or it wont be valid.
47     Actor a = Actor::New();
48     view.Add( a );
49     DALI_TEST_CHECK( false );
50   }
51   catch (Dali::DaliException& e)
52   {
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);
56   }
57   END_TEST;
58 }
59
60 // Positive test case for a method
61 int UtcDaliShadowViewNew(void)
62 {
63   ToolkitTestApplication application;
64   tet_infoline("UtcDaliShadowViewNew");
65
66   Toolkit::ShadowView view = Toolkit::ShadowView::New();
67   DALI_TEST_CHECK( view );
68
69   Toolkit::ShadowView view2 = Toolkit::ShadowView::New(1.0f, 1.0f);
70   DALI_TEST_CHECK( view2 );
71   END_TEST;
72 }
73
74 // Positive test case for a method
75 int UtcDaliShadowViewDownCast(void)
76 {
77   ToolkitTestApplication application;
78   tet_infoline("UtcDaliShadowViewDownCast");
79
80   Toolkit::ShadowView view = Toolkit::ShadowView::New();
81   BaseHandle handle(view);
82
83   Toolkit::ShadowView shadowView = Toolkit::ShadowView::DownCast( handle );
84   DALI_TEST_CHECK( view );
85   DALI_TEST_CHECK( shadowView );
86   DALI_TEST_CHECK( shadowView == view );
87   END_TEST;
88 }
89
90 // Positive test case for a method
91 int UtcDaliShadowViewPropertyNames(void)
92 {
93   ToolkitTestApplication application;
94   tet_infoline("UtcDaliShadowViewPropertyNames");
95
96   Toolkit::ShadowView view = Toolkit::ShadowView::New();
97   DALI_TEST_CHECK( view );
98
99   // Check the names, this names are used in the shader code,
100   // if they change in the shader code, then it has to be updated here.
101   DALI_TEST_EQUALS( view.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
102   DALI_TEST_EQUALS( view.GetShadowColorPropertyIndex(), view.GetPropertyIndex("ShadowColorProperty"), TEST_LOCATION );
103   END_TEST;
104 }
105
106 // Positive test case for a method
107 int UtcDaliShadowViewAddRemove(void)
108 {
109   ToolkitTestApplication application;
110   tet_infoline("UtcDaliShadowViewAddRemove");
111
112   Toolkit::ShadowView view = Toolkit::ShadowView::New();
113   DALI_TEST_CHECK( view );
114
115   Actor actor = Actor::New();
116   DALI_TEST_CHECK( !actor.OnStage() );
117
118
119   view.SetParentOrigin(ParentOrigin::CENTER);
120   view.SetSize(Stage::GetCurrent().GetSize());
121   view.Add(actor);
122   Stage::GetCurrent().Add(view);
123
124   DALI_TEST_CHECK( actor.OnStage() );
125
126   view.Remove(actor);
127
128   DALI_TEST_CHECK( !actor.OnStage() );
129   END_TEST;
130 }
131
132 // Positive test case for a method
133 int UtcDaliShadowViewActivateDeactivate(void)
134 {
135   ToolkitTestApplication application;
136   tet_infoline("UtcDaliShadowViewActivateDeactivate");
137
138   Toolkit::ShadowView view = Toolkit::ShadowView::New();
139   DALI_TEST_CHECK( view );
140
141   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
142   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
143
144   view.SetParentOrigin(ParentOrigin::CENTER);
145   view.SetSize(Stage::GetCurrent().GetSize());
146   view.Add(Actor::New());
147   Stage::GetCurrent().Add(view);
148   view.Activate();
149
150   RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
151   DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
152
153   view.Deactivate();
154
155   RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
156   DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );
157   END_TEST;
158 }