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/carousel-effect.h>
27 void carousel_effect_startup(void)
29 test_return_value = TET_UNDEF;
32 void carousel_effect_cleanup(void)
34 test_return_value = TET_PASS;
38 int UtcDaliCarouselEffectUninitialized(void)
40 ToolkitTestApplication application;
42 Toolkit::CarouselEffect effect;
46 // New() must be called to create a CarouselEffect or it wont be valid.
47 effect.SetRadius( 100.0f );
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 UtcDaliCarouselEffectPropertyNames(void)
61 ToolkitTestApplication application;
63 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
65 // Check the names, these names are used in the shaders code,
66 // if they change the shader code has to be updated
67 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
68 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
69 DALI_TEST_EQUALS( effect.GetAnglePerUnitPropertyName(), "uAnglePerUnit", TEST_LOCATION );
73 int UtcDaliCarouselEffectDefaultValues(void)
75 ToolkitTestApplication application;
77 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
78 DALI_TEST_CHECK( effect );
80 BufferImage image = CreateBufferImage();
82 ImageActor actor = ImageActor::New( image );
83 actor.SetSize( 100.0f, 100.0f );
85 const float radiusValue(0.0f);
86 const Vector2 centerValue(0.0f, 0.0f);
87 const Vector2 anglePerUnitValue(0.0f, 0.0f);
89 actor.SetShaderEffect( effect );
90 Stage::GetCurrent().Add( actor );
92 application.SendNotification();
95 TestGlAbstraction& gl = application.GetGlAbstraction();
96 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
97 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
98 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );
102 int UtcDaliCarouselEffectCustomValues(void)
104 ToolkitTestApplication application;
106 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
107 DALI_TEST_CHECK( effect );
109 BufferImage image = CreateBufferImage();
111 ImageActor actor = ImageActor::New( image );
112 actor.SetSize( 100.0f, 100.0f );
114 const float radiusValue(100.0f);
115 const Vector2 centerValue(150.0f, 200.0f);
116 const Vector2 anglePerUnitValue(0.1f, 0.25f);
118 effect.SetRadius( radiusValue );
119 effect.SetCenter( centerValue );
120 effect.SetAnglePerUnit( anglePerUnitValue );
122 actor.SetShaderEffect(effect);
123 Stage::GetCurrent().Add(actor);
125 application.SendNotification();
126 application.Render();
128 TestGlAbstraction& gl = application.GetGlAbstraction();
129 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
130 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
131 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );