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 carousel_effect_startup(void)
28 test_return_value = TET_UNDEF;
31 void carousel_effect_cleanup(void)
33 test_return_value = TET_PASS;
37 int UtcDaliCarouselEffectUninitialized(void)
39 ToolkitTestApplication application;
41 Toolkit::CarouselEffect effect;
45 // New() must be called to create a CarouselEffect or it wont be valid.
46 effect.SetRadius( 100.0f );
47 DALI_TEST_CHECK( false );
49 catch (Dali::DaliException& e)
51 // Tests that a negative test of an assertion succeeds
52 DALI_TEST_PRINT_ASSERT( e );
53 DALI_TEST_CHECK(!effect);
58 int UtcDaliCarouselEffectPropertyNames(void)
60 ToolkitTestApplication application;
62 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
64 // Check the names, these names are used in the shaders code,
65 // if they change the shader code has to be updated
66 DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
67 DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
68 DALI_TEST_EQUALS( effect.GetAnglePerUnitPropertyName(), "uAnglePerUnit", TEST_LOCATION );
72 int UtcDaliCarouselEffectDefaultValues(void)
74 ToolkitTestApplication application;
76 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
77 DALI_TEST_CHECK( effect );
79 BufferImage image = CreateBufferImage();
81 ImageActor actor = ImageActor::New( image );
82 actor.SetSize( 100.0f, 100.0f );
84 const float radiusValue(0.0f);
85 const Vector2 centerValue(0.0f, 0.0f);
86 const Vector2 anglePerUnitValue(0.0f, 0.0f);
88 actor.SetShaderEffect( effect );
89 Stage::GetCurrent().Add( actor );
91 application.SendNotification();
94 TestGlAbstraction& gl = application.GetGlAbstraction();
95 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
96 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
97 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );
101 int UtcDaliCarouselEffectCustomValues(void)
103 ToolkitTestApplication application;
105 Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
106 DALI_TEST_CHECK( effect );
108 BufferImage image = CreateBufferImage();
110 ImageActor actor = ImageActor::New( image );
111 actor.SetSize( 100.0f, 100.0f );
113 const float radiusValue(100.0f);
114 const Vector2 centerValue(150.0f, 200.0f);
115 const Vector2 anglePerUnitValue(0.1f, 0.25f);
117 effect.SetRadius( radiusValue );
118 effect.SetCenter( centerValue );
119 effect.SetAnglePerUnit( anglePerUnitValue );
121 actor.SetShaderEffect(effect);
122 Stage::GetCurrent().Add(actor);
124 application.SendNotification();
125 application.Render();
127 TestGlAbstraction& gl = application.GetGlAbstraction();
128 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
129 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
130 DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAnglePerUnitPropertyName().c_str(), anglePerUnitValue ) );