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>
30 #include "dummy-control.h"
33 using namespace Dali::Toolkit;
35 void utc_dali_toolkit_control_startup(void)
37 test_return_value = TET_UNDEF;
40 void utc_dali_toolkit_control_cleanup(void)
42 test_return_value = TET_PASS;
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
50 bool gObjectCreatedCallBackCalled;
52 void TestCallback(BaseHandle handle)
54 gObjectCreatedCallBackCalled = true;
57 void TestVoidCallback()
61 static bool gKeyInputFocusCallBackCalled;
63 static void TestKeyInputFocusCallback( Control control )
65 tet_infoline(" TestKeyInputFocusCallback");
67 gKeyInputFocusCallBackCalled = true;
72 ///////////////////////////////////////////////////////////////////////////////////////////////////
75 int UtcDaliControlConstructor(void)
77 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
81 DALI_TEST_CHECK( !Control::DownCast(dummy) );
83 dummy = DummyControl::New();
85 DALI_TEST_CHECK( Control::DownCast(dummy) );
89 int UtcDaliControlNew(void)
91 ToolkitTestApplication application; // Exceptions require ToolkitTestApplication
95 DALI_TEST_CHECK( !Control::DownCast(control) );
97 control = Control::New();
99 DALI_TEST_CHECK( Control::DownCast(control) );
104 int UtcDaliControlRegister(void)
106 ToolkitTestApplication application;
108 // Ensure the object is registered after creation
109 ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
110 DALI_TEST_CHECK( registry );
112 gObjectCreatedCallBackCalled = false;
113 registry.ObjectCreatedSignal().Connect( &TestCallback );
115 Alignment alignment = Alignment::New();
117 DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
121 int UtcDaliControlCopyAndAssignment(void)
123 ToolkitTestApplication application;
125 DummyControl control = DummyControl::New();
126 Control emptyControl;
128 Control controlCopy( control );
129 DALI_TEST_CHECK( control == controlCopy );
131 Control emptyControlCopy( emptyControl );
132 DALI_TEST_CHECK( emptyControl == emptyControlCopy );
134 Control controlEquals;
135 controlEquals = control;
136 DALI_TEST_CHECK( control == controlEquals );
138 Control emptyControlEquals;
139 emptyControlEquals = emptyControl;
140 DALI_TEST_CHECK( emptyControl == emptyControlEquals );
144 DALI_TEST_CHECK( control == controlCopy );
148 int UtcDaliControlDownCast(void)
150 ToolkitTestApplication application;
152 DummyControl control;
154 DALI_TEST_CHECK( !Control::DownCast( control ) );
156 control = DummyControl::New();
158 DALI_TEST_CHECK( Control::DownCast( control ) );
162 DALI_TEST_CHECK( !Control::DownCast( actor ) );
164 actor = Actor::New();
166 DALI_TEST_CHECK( !Control::DownCast( actor ) );
170 int UtcDaliControlDownCastTemplate(void)
172 ToolkitTestApplication application;
174 DummyControl control;
176 DALI_TEST_CHECK( !DummyControl::DownCast( control ));
178 control = DummyControl::New();
180 DALI_TEST_CHECK( DummyControl::DownCast( control ) );
184 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
186 actor = Actor::New();
188 DALI_TEST_CHECK( !DummyControl::DownCast( actor ) );
192 int UtcDaliControlKeyInputFocus(void)
194 ToolkitTestApplication application;
195 Stage stage = Stage::GetCurrent();
197 DummyControl control;
199 PushButton pushButton1 = PushButton::New();
200 stage.Add( pushButton1 );
202 pushButton1.SetKeyInputFocus();
203 DALI_TEST_CHECK( pushButton1.HasKeyInputFocus() );
205 pushButton1.ClearKeyInputFocus();
206 DALI_TEST_CHECK( !pushButton1.HasKeyInputFocus() );
210 int UtcDaliControlGetImplementationN(void)
212 ToolkitTestApplication application;
213 DummyControl control;
219 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
220 (void)controlImpl; // Avoid unused warning
221 tet_result(TET_FAIL);
223 catch (DaliException &exception)
225 tet_result(TET_PASS);
231 int UtcDaliControlGetImplementationConstN(void)
233 ToolkitTestApplication application;
234 DummyControl control;
240 const DummyControl constControl(control);
241 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
242 (void)controlImpl; // Avoid unused warning
243 tet_result(TET_FAIL);
245 catch (DaliException &exception)
247 tet_result(TET_PASS);
253 int UtcDaliControlGetImplementationP(void)
255 ToolkitTestApplication application;
256 DummyControl control = DummyControl::New();
262 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
263 (void)controlImpl; // Avoid unused warning
264 tet_result(TET_PASS);
266 catch (DaliException &exception)
268 tet_result(TET_FAIL);
274 int UtcDaliControlGetImplementationConstP(void)
276 ToolkitTestApplication application;
277 DummyControl control = DummyControl::New();
282 const DummyControl constControl(control);
283 const Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( constControl );
284 (void)controlImpl; // Avoid unused warning
285 tet_result(TET_PASS);
287 catch (DaliException &exception)
289 tet_result(TET_FAIL);
295 int UtcDaliControlSignalConnectDisconnect(void)
297 ToolkitTestApplication application;
300 DummyControl dummy = DummyControlImpl::New();
302 Actor actor = Actor::New();
303 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
304 Toolkit::Internal::Control& control = Toolkit::Internal::GetImplementation( dummy );
305 DummyControlImpl* dummyImpl = dynamic_cast<DummyControlImpl*>(&control);
307 if( dummyImpl == NULL )
309 tet_result( TET_FAIL );
313 actor.OnStageSignal().Connect( dummyImpl, &DummyControlImpl::CustomSlot1 );
314 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 1u, TEST_LOCATION );
315 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
317 Stage::GetCurrent().Add( actor );
318 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, true, TEST_LOCATION );
320 dummyImpl->mCustomSlot1Called = false;
321 actor.OnStageSignal().Disconnect( dummyImpl, &DummyControlImpl::CustomSlot1 );
322 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
323 Stage::GetCurrent().Remove( actor );
324 Stage::GetCurrent().Add( actor );
325 DALI_TEST_EQUALS( dummyImpl->mCustomSlot1Called, false, TEST_LOCATION );
330 int UtcDaliControlSignalAutomaticDisconnect(void)
332 ToolkitTestApplication application;
334 Actor actor = Actor::New();
337 DummyControl dummy = DummyControlImpl::New();
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 );
353 Stage::GetCurrent().Remove( actor );
355 // dummyControl automatically disconnects
357 DALI_TEST_EQUALS( actor.OnStageSignal().GetConnectionCount(), 0u, TEST_LOCATION );
359 const Vector3 ignoredSize( 20, 20, 0 );
360 actor.SetSize( ignoredSize );
364 int UtcDaliControlTestParameters(void)
366 ToolkitTestApplication application;
367 DummyControl test = DummyControl::New();
369 test.SetSize( 0.7f, 0.7f, 0.7f );
371 Stage::GetCurrent().Add( test );
373 application.SendNotification();
374 application.Render();
376 float width = 640.0f;
377 float height = test.GetHeightForWidth( width );
378 DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
379 DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
381 test.KeyEventSignal();
383 // Provide coverage for pointer destructor
384 Control* testControlPtr = new Control;
385 DALI_TEST_CHECK( testControlPtr );
386 delete testControlPtr;
390 int UtcDaliControlBackgroundColor(void)
392 ToolkitTestApplication application;
393 Control control = Control::New();
395 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
397 control.SetBackgroundColor( Color::RED );
399 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
400 Property::Map* resultMap = propValue.GetMap();
401 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
402 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::COLOR );
403 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
404 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::RED );
406 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::RED, TEST_LOCATION );
408 control.SetBackgroundColor( Color::YELLOW );
410 propValue = control.GetProperty( Control::Property::BACKGROUND );
411 resultMap = propValue.GetMap();
412 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
413 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>() == Color::YELLOW );
415 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::YELLOW, TEST_LOCATION );
420 int UtcDaliControlBackgroundImage(void)
422 ToolkitTestApplication application;
423 Control control = Control::New();
425 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
427 Image image = ResourceImage::New("TestImage");
428 control.SetBackgroundImage( image );
430 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
431 Property::Map* resultMap = propValue.GetMap();
432 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
433 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE )->Get<int>() == Visual::IMAGE );
434 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
435 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage" );
437 image = ResourceImage::New("TestImage2");
438 control.SetBackgroundImage( image );
440 propValue = control.GetProperty( Control::Property::BACKGROUND );
441 resultMap = propValue.GetMap();
442 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
443 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>() == "TestImage2" );
448 int UtcDaliControlBackgroundProperties(void)
450 ToolkitTestApplication application;
451 Control control = Control::New();
453 DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
454 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
456 Property::Map imageMap;
457 imageMap[ Visual::Property::TYPE ] = Visual::IMAGE;
458 imageMap[ ImageVisual::Property::URL ] = "TestImage";
459 control.SetProperty( Control::Property::BACKGROUND, imageMap );
460 Property::Value propValue = control.GetProperty( Control::Property::BACKGROUND );
461 Property::Map* resultMap = propValue.GetMap();
462 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
463 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(),(int)Visual::IMAGE, TEST_LOCATION );
464 DALI_TEST_CHECK( resultMap->Find( ImageVisual::Property::URL ) );
465 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "TestImage", TEST_LOCATION );
467 Property::Map rendererMap;
468 rendererMap[Visual::Property::TYPE] = Visual::COLOR;
469 rendererMap[ColorVisual::Property::MIX_COLOR] = Color::CYAN;
470 control.SetProperty( Control::Property::BACKGROUND, rendererMap );
471 propValue = control.GetProperty( Control::Property::BACKGROUND );
472 resultMap = propValue.GetMap();
473 DALI_TEST_CHECK( resultMap->Find( Visual::Property::TYPE ) );
474 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
475 DALI_TEST_CHECK( resultMap->Find( ColorVisual::Property::MIX_COLOR ) );
476 DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::CYAN, TEST_LOCATION );
478 Property::Map emptyMap;
479 control.SetProperty( Control::Property::BACKGROUND, emptyMap );
480 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
483 control.SetProperty( Control::Property::BACKGROUND, "Foobar.png" );
484 propValue = control.GetProperty( Control::Property::BACKGROUND );
485 resultMap = propValue.GetMap();
486 DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
487 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
489 // Deprecated Properties
490 control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
491 DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW, TEST_LOCATION );
492 DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), control.GetBackgroundColor(), TEST_LOCATION );
494 control.ClearBackground();
496 Property::Map deprecatedImageMap;
497 deprecatedImageMap[ "filename" ] = "TestImage";
498 control.SetProperty( Control::Property::BACKGROUND_IMAGE, deprecatedImageMap );
499 propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
500 resultMap = propValue.GetMap();
501 DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get< std::string >(), "TestImage" , TEST_LOCATION );
503 control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
504 DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
509 int UtcDaliControlKeyProperties(void)
511 ToolkitTestApplication application;
513 Control control = Control::New();
514 Stage::GetCurrent().Add( control );
516 DALI_TEST_EQUALS( control.HasKeyInputFocus(), control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
518 control.SetKeyInputFocus();
519 DALI_TEST_EQUALS( true, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
521 control.ClearKeyInputFocus();
522 DALI_TEST_EQUALS( false, control.GetProperty( Control::Property::KEY_INPUT_FOCUS ).Get< bool >(), TEST_LOCATION );
524 control.SetProperty( Control::Property::KEY_INPUT_FOCUS, true );
525 DALI_TEST_EQUALS( true, control.HasKeyInputFocus(), TEST_LOCATION );
530 int UtcDaliControlGestureSignals(void)
532 ToolkitTestApplication application;
533 ConnectionTracker connectionTracker;
534 Control control = Control::New();
536 // Each gesture detector gets created when connecting to the gesture signals
537 DALI_TEST_CHECK( !control.GetTapGestureDetector() );
538 control.ConnectSignal( &connectionTracker, "tapped", &TestVoidCallback );
539 DALI_TEST_CHECK( control.GetTapGestureDetector() );
541 DALI_TEST_CHECK( !control.GetPanGestureDetector() );
542 control.ConnectSignal( &connectionTracker, "panned", &TestVoidCallback );
543 DALI_TEST_CHECK( control.GetPanGestureDetector() );
545 DALI_TEST_CHECK( !control.GetPinchGestureDetector() );
546 control.ConnectSignal( &connectionTracker, "pinched", &TestVoidCallback );
547 DALI_TEST_CHECK( control.GetPinchGestureDetector() );
549 DALI_TEST_CHECK( !control.GetLongPressGestureDetector() );
550 control.ConnectSignal( &connectionTracker, "longPressed", &TestVoidCallback );
551 DALI_TEST_CHECK( control.GetLongPressGestureDetector() );
556 int UtcDaliControlImplKeyInputFocusGainedSignal(void)
558 ToolkitTestApplication application;
560 Control control = Control::New();
561 Stage::GetCurrent().Add( control );
563 gKeyInputFocusCallBackCalled = false;
564 control.KeyInputFocusGainedSignal().Connect(&TestKeyInputFocusCallback);
566 application.SendNotification();
567 application.Render();
569 control.SetKeyInputFocus();
571 DALI_TEST_CHECK( control.HasKeyInputFocus() );
573 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
578 int UtcDaliControlImplKeyInputFocusLostSignal(void)
580 ToolkitTestApplication application;
582 Control control = Control::New();
583 Stage::GetCurrent().Add( control );
585 gKeyInputFocusCallBackCalled = false;
586 control.KeyInputFocusLostSignal().Connect(&TestKeyInputFocusCallback);
588 application.SendNotification();
589 application.Render();
591 control.SetKeyInputFocus();
593 DALI_TEST_CHECK( control.HasKeyInputFocus() );
595 control.ClearKeyInputFocus();
597 DALI_TEST_CHECK( gKeyInputFocusCallBackCalled );
602 int UtcDaliControlImplGetControlExtensionP(void)
604 ToolkitTestApplication application;
605 Control control = Control::New();
607 Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control );
609 DALI_TEST_CHECK( NULL == controlImpl.GetControlExtension() );
614 int UtcDaliControlAutoClipping(void)
616 ToolkitTestApplication application;
617 Control control = Control::New();
619 tet_infoline( "Test to see if a renderer gets added when we are clipping children" );
621 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
623 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
625 Stage::GetCurrent().Add( control );
627 application.SendNotification();
628 application.Render();
630 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
635 int UtcDaliControlAutoClippingN(void)
637 ToolkitTestApplication application;
638 Control control = Control::New();
639 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
640 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
642 tet_infoline( "Test to ensure that a renderer does NOT get added when we are clipping children and already have renderers/visuals" );
644 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
646 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
648 Stage::GetCurrent().Add( control );
650 application.SendNotification();
651 application.Render();
653 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Only 1, not 2
655 // Ensure the background color is still RED rather than what's set by the automatic clipping
656 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
657 Property::Map* map = value.GetMap();
658 DALI_TEST_CHECK( map );
659 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
660 DALI_TEST_CHECK( colorValue );
661 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
666 int UtcDaliControlAutoClippingWhenAlreadyOnStage(void)
668 ToolkitTestApplication application;
669 Control control = Control::New();
671 tet_infoline( "Test to see if a renderer gets added when we are clipping children and when already on stage" );
673 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
675 Stage::GetCurrent().Add( control );
677 application.SendNotification();
678 application.Render();
680 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
682 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
684 application.SendNotification();
685 application.Render();
687 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
692 int UtcDaliControlAutoClippingWhenAlreadyOnStageN(void)
694 ToolkitTestApplication application;
695 Control control = Control::New();
696 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
697 .Add( ColorVisual::Property::MIX_COLOR, Color::RED ) );
699 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" );
701 DALI_TEST_EQUALS( 0, control.GetRendererCount(), TEST_LOCATION );
703 Stage::GetCurrent().Add( control );
705 application.SendNotification();
706 application.Render();
708 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION );
710 control.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
712 application.SendNotification();
713 application.Render();
715 DALI_TEST_EQUALS( 1, control.GetRendererCount(), TEST_LOCATION ); // Still should be 1
717 // Ensure the background color is still RED rather than what's set by the automatic clipping
718 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
719 Property::Map* map = value.GetMap();
720 DALI_TEST_CHECK( map );
721 Property::Value* colorValue = map->Find(ColorVisual::Property::MIX_COLOR );
722 DALI_TEST_CHECK( colorValue );
723 DALI_TEST_EQUALS( colorValue->Get< Vector4 >(), Color::RED, TEST_LOCATION );
728 int UtcDaliControlSetTransformSize(void)
730 ToolkitTestApplication application;
731 Control control = Control::New();
733 Property::Map transformMap;
734 transformMap.Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 10 ) )
735 .Add( DevelVisual::Transform::Property::ANCHOR_POINT, Align::BOTTOM_END )
736 .Add( DevelVisual::Transform::Property::ORIGIN, Align::BOTTOM_END )
737 .Add( DevelVisual::Transform::Property::SIZE, Vector2( 10, 20 ) );
739 control.SetProperty( Control::Property::BACKGROUND, Property::Map().Add( Visual::Property::TYPE, Visual::COLOR )
740 .Add( DevelVisual::Property::TRANSFORM, transformMap ) );
742 tet_infoline( "Test to ensure that the control background transform does not get overwritten when adding to the stage" );
744 Stage::GetCurrent().Add( control );
746 application.SendNotification();
747 application.Render();
749 // Ensure the transform property still matches what we set
750 Property::Value value = control.GetProperty( Control::Property::BACKGROUND );
751 Property::Map* map = value.GetMap();
752 DALI_TEST_CHECK( map );
753 Property::Value* transformValue = map->Find( DevelVisual::Property::TRANSFORM );
754 DALI_TEST_CHECK( transformValue );
756 Property::Map* retMap = transformValue->GetMap();
757 DALI_TEST_CHECK( retMap );
758 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 10, 10 ), TEST_LOCATION );
759 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ANCHOR_POINT )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
760 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::ORIGIN )->Get< int >(), (int)Align::BOTTOM_END, TEST_LOCATION );
761 DALI_TEST_EQUALS( retMap->Find( DevelVisual::Transform::Property::SIZE )->Get< Vector2 >(), Vector2( 10, 20 ), TEST_LOCATION );