Property refactor in dali-core: Toolkit changes for compiling
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-BloomView.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
27 void bloom_view_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void bloom_view_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37 // Negative test case for a method
38 int UtcDaliBloomViewUninitialized(void)
39 {
40   ToolkitTestApplication application;
41   tet_infoline(" UtcDaliBloomViewUninitialized");
42
43   Toolkit::BloomView view;
44
45   try
46   {
47     // New() must be called to create a BloomView or it wont be valid.
48     Actor a = Actor::New();
49     view.Add( a );
50     DALI_TEST_CHECK( false );
51   }
52   catch (Dali::DaliException& e)
53   {
54     // Tests that a negative test of an assertion succeeds
55     DALI_TEST_PRINT_ASSERT( e );
56     DALI_TEST_CHECK(!view);
57   }
58   END_TEST;
59 }
60
61 // Positive test case for a method
62 int UtcDaliBloomViewNew(void)
63 {
64   ToolkitTestApplication application;
65   tet_infoline(" UtcDaliBloomViewNew");
66
67   Toolkit::BloomView view = Toolkit::BloomView::New();
68   DALI_TEST_CHECK( view );
69
70   Toolkit::BloomView view2 = Toolkit::BloomView::New(10, 1.0f, Pixel::RGB888, 0.5f, 0.5f);
71   DALI_TEST_CHECK( view2 );
72   END_TEST;
73 }
74
75 // Positive test case for a method
76 int UtcDaliBloomViewDownCast(void)
77 {
78   ToolkitTestApplication application;
79   tet_infoline(" UtcDaliBloomViewDownCast");
80
81   Toolkit::BloomView view = Toolkit::BloomView::New();
82   BaseHandle handle(view);
83
84   Toolkit::BloomView bloomView = Toolkit::BloomView::DownCast( handle );
85   DALI_TEST_CHECK( view );
86   DALI_TEST_CHECK( bloomView );
87   DALI_TEST_CHECK( bloomView == view );
88   END_TEST;
89 }
90
91
92 // Positive test case for a method
93 int UtcDaliBloomViewPropertyNames(void)
94 {
95   ToolkitTestApplication application;
96   tet_infoline(" UtcDaliBloomViewPropertyNames");
97
98   Toolkit::BloomView view = Toolkit::BloomView::New();
99   DALI_TEST_CHECK( view );
100
101   // Check the names, this names are used in the shader code,
102   // if they change in the shader code, then it has to be updated here.
103   DALI_TEST_EQUALS( view.GetBloomThresholdPropertyIndex(), view.GetPropertyIndex("uBloomThreshold"), TEST_LOCATION );
104   DALI_TEST_EQUALS( view.GetBlurStrengthPropertyIndex(), view.GetPropertyIndex("BlurStrengthProperty"), TEST_LOCATION );
105   DALI_TEST_EQUALS( view.GetBloomIntensityPropertyIndex(), view.GetPropertyIndex("uBloomIntensity"), TEST_LOCATION );
106   DALI_TEST_EQUALS( view.GetBloomSaturationPropertyIndex(), view.GetPropertyIndex("uBloomSaturation"), TEST_LOCATION );
107   DALI_TEST_EQUALS( view.GetImageIntensityPropertyIndex(), view.GetPropertyIndex("uImageIntensity"), TEST_LOCATION );
108   DALI_TEST_EQUALS( view.GetImageSaturationPropertyIndex(), view.GetPropertyIndex("uImageSaturation"), TEST_LOCATION );
109   END_TEST;
110 }
111
112 // Positive test case for a method
113 int UtcDaliBloomViewAddRemove(void)
114 {
115   ToolkitTestApplication application;
116   tet_infoline(" UtcDaliBloomViewAddRemove");
117
118   Toolkit::BloomView view = Toolkit::BloomView::New();
119   DALI_TEST_CHECK( view );
120
121   Actor actor = Actor::New();
122   DALI_TEST_CHECK( !actor.OnStage() );
123
124
125   view.SetParentOrigin(ParentOrigin::CENTER);
126   view.SetSize(Stage::GetCurrent().GetSize());
127   view.Add(actor);
128   Stage::GetCurrent().Add(view);
129
130   DALI_TEST_CHECK( actor.OnStage() );
131
132   view.Remove(actor);
133
134   DALI_TEST_CHECK( !actor.OnStage() );
135   END_TEST;
136 }
137
138 // Positive test case for a method
139 int UtcDaliBloomActivateDeactivate(void)
140 {
141   ToolkitTestApplication application;
142   tet_infoline(" UtcDaliBloomActivateDeactivate");
143
144   Toolkit::BloomView view = Toolkit::BloomView::New();
145   DALI_TEST_CHECK( view );
146
147   RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
148   DALI_TEST_CHECK( 1u == taskList.GetTaskCount() );
149
150   view.SetParentOrigin(ParentOrigin::CENTER);
151   view.SetSize(Stage::GetCurrent().GetSize());
152   view.Add(Actor::New());
153   Stage::GetCurrent().Add(view);
154   view.Activate();
155
156   RenderTaskList taskList2 = Stage::GetCurrent().GetRenderTaskList();
157   DALI_TEST_CHECK( 1u != taskList2.GetTaskCount() );
158
159   view.Deactivate();
160
161   RenderTaskList taskList3 = Stage::GetCurrent().GetRenderTaskList();
162   DALI_TEST_CHECK( 1u == taskList3.GetTaskCount() );
163   END_TEST;
164 }