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-TextField.cpp;h=d72f2321335ed61138c35cd6a451b98275defd67;hp=80ed1d7cd4e2de01db68dcc9f6da2042ee4a7b7d;hb=533d8c2ec94a43bbe098b556bb905cbe10f427ab;hpb=f4c1e7f52d49c3ce033b9ee4c3c7414b06a22d45 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 80ed1d7..d72f232 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -282,7 +282,6 @@ Integration::TapGestureEvent GenerateTap( return tap; } - Integration::LongPressGestureEvent GenerateLongPress( Gesture::State state, unsigned int numberOfTouches, @@ -311,6 +310,34 @@ Integration::KeyEvent GenerateKey( const std::string& keyName, keyState ); } +bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet ) +{ + if( fontStyleMapGet.Count() == fontStyleMapSet.Count() ) + { + for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index ) + { + const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index ); + + Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey ); + if( NULL != valueSet ) + { + if( valueGet.second.Get() != valueSet->Get() ) + { + tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get().c_str(), valueSet->Get().c_str() ); + return false; + } + } + else + { + tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() ); + return false; + } + } + } + + return true; +} + } // namespace int UtcDaliToolkitTextFieldConstructorP(void) @@ -501,18 +528,56 @@ int UtcDaliTextFieldSetPropertyP(void) // Check font properties. field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION ); - field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION ); + + Property::Map fontStyleMapSet; + Property::Map fontStyleMapGet; + Property::Value* slantValue = NULL; + + fontStyleMapSet.Insert( "weight", "bold" ); + fontStyleMapSet.Insert( "width", "condensed" ); + fontStyleMapSet.Insert( "slant", "italic" ); + field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet ); + + fontStyleMapGet = field.GetProperty( TextField::Property::FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); // Reset font style. - field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::FONT_STYLE, "{\"slant\":\"roman\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::FONT_STYLE, "" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string(""), TEST_LOCATION ); + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "weight", "normal" ); + fontStyleMapSet.Insert( "slant", "oblique" ); + field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet ); + + fontStyleMapGet = field.GetProperty( TextField::Property::FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "slant", "roman" ); + field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet ); + fontStyleMapGet = field.GetProperty( TextField::Property::FONT_STYLE ); + + // Replace 'roman' for 'normal'. + slantValue = fontStyleMapGet.Find( "slant" ); + if( NULL != slantValue ) + { + if( "normal" == slantValue->Get() ) + { + fontStyleMapGet["slant"] = "roman"; + } + } + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + + fontStyleMapSet.Clear(); + + field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet ); + fontStyleMapGet = field.GetProperty( TextField::Property::FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); // Check that the MAX_LENGTH property can be correctly set const int maxNumberOfCharacters = 20; @@ -598,18 +663,54 @@ int UtcDaliTextFieldSetPropertyP(void) // Check input font properties. field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION ); + + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "weight", "bold" ); + fontStyleMapSet.Insert( "width", "condensed" ); + fontStyleMapSet.Insert( "slant", "italic" ); + + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet ); + fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); // Reset input font style. - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"slant\":\"roman\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION ); + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "weight", "normal" ); + fontStyleMapSet.Insert( "slant", "oblique" ); + + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet ); + fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "slant", "roman" ); + + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet ); + fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ); + + // Replace 'roman' for 'normal'. + slantValue = fontStyleMapGet.Find( "slant" ); + if( NULL != slantValue ) + { + if( "normal" == slantValue->Get() ) + { + fontStyleMapGet["slant"] = "roman"; + } + } + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + + fontStyleMapSet.Clear(); + + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet ); + fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); // Check the underline property field.SetProperty( TextField::Property::UNDERLINE, "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" ); @@ -940,8 +1041,13 @@ int utcDaliTextFieldInputStyleChanged01(void) const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get(); DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION ); - const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get(); - DALI_TEST_EQUALS( style, "{\"weight\":\"bold\"}", TEST_LOCATION ); + const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get(); + + Property::Map fontStyleMapSet; + fontStyleMapSet.Insert( "weight", "bold" ); + + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); } DALI_TEST_CHECK( inputStyleChangedSignal ); @@ -1168,7 +1274,12 @@ int utcDaliTextFieldInputStyleChanged02(void) field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"condensed\",\"slant\":\"italic\"}" ); + Property::Map fontStyleMapSet; + fontStyleMapSet.Insert( "weight", "thin" ); + fontStyleMapSet.Insert( "width", "condensed" ); + fontStyleMapSet.Insert( "slant", "italic" ); + + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet ); field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f ); field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" ); @@ -1853,11 +1964,25 @@ int utcDaliTextFieldStyleWhilstSelected(void) field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION ); + Property::Map fontStyleMapSet; + Property::Map fontStyleMapGet; + + fontStyleMapSet.Insert( "weight", "bold" ); + fontStyleMapSet.Insert( "slant", "italic" ); + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet ); + + fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "width", "expanded" ); + fontStyleMapSet.Insert( "slant", "italic" ); + field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet ); - field.SetProperty( TextField::Property::INPUT_FONT_STYLE, "{\"width\":\"expanded\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_FONT_STYLE ), "{\"width\":\"expanded\",\"slant\":\"italic\"}", TEST_LOCATION ); + fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); @@ -1865,11 +1990,24 @@ int utcDaliTextFieldStyleWhilstSelected(void) field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED ); DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION ); - field.SetProperty( TextField::Property::FONT_STYLE, "{\"weight\":\"bold\",\"slant\":\"italic\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), "{\"weight\":\"bold\",\"slant\":\"italic\"}", TEST_LOCATION ); + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "weight", "bold" ); + fontStyleMapSet.Insert( "slant", "italic" ); + + field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet ); + + fontStyleMapGet = field.GetProperty( TextField::Property::FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); + + fontStyleMapSet.Clear(); + fontStyleMapSet.Insert( "width", "expanded" ); + + field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet ); - field.SetProperty( TextField::Property::FONT_STYLE, "{\"width\":\"expanded\"}" ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), "{\"width\":\"expanded\"}", TEST_LOCATION ); + fontStyleMapGet = field.GetProperty( TextField::Property::FONT_STYLE ); + DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION ); END_TEST; }