TET cases for Text.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-RippleEffect.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
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24
25 #include <dali.h>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit/devel-api/shader-effects/ripple-effect.h>
28
29
30 using namespace Dali;
31
32 void utc_dali_toolkit_ripple_effect_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void utc_dali_toolkit_ripple_effect_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42
43 int UtcDaliRippleUninitializedEffect(void)
44 {
45   ToolkitTestApplication application;
46
47   Toolkit::RippleEffect effect;
48
49   try
50   {
51     // New() must be called to create a RippleEffect or it wont be valid.
52     effect.SetAmplitude( 0.5f );
53     DALI_TEST_CHECK( false );
54   }
55   catch (Dali::DaliException& e)
56   {
57     // Tests that a negative test of an assertion succeeds
58     DALI_TEST_PRINT_ASSERT( e );
59     DALI_TEST_CHECK(!effect);
60   }
61   END_TEST;
62 }
63
64 int UtcDaliRipplePropertyNamesEffect(void)
65 {
66   ToolkitTestApplication application;
67
68   Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
69
70   // Check the names, this names are used in the shaders code,
71   // if they change the shader code has to be updated
72   DALI_TEST_EQUALS( effect.GetAmplitudePropertyName(), "uAmplitude", TEST_LOCATION );
73   DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
74   DALI_TEST_EQUALS( effect.GetTimePropertyName(), "uTime", TEST_LOCATION );
75
76   END_TEST;
77 }
78
79 int UtcDaliRippleDefaultValuesEffect(void)
80 {
81   ToolkitTestApplication application;
82
83   Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
84   DALI_TEST_CHECK( effect );
85
86   BufferImage image = CreateBufferImage();
87
88   ImageActor actor = ImageActor::New( image );
89   actor.SetSize( 100.0f, 100.0f );
90   actor.SetShaderEffect( effect );
91   Stage::GetCurrent().Add( actor );
92
93   application.SendNotification();
94   application.Render();
95
96   DALI_TEST_CHECK(
97       application.GetGlAbstraction().CheckUniformValue(
98           effect.GetAmplitudePropertyName().c_str(),
99           0.0f ) );
100   DALI_TEST_CHECK(
101       application.GetGlAbstraction().CheckUniformValue(
102           effect.GetCenterPropertyName().c_str(),
103           Vector2( 0.0f, 0.0f ) ) );
104   DALI_TEST_CHECK(
105       application.GetGlAbstraction().CheckUniformValue(
106           effect.GetTimePropertyName().c_str(),
107           0.0f ) );
108   END_TEST;
109 }
110
111 int UtcDaliRippleCustomValuesEffect(void)
112 {
113   ToolkitTestApplication application;
114
115   Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
116   DALI_TEST_CHECK( effect );
117
118   BufferImage image = CreateBufferImage();
119
120   ImageActor actor = ImageActor::New( image );
121   actor.SetSize( 100.0f, 100.0f );
122
123   effect.SetAmplitude( 0.5f );
124   effect.SetCenter( Vector2( 10.0f, 10.0f ) );
125   effect.SetTime( 2.0f );
126
127   actor.SetShaderEffect( effect );
128   Stage::GetCurrent().Add( actor );
129
130   application.SendNotification();
131   application.Render();
132
133   DALI_TEST_CHECK(
134       application.GetGlAbstraction().CheckUniformValue(
135           effect.GetAmplitudePropertyName().c_str(),
136           0.5f ) );
137   DALI_TEST_CHECK(
138       application.GetGlAbstraction().CheckUniformValue(
139           effect.GetCenterPropertyName().c_str(),
140           Vector2( 10.0f, 10.0f ) ) );
141   DALI_TEST_CHECK(
142       application.GetGlAbstraction().CheckUniformValue(
143           effect.GetTimePropertyName().c_str(),
144           2.0f ) );
145   END_TEST;
146 }