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>
25 void spot_effect_startup(void)
27 test_return_value = TET_UNDEF;
30 void spot_effect_cleanup(void)
32 test_return_value = TET_PASS;
36 int UtcDaliSpotUninitializedEffect(void)
38 ToolkitTestApplication application;
40 Toolkit::SpotEffect effect;
44 // New() must be called to create a SpotEffect or it wont be valid.
45 effect.SetRadius( 0.5f );
46 DALI_TEST_CHECK( false );
48 catch (Dali::DaliException& e)
50 // Tests that a negative test of an assertion succeeds
51 tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
52 DALI_TEST_CHECK(!effect);
57 int UtcDaliSpotPropertyNamesEffect(void)
59 ToolkitTestApplication application;
61 Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
63 // Check the names, this names are used in the shaders code,
64 // if they change the shader code has to be updated
65 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
66 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
70 int UtcDaliSpotDefaultValuesEffect(void)
72 ToolkitTestApplication application;
74 Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
75 DALI_TEST_CHECK( effect );
77 BitmapImage image = CreateBitmapImage();
79 ImageActor actor = ImageActor::New( image );
80 actor.SetSize( 100.0f, 100.0f );
81 actor.SetShaderEffect( effect );
82 Stage::GetCurrent().Add( actor );
84 application.SendNotification();
87 // Gets converted to opengl viewport coordinates
89 application.GetGlAbstraction().CheckUniformValue(
90 effect.GetCenterPropertyName().c_str(),
91 Vector2(0.0f, 0.0f) ) );
94 application.GetGlAbstraction().CheckUniformValue(
95 effect.GetRadiusPropertyName().c_str(),
100 int UtcDaliSpotCustomValuesEffect(void)
102 ToolkitTestApplication application;
104 Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
105 DALI_TEST_CHECK( effect );
107 BitmapImage image = CreateBitmapImage();
109 ImageActor actor = ImageActor::New( image );
110 actor.SetSize( 100.0f, 100.0f );
112 effect.SetCenter( Vector2(480.0f, 800.0f) );
113 effect.SetRadius( 5.0f );
115 actor.SetShaderEffect( effect );
116 Stage::GetCurrent().Add( actor );
118 application.SendNotification();
119 application.Render();
121 // Gets converted to opengl viewport coordinates
123 application.GetGlAbstraction().CheckUniformValue(
124 effect.GetCenterPropertyName().c_str(),
125 Vector2(480.0f, 800.0f) ) );
128 application.GetGlAbstraction().CheckUniformValue(
129 effect.GetRadiusPropertyName().c_str(),