Removing GetDefaultFontDescription from Platform Abstraction Test
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ControlRenderer.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 #include <iostream>
18 #include <stdlib.h>
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <dali/devel-api/rendering/renderer.h>
21 #include <dali/devel-api/rendering/material.h>
22 #include <dali/devel-api/rendering/shader.h>
23 #include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
24
25 using namespace Dali;
26 using namespace Dali::Toolkit;
27
28 void dali_control_renderer_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void dali_control_renderer_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 int UtcDaliControlRendererCopyAndAssignment(void)
39 {
40   ToolkitTestApplication application;
41   tet_infoline( "UtcDaliControlRendererCopyAndAssignment" );
42
43   RendererFactory factory = RendererFactory::Get();
44   Property::Map propertyMap;
45   propertyMap.Insert("renderer-type", "color-renderer");
46   propertyMap.Insert("blend-color", Color::BLUE);
47   ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
48
49   ControlRenderer controlRendererCopy( controlRenderer );
50   DALI_TEST_CHECK(controlRenderer == controlRendererCopy);
51
52   ControlRenderer emptyControlRenderer;
53   ControlRenderer emptyControlRendererCopy( emptyControlRenderer );
54   DALI_TEST_CHECK(emptyControlRenderer == emptyControlRendererCopy);
55
56   ControlRenderer controlRendererEquals;
57   controlRendererEquals = controlRenderer;
58   DALI_TEST_CHECK(controlRenderer == controlRendererEquals);
59
60   ControlRenderer emptyControlRendererEquals;
61   emptyControlRendererEquals = emptyControlRenderer;
62   DALI_TEST_CHECK( emptyControlRenderer == emptyControlRendererEquals );
63
64   //self assignment
65   controlRenderer = controlRenderer;
66   DALI_TEST_CHECK( controlRenderer = controlRendererCopy );
67
68   END_TEST;
69 }
70
71 int UtcDaliControlRendererSetDepthIndex(void)
72 {
73   ToolkitTestApplication application;
74   tet_infoline( "UtcDaliControlRendererSetDepthIndex" );
75
76   RendererFactory factory = RendererFactory::Get();
77   Property::Map propertyMap;
78   propertyMap.Insert("renderer-type", "color-renderer");
79   propertyMap.Insert("blend-color", Color::BLUE);
80   ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
81
82   controlRenderer.SetDepthIndex( 1.f );
83
84   Actor actor = Actor::New();
85   actor.SetSize(200.f, 200.f);
86   Stage::GetCurrent().Add( actor );
87   controlRenderer.SetOnStage( actor );
88
89   DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), 1.f, TEST_LOCATION );
90
91   controlRenderer.SetDepthIndex( -1.f );
92   DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), -1.f, TEST_LOCATION );
93
94   END_TEST;
95 }
96
97 int UtcDaliControlRendererSetOnStage(void)
98 {
99   ToolkitTestApplication application;
100   tet_infoline( "UtcDaliControlRendererSetDepthIndex" );
101
102   RendererFactory factory = RendererFactory::Get();
103   Property::Map propertyMap;
104   propertyMap.Insert("renderer-type", "color-renderer");
105   propertyMap.Insert("blend-color", Color::BLUE);
106   ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
107
108   Actor actor = Actor::New();
109   actor.SetSize(200.f, 200.f);
110   Stage::GetCurrent().Add( actor );
111
112   application.SendNotification();
113   application.Render(0);
114   DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
115
116   controlRenderer.SetOnStage( actor );
117
118   application.SendNotification();
119   application.Render(0);
120   DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
121
122   END_TEST;
123 }