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