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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
27 void bendy_effect_startup(void)
29 test_return_value = TET_UNDEF;
32 void bendy_effect_cleanup(void)
34 test_return_value = TET_PASS;
38 int UtcDaliBendyUninitializedEffect(void)
40 ToolkitTestApplication application;
42 Toolkit::BendyEffect effect;
46 // New() must be called to create a BendyEffect or it wont be valid.
47 effect.SetRadius( 2.0f );
48 DALI_TEST_CHECK( false );
50 catch (Dali::DaliException& e)
52 // Tests that a negative test of an assertion succeeds
53 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
54 DALI_TEST_CHECK(!effect);
59 int UtcDaliBendyPropertyNamesEffect(void)
61 ToolkitTestApplication application;
63 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
65 // Check the names, this names are used in the shaders code,
66 // if they change the shader code has to be updated
67 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
68 DALI_TEST_EQUALS( effect.GetDirectionPropertyName(), "uDirection", TEST_LOCATION );
69 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
73 int UtcDaliBendyDefaultValuesEffect(void)
75 ToolkitTestApplication application;
77 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
78 DALI_TEST_CHECK( effect );
80 BitmapImage image = CreateBitmapImage();
82 ImageActor actor = ImageActor::New( image );
83 actor.SetSize( 100.0f, 100.0f );
84 actor.SetShaderEffect( effect );
85 Stage::GetCurrent().Add( actor );
87 application.SendNotification();
90 Vector2 topLeft( Stage::GetCurrent().GetSize() * 0.5f );
91 topLeft.y = -topLeft.y;
93 // Gets converted to opengl view space
95 application.GetGlAbstraction().CheckUniformValue(
96 effect.GetCenterPropertyName().c_str(),
100 application.GetGlAbstraction().CheckUniformValue(
101 effect.GetDirectionPropertyName().c_str(),
102 Vector2(0.0f, 0.0f) ) );
105 application.GetGlAbstraction().CheckUniformValue(
106 effect.GetRadiusPropertyName().c_str(),
111 int UtcDaliBendyCustomValuesEffect(void)
113 ToolkitTestApplication application;
115 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
116 DALI_TEST_CHECK( effect );
118 BitmapImage image = CreateBitmapImage();
120 ImageActor actor = ImageActor::New( image );
121 actor.SetSize( 100.0f, 100.0f );
123 Vector2 direction(1.0f, 1.0f);
124 effect.SetCenter( Vector2(480.0f, 800.0f) );
125 effect.SetDirection( direction );
126 effect.SetRadius( 2.0f );
128 actor.SetShaderEffect(effect);
129 Stage::GetCurrent().Add(actor);
131 application.SendNotification();
132 application.Render();
134 Vector2 bottomRight( Stage::GetCurrent().GetSize() * 0.5f );
135 bottomRight.x = -bottomRight.x;
137 // Gets converted to opengl viewport coordinates
139 application.GetGlAbstraction().CheckUniformValue(
140 effect.GetCenterPropertyName().c_str(),
143 direction.Normalize();
144 direction.x *= -1.0f;
146 application.GetGlAbstraction().CheckUniformValue(
147 effect.GetDirectionPropertyName().c_str(),
151 application.GetGlAbstraction().CheckUniformValue(
152 effect.GetRadiusPropertyName().c_str(),