text popup callbacks.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Ripple2DEffect.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/ripple2d-effect.h>
28
29 using namespace Dali;
30
31
32 void utc_dali_toolkit_ripple_2d_effect_startup(void)
33 {
34   test_return_value = TET_UNDEF;
35 }
36
37 void utc_dali_toolkit_ripple_2d_effect_cleanup(void)
38 {
39   test_return_value = TET_PASS;
40 }
41
42 int UtcDaliRipple2DEffectUninitialized(void)
43 {
44   ToolkitTestApplication application;
45
46   Toolkit::Ripple2DEffect effect;
47
48   try
49   {
50     // New() must be called to create a Ripple2DEffect or it wont be valid.
51     effect.SetAmplitude( 0.5f );
52     DALI_TEST_CHECK( false );
53   }
54   catch (Dali::DaliException& e)
55   {
56     // Tests that a negative test of an assertion succeeds
57     DALI_TEST_PRINT_ASSERT( e );
58     DALI_TEST_CHECK(!effect);
59   }
60   END_TEST;
61 }
62
63 int UtcDaliRipple2DEffectPropertyNames(void)
64 {
65   ToolkitTestApplication application;
66
67   Toolkit::Ripple2DEffect effect = Toolkit::Ripple2DEffect::New();
68
69   // Check the names, this names are used in the shaders code,
70   // if they change the shader code has to be updated
71   DALI_TEST_EQUALS( effect.GetAmplitudePropertyName(), "uAmplitude", TEST_LOCATION );
72   DALI_TEST_EQUALS( effect.GetTimePropertyName(), "uTime", TEST_LOCATION );
73   END_TEST;
74 }
75
76 int UtcDaliRipple2DEffectDefaultValues(void)
77 {
78   ToolkitTestApplication application;
79
80   Toolkit::Ripple2DEffect effect = Toolkit::Ripple2DEffect::New();
81   DALI_TEST_CHECK( effect );
82
83   BufferImage image = CreateBufferImage();
84
85   ImageActor actor = ImageActor::New( image );
86   actor.SetSize( 100.0f, 100.0f );
87   actor.SetShaderEffect( effect );
88   Stage::GetCurrent().Add( actor );
89
90   application.SendNotification();
91   application.Render();
92
93   DALI_TEST_CHECK(
94       application.GetGlAbstraction().CheckUniformValue(
95           effect.GetAmplitudePropertyName().c_str(),
96           0.0f ) );
97   DALI_TEST_CHECK(
98       application.GetGlAbstraction().CheckUniformValue(
99           effect.GetTimePropertyName().c_str(),
100           0.0f ) );
101   END_TEST;
102 }
103
104 int UtcDaliRipple2DEffectCustomValues(void)
105 {
106   ToolkitTestApplication application;
107
108   Toolkit::Ripple2DEffect effect = Toolkit::Ripple2DEffect::New();
109   DALI_TEST_CHECK( effect );
110
111   BufferImage image = CreateBufferImage();
112
113   ImageActor actor = ImageActor::New( image );
114   actor.SetSize( 100.0f, 100.0f );
115   actor.SetShaderEffect( effect );
116
117   effect.SetAmplitude( 5.0f );
118   effect.SetTime( 2.0f );
119
120   Stage::GetCurrent().Add( actor );
121
122   application.SendNotification();
123   application.Render();
124
125   DALI_TEST_CHECK(
126       application.GetGlAbstraction().CheckUniformValue(
127           effect.GetAmplitudePropertyName().c_str(),
128           5.0f ) );
129   DALI_TEST_CHECK(
130       application.GetGlAbstraction().CheckUniformValue(
131           effect.GetTimePropertyName().c_str(),
132           2.0f ) );
133   END_TEST;
134 }