Conversion to Apache 2.0 license
[platform/core/uifw/dali-toolkit.git] / automated-tests / TET / dali-test-suite / shader-effects / utc-Dali-SoftButtonEffect.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 <tet_api.h>
22
23 #include <dali/public-api/dali-core.h>
24 #include <dali-toolkit/dali-toolkit.h>
25
26 #include <dali-toolkit-test-suite-utils.h>
27
28 using namespace Dali;
29 using namespace Dali::Toolkit;
30
31 static void Startup();
32 static void Cleanup();
33
34 extern "C" {
35   void (*tet_startup)() = Startup;
36   void (*tet_cleanup)() = Cleanup;
37 }
38
39 static void UtcDaliSoftButtonEffectUninitialized();
40 static void UtcDaliSoftButtonEffectNew();
41 static void UtcDaliSoftButtonEffectPropertyNames();
42
43 enum {
44   POSITIVE_TC_IDX = 0x01,
45   NEGATIVE_TC_IDX,
46 };
47
48 // Add test functionality for all APIs in the class (Positive and Negative)
49 extern "C" {
50   struct tet_testlist tet_testlist[] = {
51       { UtcDaliSoftButtonEffectUninitialized, NEGATIVE_TC_IDX },
52       { UtcDaliSoftButtonEffectNew, POSITIVE_TC_IDX },
53       { UtcDaliSoftButtonEffectPropertyNames, POSITIVE_TC_IDX },
54     { NULL, 0 }
55   };
56 }
57
58 // Called only once before first test is run.
59 static void Startup()
60 {
61 }
62
63 // Called only once after last test is run
64 static void Cleanup()
65 {
66 }
67
68 // Negative test case for a method
69 static void UtcDaliSoftButtonEffectUninitialized()
70 {
71   ToolkitTestApplication application;
72   tet_infoline("UtcDaliSoftButtonEffectUninitialized");
73
74   Toolkit::SoftButtonEffect effect;
75
76   // New() must be called to create a SoftButtonEffect or it wont be valid.
77
78   DALI_TEST_CHECK(!effect);
79 }
80
81 // Positive test case for a method
82 static void UtcDaliSoftButtonEffectNew()
83 {
84   ToolkitTestApplication application;
85   tet_infoline("UtcDaliGaussianBlurViewNew");
86
87   Toolkit::SoftButtonEffect effect = Toolkit::SoftButtonEffect::New(Toolkit::SoftButtonEffect::ELLIPTICAL);
88   DALI_TEST_CHECK( effect );
89 }
90
91 // Positive test case for a method
92 static void UtcDaliSoftButtonEffectPropertyNames()
93 {
94   ToolkitTestApplication application;
95   tet_infoline("UtcDaliSoftButtonEffectPropertyNames");
96
97   Toolkit::SoftButtonEffect effect = Toolkit::SoftButtonEffect::New(Toolkit::SoftButtonEffect::ELLIPTICAL);
98   DALI_TEST_CHECK( effect );
99
100   // Check the names, this names are used in the shader code,
101   // if they change in the shader code, then it has to be updated here.
102   DALI_TEST_EQUALS( effect.GetLightingIndentationAmountPropertyName(), "uLightingIndentationAmount", TEST_LOCATION );
103   DALI_TEST_EQUALS( effect.GetTextureDistortionAmountPropertyName(), "uTextureDistortAmount", TEST_LOCATION );
104   DALI_TEST_EQUALS( effect.GetAmbientLightAmountPropertyName(), "uAmbientLight", TEST_LOCATION );
105   DALI_TEST_EQUALS( effect.GetDiffuseLightPropertyName(), "uDiffuseLight", TEST_LOCATION );
106   DALI_TEST_EQUALS( effect.GetLightingMultiplierPropertyName(), "uLightMultiplier", TEST_LOCATION );
107   DALI_TEST_EQUALS( effect.GetInsideShapeSizeScalePropertyName(), "uInsideCircleSizeScale", TEST_LOCATION );
108   DALI_TEST_EQUALS( effect.GetOutsideShapeDepthPropertyName(), "uOutsideCircleDepth", TEST_LOCATION );
109   DALI_TEST_EQUALS( effect.GetEffectPixelAreaPropertyName(), "uEffectRegion", TEST_LOCATION );
110   DALI_TEST_EQUALS( effect.GetRectangleSizeScalePropertyName(), "uRectangleSizeScale", TEST_LOCATION );
111 }