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