Saving a bit of memory by using pretty function instead of full file name
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit-unmanaged / 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
24
25 using namespace Dali;
26
27
28 void blind_effect_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void blind_effect_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38
39 int UtcDaliBlindEffectUninitialized(void)
40 {
41   ToolkitTestApplication application;
42
43   Toolkit::BlindEffect effect;
44
45   try
46   {
47     // New() must be called to create a BlindEffect or it wont be valid.
48     effect.SetStep( 2.0f );
49     DALI_TEST_CHECK( false );
50   }
51   catch (Dali::DaliException& e)
52   {
53     // Tests that a negative test of an assertion succeeds
54     DALI_TEST_PRINT_ASSERT( e );
55     DALI_TEST_CHECK(!effect);
56   }
57   END_TEST;
58 }
59
60 int UtcDaliBlindEffectPropertyNames(void)
61 {
62   ToolkitTestApplication application;
63
64   Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
65
66   // Check the names, this names are used in the shaders code,
67   // if they change the shader code has to be updated
68   DALI_TEST_EQUALS( effect.GetStepPropertyName(), "uStep", TEST_LOCATION );
69   END_TEST;
70 }
71
72 int UtcDaliBlindEffectDefaultValues(void)
73 {
74   ToolkitTestApplication application;
75
76   Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
77   DALI_TEST_CHECK( effect );
78
79   BitmapImage image = CreateBitmapImage();
80
81   ImageActor actor = ImageActor::New( image );
82   actor.SetSize( 100.0f, 100.0f );
83   actor.SetShaderEffect( effect );
84   Stage::GetCurrent().Add( actor );
85
86   application.SendNotification();
87   application.Render();
88
89   // Gets converted to opengl viewport coordinates
90   DALI_TEST_CHECK(
91       application.GetGlAbstraction().CheckUniformValue(
92           effect.GetStepPropertyName().c_str(),
93           0.0f ) );
94   END_TEST;
95 }
96
97 int UtcDaliBlindEffectCustomValues(void)
98 {
99   ToolkitTestApplication application;
100
101   Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
102   DALI_TEST_CHECK( effect );
103
104   BitmapImage image = CreateBitmapImage();
105
106   ImageActor actor = ImageActor::New( image );
107   actor.SetSize( 100.0f, 100.0f );
108
109   effect.SetStep( 2.0f );
110
111   actor.SetShaderEffect(effect);
112   Stage::GetCurrent().Add(actor);
113
114   application.SendNotification();
115   application.Render();
116
117   // Gets converted to opengl viewport coordinates
118   DALI_TEST_CHECK(
119       application.GetGlAbstraction().CheckUniformValue(
120           effect.GetStepPropertyName().c_str(),
121           2.0f ) );
122   END_TEST;
123 }