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