int UtcDaliScriptingCreatePropertyMapImage(void) { TestApplication application; // Empty { Image image; Property::Map map; CreatePropertyMap( image, map ); DALI_TEST_CHECK( map.empty() ); } // Default { Image image = Image::New( "MY_PATH" ); Property::Map map; CreatePropertyMap( image, map ); DALI_TEST_CHECK( !map.empty() ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "type" ) ); DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Image", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "filename" ) ); DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "load-policy") ); DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "IMMEDIATE", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "release-policy") ); DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "NEVER", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "pixel-format") ); DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "RGBA8888", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "scaling-mode") ); DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "SHRINK_TO_FIT", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "crop" ) ); DALI_TEST_EQUALS( value.GetValue( "crop" ).Get< Vector4 >(), Vector4( 0.0f, 0.0f, 1.0f, 1.0f ), TEST_LOCATION ); DALI_TEST_CHECK( !value.HasKey( "width" ) ); DALI_TEST_CHECK( !value.HasKey( "height" ) ); } // Change values { ImageAttributes attributes; attributes.SetPixelFormat( Pixel::A8 ); attributes.SetScalingMode( ImageAttributes::FitWidth ); attributes.SetCrop( Rect< float >( 0.5f, 0.2f, 0.2f, 0.4f ) ); attributes.SetSize( 300, 400 ); Image image = Image::New( "MY_PATH", attributes, Image::OnDemand, Image::Unused ); Property::Map map; CreatePropertyMap( image, map ); DALI_TEST_CHECK( !map.empty() ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "type" ) ); DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Image", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "filename" ) ); DALI_TEST_EQUALS( value.GetValue( "filename" ).Get< std::string >(), "MY_PATH", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "load-policy") ); DALI_TEST_EQUALS( value.GetValue( "load-policy" ).Get< std::string >(), "ON_DEMAND", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "release-policy") ); DALI_TEST_EQUALS( value.GetValue( "release-policy" ).Get< std::string >(), "UNUSED", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "pixel-format") ); DALI_TEST_EQUALS( value.GetValue( "pixel-format" ).Get< std::string >(), "A8", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "scaling-mode") ); DALI_TEST_EQUALS( value.GetValue( "scaling-mode" ).Get< std::string >(), "FIT_WIDTH", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "crop" ) ); DALI_TEST_EQUALS( value.GetValue( "crop" ).Get< Vector4 >(), Vector4( 0.5f, 0.2f, 0.2f, 0.4f ), TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "width" ) ); DALI_TEST_EQUALS( value.GetValue( "width" ).Get< int >(), 300, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "height" ) ); DALI_TEST_EQUALS( value.GetValue( "height" ).Get< int >(), 400, TEST_LOCATION ); } // BitmapImage { Image image = BitmapImage::New( 200, 300, Pixel::RGBA8888 ); Property::Map map; CreatePropertyMap( image, map ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "type" ) ); DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "BitmapImage", TEST_LOCATION ); } // FrameBufferImage { Image image = FrameBufferImage::New( 200, 300, Pixel::RGBA8888 ); Property::Map map; CreatePropertyMap( image, map ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "type" ) ); DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "FrameBufferImage", TEST_LOCATION ); } END_TEST; }
int UtcDaliScriptingCreatePropertyMapActor(void) { TestApplication application; // Actor Type { Actor actor = Actor::New(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.empty() ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "type" ) ); DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "Actor", TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } // ImageActor Type { Actor actor = ImageActor::New(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.empty() ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "type" ) ); DALI_TEST_EQUALS( value.GetValue( "type").Get< std::string >(), "ImageActor", TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } // Default properties { Actor actor = Actor::New(); actor.SetSize( Vector3::ONE ); actor.SetPosition( Vector3::XAXIS ); actor.SetScale( Vector3::ZAXIS ); actor.SetVisible( false ); actor.SetColor( Color::MAGENTA ); actor.SetName( "MyActor" ); actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); actor.SetParentOrigin( ParentOrigin::TOP_RIGHT ); actor.SetInheritShaderEffect( false ); actor.SetSensitive( false ); actor.SetLeaveRequired( true ); actor.SetInheritRotation( false ); actor.SetInheritScale( false ); Stage::GetCurrent().Add( actor ); application.SendNotification(); application.Render(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.empty() ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "size" ) ); DALI_TEST_EQUALS( value.GetValue( "size" ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "position" ) ); DALI_TEST_EQUALS( value.GetValue( "position" ).Get< Vector3 >(), Vector3::XAXIS, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "scale" ) ); DALI_TEST_EQUALS( value.GetValue( "scale" ).Get< Vector3 >(), Vector3::ZAXIS, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "visible" ) ); DALI_TEST_EQUALS( value.GetValue( "visible" ).Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "color" ) ); DALI_TEST_EQUALS( value.GetValue( "color" ).Get< Vector4 >(), Color::MAGENTA, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "name" ) ); DALI_TEST_EQUALS( value.GetValue( "name").Get< std::string >(), "MyActor", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "anchor-point" ) ); DALI_TEST_EQUALS( value.GetValue( "anchor-point" ).Get< Vector3 >(), AnchorPoint::CENTER_LEFT, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "parent-origin" ) ); DALI_TEST_EQUALS( value.GetValue( "parent-origin" ).Get< Vector3 >(), ParentOrigin::TOP_RIGHT, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "inherit-shader-effect" ) ); DALI_TEST_EQUALS( value.GetValue( "inherit-shader-effect" ).Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "sensitive" ) ); DALI_TEST_EQUALS( value.GetValue( "sensitive" ).Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "leave-required" ) ); DALI_TEST_EQUALS( value.GetValue( "leave-required" ).Get< bool >(), true, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "inherit-rotation" ) ); DALI_TEST_EQUALS( value.GetValue( "inherit-rotation" ).Get< bool >(), false, TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "inherit-scale" ) ); DALI_TEST_EQUALS( value.GetValue( "inherit-scale" ).Get< bool >(), false, TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } // ColorMode TestEnumStrings< ColorMode >( "color-mode", application, COLOR_MODE_VALUES, COLOR_MODE_VALUES_COUNT, &Actor::SetColorMode ); // PositionInheritanceMode TestEnumStrings< PositionInheritanceMode >( "position-inheritance", application, POSITION_INHERITANCE_MODE_VALUES, POSITION_INHERITANCE_MODE_VALUES_COUNT, &Actor::SetPositionInheritanceMode ); // DrawMode TestEnumStrings< DrawMode::Type >( "draw-mode", application, DRAW_MODE_VALUES, DRAW_MODE_VALUES_COUNT, &Actor::SetDrawMode ); // Children { Actor actor = Actor::New(); Actor child = ImageActor::New(); Actor grandChild = TextActor::New(); Actor grandChild2 = LightActor::New(); actor.Add( child ); child.Add( grandChild ); child.Add( grandChild2 ); Stage::GetCurrent().Add( actor ); application.SendNotification(); application.Render(); Property::Map map; CreatePropertyMap( actor, map ); DALI_TEST_CHECK( !map.empty() ); Property::Value value( map ); DALI_TEST_CHECK( value.HasKey( "type" ) ); DALI_TEST_EQUALS( value.GetValue( "type" ).Get< std::string >(), "Actor", TEST_LOCATION ); DALI_TEST_CHECK( value.HasKey( "actors" ) ); Property::Array children( value.GetValue( "actors").Get< Property::Array >() ); DALI_TEST_CHECK( !children.empty() ); Property::Map childMap( children[0].Get< Property::Map >() ); DALI_TEST_CHECK( !childMap.empty() ); Property::Value childValue( childMap ); DALI_TEST_CHECK( childValue.HasKey( "type" ) ); DALI_TEST_EQUALS( childValue.GetValue( "type" ).Get< std::string >(), "ImageActor", TEST_LOCATION ); DALI_TEST_CHECK( childValue.HasKey( "actors" ) ); Property::Array grandChildren( childValue.GetValue( "actors").Get< Property::Array >() ); DALI_TEST_CHECK( grandChildren.size() == 2u ); Property::Map grandChildMap( grandChildren[0].Get< Property::Map >() ); DALI_TEST_CHECK( !grandChildMap.empty() ); Property::Value grandChildValue( grandChildMap ); DALI_TEST_CHECK( grandChildValue.HasKey( "type" ) ); DALI_TEST_EQUALS( grandChildValue.GetValue( "type" ).Get< std::string >(), "TextActor", TEST_LOCATION ); Property::Map grandChild2Map( grandChildren[1].Get< Property::Map >() ); DALI_TEST_CHECK( !grandChild2Map.empty() ); Property::Value grandChild2Value( grandChild2Map ); DALI_TEST_CHECK( grandChild2Value.HasKey( "type" ) ); DALI_TEST_EQUALS( grandChild2Value.GetValue( "type" ).Get< std::string >(), "LightActor", TEST_LOCATION ); Stage::GetCurrent().Remove( actor ); } END_TEST; }