X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextLabel.cpp;h=6f04d64ff77787734ab88fe54f0eb8185ff017cf;hp=82615306429df1684ea99d3bae37b741838fe09f;hb=09ae840a22681a4bbdc770f00674498ab75aec69;hpb=49557ae728fe830bf27a23ab230d72294b3a1a39 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index 8261530..6f04d64 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -17,6 +17,8 @@ #include #include +#include + #include #include @@ -63,6 +65,8 @@ const char* const PROPERTY_NAME_EMBOSS = "emboss"; const char* const PROPERTY_NAME_OUTLINE = "outline"; const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND; +const std::string DEFAULT_FONT_DIR( "/resources/fonts" ); +const unsigned int EMOJI_FONT_SIZE = 3968u; bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet ) { @@ -299,7 +303,16 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) // The underline color is changed as well. DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE ), std::string("{\"enable\":\"false\",\"color\":\"blue\",\"height\":\"0\"}"), TEST_LOCATION ); + Property::Map underlineMapSet; + Property::Map underlineMapGet; + + underlineMapSet.Insert( "enable", "false" ); + underlineMapSet.Insert( "color", "blue" ); + underlineMapSet.Insert( "height", "0" ); + + underlineMapGet = label.GetProperty( TextLabel::Property::UNDERLINE ); + DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION ); // Check that shadow parameters can be correctly set label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) ); @@ -345,18 +358,54 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); // Check the underline property - label.SetProperty( TextLabel::Property::UNDERLINE, "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE ), std::string("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION ); - label.SetProperty( TextLabel::Property::UNDERLINE, "" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE ), std::string("{\"enable\":\"false\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION ); + underlineMapSet.Clear(); + underlineMapSet.Insert( "enable", "true" ); + underlineMapSet.Insert( "color", "red" ); + underlineMapSet.Insert( "height", "1" ); + + label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet ); + + underlineMapGet = label.GetProperty( TextLabel::Property::UNDERLINE ); + DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION ); + + underlineMapSet.Clear(); + + Property::Map underlineDisabledMapGet; + underlineDisabledMapGet.Insert( "enable", "false" ); + underlineDisabledMapGet.Insert( "color", "red" ); + underlineDisabledMapGet.Insert( "height", "1" ); + + label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet ); + underlineMapGet = label.GetProperty( TextLabel::Property::UNDERLINE ); + DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION ); // Check the shadow property - label.SetProperty( TextLabel::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"2 2\"}"), TEST_LOCATION ); - label.SetProperty( TextLabel::Property::SHADOW, "" ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"0 0\"}"), TEST_LOCATION ); + Property::Map shadowMapSet; + Property::Map shadowMapGet; + + shadowMapSet.Insert( "color", "green" ); + shadowMapSet.Insert( "offset", "2 2" ); + + label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet ); + + shadowMapGet = label.GetProperty( TextLabel::Property::SHADOW ); + DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION ); + + shadowMapSet.Clear(); + Property::Map shadowDisabledMapGet; + shadowDisabledMapGet.Insert( "color", "green" ); + shadowDisabledMapGet.Insert( "offset", "0 0" ); + + label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet ); + + shadowMapGet = label.GetProperty( TextLabel::Property::SHADOW ); + DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION ); // Check the emboss property label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" ); @@ -426,46 +475,21 @@ int UtcDaliToolkitTextLabelLanguagesP(void) application.SendNotification(); application.Render(); - END_TEST; -} - -int UtcDaliToolkitTextLabelVectorBasedP(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliToolkitTextLabelVectorBasedP"); - - TestGlAbstraction& glAbstraction = application.GetGlAbstraction(); - glAbstraction.EnableTextureCallTrace( true ); - - TextLabel label = TextLabel::New(); - label.SetParentOrigin( ParentOrigin::CENTER ); - label.SetSize( Stage::GetCurrent().GetSize() ); - label.SetProperty( TextLabel::Property::TEXT, "Hello World" ); - label.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f ); - label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED ); - Stage::GetCurrent().Add( label ); + TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get(); - application.SendNotification(); - application.Render(); + char* pathNamePtr = get_current_dir_name(); + const std::string pathName( pathNamePtr ); + free( pathNamePtr ); - // Test that the vector data is uploaded to atlas - DALI_TEST_CHECK( glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") ); - glAbstraction.GetTextureTrace().Reset(); + fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE ); - // Add another label with the same text in a different point-size - TextLabel label2 = TextLabel::New(); - label2.SetProperty( TextLabel::Property::TEXT, "Hello World" ); - label2.SetProperty( TextLabel::Property::POINT_SIZE, 13.0f ); - label2.SetProperty( TextLabel::Property::RENDERING_BACKEND, Toolkit::Text::RENDERING_VECTOR_BASED ); - Stage::GetCurrent().Add( label2 ); + const std::string emojis = "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84"; + label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true ); + label.SetProperty( TextLabel::Property::TEXT, emojis ); application.SendNotification(); application.Render(); - // Test that no additional vector data was uploaded to atlas - // i.e. the same vector data can be used to render any point-size - DALI_TEST_CHECK( ! glAbstraction.GetTextureTrace().FindMethod("TexSubImage2D") ); - END_TEST; }