2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
20 // Need to override adaptor classes for toolkit test harness, so include
21 // test harness headers before dali headers.
22 #include <dali-toolkit-test-suite-utils.h>
25 #include <dali-toolkit/dali-toolkit.h>
29 void utc_dali_toolkit_iris_effect_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_toolkit_iris_effect_cleanup(void)
36 test_return_value = TET_PASS;
40 int UtcDaliIrisEffectUninitialized(void)
42 ToolkitTestApplication application;
44 Toolkit::IrisEffect effect;
48 // New() must be called to create a IrisEffect or it wont be valid.
49 effect.SetRadius( 2.0f );
50 DALI_TEST_CHECK( false );
52 catch (Dali::DaliException& e)
54 // Tests that a negative test of an assertion succeeds
55 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
56 DALI_TEST_CHECK(!effect);
61 int UtcDaliIrisEffectPropertyNames(void)
63 ToolkitTestApplication application;
65 Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
67 // Check the names, this names are used in the shaders code,
68 // if they change the shader code has to be updated
69 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
70 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
71 DALI_TEST_EQUALS( effect.GetBlendFactorPropertyName(), "uBlendFactor", TEST_LOCATION );
75 int UtcDaliIrisEffectDefaultValues(void)
77 ToolkitTestApplication application;
79 Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
80 DALI_TEST_CHECK( effect );
82 BitmapImage image = CreateBitmapImage();
84 ImageActor actor = ImageActor::New( image );
85 actor.SetSize( 100.0f, 100.0f );
87 const float radiusValue(0.0f);
88 const Vector2 centerValue(0.5f, 0.5f);
89 const float blendFactorValue(100.0f);
91 actor.SetShaderEffect( effect );
92 Stage::GetCurrent().Add( actor );
94 application.SendNotification();
97 TestGlAbstraction& gl = application.GetGlAbstraction();
98 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
99 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
100 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );
104 int UtcDaliIrisEffectCustomValues(void)
106 ToolkitTestApplication application;
108 Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
109 DALI_TEST_CHECK( effect );
111 BitmapImage image = CreateBitmapImage();
113 ImageActor actor = ImageActor::New( image );
114 actor.SetSize( 100.0f, 100.0f );
116 const float radiusValue(23.0f);
117 const Vector2 centerValue(0.2f, 0.7f);
118 const float blendFactorValue(10.0f);
120 effect.SetRadius( radiusValue );
121 effect.SetCenter( centerValue );
122 effect.SetBlendFactor( blendFactorValue );
124 actor.SetShaderEffect(effect);
125 Stage::GetCurrent().Add(actor);
127 application.SendNotification();
128 application.Render();
130 TestGlAbstraction& gl = application.GetGlAbstraction();
131 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
132 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
133 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );