Dali 3D User Interface Engine
utc-Dali-Actor.cpp
Go to the documentation of this file.
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 
19 #include <dali-test-suite-utils.h>
20 #include <mesh-builder.h>
21 
22 //& set: DaliActor
23 
24 using std::string;
25 using namespace Dali;
26 
27 
29 {
30  tet_infoline("Testing Actor::AddRenderer");
31  TestApplication application;
32 
33  Actor actor = Actor::New();
34 
36 
37  Geometry geometry = CreateQuadGeometry();
38  Material material = CreateMaterial();
39  Renderer renderer = Renderer::New(geometry, material);
40 
41  actor.AddRenderer( renderer );
43  DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
44 
45  END_TEST;
46 }
47 
49 {
50  tet_infoline("Testing Actor::AddRenderer");
51  TestApplication application;
52 
53  Actor actor = Actor::New();
54  Renderer renderer;
55 
56  // try illegal Add
57  try
58  {
59  actor.AddRenderer( renderer );
60  tet_printf("Assertion test failed - no Exception\n" );
62  }
63  catch(Dali::DaliException& e)
64  {
66  DALI_TEST_ASSERT(e, "Renderer handle is empty", TEST_LOCATION);
68  }
69  catch(...)
70  {
71  tet_printf("Assertion test failed - wrong Exception\n" );
73  }
74 
75  END_TEST;
76 }
77 
79 {
80  tet_infoline("Testing Actor::AddRenderer");
81  TestApplication application;
82 
83  Actor actor = Actor::New();
84  Stage::GetCurrent().Add(actor);
85 
86  application.SendNotification();
87  application.Render(0);
88 
89  Geometry geometry = CreateQuadGeometry();
90  Material material = CreateMaterial();
91  Renderer renderer = Renderer::New(geometry, material);
92 
93  application.SendNotification();
94  application.Render(0);
95 
96  try
97  {
98  actor.AddRenderer( renderer );
100  }
101  catch(...)
102  {
104  }
105 
106  END_TEST;
107 }
108 
110 {
111  tet_infoline("Testing Actor::RemoveRenderer");
112  TestApplication application;
113 
114  Actor actor = Actor::New();
115 
117 
118  Geometry geometry = CreateQuadGeometry();
119  Material material = CreateMaterial();
120  Renderer renderer = Renderer::New(geometry, material);
121 
122  actor.AddRenderer( renderer );
124  DALI_TEST_EQUALS( actor.GetRendererAt(0), renderer, TEST_LOCATION );
125 
126  actor.RemoveRenderer(0);
128 
129 
130  END_TEST;
131 }
Dali Docs Home
Read more about Dali