Adding new test harness
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-unmanaged / utc-Dali-CarouselEffect.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
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 #include <iostream>
18 #include <stdlib.h>
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali-toolkit/dali-toolkit.h>
21
22 using namespace Dali;
23
24
25 void carousel_effect_startup(void)
26 {
27   test_return_value = TET_UNDEF;
28 }
29
30 void carousel_effect_cleanup(void)
31 {
32   test_return_value = TET_PASS;
33 }
34
35
36 int UtcDaliCarouselEffectUninitialized(void)
37 {
38   ToolkitTestApplication application;
39
40   Toolkit::CarouselEffect effect;
41
42   try
43   {
44     // New() must be called to create a CarouselEffect or it wont be valid.
45     effect.SetRadius( 100.0f );
46     DALI_TEST_CHECK( false );
47   }
48   catch (Dali::DaliException& e)
49   {
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);
53   }
54   END_TEST;
55 }
56
57 int UtcDaliCarouselEffectPropertyNames(void)
58 {
59   ToolkitTestApplication application;
60
61   Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
62
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 );
68   END_TEST;
69 }
70
71 int UtcDaliCarouselEffectDefaultValues(void)
72 {
73   ToolkitTestApplication application;
74
75   Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
76   DALI_TEST_CHECK( effect );
77
78   BitmapImage image = CreateBitmapImage();
79
80   ImageActor actor = ImageActor::New( image );
81   actor.SetSize( 100.0f, 100.0f );
82
83   const float radiusValue(0.0f);
84   const Vector2 centerValue(0.0f, 0.0f);
85   const Vector2 anglePerUnitValue(0.0f, 0.0f);
86
87   actor.SetShaderEffect( effect );
88   Stage::GetCurrent().Add( actor );
89
90   application.SendNotification();
91   application.Render();
92
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 ) );
97   END_TEST;
98 }
99
100 int UtcDaliCarouselEffectCustomValues(void)
101 {
102   ToolkitTestApplication application;
103
104   Toolkit::CarouselEffect effect = Toolkit::CarouselEffect::New();
105   DALI_TEST_CHECK( effect );
106
107   BitmapImage image = CreateBitmapImage();
108
109   ImageActor actor = ImageActor::New( image );
110   actor.SetSize( 100.0f, 100.0f );
111
112   const float radiusValue(100.0f);
113   const Vector2 centerValue(150.0f, 200.0f);
114   const Vector2 anglePerUnitValue(0.1f, 0.25f);
115
116   effect.SetRadius( radiusValue );
117   effect.SetCenter( centerValue );
118   effect.SetAnglePerUnit( anglePerUnitValue );
119
120   actor.SetShaderEffect(effect);
121   Stage::GetCurrent().Add(actor);
122
123   application.SendNotification();
124   application.Render();
125
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 ) );
130   END_TEST;
131 }