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