2 * Copyright (c) 2017 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>
26 #include <dali-toolkit/dali-toolkit.h>
27 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
28 #include <dali-toolkit/devel-api/align-enums.h>
29 #include <dali-toolkit/devel-api/controls/control-devel.h>
31 #include "dummy-control.h"
34 using namespace Dali::Toolkit;
36 void utc_dali_toolkit_control_startup(void)
38 test_return_value = TET_UNDEF;
41 void utc_dali_toolkit_control_cleanup(void)
43 test_return_value = TET_PASS;
46 ///////////////////////////////////////////////////////////////////////////////////////////////////
51 bool gObjectCreatedCallBackCalled;
53 void TestCallback(BaseHandle handle)
55 gObjectCreatedCallBackCalled = true;
58 void TestVoidCallback()
62 static bool gKeyInputFocusCallBackCalled;
64 static void TestKeyInputFocusCallback( Control control )
66 tet_infoline(" TestKeyInputFocusCallback");
68 gKeyInputFocusCallBackCalled = true;
73 ///////////////////////////////////////////////////////////////////////////////////////////////////
76 int UtcDaliControlConstructor(void)
78 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
82 DALI_TEST_CHECK( !Control::DownCast(dummy) );
84 dummy = DummyControl::New();
86 DALI_TEST_CHECK( Control::DownCast(dummy) );
90 int UtcDaliControlNew(void)
92 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
96 DALI_TEST_CHECK( !Control::DownCast(control) );
98 control = Control::New();
100 DALI_TEST_CHECK( Control::DownCast(control) );
105 int UtcDaliControlRegister(void)
107 ToolkitTestApplication application;
109 // Ensure the object is registered after creation
110 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
111 DALI_TEST_CHECK( registry );
113 gObjectCreatedCallBackCalled = false;
114 registry.ObjectCreatedSignal().Connect( &TestCallback );
116 Alignment alignment = Alignment::New();
118 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
122 int UtcDaliControlCopyAndAssignment(void)
124 ToolkitTestApplication application;
126 DummyControl control = DummyControl::New();
127 Control emptyControl;
129 Control controlCopy( control );
130 DALI_TEST_CHECK( control == controlCopy );
132 Control emptyControlCopy( emptyControl );
133 DALI_TEST_CHECK( emptyControl == emptyControlCopy );
135 Control controlEquals;
136 controlEquals = control;
137 DALI_TEST_CHECK( control == controlEquals );
139 Control emptyControlEquals;
140 emptyControlEquals = emptyControl;
141 DALI_TEST_CHECK( emptyControl == emptyControlEquals );
145 DALI_TEST_CHECK( control == controlCopy );
149 int UtcDaliControlDownCast(void)
151 ToolkitTestApplication application;
153 DummyControl control;
155 DALI_TEST_CHECK( !Control::DownCast( control ) );
157 control = DummyControl::New();
159 DALI_TEST_CHECK( Control::DownCast( control ) );
163 DALI_TEST_CHECK( !Control::DownCast( actor ) );
165 actor = Actor::New();
167 DALI_TEST_CHECK( !Control::DownCast( actor ) );
171 int UtcDaliControlDownCastTemplate(void)
173 ToolkitTestApplication application;
175 DummyControl control;
177 DALI_TEST_CHECK( !DummyControl::DownCast( control ));
179 control = DummyControl::New();
181 DALI_TEST_CHECK( DummyControl::DownCast( control ) );
185 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
187 actor = Actor::New();
189 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
193 int UtcDaliControlNavigationProperties(void)
195 ToolkitTestApplication application;
197 Control control = Control::New();
198 Stage::GetCurrent().Add( control );
200 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
201 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
202 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
203 DALI_TEST_EQUALS( -1, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
205 control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 1 );
206 DALI_TEST_EQUALS( 1, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
207 control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 2 );
208 DALI_TEST_EQUALS( 2, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
209 control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 3 );
210 DALI_TEST_EQUALS( 3, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
211 control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 4 );
212 DALI_TEST_EQUALS( 4, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
214 control.SetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 15 );
215 DALI_TEST_EQUALS( 15, control.GetProperty( DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
216 control.SetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID, 16 );
217 DALI_TEST_EQUALS( 16, control.GetProperty( DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
218 control.SetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, 17 );
219 DALI_TEST_EQUALS( 17, control.GetProperty( DevelControl::Property::UP_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
220 control.SetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 18 );
221 DALI_TEST_EQUALS( 18, control.GetProperty( DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION );
226 int UtcDaliControlKeyInputFocus(void)
228 ToolkitTestApplication application;
229 Stage stage = Stage::GetCurrent();
231 DummyControl control;
233 PushButton pushButton1 = PushButton::New();
234 stage.Add( pushButton1 );
236 pushButton1.SetKeyInputFocus();
237 DALI_TEST_CHECK( pushButton1.HasKeyInputFocus() );
239 pushButton1.ClearKeyInputFocus();
240 DALI_TEST_CHECK( !pushButton1.HasKeyInputFocus() );
244 int UtcDaliControlGetImplementationN(void)
246 ToolkitTestApplication application;
247 DummyControl control;
253 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
254 (void)controlImpl; // Avoid unused warning
255 tet_result(TET_FAIL);
257 catch (DaliException &exception)
259 tet_result(TET_PASS);
265 int UtcDaliControlGetImplementationConstN(void)
267 ToolkitTestApplication application;
268 DummyControl control;
274 const DummyControl constControl(control);
275 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
276 (void)controlImpl; // Avoid unused warning
277 tet_result(TET_FAIL);
279 catch (DaliException &exception)
281 tet_result(TET_PASS);
287 int UtcDaliControlGetImplementationP(void)
289 ToolkitTestApplication application;
290 DummyControl control = DummyControl::New();
296 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
297 (void)controlImpl; // Avoid unused warning
298 tet_result(TET_PASS);
300 catch (DaliException &exception)
302 tet_result(TET_FAIL);
308 int UtcDaliControlGetImplementationConstP(void)
310 ToolkitTestApplication application;
311 DummyControl control = DummyControl::New();
316 const DummyControl constControl(control);
317 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
318 (void)controlImpl; // Avoid unused warning
319 tet_result(TET_PASS);
321 catch (DaliException &exception)
323 tet_result(TET_FAIL);
329 int UtcDaliControlSignalConnectDisconnect(void)
331 ToolkitTestApplication application;
334 DummyControl dummy = DummyControlImpl::New();
336 Actor actor = Actor::New();
337 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
338 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
339 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
341 if( dummyImpl == NULL )
343 tet_result( TET_FAIL );
347 actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
348 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
349 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
351 Stage::GetCurrent().Add( actor );
352 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
354 dummyImpl->mCustomSlot1Called = false;
355 actor.OnStageSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
356 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
357 Stage::GetCurrent().Remove( actor );
358 Stage::GetCurrent().Add( actor );
359 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
364 int UtcDaliControlSignalAutomaticDisconnect(void)
366 ToolkitTestApplication application;
368 Actor actor = Actor::New();
371 DummyControl dummy = DummyControlImpl::New();
372 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
373 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
375 if( dummyImpl == NULL )
377 tet_result( TET_FAIL );
381 actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
382 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
383 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
385 Stage::GetCurrent().Add( actor );
386 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
387 Stage::GetCurrent().Remove( actor );
389 // dummyControl automatically disconnects
391 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
393 const Vector3 ignoredSize( 20, 20, 0 );
394 actor.SetSize( ignoredSize );
398 int UtcDaliControlTestParameters(void)
400 ToolkitTestApplication application;
401 DummyControl test = DummyControl::New();
403 test.SetSize( 0.7f, 0.7f, 0.7f );
405 Stage::GetCurrent().Add( test );
407 application.SendNotification();
408 application.Render();
410 float width = 640.0f;
411 float height = test.GetHeightForWidth( width );
412 DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
413 DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
415 test.KeyEventSignal();
417 // Provide coverage for pointer destructor
418 Control* testControlPtr = new Control;
419 DALI_TEST_CHECK( testControlPtr );
420 delete testControlPtr;
424 int UtcDaliControlBackgroundColor(void)
426 ToolkitTestApplication application;
427 Control control = Control::New();
429 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
431 control.SetBackgroundColor( Color::RED );
433 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
434 Property::Map* resultMap = propValue.GetMap();
435 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
436 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
437 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
438 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::RED );
440 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
442 control.SetBackgroundColor( Color::YELLOW );
444 propValue = control.GetProperty( Control::Property::BACKGROUND );
445 resultMap = propValue.GetMap();
446 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
447 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::YELLOW );
449 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
454 int UtcDaliControlBackgroundImage(void)
456 ToolkitTestApplication application;
457 Control control = Control::New();
459 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
461 Image image = ResourceImage::New("TestImage");
462 control.SetBackgroundImage( image );
464 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
465 Property::Map* resultMap = propValue.GetMap();
466 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
467 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
468 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
469 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
471 image = ResourceImage::New("TestImage2");
472 control.SetBackgroundImage( image );
474 propValue = control.GetProperty( Control::Property::BACKGROUND );
475 resultMap = propValue.GetMap();
476 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
477 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage2" );
482 int UtcDaliControlBackgroundProperties(void)
484 ToolkitTestApplication application;
485 Control control = Control::New();
487 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
488 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
490 Property::Map imageMap;
491 imageMap[ Visual::Property::TYPE ] = Visual::IMAGE;
492 imageMap[ ImageVisual::Property::URL ] = "TestImage";
493 control.SetProperty( Control::Property::BACKGROUND, imageMap );
494 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
495 Property::Map* resultMap = propValue.GetMap();
496 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
497 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
498 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
499 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
501 Property::Map rendererMap;
502 rendererMap[Visual::Property::TYPE] = Visual::COLOR;
503 rendererMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
504 control.SetProperty( Control::Property::BACKGROUND, rendererMap );
505 propValue = control.GetProperty( Control::Property::BACKGROUND );
506 resultMap = propValue.GetMap();
507 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
508 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
509 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
510 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
512 Property::Map emptyMap;
513 control.SetProperty( Control::Property::BACKGROUND, emptyMap );
514 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
517 control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" );
518 propValue = control.GetProperty( Control::Property::BACKGROUND );
519 resultMap = propValue.GetMap();
520 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
521 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
524 control.SetProperty( Control::Property::BACKGROUND, Color::RED );
525 propValue = control.GetProperty( Control::Property::BACKGROUND );
526 resultMap = propValue.GetMap();
527 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
528 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
530 // Deprecated Properties
531 control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
532 DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW, TEST_LOCATION );
533 DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), control.GetBackgroundColor(), TEST_LOCATION );
535 control.ClearBackground();
537 Property::Map deprecatedImageMap;
538 deprecatedImageMap[ "filename" ] = "TestImage";
539 control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap );
540 propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
541 resultMap = propValue.GetMap();
542 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION );
544 control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
545 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
550 int UtcDaliControlKeyProperties(void)
552 ToolkitTestApplication application;
554 Control control = Control::New();
555 Stage::GetCurrent().Add( control );
557 DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
559 control.SetKeyInputFocus();
560 DALI_TEST_EQUALS( true, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
562 control.ClearKeyInputFocus();
563 DALI_TEST_EQUALS( false, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
565 control.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
566 DALI_TEST_EQUALS( true, control.HasKeyInputFocus(), TEST_LOCATION );
571 int UtcDaliControlGestureSignals(void)
573 ToolkitTestApplication application;
574 ConnectionTracker connectionTracker;
575 Control control = Control::New();
577 // Each gesture detector gets created when connecting to the gesture signals
578 DALI_TEST_CHECK( !control.GetTapGestureDetector() );
579 control.ConnectSignal( &connectionTracker, "tapped", &TestVoidCallback );
580 DALI_TEST_CHECK( control.GetTapGestureDetector() );
582 DALI_TEST_CHECK( !control.GetPanGestureDetector() );
583 control.ConnectSignal( &connectionTracker, "panned", &TestVoidCallback );
584 DALI_TEST_CHECK( control.GetPanGestureDetector() );
586 DALI_TEST_CHECK( !control.GetPinchGestureDetector() );
587 control.ConnectSignal( &connectionTracker, "pinched", &TestVoidCallback );
588 DALI_TEST_CHECK( control.GetPinchGestureDetector() );
590 DALI_TEST_CHECK( !control.GetLongPressGestureDetector() );
591 control.ConnectSignal( &connectionTracker, "longPressed", &TestVoidCallback );
592 DALI_TEST_CHECK( control.GetLongPressGestureDetector() );
597 int UtcDaliControlImplKeyInputFocusGainedSignal(void)
599 ToolkitTestApplication application;
601 Control control = Control::New();
602 Stage::GetCurrent().Add( control );
604 gKeyInputFocusCallBackCalled = false;
605 control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
607 application.SendNotification();
608 application.Render();
610 control.SetKeyInputFocus();
612 DALI_TEST_CHECK( control.HasKeyInputFocus() );
614 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
619 int UtcDaliControlImplKeyInputFocusLostSignal(void)
621 ToolkitTestApplication application;
623 Control control = Control::New();
624 Stage::GetCurrent().Add( control );
626 gKeyInputFocusCallBackCalled = false;
627 control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
629 application.SendNotification();
630 application.Render();
632 control.SetKeyInputFocus();
634 DALI_TEST_CHECK( control.HasKeyInputFocus() );
636 control.ClearKeyInputFocus();
638 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
643 int UtcDaliControlImplGetControlExtensionP(void)
645 ToolkitTestApplication application;
646 Control control = Control::New();
648 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
650 DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() );
655 int UtcDaliControlAutoClipping(void)
657 ToolkitTestApplication application;
658 Control control = Control::New();
660 tet_infoline( "Test to see if a renderer gets added when we are clipping children" );
662 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
664 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
666 Stage::GetCurrent().Add( control );
668 application.SendNotification();
669 application.Render();
671 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
676 int UtcDaliControlAutoClippingN(void)
678 ToolkitTestApplication application;
679 Control control = Control::New();
680 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
681 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
683 tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" );
685 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
687 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
689 Stage::GetCurrent().Add( control );
691 application.SendNotification();
692 application.Render();
694 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2
696 // Ensure the background color is still RED rather than what's set by the automatic clipping
697 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
698 Property::Map* map = value.GetMap();
699 DALI_TEST_CHECK( map );
700 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
701 DALI_TEST_CHECK( colorValue );
702 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
707 int UtcDaliControlAutoClippingWhenAlreadyOnStage(void)
709 ToolkitTestApplication application;
710 Control control = Control::New();
712 tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" );
714 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
716 Stage::GetCurrent().Add( control );
718 application.SendNotification();
719 application.Render();
721 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
723 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
725 application.SendNotification();
726 application.Render();
728 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
733 int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
735 ToolkitTestApplication application;
736 Control control = Control::New();
737 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
738 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
740 tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals and when already on stage" );
742 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
744 Stage::GetCurrent().Add( control );
746 application.SendNotification();
747 application.Render();
749 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
751 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
753 application.SendNotification();
754 application.Render();
756 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1
758 // Ensure the background color is still RED rather than what's set by the automatic clipping
759 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
760 Property::Map* map = value.GetMap();
761 DALI_TEST_CHECK( map );
762 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
763 DALI_TEST_CHECK( colorValue );
764 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
769 int UtcDaliControlSetTransformSize(void)
771 ToolkitTestApplication application;
772 Control control = Control::New();
774 Property::Map transformMap;
775 transformMap.Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
776 .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
777 .Add( DevelVisual::Transform::Property::ORIGIN, Align::BOTTOM_END )
778 .Add( DevelVisual::Transform::Property::SIZE, Vector2( 10, 20 ) );
780 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
781 .Add( DevelVisual::Property::TRANSFORM, transformMap ) );
783 tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
785 Stage::GetCurrent().Add( control );
787 application.SendNotification();
788 application.Render();
790 // Ensure the transform property still matches what we set
791 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
792 Property::Map* map = value.GetMap();
793 DALI_TEST_CHECK( map );
794 Property::Value* transformValue = map->Find( DevelVisual::Property::TRANSFORM );
795 DALI_TEST_CHECK( transformValue );
797 Property::Map* retMap = transformValue->GetMap();
798 DALI_TEST_CHECK( retMap );
799 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
800 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
801 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
802 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );