Merge "(Visual) Support CORNER_RADIUS_POLICY" into devel/master
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 17 Jul 2020 03:14:35 +0000 (03:14 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 17 Jul 2020 03:14:35 +0000 (03:14 +0000)
1  2 
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp

@@@ -248,7 -248,7 +248,7 @@@ int UtcDaliVisualSetGetDepthIndex(void
    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
  
    dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
  
  
    int depthIndex = dummyControl.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
@@@ -418,13 -418,13 +418,13 @@@ int UtcDaliVisualSetOnOffStage(void
    application.Render(0);
    DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
  
 -  Stage::GetCurrent().Add( actor );
 +  application.GetScene().Add( actor );
  
    application.SendNotification();
    application.Render(0);
    DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
  
 -  Stage::GetCurrent().Remove( actor );
 +  application.GetScene().Remove( actor );
  
    application.SendNotification();
    application.Render(0);
@@@ -455,7 -455,7 +455,7 @@@ int UtcDaliVisualSetOnOffStage2(void
    DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
  
    // First on/off
 -  Stage::GetCurrent().Add( actor );
 +  application.GetScene().Add( actor );
  
    application.SendNotification();
    application.Render(0);
    auto textures = renderer.GetTextures();
    DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
  
 -  Stage::GetCurrent().Remove( actor );
 +  application.GetScene().Remove( actor );
  
    application.SendNotification();
    application.Render(0);
    DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
  
    // Second on/off
 -  Stage::GetCurrent().Add( actor );
 +  application.GetScene().Add( actor );
  
    application.SendNotification();
    application.Render(0);
    textures = renderer.GetTextures();
    DALI_TEST_CHECK( textures.GetTextureCount() != 0u );
  
 -  Stage::GetCurrent().Remove( actor );
 +  application.GetScene().Remove( actor );
  
    application.SendNotification();
    application.Render(0);
@@@ -501,6 -501,7 +501,7 @@@ int UtcDaliVisualGetPropertyMap1(void
    propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
    propertyMap.Insert(Visual::Property::MIX_COLOR,  Color::BLUE);
    propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS, 10.0f );
+   propertyMap.Insert( DevelVisual::Property::CORNER_RADIUS_POLICY, Toolkit::Visual::Transform::Policy::RELATIVE );
    propertyMap.Insert( DevelColorVisual::Property::BLUR_RADIUS, 20.0f );
    Visual::Base colorVisual = factory.CreateVisual( propertyMap );
  
    DALI_TEST_CHECK( cornerRadiusValue );
    DALI_TEST_CHECK( cornerRadiusValue->Get< float >() == 10.0f );
  
+   Property::Value* cornerRadiusPolicyValue = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, Property::INTEGER );
+   DALI_TEST_CHECK( cornerRadiusPolicyValue );
+   DALI_TEST_CHECK( cornerRadiusPolicyValue->Get< int >() == Toolkit::Visual::Transform::Policy::RELATIVE );
    Property::Value* blurRadiusValue = resultMap.Find( DevelColorVisual::Property::BLUR_RADIUS, Property::FLOAT );
    DALI_TEST_CHECK( blurRadiusValue );
    DALI_TEST_CHECK( blurRadiusValue->Get< float >() == 20.0f );
@@@ -618,7 -623,7 +623,7 @@@ int UtcDaliVisualGetPropertyMap2N(void
    DummyControl dummyControl = DummyControl::New(true);
    Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
  
    DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
  
@@@ -1765,7 -1770,7 +1770,7 @@@ int UtcDaliVisualAnimateBorderVisual01(
    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
    actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
    actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
 -  Stage::GetCurrent().Add(actor);
 +  application.GetScene().Add(actor);
  
    DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
  
@@@ -1833,7 -1838,7 +1838,7 @@@ int UtcDaliVisualAnimateBorderVisual02(
    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
    actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
    actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
 -  Stage::GetCurrent().Add(actor);
 +  application.GetScene().Add(actor);
  
    DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
  
@@@ -1877,7 -1882,7 +1882,7 @@@ int UtcDaliVisualAnimateColorVisual(voi
    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, borderVisual );
    actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
    actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
 -  Stage::GetCurrent().Add(actor);
 +  application.GetScene().Add(actor);
  
    DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
  
@@@ -1933,7 -1938,7 +1938,7 @@@ int UtcDaliVisualAnimatePrimitiveVisual
      actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
      actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
      actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
 -    Stage::GetCurrent().Add(actor);
 +    application.GetScene().Add(actor);
  
      DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
  
@@@ -2008,7 -2013,7 +2013,7 @@@ int UtcDaliVisualAnimatedGradientVisual
      actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
      actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
      actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
 -    Stage::GetCurrent().Add(actor);
 +    application.GetScene().Add(actor);
  
      application.SendNotification();
      application.Render(0);
@@@ -2179,7 -2184,7 +2184,7 @@@ int UtcDaliVisualAnimatedGradientVisual
        actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
        actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
        actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
 -      Stage::GetCurrent().Add(actor);
 +      application.GetScene().Add(actor);
  
        application.SendNotification();
        application.Render( 0 );
@@@ -2453,7 -2458,7 +2458,7 @@@ int UtcDaliVisualAnimatedGradientVisual
        actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
        actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
        actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
 -      Stage::GetCurrent().Add(actor);
 +      application.GetScene().Add(actor);
  
        application.SendNotification();
        application.Render( 0 );
@@@ -2740,7 -2745,7 +2745,7 @@@ static void TestTransform( ToolkitTestA
    Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
    actor.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
    actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
 -  Stage::GetCurrent().Add(actor);
 +  application.GetScene().Add(actor);
  
    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
    dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transform );
@@@ -3036,7 -3041,7 +3041,7 @@@ int UtcDaliNPatchVisualCustomShader(voi
    dummyImpl.SetLayout( DummyControl::Property::TEST_VISUAL, transformMap );
    dummy.SetProperty( Actor::Property::SIZE, Vector2( 2000.f, 2000.f ) );
    dummy.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
 -  Stage::GetCurrent().Add(dummy);
 +  application.GetScene().Add(dummy);
    application.SendNotification();
  
    Renderer renderer = dummy.GetRendererAt( 0 );
@@@ -3081,7 -3086,7 +3086,7 @@@ int UtcDaliGradientVisualBlendMode(void
  
    DummyControl control = DummyControl::New(true);
    control.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
 -  Stage::GetCurrent().Add( control );
 +  application.GetScene().Add( control );
  
    Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>( control.GetImplementation() );
    dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL,  opaqueGradientVisual );
@@@ -3119,7 -3124,7 +3124,7 @@@ int UtcDaliVisualRendererRemovalAndReAd
    dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
    tet_infoline( "Add control with visual to stage and check renderer count is 1" );
  
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
  
    application.SendNotification();
    application.Render();
    DALI_TEST_EQUALS( dummyControl.GetRendererCount(), 1, TEST_LOCATION );
  
    tet_infoline( "Remove control with visual from stage and check renderer count is 0" );
 -  Stage::GetCurrent().Remove( dummyControl );
 +  application.GetScene().Remove( dummyControl );
    application.SendNotification();
    application.Render();
  
  
    tet_infoline( "Re-add control with visual to stage and check renderer count is still 1" );
  
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
  
    application.SendNotification();
    application.Render();
@@@ -3181,7 -3186,7 +3186,7 @@@ int UtcDaliVisualTextVisualRender(void
    dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
    dummyControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
  
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
    application.SendNotification();
    application.Render();
  
@@@ -3250,7 -3255,7 +3255,7 @@@ int UtcDaliVisualTextVisualDisableEnabl
    dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
    dummyControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
  
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
    application.SendNotification();
    application.Render();
  
@@@ -3378,7 -3383,7 +3383,7 @@@ int UtcDaliRegisterVisualOrder(void
    DALI_TEST_EQUALS( anotherTestVisual2Replacement.GetDepthIndex(), 2000, TEST_LOCATION );
  
    dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
  
    END_TEST;
  }
@@@ -3414,7 -3419,7 +3419,7 @@@ int UtcDaliRegisterVisualOrder02(void
    DALI_TEST_CHECK( testVisual2.GetDepthIndex() >  testVisual1.GetDepthIndex() );
  
    dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
  
    END_TEST;
  }
@@@ -3451,7 -3456,7 +3456,7 @@@ int UtcDaliRegisterVisualWithDepthIndex
    DALI_TEST_EQUALS( DevelControl::IsVisualEnabled( dummyImpl, DummyControl::Property::TEST_VISUAL2 ), true, TEST_LOCATION );
  
    dummyControl.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
 -  Stage::GetCurrent().Add( dummyControl );
 +  application.GetScene().Add( dummyControl );
  
    END_TEST;
  }
@@@ -3532,7 -3537,7 +3537,7 @@@ int UtcDaliSvgVisualCustomShader(void
  
    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 -  Stage::GetCurrent().Add( dummy );
 +  application.GetScene().Add( dummy );
  
    application.SendNotification();
    application.Render();
@@@ -3578,7 -3583,7 +3583,7 @@@ int UtcDaliVisualRoundedCorner(void
  
      dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
      dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 -    Stage::GetCurrent().Add( dummy );
 +    application.GetScene().Add( dummy );
  
      application.SendNotification();
      application.Render();
      DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
    }
  
-   // color visual
+   // color visual 1
    {
      VisualFactory factory = VisualFactory::Get();
      Property::Map properties;
      properties[Visual::Property::TYPE] = Visual::COLOR;
      properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
      properties["cornerRadius"] = cornerRadius;
+     properties["cornerRadiusPolicy"] = Toolkit::Visual::Transform::Policy::ABSOLUTE;
  
      Visual::Base visual = factory.CreateVisual( properties );
  
  
      dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
      dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 -    Stage::GetCurrent().Add( dummy );
 +    application.GetScene().Add( dummy );
  
      application.SendNotification();
      application.Render();
      application.Render();
  
      DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
+   }
+   // color visual 2
+   {
+     VisualFactory factory = VisualFactory::Get();
+     Property::Map properties;
+     float cornerRadius = 0.5f;
+     properties[Visual::Property::TYPE] = Visual::COLOR;
+     properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+     properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+     properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = Toolkit::Visual::Transform::Policy::RELATIVE;
+     Visual::Base visual = factory.CreateVisual( properties );
+     // trigger creation through setting on stage
+     DummyControl dummy = DummyControl::New( true );
+     Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+     dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+     dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+     Stage::GetCurrent().Add( dummy );
+     application.SendNotification();
+     application.Render();
+     application.SendNotification();
+     application.Render();
+     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::RELATIVE ), true, TEST_LOCATION );
+   }
+   // color visual 3 - invalid value
+   {
+     VisualFactory factory = VisualFactory::Get();
+     Property::Map properties;
+     float cornerRadius = 30.0f;
+     properties[Visual::Property::TYPE] = Visual::COLOR;
+     properties[ColorVisual::Property::MIX_COLOR] = Color::BLUE;
+     properties[DevelVisual::Property::CORNER_RADIUS] = cornerRadius;
+     properties[DevelVisual::Property::CORNER_RADIUS_POLICY] = -1; // Set an invalid value
+     Visual::Base visual = factory.CreateVisual( properties );
+     // trigger creation through setting on stage
+     DummyControl dummy = DummyControl::New( true );
+     Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
+     dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
+     dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
+     dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+     Stage::GetCurrent().Add( dummy );
+     application.SendNotification();
+     application.Render();
+     application.SendNotification();
+     application.Render();
+     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadius", cornerRadius ), true, TEST_LOCATION );
+     // Default corner radius policy is absolute.
+     DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue< float >( "cornerRadiusPolicy", Toolkit::Visual::Transform::Policy::ABSOLUTE ), true, TEST_LOCATION );
    }
  
    // gradient visual
  
      dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
      dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 -    Stage::GetCurrent().Add( dummy );
 +    application.GetScene().Add( dummy );
  
      application.SendNotification();
      application.Render();
@@@ -3691,7 -3763,7 +3763,7 @@@ int UtcDaliColorVisualBlurRadius(void
  
    dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
    dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
 -  Stage::GetCurrent().Add( dummy );
 +  application.GetScene().Add( dummy );
  
    application.SendNotification();
    application.Render();