Updating code formatting
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Tooltip.cpp
1 /*
2  * Copyright (c) 2022 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 <stdlib.h>
19 #include <iostream>
20
21 // Need to override adaptor classes for toolkit test harness, so include
22 // test harness headers before dali headers.
23 #include <dali-toolkit-test-suite-utils.h>
24 #include <toolkit-timer.h>
25
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit/devel-api/controls/control-devel.h>
28 #include <dali-toolkit/devel-api/controls/popup/popup.h>
29 #include <dali-toolkit/devel-api/controls/tooltip/tooltip-properties.h>
30 #include <dali.h>
31 #include <dali/integration-api/events/hover-event-integ.h>
32
33 using namespace Dali;
34 using namespace Dali::Toolkit;
35
36 ///////////////////////////////////////////////////////////////////////////////////////////////////
37
38 void utc_dali_toolkit_tooltip_startup(void)
39 {
40   test_return_value = TET_UNDEF;
41 }
42
43 void utc_dali_toolkit_tooltip_cleanup(void)
44 {
45   test_return_value = TET_PASS;
46 }
47
48 ///////////////////////////////////////////////////////////////////////////////////////////////////
49
50 namespace
51 {
52 Integration::HoverEvent GenerateSingleHover(PointState::Type state, const Vector2& screenPosition)
53 {
54   Integration::HoverEvent hoverEvent;
55   Integration::Point      point;
56   point.SetState(static_cast<PointState::Type>(state));
57   point.SetScreenPosition(screenPosition);
58   hoverEvent.points.push_back(point);
59   return hoverEvent;
60 }
61
62 } // unnamed namespace
63
64 ///////////////////////////////////////////////////////////////////////////////////////////////////
65
66 int UtcDaliTooltipGetWithoutSetting(void)
67 {
68   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
69
70   Control control = Control::New();
71   tet_infoline("Check if Property::MAP is returned");
72   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
73   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
74
75   tet_infoline("Ensure map is valid");
76   Property::Map* map = value.GetMap();
77   DALI_TEST_CHECK(map);
78
79   tet_infoline("Ensure map is empty");
80   DALI_TEST_EQUALS(true, map->Empty(), TEST_LOCATION);
81
82   END_TEST;
83 }
84
85 int UtcDaliTooltipCreateWithString(void)
86 {
87   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
88
89   Control control = Control::New();
90   control.SetProperty(DevelControl::Property::TOOLTIP, "Hello Test");
91
92   tet_infoline("Check if Property::MAP is returned");
93   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
94   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
95
96   tet_infoline("Ensure map is valid");
97   Property::Map* map = value.GetMap();
98   DALI_TEST_CHECK(map);
99
100   tet_infoline("Ensure map contains the content");
101   Property::Value* contentValue = map->Find(Tooltip::Property::CONTENT);
102   DALI_TEST_CHECK(contentValue);
103
104   tet_infoline("Check content is a property map");
105   Property::Map* contentMap = contentValue->GetMap();
106   DALI_TEST_CHECK(contentMap);
107
108   tet_infoline("Check that the map contains the text item");
109   Property::Value* textStringValue = contentMap->Find(TextVisual::Property::TEXT);
110   DALI_TEST_CHECK(textStringValue);
111
112   tet_infoline("Ensure it matches what we set");
113   DALI_TEST_EQUALS("Hello Test", textStringValue->Get<std::string>(), TEST_LOCATION);
114
115   tet_infoline("We sent valid text, so ensure the hover signal has been connected to");
116   DALI_TEST_EQUALS(control.HoveredSignal().GetConnectionCount(), 1u, TEST_LOCATION);
117
118   END_TEST;
119 }
120
121 int UtcDaliTooltipCreateWithTextVisualMap(void)
122 {
123   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
124
125   Control control = Control::New();
126   control.SetProperty(DevelControl::Property::TOOLTIP,
127                       Property::Map().Add(Tooltip::Property::CONTENT,
128                                           Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::TEXT).Add(TextVisual::Property::TEXT, "Hello TextVisual Test")));
129
130   tet_infoline("Check if Property::MAP is returned");
131   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
132   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
133
134   tet_infoline("Ensure map is valid");
135   Property::Map* map = value.GetMap();
136   DALI_TEST_CHECK(map);
137
138   tet_infoline("Ensure map contains the content");
139   Property::Value* contentValue = map->Find(Tooltip::Property::CONTENT);
140   DALI_TEST_CHECK(contentValue);
141
142   tet_infoline("Check content is a property map");
143   Property::Map* contentMap = contentValue->GetMap();
144   DALI_TEST_CHECK(contentMap);
145
146   tet_infoline("Check that the map contains the text item");
147   Property::Value* textStringValue = contentMap->Find(TextVisual::Property::TEXT);
148   DALI_TEST_CHECK(textStringValue);
149
150   tet_infoline("Ensure it matches what we set");
151   DALI_TEST_EQUALS("Hello TextVisual Test", textStringValue->Get<std::string>(), TEST_LOCATION);
152
153   tet_infoline("We sent a text visual with TEXT property set, so ensure the hover signal has been connected to");
154   DALI_TEST_EQUALS(control.HoveredSignal().GetConnectionCount(), 1u, TEST_LOCATION);
155
156   END_TEST;
157 }
158
159 int UtcDaliTooltipCreateWithTextVisualMapWithoutString(void)
160 {
161   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
162
163   Control control = Control::New();
164   control.SetProperty(DevelControl::Property::TOOLTIP,
165                       Property::Map().Add(Tooltip::Property::CONTENT,
166                                           Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::TEXT).Add(TextVisual::Property::POINT_SIZE, 20)));
167
168   tet_infoline("Check if Property::MAP is returned");
169   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
170   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
171
172   tet_infoline("Ensure map is valid");
173   Property::Map* map = value.GetMap();
174   DALI_TEST_CHECK(map);
175
176   tet_infoline("Ensure map contains the content");
177   Property::Value* contentValue = map->Find(Tooltip::Property::CONTENT);
178   DALI_TEST_CHECK(contentValue);
179
180   tet_infoline("Check content is a property map");
181   Property::Map* contentMap = contentValue->GetMap();
182   DALI_TEST_CHECK(contentMap);
183
184   tet_infoline("Check that the map contains the point-size item");
185   Property::Value* pointSizeValue = contentMap->Find(TextVisual::Property::POINT_SIZE);
186   DALI_TEST_CHECK(pointSizeValue);
187
188   tet_infoline("Ensure it matches what we set");
189   DALI_TEST_EQUALS(20, pointSizeValue->Get<int>(), TEST_LOCATION);
190
191   tet_infoline("We sent a text visual without a TEXT property set, so ensure the hover signal has NOT been connected to");
192   DALI_TEST_EQUALS(control.HoveredSignal().GetConnectionCount(), 0u, TEST_LOCATION);
193
194   END_TEST;
195 }
196
197 int UtcDaliTooltipCreateWithImageVisualMap(void)
198 {
199   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
200
201   Control control = Control::New();
202   control.SetProperty(DevelControl::Property::TOOLTIP,
203                       Property::Map().Add(Tooltip::Property::CONTENT,
204                                           Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::IMAGE).Add(ImageVisual::Property::URL, "dummy-url.png")));
205
206   tet_infoline("Check if Property::MAP is returned");
207   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
208   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
209
210   tet_infoline("Ensure map is valid");
211   Property::Map* map = value.GetMap();
212   DALI_TEST_CHECK(map);
213
214   tet_infoline("Ensure map contains the content");
215   Property::Value* contentValue = map->Find(Tooltip::Property::CONTENT);
216   DALI_TEST_CHECK(contentValue);
217
218   tet_infoline("Check content is a property map");
219   Property::Map* contentMap = contentValue->GetMap();
220   DALI_TEST_CHECK(contentMap);
221
222   tet_infoline("Check that the map contains the url item");
223   Property::Value* urlValue = contentMap->Find(ImageVisual::Property::URL);
224   DALI_TEST_CHECK(urlValue);
225
226   tet_infoline("Ensure it matches what we set");
227   DALI_TEST_EQUALS("dummy-url.png", urlValue->Get<std::string>(), TEST_LOCATION);
228
229   tet_infoline("We sent an ImageVisual, so ensure the hover signal has been connected to");
230   DALI_TEST_EQUALS(control.HoveredSignal().GetConnectionCount(), 1u, TEST_LOCATION);
231
232   END_TEST;
233 }
234
235 int UtcDaliTooltipCreateWithArray(void)
236 {
237   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
238
239   Control control = Control::New();
240   control.SetProperty(DevelControl::Property::TOOLTIP,
241                       Property::Array().Add(Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::IMAGE).Add(ImageVisual::Property::URL, "dummy-url.png")).Add(Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::TEXT).Add(TextVisual::Property::TEXT, "Hello Array Test")));
242
243   tet_infoline("Check if Property::MAP is returned");
244   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
245   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
246
247   tet_infoline("Ensure map is valid");
248   Property::Map* map = value.GetMap();
249   DALI_TEST_CHECK(map);
250
251   tet_infoline("Ensure map contains the content");
252   Property::Value* contentValue = map->Find(Tooltip::Property::CONTENT);
253   DALI_TEST_CHECK(contentValue);
254
255   tet_infoline("Check content is a property array");
256   Property::Array* contentArray = contentValue->GetArray();
257   DALI_TEST_CHECK(contentArray);
258
259   tet_infoline("Ensure the array contains two items");
260   DALI_TEST_EQUALS(2u, contentArray->Count(), TEST_LOCATION);
261
262   tet_infoline("Ensure first value is a map and contains the right item");
263   const Property::Value mapValue1 = contentArray->GetElementAt(0);
264   const Property::Map*  map1      = mapValue1.GetMap();
265   DALI_TEST_CHECK(map1);
266   Property::Value* urlValue = map1->Find(ImageVisual::Property::URL);
267   DALI_TEST_CHECK(urlValue);
268   DALI_TEST_EQUALS("dummy-url.png", urlValue->Get<std::string>(), TEST_LOCATION);
269
270   tet_infoline("Ensure second value is a map and contains the right item");
271   const Property::Value mapValue2 = contentArray->GetElementAt(1);
272   const Property::Map*  map2      = mapValue2.GetMap();
273   DALI_TEST_CHECK(map2);
274   Property::Value* textValue = map2->Find(TextVisual::Property::TEXT);
275   DALI_TEST_CHECK(textValue);
276   DALI_TEST_EQUALS("Hello Array Test", textValue->Get<std::string>(), TEST_LOCATION);
277
278   tet_infoline("We sent an array, so ensure the hover signal has been connected to");
279   DALI_TEST_EQUALS(control.HoveredSignal().GetConnectionCount(), 1u, TEST_LOCATION);
280
281   END_TEST;
282 }
283
284 int UtcDaliTooltipCreateWithFullMap(void)
285 {
286   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
287
288   Control control = Control::New();
289   control.SetProperty(DevelControl::Property::TOOLTIP,
290                       Property::Map().Add(Tooltip::Property::CONTENT,
291                                           Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::TEXT).Add(TextVisual::Property::TEXT, "Hello TextVisual Test"))
292                         .Add(Tooltip::Property::LAYOUT, Vector2(1.0f, 2.0f))
293                         .Add(Tooltip::Property::WAIT_TIME, 2.5f)
294                         .Add(Tooltip::Property::BACKGROUND, "tooltip-background.png")
295                         .Add(Tooltip::Property::TAIL, true)
296                         .Add(Tooltip::Property::POSITION, Tooltip::Position::HOVER_POINT)
297                         .Add(Tooltip::Property::HOVER_POINT_OFFSET, Vector2(100.0f, 50.f))
298                         .Add(Tooltip::Property::MOVEMENT_THRESHOLD, 50)
299                         .Add(Tooltip::Property::DISAPPEAR_ON_MOVEMENT, true));
300
301   tet_infoline("Check if Property::MAP is returned");
302   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
303   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
304
305   tet_infoline("Ensure map is valid");
306   Property::Map* map = value.GetMap();
307   DALI_TEST_CHECK(map);
308
309   tet_infoline("Check content");
310   Property::Value* contentValue = map->Find(Tooltip::Property::CONTENT);
311   DALI_TEST_CHECK(contentValue);
312   Property::Map* contentMap = contentValue->GetMap();
313   DALI_TEST_CHECK(contentMap);
314
315   tet_infoline("Check layout");
316   Property::Value* layoutValue = map->Find(Tooltip::Property::LAYOUT);
317   DALI_TEST_CHECK(layoutValue);
318   DALI_TEST_EQUALS(layoutValue->Get<Vector2>(), Vector2(1.0f, 2.0f), TEST_LOCATION);
319
320   tet_infoline("Check wait time");
321   Property::Value* waitTimeValue = map->Find(Tooltip::Property::WAIT_TIME);
322   DALI_TEST_CHECK(waitTimeValue);
323   DALI_TEST_EQUALS(waitTimeValue->Get<float>(), 2.5f, TEST_LOCATION);
324
325   tet_infoline("Check background");
326   Property::Value* backgroundMapValue = map->Find(Tooltip::Property::BACKGROUND);
327   DALI_TEST_CHECK(backgroundMapValue);
328   Property::Map* backgroundMap = backgroundMapValue->GetMap();
329   DALI_TEST_CHECK(backgroundMap);
330   Property::Value* backgroundStringValue = backgroundMap->Find(Tooltip::Background::Property::VISUAL);
331   DALI_TEST_CHECK(backgroundStringValue);
332   DALI_TEST_EQUALS(backgroundStringValue->Get<std::string>(), "tooltip-background.png", TEST_LOCATION);
333
334   tet_infoline("Check Tail");
335   Property::Value* tailMapValue = map->Find(Tooltip::Property::TAIL);
336   DALI_TEST_CHECK(tailMapValue);
337   Property::Map* tailMap = tailMapValue->GetMap();
338   DALI_TEST_CHECK(tailMap);
339   Property::Value* tailVisibilityValue = tailMap->Find(Tooltip::Tail::Property::VISIBILITY);
340   DALI_TEST_CHECK(tailVisibilityValue);
341   DALI_TEST_EQUALS(tailVisibilityValue->Get<bool>(), true, TEST_LOCATION);
342
343   tet_infoline("Check position");
344   Property::Value* positionValue = map->Find(Tooltip::Property::POSITION);
345   DALI_TEST_CHECK(positionValue);
346   DALI_TEST_EQUALS(positionValue->Get<int>(), static_cast<int>(Tooltip::Position::HOVER_POINT), TEST_LOCATION);
347
348   tet_infoline("Check hover point offset");
349   Property::Value* hoverPointOffsetValue = map->Find(Tooltip::Property::HOVER_POINT_OFFSET);
350   DALI_TEST_CHECK(hoverPointOffsetValue);
351   DALI_TEST_EQUALS(hoverPointOffsetValue->Get<Vector2>(), Vector2(100.0f, 50.f), TEST_LOCATION);
352
353   tet_infoline("Check movement threshold");
354   Property::Value* movementThresholdValue = map->Find(Tooltip::Property::MOVEMENT_THRESHOLD);
355   DALI_TEST_CHECK(movementThresholdValue);
356   DALI_TEST_EQUALS(movementThresholdValue->Get<int>(), 50, TEST_LOCATION);
357
358   tet_infoline("Check disappear on movement");
359   Property::Value* disappearOnMovementValue = map->Find(Tooltip::Property::DISAPPEAR_ON_MOVEMENT);
360   DALI_TEST_CHECK(disappearOnMovementValue);
361   DALI_TEST_EQUALS(disappearOnMovementValue->Get<bool>(), true, TEST_LOCATION);
362
363   tet_infoline("We sent a text visual with TEXT property set, so ensure the hover signal has been connected to");
364   DALI_TEST_EQUALS(control.HoveredSignal().GetConnectionCount(), 1u, TEST_LOCATION);
365
366   END_TEST;
367 }
368
369 int UtcDaliTooltipCreateWithBackgroundMap(void)
370 {
371   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
372
373   Control control = Control::New();
374   control.SetProperty(DevelControl::Property::TOOLTIP,
375                       Property::Map().Add(Tooltip::Property::CONTENT, "Hello TextVisual Test").Add(Tooltip::Property::BACKGROUND, Property::Map().Add(Tooltip::Background::Property::VISUAL, "tooltip-background.png").Add(Tooltip::Background::Property::BORDER, Rect<int>(10, 20, 30, 40))));
376
377   tet_infoline("Check if Property::MAP is returned");
378   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
379   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
380
381   tet_infoline("Ensure map is valid");
382   Property::Map* map = value.GetMap();
383   DALI_TEST_CHECK(map);
384
385   tet_infoline("Check background map");
386   Property::Value* backgroundMapValue = map->Find(Tooltip::Property::BACKGROUND);
387   DALI_TEST_CHECK(backgroundMapValue);
388   Property::Map* backgroundMap = backgroundMapValue->GetMap();
389   DALI_TEST_CHECK(backgroundMap);
390
391   tet_infoline("Check visual");
392   Property::Value* backgroundStringValue = backgroundMap->Find(Tooltip::Background::Property::VISUAL);
393   DALI_TEST_CHECK(backgroundStringValue);
394   DALI_TEST_EQUALS(backgroundStringValue->Get<std::string>(), "tooltip-background.png", TEST_LOCATION);
395
396   tet_infoline("Check border");
397   Property::Value* borderValue = backgroundMap->Find(Tooltip::Background::Property::BORDER);
398   DALI_TEST_CHECK(borderValue);
399   DALI_TEST_EQUALS(borderValue->Get<Rect<int> >(), Rect<int>(10, 20, 30, 40), TEST_LOCATION);
400
401   END_TEST;
402 }
403
404 int UtcDaliTooltipCreateWithBackgroundMapVector4(void)
405 {
406   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
407
408   Control control = Control::New();
409   control.SetProperty(DevelControl::Property::TOOLTIP,
410                       Property::Map().Add(Tooltip::Property::CONTENT, "Hello TextVisual Test").Add(Tooltip::Property::BACKGROUND, Property::Map().Add(Tooltip::Background::Property::VISUAL, "tooltip-background.png").Add(Tooltip::Background::Property::BORDER, Vector4(40.0f, 30.0f, 20.0f, 10.0f))));
411
412   tet_infoline("Check if Property::MAP is returned");
413   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
414   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
415
416   tet_infoline("Ensure map is valid");
417   Property::Map* map = value.GetMap();
418   DALI_TEST_CHECK(map);
419
420   tet_infoline("Check background map");
421   Property::Value* backgroundMapValue = map->Find(Tooltip::Property::BACKGROUND);
422   DALI_TEST_CHECK(backgroundMapValue);
423   Property::Map* backgroundMap = backgroundMapValue->GetMap();
424   DALI_TEST_CHECK(backgroundMap);
425
426   tet_infoline("Check visual");
427   Property::Value* backgroundStringValue = backgroundMap->Find(Tooltip::Background::Property::VISUAL);
428   DALI_TEST_CHECK(backgroundStringValue);
429   DALI_TEST_EQUALS(backgroundStringValue->Get<std::string>(), "tooltip-background.png", TEST_LOCATION);
430
431   tet_infoline("Check border");
432   Property::Value* borderValue = backgroundMap->Find(Tooltip::Background::Property::BORDER);
433   DALI_TEST_CHECK(borderValue);
434   DALI_TEST_EQUALS(borderValue->Get<Rect<int> >(), Rect<int>(40, 30, 20, 10), TEST_LOCATION);
435
436   END_TEST;
437 }
438
439 int UtcDaliTooltipCreateWithTailMap(void)
440 {
441   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
442
443   Control control = Control::New();
444   control.SetProperty(DevelControl::Property::TOOLTIP,
445                       Property::Map().Add(Tooltip::Property::CONTENT, "Hello TextVisual Test").Add(Tooltip::Property::TAIL, Property::Map().Add(Tooltip::Tail::Property::VISIBILITY, true).Add(Tooltip::Tail::Property::ABOVE_VISUAL, "above-visual.png").Add(Tooltip::Tail::Property::BELOW_VISUAL, "below-visual.png")));
446
447   tet_infoline("Check if Property::MAP is returned");
448   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
449   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
450
451   tet_infoline("Ensure map is valid");
452   Property::Map* map = value.GetMap();
453   DALI_TEST_CHECK(map);
454
455   tet_infoline("Check Tail");
456   Property::Value* tailMapValue = map->Find(Tooltip::Property::TAIL);
457   DALI_TEST_CHECK(tailMapValue);
458   Property::Map* tailMap = tailMapValue->GetMap();
459   DALI_TEST_CHECK(tailMap);
460
461   tet_infoline("Check visibility");
462   Property::Value* tailVisibilityValue = tailMap->Find(Tooltip::Tail::Property::VISIBILITY);
463   DALI_TEST_CHECK(tailVisibilityValue);
464   DALI_TEST_EQUALS(tailVisibilityValue->Get<bool>(), true, TEST_LOCATION);
465
466   tet_infoline("Check above visual");
467   Property::Value* aboveVisualValue = tailMap->Find(Tooltip::Tail::Property::ABOVE_VISUAL);
468   DALI_TEST_CHECK(aboveVisualValue);
469   DALI_TEST_EQUALS(aboveVisualValue->Get<std::string>(), "above-visual.png", TEST_LOCATION);
470
471   tet_infoline("Check below visual");
472   Property::Value* belowVisualValue = tailMap->Find(Tooltip::Tail::Property::BELOW_VISUAL);
473   DALI_TEST_CHECK(belowVisualValue);
474   DALI_TEST_EQUALS(belowVisualValue->Get<std::string>(), "below-visual.png", TEST_LOCATION);
475
476   END_TEST;
477 }
478
479 int UtcDaliTooltipDisplay(void)
480 {
481   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
482
483   Control control = Control::New();
484   control.SetProperty(DevelControl::Property::TOOLTIP, "Test");
485   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
486   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
487   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
488
489   Actor rootActor = application.GetScene().GetRootLayer();
490   rootActor.Add(control);
491
492   application.SendNotification();
493   application.Render();
494
495   int rootChildCount = rootActor.GetChildCount();
496
497   Vector2 centerPoint = application.GetScene().GetSize() * 0.5f;
498   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
499
500   Dali::Timer timer = Timer::New(1u);
501   timer.MockEmitSignal();
502
503   application.SendNotification();
504   application.Render();
505
506   tet_infoline("Get number of actors on the Stage, they should have incremented by one");
507   ++rootChildCount;
508   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
509
510   application.ProcessEvent(GenerateSingleHover(PointState::STATIONARY, centerPoint)); // Emit for code coverage, will have no effect
511
512   END_TEST;
513 }
514
515 int UtcDaliTooltipDisplayWithTail(void)
516 {
517   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
518
519   Control control = Control::New();
520   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
521   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
522   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
523   control.SetProperty(DevelControl::Property::TOOLTIP,
524                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::TAIL, Property::Map().Add(Tooltip::Tail::Property::VISIBILITY, true).Add(Tooltip::Tail::Property::ABOVE_VISUAL, "above-visual.png").Add(Tooltip::Tail::Property::BELOW_VISUAL, "below-visual.png")));
525
526   Actor rootActor = application.GetScene().GetRootLayer();
527   rootActor.Add(control);
528
529   application.SendNotification();
530   application.Render();
531
532   int rootChildCount = rootActor.GetChildCount();
533
534   Vector2 centerPoint = application.GetScene().GetSize() * 0.5f;
535   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
536
537   Dali::Timer timer = Timer::New(1u);
538   timer.MockEmitSignal();
539
540   application.SendNotification();
541   application.Render();
542
543   tet_infoline("Get number of actors on the Stage, they should have incremented by one");
544   ++rootChildCount;
545   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
546
547   END_TEST;
548 }
549
550 int UtcDaliTooltipDisplayWithContentArray(void)
551 {
552   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
553
554   Control control = Control::New();
555   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
556   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
557   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
558   control.SetProperty(DevelControl::Property::TOOLTIP,
559                       Property::Map().Add(Tooltip::Property::CONTENT,
560                                           Property::Array().Add(Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::IMAGE).Add(ImageVisual::Property::URL, "dummy-url.png")).Add(Property::Map().Add(Toolkit::Visual::Property::TYPE, Visual::TEXT).Add(TextVisual::Property::TEXT, "Hello Array Test")))
561                         .Add(Tooltip::Property::TAIL,
562                              Property::Map().Add(Tooltip::Tail::Property::VISIBILITY, true).Add(Tooltip::Tail::Property::ABOVE_VISUAL, "above-visual.png").Add(Tooltip::Tail::Property::BELOW_VISUAL, "below-visual.png")));
563
564   Actor rootActor = application.GetScene().GetRootLayer();
565   rootActor.Add(control);
566
567   application.SendNotification();
568   application.Render();
569
570   int rootChildCount = rootActor.GetChildCount();
571
572   Vector2 centerPoint = application.GetScene().GetSize() * 0.5f;
573   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
574
575   Dali::Timer timer = Timer::New(1u);
576   timer.MockEmitSignal();
577
578   application.SendNotification();
579   application.Render();
580
581   tet_infoline("Get number of actors on the Stage, they should have incremented by one");
582   ++rootChildCount;
583   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
584
585   END_TEST;
586 }
587
588 int UtcDaliTooltipDisplayBelow(void)
589 {
590   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
591
592   Control control = Control::New();
593   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
594   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
595   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
596   control.SetProperty(DevelControl::Property::TOOLTIP,
597                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::POSITION, Tooltip::Position::BELOW));
598
599   Actor rootActor = application.GetScene().GetRootLayer();
600   rootActor.Add(control);
601
602   application.SendNotification();
603   application.Render();
604
605   Vector2 centerPoint = application.GetScene().GetSize() * 0.5f;
606   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
607
608   Dali::Timer timer = Timer::New(1u);
609   timer.MockEmitSignal();
610
611   application.SendNotification();
612   application.Render();
613
614   Actor tooltip = rootActor.GetChildAt(rootActor.GetChildCount() - 1); // Last actor added will be our tooltip
615
616   tet_infoline("Ensure tooltip is below control");
617   DALI_TEST_CHECK((control.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y + 50.0f /* Half Size */) < tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y);
618
619   END_TEST;
620 }
621
622 int UtcDaliTooltipDisplayAbove(void)
623 {
624   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
625
626   Control control = Control::New();
627   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
628   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
629   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
630   control.SetProperty(DevelControl::Property::TOOLTIP,
631                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::POSITION, Tooltip::Position::ABOVE));
632
633   Actor rootActor = application.GetScene().GetRootLayer();
634   rootActor.Add(control);
635
636   application.SendNotification();
637   application.Render();
638
639   Vector2 centerPoint = application.GetScene().GetSize() * 0.5f;
640   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
641
642   Dali::Timer timer = Timer::New(1u);
643   timer.MockEmitSignal();
644
645   application.SendNotification();
646   application.Render();
647
648   Actor tooltip = rootActor.GetChildAt(rootActor.GetChildCount() - 1); // Last actor added will be our tooltip
649
650   tet_infoline("Ensure tooltip is above control");
651   DALI_TEST_CHECK((control.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y - 50.0f /* Half Size */) >= (tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y + 0.5f * tooltip.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height));
652
653   END_TEST;
654 }
655
656 int UtcDaliTooltipDisplayAtHoverPoint(void)
657 {
658   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
659
660   Control control = Control::New();
661   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
662   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
663   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
664   control.SetProperty(DevelControl::Property::TOOLTIP,
665                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::POSITION, Tooltip::Position::HOVER_POINT));
666
667   Actor rootActor = application.GetScene().GetRootLayer();
668   rootActor.Add(control);
669
670   application.SendNotification();
671   application.Render();
672
673   const Vector2 stageSize  = application.GetScene().GetSize();
674   Vector2       hoverPoint = stageSize * 0.5f;
675   hoverPoint.x -= 10.0f;
676   hoverPoint.y -= 10.0f;
677   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, hoverPoint));
678
679   Dali::Timer timer = Timer::New(1u);
680   timer.MockEmitSignal();
681
682   application.SendNotification();
683   application.Render();
684
685   Actor tooltip = rootActor.GetChildAt(rootActor.GetChildCount() - 1); // Last actor added will be our tooltip
686
687   tet_infoline("Ensure tooltip is below and to the right of control");
688   DALI_TEST_CHECK((hoverPoint.y - stageSize.height * 0.5f) < tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y);
689   DALI_TEST_CHECK((hoverPoint.x - stageSize.width * 0.5f) < tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x);
690
691   END_TEST;
692 }
693
694 int UtcDaliTooltipExceedThreshold(void)
695 {
696   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
697
698   Control control = Control::New();
699   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
700   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
701   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
702   control.SetProperty(DevelControl::Property::TOOLTIP,
703                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::MOVEMENT_THRESHOLD, 5));
704
705   Actor rootActor = application.GetScene().GetRootLayer();
706   rootActor.Add(control);
707
708   application.SendNotification();
709   application.Render();
710
711   int rootChildCount = rootActor.GetChildCount();
712
713   tet_infoline("Start hover");
714   Vector2 hoverPoint = application.GetScene().GetSize() * 0.5f;
715   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, hoverPoint));
716
717   application.SendNotification();
718   application.Render();
719
720   tet_infoline("Emit a value which exceeds threshold, timer should start again");
721   hoverPoint.x += 10.0f;
722   application.ProcessEvent(GenerateSingleHover(PointState::MOTION, hoverPoint));
723
724   application.SendNotification();
725   application.Render();
726
727   tet_infoline("Emit Timer signal - timeout at new point which is still within bounds");
728   Dali::Timer timer = Timer::New(1u);
729   timer.MockEmitSignal();
730
731   application.SendNotification();
732   application.Render();
733
734   tet_infoline("Get number of actors on the Stage, they should have incremented by one");
735   ++rootChildCount;
736   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
737
738   END_TEST;
739 }
740
741 int UtcDaliTooltipGoOutOfBounds(void)
742 {
743   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
744
745   Control control = Control::New();
746   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
747   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
748   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
749   control.SetProperty(DevelControl::Property::TOOLTIP, "Test");
750
751   Actor rootActor = application.GetScene().GetRootLayer();
752   rootActor.Add(control);
753
754   application.SendNotification();
755   application.Render();
756
757   int rootChildCount = rootActor.GetChildCount();
758
759   tet_infoline("Start hover");
760   Vector2 hoverPoint = application.GetScene().GetSize() * 0.5f;
761   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, hoverPoint));
762
763   application.SendNotification();
764   application.Render();
765
766   tet_infoline("Emit a value which goes out of bounds");
767   hoverPoint.x += 100.0f;
768   application.ProcessEvent(GenerateSingleHover(PointState::MOTION, hoverPoint));
769
770   application.SendNotification();
771   application.Render();
772
773   tet_infoline("Emit Timer signal - nothing should happen");
774   Dali::Timer timer = Timer::New(1u);
775   timer.MockEmitSignal();
776
777   application.SendNotification();
778   application.Render();
779
780   tet_infoline("Get number of actors on the Stage, they should be the same as before");
781   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
782
783   END_TEST;
784 }
785
786 int UtcDaliTooltipHideTooltipWhenOutOfBounds(void)
787 {
788   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
789
790   Control control = Control::New();
791   control.SetProperty(DevelControl::Property::TOOLTIP, "Test");
792   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
793   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
794   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
795
796   Actor rootActor = application.GetScene().GetRootLayer();
797   rootActor.Add(control);
798
799   application.SendNotification();
800   application.Render();
801
802   int rootChildCount = rootActor.GetChildCount();
803
804   Vector2 hoverPoint = application.GetScene().GetSize() * 0.5f;
805   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, hoverPoint));
806
807   Dali::Timer timer = Timer::New(1u);
808   timer.MockEmitSignal();
809
810   application.SendNotification();
811   application.Render();
812
813   tet_infoline("Get number of actors on the Stage, they should have incremented by one");
814   ++rootChildCount;
815   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
816
817   hoverPoint.x += 100.0f;
818   application.ProcessEvent(GenerateSingleHover(PointState::MOTION, hoverPoint));
819
820   application.SendNotification();
821   application.Render();
822
823   tet_infoline("Get number of actors on the Stage, they should be back to what was there before the tooltip was shown");
824   --rootChildCount;
825   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
826
827   END_TEST;
828 }
829
830 int UtcDaliTooltipHideTooltipWhenSetToDisapperOnMovement(void)
831 {
832   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
833
834   Control control = Control::New();
835   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
836   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
837   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
838   control.SetProperty(DevelControl::Property::TOOLTIP,
839                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::DISAPPEAR_ON_MOVEMENT, true).Add(Tooltip::Property::MOVEMENT_THRESHOLD, 5));
840
841   Actor rootActor = application.GetScene().GetRootLayer();
842   rootActor.Add(control);
843
844   application.SendNotification();
845   application.Render();
846
847   int rootChildCount = rootActor.GetChildCount();
848
849   Vector2 hoverPoint = application.GetScene().GetSize() * 0.5f;
850   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, hoverPoint));
851
852   Dali::Timer timer = Timer::New(1u);
853   timer.MockEmitSignal();
854
855   application.SendNotification();
856   application.Render();
857
858   tet_infoline("Get number of actors on the Stage, they should have incremented by one");
859   ++rootChildCount;
860   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
861
862   hoverPoint.x += 10.0f; // Stay within bounds but exceed threshold
863   application.ProcessEvent(GenerateSingleHover(PointState::MOTION, hoverPoint));
864
865   application.SendNotification();
866   application.Render();
867
868   tet_infoline("Get number of actors on the Stage, they should be back to what was there before the tooltip was shown");
869   --rootChildCount;
870   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
871
872   END_TEST;
873 }
874
875 int UtcDaliTooltipChangeContent(void)
876 {
877   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
878
879   Control control = Control::New();
880   control.SetProperty(DevelControl::Property::TOOLTIP, "Test");
881   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
882   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
883   control.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
884
885   Actor rootActor = application.GetScene().GetRootLayer();
886   rootActor.Add(control);
887
888   application.SendNotification();
889   application.Render();
890
891   int rootChildCount = rootActor.GetChildCount();
892
893   Vector2 centerPoint = application.GetScene().GetSize() * 0.5f;
894   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
895
896   tet_infoline("Change content while timer is running and ensure it matches the new value");
897   control.SetProperty(DevelControl::Property::TOOLTIP, "Second Value");
898
899   Property::Value value = control.GetProperty(DevelControl::Property::TOOLTIP);
900   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
901   Property::Map* map = value.GetMap();
902   DALI_TEST_CHECK(map);
903   Property::Value* contentValue = map->Find(Tooltip::Property::CONTENT);
904   DALI_TEST_CHECK(contentValue);
905   Property::Map* contentMap = contentValue->GetMap();
906   DALI_TEST_CHECK(contentMap);
907   Property::Value* textStringValue = contentMap->Find(TextVisual::Property::TEXT);
908   DALI_TEST_CHECK(textStringValue);
909   DALI_TEST_EQUALS("Second Value", textStringValue->Get<std::string>(), TEST_LOCATION);
910
911   tet_infoline("Emit signal, nothing should happen as everything has been reset");
912   Dali::Timer timer = Timer::New(1u);
913   timer.MockEmitSignal();
914
915   application.SendNotification();
916   application.Render();
917
918   tet_infoline("Get number of actors on the Stage, there should NOT be any new actors");
919   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
920
921   tet_infoline("More movement at same point, and emit signal, we should get the tooltip");
922   application.ProcessEvent(GenerateSingleHover(PointState::MOTION, centerPoint));
923   timer.MockEmitSignal();
924
925   application.SendNotification();
926   application.Render();
927
928   tet_infoline("Get number of actors on the Stage, they should have incremented by one");
929   ++rootChildCount;
930   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
931
932   tet_infoline("Change content while tooltip is showing, current one should be removed from the stage and ensure it matches new value");
933   control.SetProperty(DevelControl::Property::TOOLTIP, "Third Value");
934
935   value = control.GetProperty(DevelControl::Property::TOOLTIP);
936   DALI_TEST_EQUALS(value.GetType(), Property::MAP, TEST_LOCATION);
937   map = value.GetMap();
938   DALI_TEST_CHECK(map);
939   contentValue = map->Find(Tooltip::Property::CONTENT);
940   DALI_TEST_CHECK(contentValue);
941   contentMap = contentValue->GetMap();
942   DALI_TEST_CHECK(contentMap);
943   textStringValue = contentMap->Find(TextVisual::Property::TEXT);
944   DALI_TEST_CHECK(textStringValue);
945   DALI_TEST_EQUALS("Third Value", textStringValue->Get<std::string>(), TEST_LOCATION);
946
947   tet_infoline("Emit signal, nothing should happen as everything has been reset");
948   timer.MockEmitSignal();
949
950   application.SendNotification();
951   application.Render();
952
953   tet_infoline("Get number of actors on the Stage, there should be one less actor on the stage");
954   --rootChildCount;
955   DALI_TEST_EQUALS(rootActor.GetChildCount(), rootChildCount, TEST_LOCATION);
956
957   END_TEST;
958 }
959
960 int UtcDaliTooltipEnsureRemainsOnStage1(void)
961 {
962   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
963
964   Vector2 stageSize = application.GetScene().GetSize();
965
966   tet_infoline("Create a control and place it at the bottom of the screen, setting the tooltip to appear below");
967   Control control = Control::New();
968   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER);
969   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER);
970   control.SetProperty(Actor::Property::SIZE, stageSize);
971   control.SetProperty(DevelControl::Property::TOOLTIP,
972                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::TAIL, Property::Map().Add(Tooltip::Tail::Property::VISIBILITY, true).Add(Tooltip::Tail::Property::ABOVE_VISUAL, "above-visual.png").Add(Tooltip::Tail::Property::BELOW_VISUAL, "below-visual.png")).Add(Tooltip::Property::POSITION, Tooltip::Position::BELOW));
973
974   Actor rootActor = application.GetScene().GetRootLayer();
975   rootActor.Add(control);
976
977   application.SendNotification();
978   application.Render();
979
980   Vector2 centerPoint = stageSize * 0.5f;
981   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
982
983   Dali::Timer timer = Timer::New(1u);
984   timer.MockEmitSignal();
985
986   application.SendNotification();
987   application.Render();
988
989   tet_infoline("Ensure tooltip is still on the screen");
990   Actor tooltip = rootActor.GetChildAt(rootActor.GetChildCount() - 1); // Last actor added will be our tooltip
991   DALI_TEST_CHECK((tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y + tooltip.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height * 0.5f) <= centerPoint.height);
992
993   END_TEST;
994 }
995
996 int UtcDaliTooltipEnsureRemainsOnStage2(void)
997 {
998   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
999
1000   Vector2 stageSize = application.GetScene().GetSize();
1001
1002   tet_infoline("Create a control and place it at the top of the screen, setting the tooltip to appear above");
1003   Control control = Control::New();
1004   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
1005   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
1006   control.SetProperty(Actor::Property::SIZE, stageSize);
1007   control.SetProperty(DevelControl::Property::TOOLTIP,
1008                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::TAIL, Property::Map().Add(Tooltip::Tail::Property::VISIBILITY, true).Add(Tooltip::Tail::Property::ABOVE_VISUAL, "above-visual.png").Add(Tooltip::Tail::Property::BELOW_VISUAL, "below-visual.png")).Add(Tooltip::Property::POSITION, Tooltip::Position::ABOVE));
1009
1010   Actor rootActor = application.GetScene().GetRootLayer();
1011   rootActor.Add(control);
1012
1013   application.SendNotification();
1014   application.Render();
1015
1016   Vector2 centerPoint = stageSize * 0.5f;
1017   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
1018
1019   Dali::Timer timer = Timer::New(1u);
1020   timer.MockEmitSignal();
1021
1022   application.SendNotification();
1023   application.Render();
1024
1025   tet_infoline("Ensure tooltip is still on the screen");
1026   Actor tooltip = rootActor.GetChildAt(rootActor.GetChildCount() - 1); // Last actor added will be our tooltip
1027   DALI_TEST_CHECK((tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y - tooltip.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height * 0.5f) >= -centerPoint.height);
1028
1029   END_TEST;
1030 }
1031
1032 int UtcDaliTooltipEnsureRemainsOnStage3(void)
1033 {
1034   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
1035
1036   Vector2 stageSize   = application.GetScene().GetSize();
1037   Vector2 centerPoint = stageSize * 0.5f;
1038
1039   tet_infoline("Create a control and adjust it's position so that the tooltip will attempt to appear to the left of the screen");
1040   Control control = Control::New();
1041   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER);
1042   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER);
1043   control.SetProperty(Actor::Property::SIZE, stageSize);
1044   control.SetProperty(DevelControl::Property::TOOLTIP,
1045                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::TAIL, Property::Map().Add(Tooltip::Tail::Property::VISIBILITY, true).Add(Tooltip::Tail::Property::ABOVE_VISUAL, "above-visual.png").Add(Tooltip::Tail::Property::BELOW_VISUAL, "below-visual.png")).Add(Tooltip::Property::POSITION, Tooltip::Position::BELOW));
1046   control.SetProperty(Actor::Property::POSITION_X, -centerPoint.x);
1047
1048   Actor rootActor = application.GetScene().GetRootLayer();
1049   rootActor.Add(control);
1050
1051   application.SendNotification();
1052   application.Render();
1053
1054   Vector2 hoverPoint(centerPoint);
1055   hoverPoint.x = 1.0f;
1056   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
1057
1058   Dali::Timer timer = Timer::New(1u);
1059   timer.MockEmitSignal();
1060
1061   application.SendNotification();
1062   application.Render();
1063
1064   tet_infoline("Ensure tooltip is still on the screen");
1065   Actor tooltip = rootActor.GetChildAt(rootActor.GetChildCount() - 1); // Last actor added will be our tooltip
1066   DALI_TEST_CHECK((tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x - tooltip.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width * 0.5f) >= -centerPoint.width);
1067
1068   END_TEST;
1069 }
1070
1071 int UtcDaliTooltipEnsureRemainsOnStage4(void)
1072 {
1073   ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
1074
1075   Vector2 stageSize   = application.GetScene().GetSize();
1076   Vector2 centerPoint = stageSize * 0.5f;
1077
1078   tet_infoline("Create a control and adjust it's position so that the tooltip will attempt to appear to the right of the screen");
1079   Control control = Control::New();
1080   control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER);
1081   control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER);
1082   control.SetProperty(Actor::Property::SIZE, stageSize);
1083   control.SetProperty(DevelControl::Property::TOOLTIP,
1084                       Property::Map().Add(Tooltip::Property::CONTENT, "Test").Add(Tooltip::Property::TAIL, Property::Map().Add(Tooltip::Tail::Property::VISIBILITY, true).Add(Tooltip::Tail::Property::ABOVE_VISUAL, "above-visual.png").Add(Tooltip::Tail::Property::BELOW_VISUAL, "below-visual.png")).Add(Tooltip::Property::POSITION, Tooltip::Position::BELOW));
1085   control.SetProperty(Actor::Property::POSITION_X, centerPoint.x);
1086
1087   Actor rootActor = application.GetScene().GetRootLayer();
1088   rootActor.Add(control);
1089
1090   application.SendNotification();
1091   application.Render();
1092
1093   Vector2 hoverPoint(centerPoint);
1094   hoverPoint.x = 1.0f;
1095   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, centerPoint));
1096
1097   Dali::Timer timer = Timer::New(1u);
1098   timer.MockEmitSignal();
1099
1100   application.SendNotification();
1101   application.Render();
1102
1103   tet_infoline("Ensure tooltip is still on the screen");
1104   Actor tooltip = rootActor.GetChildAt(rootActor.GetChildCount() - 1); // Last actor added will be our tooltip
1105   DALI_TEST_CHECK((tooltip.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x + tooltip.GetCurrentProperty<Vector3>(Actor::Property::SIZE).width * 0.5f) <= centerPoint.width);
1106
1107   END_TEST;
1108 }