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