Merge "Fixed deletion of last character with no place-holder text" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-BlindEffect.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
20 #include <stdlib.h>
21 #include <dali-toolkit-test-suite-utils.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/shader-effects/blind-effect.h>
24
25
26 using namespace Dali;
27
28
29 void blind_effect_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void blind_effect_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39
40 int UtcDaliBlindEffectUninitialized(void)
41 {
42   ToolkitTestApplication application;
43
44   Toolkit::BlindEffect effect;
45
46   try
47   {
48     // New() must be called to create a BlindEffect or it wont be valid.
49     effect.SetStep( 2.0f );
50     DALI_TEST_CHECK( false );
51   }
52   catch (Dali::DaliException& e)
53   {
54     // Tests that a negative test of an assertion succeeds
55     DALI_TEST_PRINT_ASSERT( e );
56     DALI_TEST_CHECK(!effect);
57   }
58   END_TEST;
59 }
60
61 int UtcDaliBlindEffectPropertyNames(void)
62 {
63   ToolkitTestApplication application;
64
65   Toolkit::BlindEffect effect = Toolkit::BlindEffect::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.GetStepPropertyName(), "uStep", TEST_LOCATION );
70   END_TEST;
71 }
72
73 int UtcDaliBlindEffectDefaultValues(void)
74 {
75   ToolkitTestApplication application;
76
77   Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
78   DALI_TEST_CHECK( effect );
79
80   BufferImage image = CreateBufferImage();
81
82   ImageActor actor = ImageActor::New( image );
83   actor.SetSize( 100.0f, 100.0f );
84   actor.SetShaderEffect( effect );
85   Stage::GetCurrent().Add( actor );
86
87   application.SendNotification();
88   application.Render();
89
90   // Gets converted to opengl viewport coordinates
91   DALI_TEST_CHECK(
92       application.GetGlAbstraction().CheckUniformValue(
93           effect.GetStepPropertyName().c_str(),
94           0.0f ) );
95   END_TEST;
96 }
97
98 int UtcDaliBlindEffectCustomValues(void)
99 {
100   ToolkitTestApplication application;
101
102   Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
103   DALI_TEST_CHECK( effect );
104
105   BufferImage image = CreateBufferImage();
106
107   ImageActor actor = ImageActor::New( image );
108   actor.SetSize( 100.0f, 100.0f );
109
110   effect.SetStep( 2.0f );
111
112   actor.SetShaderEffect(effect);
113   Stage::GetCurrent().Add(actor);
114
115   application.SendNotification();
116   application.Render();
117
118   // Gets converted to opengl viewport coordinates
119   DALI_TEST_CHECK(
120       application.GetGlAbstraction().CheckUniformValue(
121           effect.GetStepPropertyName().c_str(),
122           2.0f ) );
123   END_TEST;
124 }