UTC added for Text, Multi-language.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-IrisEffect.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
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24
25 #include <dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit/devel-api/shader-effects/iris-effect.h>
28
29 using namespace Dali;
30
31 void utc_dali_toolkit_iris_effect_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void utc_dali_toolkit_iris_effect_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41
42 int UtcDaliIrisEffectUninitialized(void)
43 {
44   ToolkitTestApplication application;
45
46   Toolkit::IrisEffect effect;
47
48   try
49   {
50     // New() must be called to create a IrisEffect or it wont be valid.
51     effect.SetRadius( 2.0f );
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(!effect);
59   }
60   END_TEST;
61 }
62
63 int UtcDaliIrisEffectPropertyNames(void)
64 {
65   ToolkitTestApplication application;
66
67   Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
68
69   // Check the names, this names are used in the shaders code,
70   // if they change the shader code has to be updated
71   DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
72   DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
73   DALI_TEST_EQUALS( effect.GetBlendFactorPropertyName(), "uBlendFactor", TEST_LOCATION );
74   END_TEST;
75 }
76
77 int UtcDaliIrisEffectDefaultValues(void)
78 {
79   ToolkitTestApplication application;
80
81   Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
82   DALI_TEST_CHECK( effect );
83
84   BufferImage image = CreateBufferImage();
85
86   ImageActor actor = ImageActor::New( image );
87   actor.SetSize( 100.0f, 100.0f );
88
89   const float radiusValue(0.0f);
90   const Vector2 centerValue(0.5f, 0.5f);
91   const float blendFactorValue(100.0f);
92
93   actor.SetShaderEffect( effect );
94   Stage::GetCurrent().Add( actor );
95
96   application.SendNotification();
97   application.Render();
98
99   TestGlAbstraction& gl = application.GetGlAbstraction();
100   DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
101   DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
102   DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );
103   END_TEST;
104 }
105
106 int UtcDaliIrisEffectCustomValues(void)
107 {
108   ToolkitTestApplication application;
109
110   Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
111   DALI_TEST_CHECK( effect );
112
113   BufferImage image = CreateBufferImage();
114
115   ImageActor actor = ImageActor::New( image );
116   actor.SetSize( 100.0f, 100.0f );
117
118   const float radiusValue(23.0f);
119   const Vector2 centerValue(0.2f, 0.7f);
120   const float blendFactorValue(10.0f);
121
122   effect.SetRadius( radiusValue );
123   effect.SetCenter( centerValue );
124   effect.SetBlendFactor( blendFactorValue );
125
126   actor.SetShaderEffect(effect);
127   Stage::GetCurrent().Add(actor);
128
129   application.SendNotification();
130   application.Render();
131
132   TestGlAbstraction& gl = application.GetGlAbstraction();
133   DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
134   DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
135   DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );
136   END_TEST;
137 }