TET cases for Text.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-CarouselEffect.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
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>
23
24 using namespace Dali;
25
26
27 void carousel_effect_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void carousel_effect_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37
38 int UtcDaliCarouselEffectUninitialized(void)
39 {
40   ToolkitTestApplication application;
41
42   Toolkit::CarouselEffect effect;
43
44   try
45   {
46     // New() must be called to create a CarouselEffect or it wont be valid.
47     effect.SetRadius( 100.0f );
48     DALI_TEST_CHECK( false );
49   }
50   catch (Dali::DaliException& e)
51   {
52     // Tests that a negative test of an assertion succeeds
53     DALI_TEST_PRINT_ASSERT( e );
54     DALI_TEST_CHECK(!effect);
55   }
56   END_TEST;
57 }
58
59 int UtcDaliCarouselEffectPropertyNames(void)
60 {
61   ToolkitTestApplication application;
62
63   Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
64
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 );
70   END_TEST;
71 }
72
73 int UtcDaliCarouselEffectDefaultValues(void)
74 {
75   ToolkitTestApplication application;
76
77   Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
78   DALI_TEST_CHECK( effect );
79
80   BufferImage image = CreateBufferImage();
81
82   ImageActor actor = ImageActor::New( image );
83   actor.SetSize( 100.0f, 100.0f );
84
85   const float radiusValue(0.0f);
86   const Vector2 centerValue(0.0f, 0.0f);
87   const Vector2 anglePerUnitValue(0.0f, 0.0f);
88
89   actor.SetShaderEffect( effect );
90   Stage::GetCurrent().Add( actor );
91
92   application.SendNotification();
93   application.Render();
94
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 ) );
99   END_TEST;
100 }
101
102 int UtcDaliCarouselEffectCustomValues(void)
103 {
104   ToolkitTestApplication application;
105
106   Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
107   DALI_TEST_CHECK( effect );
108
109   BufferImage image = CreateBufferImage();
110
111   ImageActor actor = ImageActor::New( image );
112   actor.SetSize( 100.0f, 100.0f );
113
114   const float radiusValue(100.0f);
115   const Vector2 centerValue(150.0f, 200.0f);
116   const Vector2 anglePerUnitValue(0.1f, 0.25f);
117
118   effect.SetRadius( radiusValue );
119   effect.SetCenter( centerValue );
120   effect.SetAnglePerUnit( anglePerUnitValue );
121
122   actor.SetShaderEffect(effect);
123   Stage::GetCurrent().Add(actor);
124
125   application.SendNotification();
126   application.Render();
127
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 ) );
132   END_TEST;
133 }