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