2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 // 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>
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>
36 using namespace Dali::Toolkit;
38 ///////////////////////////////////////////////////////////////////////////////////////////////////
40 void utc_dali_toolkit_tooltip_startup(void)
42 test_return_value = TET_UNDEF;
45 void utc_dali_toolkit_tooltip_cleanup(void)
47 test_return_value = TET_PASS;
50 ///////////////////////////////////////////////////////////////////////////////////////////////////
55 Integration::HoverEvent GenerateSingleHover( TouchPoint::State state, const Vector2& screenPosition )
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 );
65 } // unnamed namespace
67 ///////////////////////////////////////////////////////////////////////////////////////////////////
69 int UtcDaliTooltipGetWithoutSetting(void)
71 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 );
78 tet_infoline( "Ensure map is valid" );
79 Property::Map* map = value.GetMap();
80 DALI_TEST_CHECK( map );
82 tet_infoline( "Ensure map is empty" );
83 DALI_TEST_EQUALS( true, map->Empty(), TEST_LOCATION );
88 int UtcDaliTooltipCreateWithString(void)
90 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
92 Control control = Control::New();
93 control.SetProperty( DevelControl::Property::TOOLTIP, "Hello Test" );
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 );
99 tet_infoline( "Ensure map is valid" );
100 Property::Map* map = value.GetMap();
101 DALI_TEST_CHECK( map );
103 tet_infoline( "Ensure map contains the content" );
104 Property::Value* contentValue = map->Find( Tooltip::Property::CONTENT );
105 DALI_TEST_CHECK( contentValue );
107 tet_infoline( "Check content is a property map" );
108 Property::Map* contentMap = contentValue->GetMap();
109 DALI_TEST_CHECK( contentMap );
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 );
115 tet_infoline( "Ensure it matches what we set" );
116 DALI_TEST_EQUALS( "Hello Test", textStringValue->Get< std::string >(), TEST_LOCATION );
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 );
124 int UtcDaliTooltipCreateWithTextVisualMap(void)
126 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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" ) )
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 );
139 tet_infoline( "Ensure map is valid" );
140 Property::Map* map = value.GetMap();
141 DALI_TEST_CHECK( map );
143 tet_infoline( "Ensure map contains the content" );
144 Property::Value* contentValue = map->Find( Tooltip::Property::CONTENT );
145 DALI_TEST_CHECK( contentValue );
147 tet_infoline( "Check content is a property map" );
148 Property::Map* contentMap = contentValue->GetMap();
149 DALI_TEST_CHECK( contentMap );
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 );
155 tet_infoline( "Ensure it matches what we set" );
156 DALI_TEST_EQUALS( "Hello TextVisual Test", textStringValue->Get< std::string >(), TEST_LOCATION );
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 );
164 int UtcDaliTooltipCreateWithTextVisualMapWithoutString(void)
166 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 ) )
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 );
179 tet_infoline( "Ensure map is valid" );
180 Property::Map* map = value.GetMap();
181 DALI_TEST_CHECK( map );
183 tet_infoline( "Ensure map contains the content" );
184 Property::Value* contentValue = map->Find( Tooltip::Property::CONTENT );
185 DALI_TEST_CHECK( contentValue );
187 tet_infoline( "Check content is a property map" );
188 Property::Map* contentMap = contentValue->GetMap();
189 DALI_TEST_CHECK( contentMap );
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 );
195 tet_infoline( "Ensure it matches what we set" );
196 DALI_TEST_EQUALS( 20, pointSizeValue->Get< int >(), TEST_LOCATION );
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 );
204 int UtcDaliTooltipCreateWithImageVisualMap(void)
206 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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" ) )
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 );
219 tet_infoline( "Ensure map is valid" );
220 Property::Map* map = value.GetMap();
221 DALI_TEST_CHECK( map );
223 tet_infoline( "Ensure map contains the content" );
224 Property::Value* contentValue = map->Find( Tooltip::Property::CONTENT );
225 DALI_TEST_CHECK( contentValue );
227 tet_infoline( "Check content is a property map" );
228 Property::Map* contentMap = contentValue->GetMap();
229 DALI_TEST_CHECK( contentMap );
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 );
235 tet_infoline( "Ensure it matches what we set" );
236 DALI_TEST_EQUALS( "dummy-url.png", urlValue->Get< std::string >(), TEST_LOCATION );
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 );
244 int UtcDaliTooltipCreateWithArray(void)
246 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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" ) )
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 );
260 tet_infoline( "Ensure map is valid" );
261 Property::Map* map = value.GetMap();
262 DALI_TEST_CHECK( map );
264 tet_infoline( "Ensure map contains the content" );
265 Property::Value* contentValue = map->Find( Tooltip::Property::CONTENT );
266 DALI_TEST_CHECK( contentValue );
268 tet_infoline( "Check content is a property array" );
269 Property::Array* contentArray = contentValue->GetArray();
270 DALI_TEST_CHECK( contentArray );
272 tet_infoline( "Ensure the array contains two items" );
273 DALI_TEST_EQUALS( 2u, contentArray->Count(), TEST_LOCATION );
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 );
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 );
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 );
297 int UtcDaliTooltipCreateWithFullMap(void)
299 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 )
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 );
320 tet_infoline( "Ensure map is valid" );
321 Property::Map* map = value.GetMap();
322 DALI_TEST_CHECK( map );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
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 );
384 int UtcDaliTooltipCreateWithBackgroundMap(void)
386 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 ) ) )
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 );
400 tet_infoline( "Ensure map is valid" );
401 Property::Map* map = value.GetMap();
402 DALI_TEST_CHECK( map );
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 );
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 );
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 );
423 int UtcDaliTooltipCreateWithBackgroundMapVector4(void)
425 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 ) ) )
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 );
439 tet_infoline( "Ensure map is valid" );
440 Property::Map* map = value.GetMap();
441 DALI_TEST_CHECK( map );
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 );
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 );
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 );
462 int UtcDaliTooltipCreateWithTailMap(void)
464 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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" ))
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 );
479 tet_infoline( "Ensure map is valid" );
480 Property::Map* map = value.GetMap();
481 DALI_TEST_CHECK( map );
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 );
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 );
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 );
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 );
507 int UtcDaliTooltipDisplay(void)
509 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 );
517 Actor rootActor = Stage::GetCurrent().GetRootLayer();
518 rootActor.Add( control );
520 application.SendNotification();
521 application.Render();
523 int rootChildCount = rootActor.GetChildCount();
525 Vector2 centerPoint = Stage::GetCurrent().GetSize() * 0.5f;
526 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
528 Dali::Timer timer = Timer::New( 1u );
529 timer.MockEmitSignal();
531 application.SendNotification();
532 application.Render();
534 tet_infoline( "Get number of actors on the Stage, they should have incremented by one" );
536 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
538 application.ProcessEvent( GenerateSingleHover( TouchPoint::Stationary, centerPoint ) ); // Emit for code coverage, will have no effect
543 int UtcDaliTooltipDisplayWithTail(void)
545 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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" ))
559 Actor rootActor = Stage::GetCurrent().GetRootLayer();
560 rootActor.Add( control );
562 application.SendNotification();
563 application.Render();
565 int rootChildCount = rootActor.GetChildCount();
567 Vector2 centerPoint = Stage::GetCurrent().GetSize() * 0.5f;
568 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
570 Dali::Timer timer = Timer::New( 1u );
571 timer.MockEmitSignal();
573 application.SendNotification();
574 application.Render();
576 tet_infoline( "Get number of actors on the Stage, they should have incremented by one" );
578 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
583 int UtcDaliTooltipDisplayWithContentArray(void)
585 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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" ))
603 Actor rootActor = Stage::GetCurrent().GetRootLayer();
604 rootActor.Add( control );
606 application.SendNotification();
607 application.Render();
609 int rootChildCount = rootActor.GetChildCount();
611 Vector2 centerPoint = Stage::GetCurrent().GetSize() * 0.5f;
612 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
614 Dali::Timer timer = Timer::New( 1u );
615 timer.MockEmitSignal();
617 application.SendNotification();
618 application.Render();
620 tet_infoline( "Get number of actors on the Stage, they should have incremented by one" );
622 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
627 int UtcDaliTooltipDisplayBelow(void)
629 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 )
640 Actor rootActor = Stage::GetCurrent().GetRootLayer();
641 rootActor.Add( control );
643 application.SendNotification();
644 application.Render();
646 Vector2 centerPoint = Stage::GetCurrent().GetSize() * 0.5f;
647 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
649 Dali::Timer timer = Timer::New( 1u );
650 timer.MockEmitSignal();
652 application.SendNotification();
653 application.Render();
655 Actor tooltip = rootActor.GetChildAt( rootActor.GetChildCount() - 1 ); // Last actor added will be our tooltip
657 tet_infoline( "Ensure tooltip is below control" );
658 DALI_TEST_CHECK( ( control.GetCurrentWorldPosition().y + 50.0f /* Half Size */) < tooltip.GetCurrentWorldPosition().y );
663 int UtcDaliTooltipDisplayAbove(void)
665 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 )
676 Actor rootActor = Stage::GetCurrent().GetRootLayer();
677 rootActor.Add( control );
679 application.SendNotification();
680 application.Render();
682 Vector2 centerPoint = Stage::GetCurrent().GetSize() * 0.5f;
683 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
685 Dali::Timer timer = Timer::New( 1u );
686 timer.MockEmitSignal();
688 application.SendNotification();
689 application.Render();
691 Actor tooltip = rootActor.GetChildAt( rootActor.GetChildCount() - 1 ); // Last actor added will be our tooltip
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 ) );
699 int UtcDaliTooltipDisplayAtHoverPoint(void)
701 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 )
712 Actor rootActor = Stage::GetCurrent().GetRootLayer();
713 rootActor.Add( control );
715 application.SendNotification();
716 application.Render();
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 ) );
724 Dali::Timer timer = Timer::New( 1u );
725 timer.MockEmitSignal();
727 application.SendNotification();
728 application.Render();
730 Actor tooltip = rootActor.GetChildAt( rootActor.GetChildCount() - 1 ); // Last actor added will be our tooltip
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 );
739 int UtcDaliTooltipExceedThreshold(void)
741 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 )
752 Actor rootActor = Stage::GetCurrent().GetRootLayer();
753 rootActor.Add( control );
755 application.SendNotification();
756 application.Render();
758 int rootChildCount = rootActor.GetChildCount();
760 tet_infoline( "Start hover" );
761 Vector2 hoverPoint = Stage::GetCurrent().GetSize() * 0.5f;
762 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, hoverPoint ) );
764 application.SendNotification();
765 application.Render();
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 ) );
771 application.SendNotification();
772 application.Render();
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();
778 application.SendNotification();
779 application.Render();
781 tet_infoline( "Get number of actors on the Stage, they should have incremented by one" );
783 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
788 int UtcDaliTooltipGoOutOfBounds(void)
790 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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" );
798 Actor rootActor = Stage::GetCurrent().GetRootLayer();
799 rootActor.Add( control );
801 application.SendNotification();
802 application.Render();
804 int rootChildCount = rootActor.GetChildCount();
806 tet_infoline( "Start hover" );
807 Vector2 hoverPoint = Stage::GetCurrent().GetSize() * 0.5f;
808 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, hoverPoint ) );
810 application.SendNotification();
811 application.Render();
813 tet_infoline( "Emit a value which goes out of bounds" );
814 hoverPoint.x += 100.0f;
815 application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, hoverPoint ) );
817 application.SendNotification();
818 application.Render();
820 tet_infoline( "Emit Timer signal - nothing should happen" );
821 Dali::Timer timer = Timer::New( 1u );
822 timer.MockEmitSignal();
824 application.SendNotification();
825 application.Render();
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 );
833 int UtcDaliTooltipHideTooltipWhenOutOfBounds(void)
835 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 );
843 Actor rootActor = Stage::GetCurrent().GetRootLayer();
844 rootActor.Add( control );
846 application.SendNotification();
847 application.Render();
849 int rootChildCount = rootActor.GetChildCount();
851 Vector2 hoverPoint = Stage::GetCurrent().GetSize() * 0.5f;
852 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, hoverPoint ) );
854 Dali::Timer timer = Timer::New( 1u );
855 timer.MockEmitSignal();
857 application.SendNotification();
858 application.Render();
860 tet_infoline( "Get number of actors on the Stage, they should have incremented by one" );
862 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
864 hoverPoint.x += 100.0f;
865 application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, hoverPoint ) );
867 application.SendNotification();
868 application.Render();
870 tet_infoline( "Get number of actors on the Stage, they should be back to what was there before the tooltip was shown" );
872 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
877 int UtcDaliTooltipHideTooltipWhenSetToDisapperOnMovement(void)
879 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 )
891 Actor rootActor = Stage::GetCurrent().GetRootLayer();
892 rootActor.Add( control );
894 application.SendNotification();
895 application.Render();
897 int rootChildCount = rootActor.GetChildCount();
899 Vector2 hoverPoint = Stage::GetCurrent().GetSize() * 0.5f;
900 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, hoverPoint ) );
902 Dali::Timer timer = Timer::New( 1u );
903 timer.MockEmitSignal();
905 application.SendNotification();
906 application.Render();
908 tet_infoline( "Get number of actors on the Stage, they should have incremented by one" );
910 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
912 hoverPoint.x += 10.0f; // Stay within bounds but exceed threshold
913 application.ProcessEvent( GenerateSingleHover( TouchPoint::Motion, hoverPoint ) );
915 application.SendNotification();
916 application.Render();
918 tet_infoline( "Get number of actors on the Stage, they should be back to what was there before the tooltip was shown" );
920 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
925 int UtcDaliTooltipChangeContent(void)
927 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
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 );
935 Actor rootActor = Stage::GetCurrent().GetRootLayer();
936 rootActor.Add( control );
938 application.SendNotification();
939 application.Render();
941 int rootChildCount = rootActor.GetChildCount();
943 Vector2 centerPoint = Stage::GetCurrent().GetSize() * 0.5f;
944 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
946 tet_infoline( "Change content while timer is running and ensure it matches the new value" );
947 control.SetProperty( DevelControl::Property::TOOLTIP, "Second Value" );
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 );
961 tet_infoline( "Emit signal, nothing should happen as everything has been reset" );
962 Dali::Timer timer = Timer::New( 1u );
963 timer.MockEmitSignal();
965 application.SendNotification();
966 application.Render();
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 );
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();
975 application.SendNotification();
976 application.Render();
978 tet_infoline( "Get number of actors on the Stage, they should have incremented by one" );
980 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
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" );
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 );
997 tet_infoline( "Emit signal, nothing should happen as everything has been reset" );
998 timer.MockEmitSignal();
1000 application.SendNotification();
1001 application.Render();
1003 tet_infoline( "Get number of actors on the Stage, there should be one less actor on the stage" );
1005 DALI_TEST_EQUALS( rootActor.GetChildCount(), rootChildCount, TEST_LOCATION );
1010 int UtcDaliTooltipEnsureRemainsOnStage1(void)
1012 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
1014 Vector2 stageSize = Stage::GetCurrent().GetSize();
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 )
1030 Actor rootActor = Stage::GetCurrent().GetRootLayer();
1031 rootActor.Add( control );
1033 application.SendNotification();
1034 application.Render();
1036 Vector2 centerPoint = stageSize * 0.5f;
1037 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
1039 Dali::Timer timer = Timer::New( 1u );
1040 timer.MockEmitSignal();
1042 application.SendNotification();
1043 application.Render();
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 );
1052 int UtcDaliTooltipEnsureRemainsOnStage2(void)
1054 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
1056 Vector2 stageSize = Stage::GetCurrent().GetSize();
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 )
1072 Actor rootActor = Stage::GetCurrent().GetRootLayer();
1073 rootActor.Add( control );
1075 application.SendNotification();
1076 application.Render();
1078 Vector2 centerPoint = stageSize * 0.5f;
1079 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
1081 Dali::Timer timer = Timer::New( 1u );
1082 timer.MockEmitSignal();
1084 application.SendNotification();
1085 application.Render();
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 );
1094 int UtcDaliTooltipEnsureRemainsOnStage3(void)
1096 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
1098 Vector2 stageSize = Stage::GetCurrent().GetSize();
1099 Vector2 centerPoint = stageSize * 0.5f;
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 )
1114 control.SetX( -centerPoint.x );
1116 Actor rootActor = Stage::GetCurrent().GetRootLayer();
1117 rootActor.Add( control );
1119 application.SendNotification();
1120 application.Render();
1122 Vector2 hoverPoint( centerPoint );
1123 hoverPoint.x = 1.0f;
1124 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
1126 Dali::Timer timer = Timer::New( 1u );
1127 timer.MockEmitSignal();
1129 application.SendNotification();
1130 application.Render();
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 );
1139 int UtcDaliTooltipEnsureRemainsOnStage4(void)
1141 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
1143 Vector2 stageSize = Stage::GetCurrent().GetSize();
1144 Vector2 centerPoint = stageSize * 0.5f;
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 )
1159 control.SetX( centerPoint.x );
1161 Actor rootActor = Stage::GetCurrent().GetRootLayer();
1162 rootActor.Add( control );
1164 application.SendNotification();
1165 application.Render();
1167 Vector2 hoverPoint( centerPoint );
1168 hoverPoint.x = 1.0f;
1169 application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, centerPoint ) );
1171 Dali::Timer timer = Timer::New( 1u );
1172 timer.MockEmitSignal();
1174 application.SendNotification();
1175 application.Render();
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 );