2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include <dali/integration-api/scene.h>
22 #include <dali-test-suite-utils.h>
24 // Internal headers are allowed here
26 int UtcDaliSceneAdd(void)
28 TestApplication application;
29 tet_infoline("Testing Dali::Integration::Scene::Add");
31 Dali::Integration::Scene scene = application.GetScene();
33 Actor actor = Actor::New();
34 DALI_TEST_CHECK( !actor.OnStage() );
37 DALI_TEST_CHECK( actor.OnStage() );
42 int UtcDaliSceneRemove(void)
44 TestApplication application;
45 tet_infoline("Testing Dali::Integration::Scene::Remove");
47 Dali::Integration::Scene scene = application.GetScene();
49 Actor actor = Actor::New();
50 DALI_TEST_CHECK( !actor.OnStage() );
53 DALI_TEST_CHECK( actor.OnStage() );
56 DALI_TEST_CHECK( !actor.OnStage() );
61 int UtcDaliSceneGetSize(void)
63 TestApplication application;
64 tet_infoline("Testing Dali::Integration::Scene::GetSize");
66 Dali::Integration::Scene scene = application.GetScene();
67 Size size = scene.GetSize();
68 DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_WIDTH, size.width, TEST_LOCATION );
69 DALI_TEST_EQUALS( TestApplication::DEFAULT_SURFACE_HEIGHT, size.height, TEST_LOCATION );
74 int UtcDaliSceneGetDpi(void)
76 TestApplication application; // Initializes core DPI to default values
78 // Test that setting core DPI explicitly also sets up the scene's DPI.
79 Dali::Integration::Scene scene = application.GetScene();
80 scene.SetDpi( Vector2(200.0f, 180.0f) );
81 Vector2 dpi = scene.GetDpi();
82 DALI_TEST_EQUALS( dpi.x, 200.0f, TEST_LOCATION );
83 DALI_TEST_EQUALS( dpi.y, 180.0f, TEST_LOCATION );
87 int UtcDaliSceneGetRenderTaskList(void)
89 TestApplication application;
90 tet_infoline("Testing Dali::Integration::Scene::GetRenderTaskList");
92 Dali::Integration::Scene scene = application.GetScene();
94 // Check we get a valid instance.
95 const RenderTaskList& tasks = scene.GetRenderTaskList();
97 // There should be 1 task by default.
98 DALI_TEST_EQUALS( tasks.GetTaskCount(), 1u, TEST_LOCATION );
100 // RenderTaskList has it's own UTC tests.
101 // But we can confirm that GetRenderTaskList in Stage retrieves the same RenderTaskList each time.
102 RenderTask newTask = scene.GetRenderTaskList().CreateTask();
104 DALI_TEST_EQUALS( scene.GetRenderTaskList().GetTask( 1 ), newTask, TEST_LOCATION );
109 int UtcDaliSceneGetRootLayer(void)
111 TestApplication application;
112 tet_infoline("Testing Dali::Integration::Scene::GetRootLayer");
114 Dali::Integration::Scene scene = application.GetScene();
115 Layer layer = scene.GetLayer( 0 );
116 DALI_TEST_CHECK( layer );
118 // Check that GetRootLayer() correctly retreived layer 0.
119 DALI_TEST_CHECK( scene.GetRootLayer() == layer );
124 int UtcDaliSceneGetLayerCount(void)
126 TestApplication application;
127 tet_infoline("Testing Dali::Integration::Scene::GetLayerCount");
129 Dali::Integration::Scene scene = application.GetScene();
130 // Initially we have a default layer
131 DALI_TEST_EQUALS( scene.GetLayerCount(), 1u, TEST_LOCATION );
133 Layer layer = Layer::New();
136 DALI_TEST_EQUALS( scene.GetLayerCount(), 2u, TEST_LOCATION );
140 int UtcDaliSceneGetLayer(void)
142 TestApplication application;
143 tet_infoline("Testing Dali::Integration::Scene::GetLayer");
145 Dali::Integration::Scene scene = application.GetScene();
147 Layer rootLayer = scene.GetLayer( 0 );
148 DALI_TEST_CHECK( rootLayer );
150 Layer layer = Layer::New();
153 Layer sameLayer = scene.GetLayer( 1 );
154 DALI_TEST_CHECK( layer == sameLayer );