Merge "Move tts-player.h from devel-api to public-api" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-SquareDissolveEffect.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 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22 #include <dali-toolkit/devel-api/shader-effects/square-dissolve-effect.h>
23
24
25 using namespace Dali;
26
27 void square_dissolve_effect_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void square_dissolve_effect_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37
38 int UtcDaliSquareDissolveEffectUninitialized(void)
39 {
40   ToolkitTestApplication application;
41
42   Toolkit::SquareDissolveEffect effect;
43
44   try
45   {
46     // New() must be called to create a SquareDissolveEffect or it wont be valid.
47     effect.SetStep( 2.0f );
48     DALI_TEST_CHECK( false );
49   }
50   catch (Dali::DaliException& e)
51   {
52     // Tests that a negative test of an assertion succeeds
53     DALI_TEST_PRINT_ASSERT( e );
54     DALI_TEST_CHECK(!effect);
55   }
56   END_TEST;
57 }
58
59 int UtcDaliSquareDissolveEffectPropertyNames(void)
60 {
61   ToolkitTestApplication application;
62
63   Toolkit::SquareDissolveEffect effect = Toolkit::SquareDissolveEffect::New();
64
65   // Check the names, this names are used in the shaders code,
66   // if they change the shader code has to be updated
67   DALI_TEST_EQUALS( effect.GetStepPropertyName(), "uStep", TEST_LOCATION );
68   DALI_TEST_EQUALS( effect.GetRowsPropertyName(), "uRows", TEST_LOCATION );
69   DALI_TEST_EQUALS( effect.GetColumnsPropertyName(), "uColumns", TEST_LOCATION );
70   DALI_TEST_EQUALS( effect.GetTexSizePropertyName(), "texSize", TEST_LOCATION );
71   END_TEST;
72 }
73
74 int UtcDaliSquareDissolveEffectDefaultValues(void)
75 {
76   ToolkitTestApplication application;
77
78   Toolkit::SquareDissolveEffect effect = Toolkit::SquareDissolveEffect::New();
79   DALI_TEST_CHECK( effect );
80
81   BufferImage image = CreateBufferImage();
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   // Gets converted to opengl viewport coordinates
92   DALI_TEST_CHECK(
93       application.GetGlAbstraction().CheckUniformValue(
94           effect.GetStepPropertyName().c_str(),
95           0.1f ) );
96
97   DALI_TEST_CHECK(
98       application.GetGlAbstraction().CheckUniformValue(
99           effect.GetRowsPropertyName().c_str(),
100           25.0f ) );
101
102   DALI_TEST_CHECK(
103       application.GetGlAbstraction().CheckUniformValue(
104           effect.GetColumnsPropertyName().c_str(),
105           25.0f ) );
106
107   DALI_TEST_CHECK(
108       application.GetGlAbstraction().CheckUniformValue(
109           effect.GetTexSizePropertyName().c_str(),
110           Vector2(1.0f, 1.0f) ) );
111   END_TEST;
112 }
113
114 int UtcDaliSquareDissolveEffectCustomValues(void)
115 {
116   ToolkitTestApplication application;
117
118   Toolkit::SquareDissolveEffect effect = Toolkit::SquareDissolveEffect::New();
119   DALI_TEST_CHECK( effect );
120
121   BufferImage image = CreateBufferImage();
122
123   ImageActor actor = ImageActor::New( image );
124   actor.SetSize( 100.0f, 100.0f );
125
126   effect.SetStep( 2.0f );
127   effect.SetRows( 3.0f );
128   effect.SetColumns( 4.0f );
129   effect.SetTextureSize( Vector2(12.0f, 13.0f) );
130
131   actor.SetShaderEffect(effect);
132   Stage::GetCurrent().Add(actor);
133
134   application.SendNotification();
135   application.Render();
136
137   // Gets converted to opengl viewport coordinates
138   DALI_TEST_CHECK(
139       application.GetGlAbstraction().CheckUniformValue(
140           effect.GetStepPropertyName().c_str(),
141           2.0f ) );
142
143   DALI_TEST_CHECK(
144       application.GetGlAbstraction().CheckUniformValue(
145           effect.GetRowsPropertyName().c_str(),
146           3.0f ) );
147
148   DALI_TEST_CHECK(
149       application.GetGlAbstraction().CheckUniformValue(
150           effect.GetColumnsPropertyName().c_str(),
151           4.0f ) );
152
153   DALI_TEST_CHECK(
154       application.GetGlAbstraction().CheckUniformValue(
155           effect.GetTexSizePropertyName().c_str(),
156           Vector2(12.0f, 13.0f) ) );
157   END_TEST;
158 }