2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit/devel-api/shader-effects/iris-effect.h>
31 void utc_dali_toolkit_iris_effect_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_toolkit_iris_effect_cleanup(void)
38 test_return_value = TET_PASS;
42 int UtcDaliIrisEffectUninitialized(void)
44 ToolkitTestApplication application;
46 Toolkit::IrisEffect effect;
50 // New() must be called to create a IrisEffect or it wont be valid.
51 effect.SetRadius( 2.0f );
52 DALI_TEST_CHECK( false );
54 catch (Dali::DaliException& e)
56 // Tests that a negative test of an assertion succeeds
57 DALI_TEST_PRINT_ASSERT( e );
58 DALI_TEST_CHECK(!effect);
63 int UtcDaliIrisEffectPropertyNames(void)
65 ToolkitTestApplication application;
67 Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
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 );
77 int UtcDaliIrisEffectDefaultValues(void)
79 ToolkitTestApplication application;
81 Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
82 DALI_TEST_CHECK( effect );
84 BufferImage image = CreateBufferImage();
86 ImageActor actor = ImageActor::New( image );
87 actor.SetSize( 100.0f, 100.0f );
89 const float radiusValue(0.0f);
90 const Vector2 centerValue(0.5f, 0.5f);
91 const float blendFactorValue(100.0f);
93 actor.SetShaderEffect( effect );
94 Stage::GetCurrent().Add( actor );
96 application.SendNotification();
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 ) );
106 int UtcDaliIrisEffectCustomValues(void)
108 ToolkitTestApplication application;
110 Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
111 DALI_TEST_CHECK( effect );
113 BufferImage image = CreateBufferImage();
115 ImageActor actor = ImageActor::New( image );
116 actor.SetSize( 100.0f, 100.0f );
118 const float radiusValue(23.0f);
119 const Vector2 centerValue(0.2f, 0.7f);
120 const float blendFactorValue(10.0f);
122 effect.SetRadius( radiusValue );
123 effect.SetCenter( centerValue );
124 effect.SetBlendFactor( blendFactorValue );
126 actor.SetShaderEffect(effect);
127 Stage::GetCurrent().Add(actor);
129 application.SendNotification();
130 application.Render();
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 ) );