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>
22 #include <dali-toolkit/devel-api/shader-effects/bendy-effect.h>
28 void bendy_effect_startup(void)
30 test_return_value = TET_UNDEF;
33 void bendy_effect_cleanup(void)
35 test_return_value = TET_PASS;
39 int UtcDaliBendyUninitializedEffect(void)
41 ToolkitTestApplication application;
43 Toolkit::BendyEffect effect;
47 // New() must be called to create a BendyEffect or it wont be valid.
48 effect.SetRadius( 2.0f );
49 DALI_TEST_CHECK( false );
51 catch (Dali::DaliException& e)
53 // Tests that a negative test of an assertion succeeds
54 DALI_TEST_PRINT_ASSERT( e );
55 DALI_TEST_CHECK(!effect);
60 int UtcDaliBendyPropertyNamesEffect(void)
62 ToolkitTestApplication application;
64 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
66 // Check the names, this names are used in the shaders code,
67 // if they change the shader code has to be updated
68 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
69 DALI_TEST_EQUALS( effect.GetDirectionPropertyName(), "uDirection", TEST_LOCATION );
70 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
74 int UtcDaliBendyDefaultValuesEffect(void)
76 ToolkitTestApplication application;
78 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
79 DALI_TEST_CHECK( effect );
81 BufferImage image = CreateBufferImage();
83 ImageActor actor = ImageActor::New( image );
84 actor.SetSize( 100.0f, 100.0f );
85 actor.SetShaderEffect( effect );
86 Stage::GetCurrent().Add( actor );
88 application.SendNotification();
91 Vector2 topLeft( Stage::GetCurrent().GetSize() * 0.5f );
92 topLeft.y = -topLeft.y;
94 // Gets converted to opengl view space
96 application.GetGlAbstraction().CheckUniformValue(
97 effect.GetCenterPropertyName().c_str(),
101 application.GetGlAbstraction().CheckUniformValue(
102 effect.GetDirectionPropertyName().c_str(),
103 Vector2(0.0f, 0.0f) ) );
106 application.GetGlAbstraction().CheckUniformValue(
107 effect.GetRadiusPropertyName().c_str(),
112 int UtcDaliBendyCustomValuesEffect(void)
114 ToolkitTestApplication application;
116 Toolkit::BendyEffect effect = Toolkit::BendyEffect::New();
117 DALI_TEST_CHECK( effect );
119 BufferImage image = CreateBufferImage();
121 ImageActor actor = ImageActor::New( image );
122 actor.SetSize( 100.0f, 100.0f );
124 Vector2 direction(1.0f, 1.0f);
125 effect.SetCenter( Vector2(480.0f, 800.0f) );
126 effect.SetDirection( direction );
127 effect.SetRadius( 2.0f );
129 actor.SetShaderEffect(effect);
130 Stage::GetCurrent().Add(actor);
132 application.SendNotification();
133 application.Render();
135 Vector2 bottomRight( Stage::GetCurrent().GetSize() * 0.5f );
136 bottomRight.x = -bottomRight.x;
138 // Gets converted to opengl viewport coordinates
140 application.GetGlAbstraction().CheckUniformValue(
141 effect.GetCenterPropertyName().c_str(),
144 direction.Normalize();
145 direction.x *= -1.0f;
147 application.GetGlAbstraction().CheckUniformValue(
148 effect.GetDirectionPropertyName().c_str(),
152 application.GetGlAbstraction().CheckUniformValue(
153 effect.GetRadiusPropertyName().c_str(),