Merge "Merge branch 'devel/new_mesh' into devel/master" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-MeshMaterial.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/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
23
24 using namespace Dali;
25
26 #include <mesh-builder.h>
27
28 void mesh_material_test_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void mesh_material_test_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38
39 namespace
40 {
41
42 Material ConstructMaterial( const std::string& vertexShader,
43                             const std::string& fragmentShader,
44                             float opacity )
45 {
46   Shader shader = Shader::New( vertexShader, fragmentShader );
47   Material customMaterial = Material::New(shader);
48   Vector4 color = Color::WHITE;
49   color.a = opacity;
50   customMaterial.SetProperty(Material::Property::COLOR, color);
51   return customMaterial;
52 }
53
54 void TestBlending( TestApplication& application, Material material, float actorOpacity, BlendingMode::Type blendingMode, bool expectedBlend )
55 {
56   // Generate geometry & renderers
57   //Mesh mesh = Mesh::New(meshData);
58
59   application.SendNotification();
60   application.Render(0);
61   application.Render();
62   application.SendNotification();
63
64   Actor actor = Actor::New();
65   Stage::GetCurrent().Add(actor);
66
67   //material.SetBlendMode(blendingMode);
68   actor.SetOpacity(actorOpacity);
69
70   TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace();
71   cullFaceTrace.Enable(true);
72   application.SendNotification();
73   application.Render();
74   //DALI_TEST_EQUALS( BlendEnabled( cullFaceTrace ), expectedBlend, TEST_LOCATION );
75 }
76
77 } // anonymous namespace
78
79
80 /**
81  * Test cases
82  *
83  * Check construction of mesh objects
84  * Check downcast of mesh objects (+ve & -ve)
85  * Check staging of mesh objects
86  *
87  * Check staging of some mesh objects but not all
88  * Create geometry with no verts - ensure it asserts
89  * Create an element based geometry with no indices - ensure it asserts
90  * Create a renderer without a material - ensure nothing renders
91  * Create a render with a material, ensure the material can be changed
92  * Create a render with a material&Sampler, ensure the sampler can be changed
93  * Create a render with a material, sampler, ensure the sampler's texture can be changed
94  * Create a render with a material, sampler, ensure that removing the sampler works
95  *
96  * Blend tests:
97  * 1 Set Material with translucent color, actor color opaque, Set Use image alpha to true
98  *   Expect blending
99  * 2 Set material to translucent, set use image alpha to false, set actor opacity to 1.0f
100  *   Expect no blending
101  * 3 Set material to opaque, set use image alpha to true, set actor opacity to 1.0f
102  *   Expect no blending
103  * 4 Set material to have image with alpha, set use image alpha to true, set actor opacity to 1.0f
104  *   Expect blending
105  * 5 Set material to have image with alpha, set use image alpha to false, set actor opacity to 1.0f
106  *   Expect no blending
107  * 6 Set material to have image without alpha, set use image alpha to true, set actor opacity to 1.0f
108  *   Expect no blending
109  * 7 Set material to have framebuffer with alpha, set use image alpha to true, set actor opacity to 1.0f
110  *   Expect blending
111  * 8 Set material to have image with alpha, set use image alpha to false, set actor opacity to 0.5f
112  *   Expect blending
113  * 9 Set material to have image with no alpha, set material opacity to 0.5, set use image alpha to true, set actor opacity to 1.0f
114  *   Expect blending
115  *
116  * Check defaults of renderer
117  *
118  * Bounding box of geometry?
119  *
120  * Check rendered vertex buffer is the right size for the initial property buffer
121  *
122  * Check PropertyBuffer set via SetData can be read thru property system
123  * Check PropertyBuffer property setters / getters
124  * Check vertex PropertyBuffer set via properties renders as expected
125  * Check Index propertyBuffer set via properties renders as expected
126  *
127  * Check geometry type renders correctly as the matching GL draw call and type
128  *
129  * Check attributes change when rendering different actors with different
130  * vertex formats (utc-Dali-Context.cpp)
131  *
132  * utc-Dali-Material.cpp
133  * Check material color affects output - see shader uniform
134  *
135  * Check material sampler's image load/release policies affect rendering correctly.
136  */