Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Shader.cpp
1 /*
2  * Copyright (c) 2015 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/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23
24 using namespace Dali;
25
26 void utc_dali_shader_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void utc_dali_shader_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 namespace
37 {
38
39 static const char* VertexSource =
40 "This is a custom vertex shader\n"
41 "made on purpose to look nothing like a normal vertex shader inside dali\n";
42
43 static const char* FragmentSource =
44 "This is a custom fragment shader\n"
45 "made on purpose to look nothing like a normal fragment shader inside dali\n";
46
47 } // anon namespace
48
49
50 int UtcDaliShaderMethodNew01(void)
51 {
52   TestApplication application;
53
54   Shader shader = Shader::New( VertexSource, FragmentSource );
55   DALI_TEST_EQUALS((bool)shader, true, TEST_LOCATION);
56   END_TEST;
57 }
58
59 int UtcDaliShaderMethodNew02(void)
60 {
61   TestApplication application;
62
63   Shader shader;
64   DALI_TEST_EQUALS((bool)shader, false, TEST_LOCATION);
65   END_TEST;
66 }
67
68 int UtcDaliShaderDownCast01(void)
69 {
70   TestApplication application;
71
72   Shader shader = Shader::New(VertexSource, FragmentSource);
73
74   BaseHandle handle(shader);
75   Shader shader2 = Shader::DownCast(handle);
76   DALI_TEST_EQUALS( (bool)shader2, true, TEST_LOCATION );
77   END_TEST;
78 }
79
80 int UtcDaliShaderDownCast02(void)
81 {
82   TestApplication application;
83
84   Handle handle = Handle::New(); // Create a custom object
85   Shader shader = Shader::DownCast(handle);
86   DALI_TEST_EQUALS( (bool)shader, false, TEST_LOCATION );
87   END_TEST;
88 }