Split text-controller files in text-controller and text-controller-impl.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-SpotEffect.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
23
24 using namespace Dali;
25
26 void spot_effect_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void spot_effect_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36
37 int UtcDaliSpotUninitializedEffect(void)
38 {
39   ToolkitTestApplication application;
40
41   Toolkit::SpotEffect effect;
42
43   try
44   {
45     // New() must be called to create a SpotEffect or it wont be valid.
46     effect.SetRadius( 0.5f );
47     DALI_TEST_CHECK( false );
48   }
49   catch (Dali::DaliException& e)
50   {
51     // Tests that a negative test of an assertion succeeds
52     DALI_TEST_PRINT_ASSERT( e );
53     DALI_TEST_CHECK(!effect);
54   }
55   END_TEST;
56 }
57
58 int UtcDaliSpotPropertyNamesEffect(void)
59 {
60   ToolkitTestApplication application;
61
62   Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
63
64   // Check the names, this names are used in the shaders code,
65   // if they change the shader code has to be updated
66   DALI_TEST_EQUALS( effect.GetCenterPropertyName(), "uCenter", TEST_LOCATION );
67   DALI_TEST_EQUALS( effect.GetRadiusPropertyName(), "uRadius", TEST_LOCATION );
68   END_TEST;
69 }
70
71 int UtcDaliSpotDefaultValuesEffect(void)
72 {
73   ToolkitTestApplication application;
74
75   Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
76   DALI_TEST_CHECK( effect );
77
78   BufferImage image = CreateBufferImage();
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.GetCenterPropertyName().c_str(),
92           Vector2(0.0f, 0.0f) ) );
93
94   DALI_TEST_CHECK(
95       application.GetGlAbstraction().CheckUniformValue(
96           effect.GetRadiusPropertyName().c_str(),
97           0.0f ) );
98   END_TEST;
99 }
100
101 int UtcDaliSpotCustomValuesEffect(void)
102 {
103   ToolkitTestApplication application;
104
105   Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
106   DALI_TEST_CHECK( effect );
107
108   BufferImage image = CreateBufferImage();
109
110   ImageActor actor = ImageActor::New( image );
111   actor.SetSize( 100.0f, 100.0f );
112
113   effect.SetCenter( Vector2(480.0f, 800.0f) );
114   effect.SetRadius( 5.0f );
115
116   actor.SetShaderEffect( effect );
117   Stage::GetCurrent().Add( actor );
118
119   application.SendNotification();
120   application.Render();
121
122   // Gets converted to opengl viewport coordinates
123   DALI_TEST_CHECK(
124       application.GetGlAbstraction().CheckUniformValue(
125           effect.GetCenterPropertyName().c_str(),
126           Vector2(480.0f, 800.0f) ) );
127
128   DALI_TEST_CHECK(
129       application.GetGlAbstraction().CheckUniformValue(
130           effect.GetRadiusPropertyName().c_str(),
131           5.0f ) );
132   END_TEST;
133 }