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 carousel_effect_startup(void)
27 test_return_value = TET_UNDEF;
30 void carousel_effect_cleanup(void)
32 test_return_value = TET_PASS;
36 int UtcDaliCarouselEffectUninitialized(void)
38 ToolkitTestApplication application;
40 Toolkit::CarouselEffect effect;
44 // New() must be called to create a CarouselEffect or it wont be valid.
45 effect.SetRadius( 100.0f );
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 UtcDaliCarouselEffectPropertyNames(void)
59 ToolkitTestApplication application;
61 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
63 // Check the names, these names are used in the shaders code,
64 // if they change the shader code has to be updated
65 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
66 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
67 DALI_TEST_EQUALS( effect.GetAnglePerUnitPropertyName(), "uAnglePerUnit", TEST_LOCATION );
71 int UtcDaliCarouselEffectDefaultValues(void)
73 ToolkitTestApplication application;
75 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
76 DALI_TEST_CHECK( effect );
78 BitmapImage image = CreateBitmapImage();
80 ImageActor actor = ImageActor::New( image );
81 actor.SetSize( 100.0f, 100.0f );
83 const float radiusValue(0.0f);
84 const Vector2 centerValue(0.0f, 0.0f);
85 const Vector2 anglePerUnitValue(0.0f, 0.0f);
87 actor.SetShaderEffect( effect );
88 Stage::GetCurrent().Add( actor );
90 application.SendNotification();
93 TestGlAbstraction& gl = application.GetGlAbstraction();
94 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
95 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
96 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );
100 int UtcDaliCarouselEffectCustomValues(void)
102 ToolkitTestApplication application;
104 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
105 DALI_TEST_CHECK( effect );
107 BitmapImage image = CreateBitmapImage();
109 ImageActor actor = ImageActor::New( image );
110 actor.SetSize( 100.0f, 100.0f );
112 const float radiusValue(100.0f);
113 const Vector2 centerValue(150.0f, 200.0f);
114 const Vector2 anglePerUnitValue(0.1f, 0.25f);
116 effect.SetRadius( radiusValue );
117 effect.SetCenter( centerValue );
118 effect.SetAnglePerUnit( anglePerUnitValue );
120 actor.SetShaderEffect(effect);
121 Stage::GetCurrent().Add(actor);
123 application.SendNotification();
124 application.Render();
126 TestGlAbstraction& gl = application.GetGlAbstraction();
127 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
128 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
129 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );