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>
26 void spot_effect_startup(void)
28 test_return_value = TET_UNDEF;
31 void spot_effect_cleanup(void)
33 test_return_value = TET_PASS;
37 int UtcDaliSpotUninitializedEffect(void)
39 ToolkitTestApplication application;
41 Toolkit::SpotEffect effect;
45 // New() must be called to create a SpotEffect or it wont be valid.
46 effect.SetRadius( 0.5f );
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 UtcDaliSpotPropertyNamesEffect(void)
60 ToolkitTestApplication application;
62 Toolkit::SpotEffect effect = Toolkit::SpotEffect::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.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
71 int UtcDaliSpotDefaultValuesEffect(void)
73 ToolkitTestApplication application;
75 Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
76 DALI_TEST_CHECK( effect );
78 BitmapImage image = CreateBitmapImage();
80 ImageActor actor = ImageActor::New( image );
81 actor.SetSize( 100.0f, 100.0f );
82 actor.SetShaderEffect( effect );
83 Stage::GetCurrent().Add( actor );
85 application.SendNotification();
88 // Gets converted to opengl viewport coordinates
90 application.GetGlAbstraction().CheckUniformValue(
91 effect.GetCenterPropertyName().c_str(),
92 Vector2(0.0f, 0.0f) ) );
95 application.GetGlAbstraction().CheckUniformValue(
96 effect.GetRadiusPropertyName().c_str(),
101 int UtcDaliSpotCustomValuesEffect(void)
103 ToolkitTestApplication application;
105 Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
106 DALI_TEST_CHECK( effect );
108 BitmapImage image = CreateBitmapImage();
110 ImageActor actor = ImageActor::New( image );
111 actor.SetSize( 100.0f, 100.0f );
113 effect.SetCenter( Vector2(480.0f, 800.0f) );
114 effect.SetRadius( 5.0f );
116 actor.SetShaderEffect( effect );
117 Stage::GetCurrent().Add( actor );
119 application.SendNotification();
120 application.Render();
122 // Gets converted to opengl viewport coordinates
124 application.GetGlAbstraction().CheckUniformValue(
125 effect.GetCenterPropertyName().c_str(),
126 Vector2(480.0f, 800.0f) ) );
129 application.GetGlAbstraction().CheckUniformValue(
130 effect.GetRadiusPropertyName().c_str(),