+int UtcDaliControlImplRegisterThenReRegisterVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+
+ DALI_TEST_CHECK( !dummyImpl.GetVisual( index ) );
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ Property::Map newMap;
+ newMap[Visual::Property::TYPE] = Visual::COLOR;
+ newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ visual = visualFactory.CreateVisual( newMap );
+ DALI_TEST_CHECK(visual);
+
+ // ReRegister with altered color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ tet_result(TET_PASS);
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterVisaulThenReRegisterToSelf(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ // ReRegister to self
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterVisualToSelf(void)
+{
+ ToolkitTestApplication application;
+
+ Test::ObjectDestructionTracker objectDestructionTracker;
+
+ {
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+ objectDestructionTracker.Start( dummy );
+
+ Property::Index index = 1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register to self
+ dummyImpl.RegisterVisual( index, visual );
+
+ DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), false, TEST_LOCATION ); // Control not destroyed yet
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+ }
+
+ DALI_TEST_EQUALS( objectDestructionTracker.IsDestroyed(), true, TEST_LOCATION ); // Should be destroyed
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterTwoVisuals(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+ Property::Index index2 =2;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+ Toolkit::Visual::Base secondVisual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ Property::Map newMap;
+ newMap[Visual::Property::TYPE] = Visual::COLOR;
+ newMap[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+
+ secondVisual = visualFactory.CreateVisual( newMap );
+ DALI_TEST_CHECK( secondVisual );
+
+ // ReRegister with altered color visual
+ dummyImpl.RegisterVisual( index2, secondVisual );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index2 ) == secondVisual );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterUnregisterVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index index =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( index, visual );
+
+ tet_infoline( "Add control with visual to stage and check renderer count is 1" );
+ Stage::GetCurrent().Add( dummy );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( index ) == visual );
+ DALI_TEST_EQUALS( dummy.GetRendererCount(), 1, TEST_LOCATION );
+
+ // Unregister visual
+ dummyImpl.UnregisterVisual( index );
+
+ tet_infoline( "Remove control with visual from stage and check renderer count is 0" );
+ Stage::GetCurrent().Remove( dummy );
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( dummy.GetRendererCount(), 0, TEST_LOCATION );
+ DALI_TEST_CHECK( !dummyImpl.GetVisual( index ) );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplRegisterDisabledVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( TEST_PROPERTY, visual, false );
+
+ DALI_TEST_CHECK( dummyImpl.GetVisual( TEST_PROPERTY ) == visual );
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == false );
+
+ Stage::GetCurrent().Add(dummy);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == false );
+
+ DALI_TEST_CHECK( dummy.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == true );
+
+ dummyImpl.EnableVisual( TEST_PROPERTY, true );
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == true );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplDisableRegisteredVisual(void)
+{
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);
+
+ // Register index with a color visual
+ dummyImpl.RegisterVisual( TEST_PROPERTY, visual );
+
+ Stage::GetCurrent().Add(dummy);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == true);
+
+ DALI_TEST_CHECK( dummy.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) == true );
+
+ dummyImpl.EnableVisual( TEST_PROPERTY, false );
+
+ DALI_TEST_CHECK( dummyImpl.IsVisualEnabled( TEST_PROPERTY ) == false );
+
+ END_TEST;
+}
+
+int UtcDaliControlImplEnabledVisualParentRemovedFromStage(void)
+{
+ // Visual enabled but then parent removed from stage, test ensures visual/renderer are also removed from stage.
+ // Then adding parent back to stage should automatically put visual/renderer back
+
+ ToolkitTestApplication application;
+
+ DummyControl dummy = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
+
+ Property::Index TEST_PROPERTY =1;
+
+ Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[Visual::Property::TYPE] = Visual::COLOR;
+ map[ColorVisual::Property::MIX_COLOR] = Color::RED;
+
+ visual = visualFactory.CreateVisual( map );
+ DALI_TEST_CHECK(visual);