Revert "License conversion from Flora to Apache 2.0"
[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 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
19 #include <stdlib.h>
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <dali-toolkit/dali-toolkit.h>
22
23
24 using namespace Dali;
25
26
27 void blind_effect_startup(void)
28 {
29   test_return_value = TET_UNDEF;
30 }
31
32 void blind_effect_cleanup(void)
33 {
34   test_return_value = TET_PASS;
35 }
36
37
38 int UtcDaliBlindEffectUninitialized(void)
39 {
40   ToolkitTestApplication application;
41
42   Toolkit::BlindEffect effect;
43
44   try
45   {
46     // New() must be called to create a BlindEffect 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     tet_printf("Assertion %s failed at %s\n", e.mCondition.c_str(), e.mLocation.c_str());
54     DALI_TEST_CHECK(!effect);
55   }
56   END_TEST;
57 }
58
59 int UtcDaliBlindEffectPropertyNames(void)
60 {
61   ToolkitTestApplication application;
62
63   Toolkit::BlindEffect effect = Toolkit::BlindEffect::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   END_TEST;
69 }
70
71 int UtcDaliBlindEffectDefaultValues(void)
72 {
73   ToolkitTestApplication application;
74
75   Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
76   DALI_TEST_CHECK( effect );
77
78   BitmapImage image = CreateBitmapImage();
79
80   ImageActor actor = ImageActor::New( image );
81   actor.SetSize( 100.0f, 100.0f );
82   actor.SetShaderEffect( effect );
83   Stage::GetCurrent().Add( actor );
84
85   application.SendNotification();
86   application.Render();
87
88   // Gets converted to opengl viewport coordinates
89   DALI_TEST_CHECK(
90       application.GetGlAbstraction().CheckUniformValue(
91           effect.GetStepPropertyName().c_str(),
92           0.0f ) );
93   END_TEST;
94 }
95
96 int UtcDaliBlindEffectCustomValues(void)
97 {
98   ToolkitTestApplication application;
99
100   Toolkit::BlindEffect effect = Toolkit::BlindEffect::New();
101   DALI_TEST_CHECK( effect );
102
103   BitmapImage image = CreateBitmapImage();
104
105   ImageActor actor = ImageActor::New( image );
106   actor.SetSize( 100.0f, 100.0f );
107
108   effect.SetStep( 2.0f );
109
110   actor.SetShaderEffect(effect);
111   Stage::GetCurrent().Add(actor);
112
113   application.SendNotification();
114   application.Render();
115
116   // Gets converted to opengl viewport coordinates
117   DALI_TEST_CHECK(
118       application.GetGlAbstraction().CheckUniformValue(
119           effect.GetStepPropertyName().c_str(),
120           2.0f ) );
121   END_TEST;
122 }