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/spot-effect.h>
27 void spot_effect_startup(void)
29 test_return_value = TET_UNDEF;
32 void spot_effect_cleanup(void)
34 test_return_value = TET_PASS;
38 int UtcDaliSpotUninitializedEffect(void)
40 ToolkitTestApplication application;
42 Toolkit::SpotEffect effect;
46 // New() must be called to create a SpotEffect or it wont be valid.
47 effect.SetRadius( 0.5f );
48 DALI_TEST_CHECK( false );
50 catch (Dali::DaliException& e)
52 // Tests that a negative test of an assertion succeeds
53 DALI_TEST_PRINT_ASSERT( e );
54 DALI_TEST_CHECK(!effect);
59 int UtcDaliSpotPropertyNamesEffect(void)
61 ToolkitTestApplication application;
63 Toolkit::SpotEffect effect = Toolkit::SpotEffect::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.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
72 int UtcDaliSpotDefaultValuesEffect(void)
74 ToolkitTestApplication application;
76 Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
77 DALI_TEST_CHECK( effect );
79 BufferImage image = CreateBufferImage();
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 // Gets converted to opengl viewport coordinates
91 application.GetGlAbstraction().CheckUniformValue(
92 effect.GetCenterPropertyName().c_str(),
93 Vector2(0.0f, 0.0f) ) );
96 application.GetGlAbstraction().CheckUniformValue(
97 effect.GetRadiusPropertyName().c_str(),
102 int UtcDaliSpotCustomValuesEffect(void)
104 ToolkitTestApplication application;
106 Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
107 DALI_TEST_CHECK( effect );
109 BufferImage image = CreateBufferImage();
111 ImageActor actor = ImageActor::New( image );
112 actor.SetSize( 100.0f, 100.0f );
114 effect.SetCenter( Vector2(480.0f, 800.0f) );
115 effect.SetRadius( 5.0f );
117 actor.SetShaderEffect( effect );
118 Stage::GetCurrent().Add( actor );
120 application.SendNotification();
121 application.Render();
123 // Gets converted to opengl viewport coordinates
125 application.GetGlAbstraction().CheckUniformValue(
126 effect.GetCenterPropertyName().c_str(),
127 Vector2(480.0f, 800.0f) ) );
130 application.GetGlAbstraction().CheckUniformValue(
131 effect.GetRadiusPropertyName().c_str(),