2 * Copyright (c) 2022 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.
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/magnifier/magnifier.h>
26 using namespace Toolkit;
28 void dali_magnifier_startup(void)
30 test_return_value = TET_UNDEF;
33 void dali_magnifier_cleanup(void)
35 test_return_value = TET_PASS;
38 int UtcDaliMagnifierNew(void)
40 ToolkitTestApplication application;
43 DALI_TEST_CHECK(!magnifier);
45 magnifier = Magnifier::New();
46 DALI_TEST_CHECK(magnifier);
48 application.GetScene().Add(magnifier);
50 application.SendNotification();
56 int UtcDaliMagnifierCopyAndAssignment(void)
58 ToolkitTestApplication application;
60 Magnifier view = Magnifier::New();
61 DALI_TEST_CHECK(view);
64 DALI_TEST_CHECK(copy == view);
67 DALI_TEST_CHECK(!assign);
69 DALI_TEST_CHECK(assign == view);
73 DALI_TEST_CHECK(assign);
74 DALI_TEST_CHECK(assign == view);
79 int UtcDaliMagnifierDownCast(void)
81 ToolkitTestApplication application;
83 BaseHandle view = Magnifier::New();
84 DALI_TEST_CHECK(Magnifier::DownCast(view));
87 DALI_TEST_CHECK(!Magnifier::DownCast(empty));
89 BaseHandle another = Actor::New();
90 DALI_TEST_CHECK(!Magnifier::DownCast(another));
95 int UtcDaliMagnifierTypeRegistry(void)
97 ToolkitTestApplication application;
99 TypeRegistry typeRegistry = TypeRegistry::Get();
100 DALI_TEST_CHECK(typeRegistry);
102 TypeInfo typeInfo = typeRegistry.GetTypeInfo("Magnifier");
103 DALI_TEST_CHECK(typeInfo);
105 BaseHandle handle = typeInfo.CreateInstance();
106 DALI_TEST_CHECK(handle);
108 Magnifier view = Magnifier::DownCast(handle);
109 DALI_TEST_CHECK(view);
114 int UtcDaliMagnifierSetSourceActorP(void)
116 ToolkitTestApplication application;
118 Integration::Scene stage = application.GetScene();
120 Magnifier view = Magnifier::New();
123 application.SendNotification();
124 application.Render();
126 RenderTaskList renderTaskList = stage.GetRenderTaskList();
127 DALI_TEST_CHECK(renderTaskList.GetTaskCount() > 1);
129 Actor actor = Actor::New();
131 DALI_TEST_CHECK(stage.GetRenderTaskList().GetTask(1).GetSourceActor() != actor);
133 view.SetSourceActor(actor);
135 application.SendNotification();
136 application.Render();
138 DALI_TEST_EQUALS(stage.GetRenderTaskList().GetTask(1).GetSourceActor(), actor, TEST_LOCATION);
143 int UtcDaliMagnifierSetSourceActorN(void)
145 ToolkitTestApplication application;
151 view.SetSourceActor(Actor::New());
152 DALI_TEST_CHECK(false); // should not get here
156 DALI_TEST_CHECK(true);
162 int UtcDaliMagnifierFrameVisibility(void)
164 ToolkitTestApplication application;
166 Integration::Scene stage = application.GetScene();
168 Magnifier view = Magnifier::New();
171 application.SendNotification();
172 application.Render();
174 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::FRAME_VISIBILITY).Get<bool>(), true, TEST_LOCATION);
176 view.SetProperty(Magnifier::Property::FRAME_VISIBILITY, false);
177 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::FRAME_VISIBILITY).Get<bool>(), false, TEST_LOCATION);
179 application.SendNotification();
180 application.Render();
182 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::FRAME_VISIBILITY).Get<bool>(), false, TEST_LOCATION);
184 view.SetProperty(Magnifier::Property::FRAME_VISIBILITY, true);
185 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::FRAME_VISIBILITY).Get<bool>(), true, TEST_LOCATION);
187 application.SendNotification();
188 application.Render();
190 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::FRAME_VISIBILITY).Get<bool>(), true, TEST_LOCATION);
195 int UtcDaliMagnifierMagnificationFactor(void)
197 ToolkitTestApplication application;
199 Integration::Scene stage = application.GetScene();
201 Magnifier view = Magnifier::New();
204 application.SendNotification();
205 application.Render();
207 float magnificationFactor(200.0f);
209 DALI_TEST_CHECK(view.GetProperty(Magnifier::Property::MAGNIFICATION_FACTOR).Get<float>() != magnificationFactor);
211 view.SetProperty(Magnifier::Property::MAGNIFICATION_FACTOR, magnificationFactor);
212 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::MAGNIFICATION_FACTOR).Get<float>(), magnificationFactor, TEST_LOCATION);
214 application.SendNotification();
215 application.Render();
217 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::MAGNIFICATION_FACTOR).Get<float>(), magnificationFactor, TEST_LOCATION);
219 view.SetProperty(Magnifier::Property::MAGNIFICATION_FACTOR, 1.0f);
220 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::MAGNIFICATION_FACTOR).Get<float>(), 1.0f, TEST_LOCATION);
222 application.SendNotification();
223 application.Render();
225 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::MAGNIFICATION_FACTOR).Get<float>(), 1.0f, TEST_LOCATION);
230 int UtcDaliMagnifierSourcePosition(void)
232 ToolkitTestApplication application;
234 Integration::Scene stage = application.GetScene();
236 Magnifier view = Magnifier::New();
239 application.SendNotification();
240 application.Render();
242 Vector3 position(100.0f, 200.0f, 300.0f);
244 DALI_TEST_CHECK(view.GetProperty(Magnifier::Property::SOURCE_POSITION).Get<Vector3>() != position);
246 view.SetProperty(Magnifier::Property::SOURCE_POSITION, position);
247 application.SendNotification();
248 application.Render();
249 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::SOURCE_POSITION).Get<Vector3>(), position, TEST_LOCATION);
251 view.SetProperty(Magnifier::Property::SOURCE_POSITION, Vector3::ONE);
252 application.SendNotification();
253 application.Render();
254 DALI_TEST_EQUALS(view.GetProperty(Magnifier::Property::SOURCE_POSITION).Get<Vector3>(), Vector3::ONE, TEST_LOCATION);
259 int UtcDaliMagnifierOnSizeSet(void)
261 ToolkitTestApplication application;
263 Magnifier view = Magnifier::New();
265 application.GetScene().Add(view);
267 application.SendNotification();
268 application.Render();
270 Vector3 size(200.0f, 300.0f, 0.0f);
271 view.SetProperty(Actor::Property::SIZE, size);
273 application.SendNotification();
274 application.Render();
276 DALI_TEST_EQUALS(view.GetCurrentProperty<Vector3>(Actor::Property::SIZE), size, TEST_LOCATION);