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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali-toolkit/dali-toolkit.h>
26 void bendy_effect_startup(void)
28 test_return_value = TET_UNDEF;
31 void bendy_effect_cleanup(void)
33 test_return_value = TET_PASS;
37 int UtcDaliBendyUninitializedEffect(void)
39 ToolkitTestApplication application;
41 Toolkit::BendyEffect effect;
45 // New() must be called to create a BendyEffect or it wont be valid.
46 effect.SetRadius( 2.0f );
47 DALI_TEST_CHECK( false );
49 catch (Dali::DaliException& e)
51 // Tests that a negative test of an assertion succeeds
52 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
53 DALI_TEST_CHECK(!effect);
58 int UtcDaliBendyPropertyNamesEffect(void)
60 ToolkitTestApplication application;
62 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
64 // Check the names, this names are used in the shaders code,
65 // if they change the shader code has to be updated
66 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
67 DALI_TEST_EQUALS( effect.GetDirectionPropertyName(), "uDirection", TEST_LOCATION );
68 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
72 int UtcDaliBendyDefaultValuesEffect(void)
74 ToolkitTestApplication application;
76 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
77 DALI_TEST_CHECK( effect );
79 BitmapImage image = CreateBitmapImage();
81 ImageActor actor = ImageActor::New( image );
82 actor.SetSize( 100.0f, 100.0f );
83 actor.SetShaderEffect( effect );
84 Stage::GetCurrent().Add( actor );
86 application.SendNotification();
89 Vector2 topLeft( Stage::GetCurrent().GetSize() * 0.5f );
90 topLeft.y = -topLeft.y;
92 // Gets converted to opengl view space
94 application.GetGlAbstraction().CheckUniformValue(
95 effect.GetCenterPropertyName().c_str(),
99 application.GetGlAbstraction().CheckUniformValue(
100 effect.GetDirectionPropertyName().c_str(),
101 Vector2(0.0f, 0.0f) ) );
104 application.GetGlAbstraction().CheckUniformValue(
105 effect.GetRadiusPropertyName().c_str(),
110 int UtcDaliBendyCustomValuesEffect(void)
112 ToolkitTestApplication application;
114 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
115 DALI_TEST_CHECK( effect );
117 BitmapImage image = CreateBitmapImage();
119 ImageActor actor = ImageActor::New( image );
120 actor.SetSize( 100.0f, 100.0f );
122 Vector2 direction(1.0f, 1.0f);
123 effect.SetCenter( Vector2(480.0f, 800.0f) );
124 effect.SetDirection( direction );
125 effect.SetRadius( 2.0f );
127 actor.SetShaderEffect(effect);
128 Stage::GetCurrent().Add(actor);
130 application.SendNotification();
131 application.Render();
133 Vector2 bottomRight( Stage::GetCurrent().GetSize() * 0.5f );
134 bottomRight.x = -bottomRight.x;
136 // Gets converted to opengl viewport coordinates
138 application.GetGlAbstraction().CheckUniformValue(
139 effect.GetCenterPropertyName().c_str(),
142 direction.Normalize();
143 direction.x *= -1.0f;
145 application.GetGlAbstraction().CheckUniformValue(
146 effect.GetDirectionPropertyName().c_str(),
150 application.GetGlAbstraction().CheckUniformValue(
151 effect.GetRadiusPropertyName().c_str(),