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-TextSelectionPopup.cpp;h=04bbf792963ddbfa0d4ab6817ca5fae3ca8562d6;hp=2cee1b52f3fc319099dd7195d93e3d7ed8dbc168;hb=HEAD;hpb=7011817795c4ae23533c8e920929c02718d04d79 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp index 2cee1b5..00dce10 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp @@ -15,16 +15,22 @@ * */ -#include -#include #include #include #include #include +#include +#include using namespace Dali; using namespace Toolkit; +namespace +{ +const char* TEST_IMAGE_FILE_NAME = "selection-popup-border.9.png"; +const char* TEST_FONT_FAMILY = "BreezeSans"; +} + void dali_textselectionpopup_startup(void) { test_return_value = TET_UNDEF; @@ -38,13 +44,13 @@ void dali_textselectionpopup_cleanup(void) int UtcDaliToolkitTextSelectionPopupNewP(void) { ToolkitTestApplication application; - TextSelectionPopup textSelectionPopup; + TextSelectionPopup textSelectionPopup; - DALI_TEST_CHECK( !textSelectionPopup ); + DALI_TEST_CHECK(!textSelectionPopup); - textSelectionPopup = TextSelectionPopup::New( NULL ); + textSelectionPopup = TextSelectionPopup::New(NULL); - DALI_TEST_CHECK( textSelectionPopup ); + DALI_TEST_CHECK(textSelectionPopup); END_TEST; } @@ -52,7 +58,7 @@ int UtcDaliToolkitTextSelectionPopupConstructorP(void) { TextSelectionPopup textSelectionPopup; - DALI_TEST_CHECK( !textSelectionPopup ); + DALI_TEST_CHECK(!textSelectionPopup); END_TEST; } @@ -60,24 +66,23 @@ int UtcDaliToolkitTextSelectionPopupConstructorP(void) int UtcDaliToolkitTextSelectionPopupCopyConstructorP(void) { ToolkitTestApplication application; - TextSelectionPopup textSelectionPopup; + TextSelectionPopup textSelectionPopup; - textSelectionPopup = TextSelectionPopup::New( NULL ); - TextSelectionPopup copy( textSelectionPopup ); + textSelectionPopup = TextSelectionPopup::New(NULL); + TextSelectionPopup copy(textSelectionPopup); - DALI_TEST_CHECK( copy == textSelectionPopup ); + DALI_TEST_CHECK(copy == textSelectionPopup); END_TEST; } - int UtcDaliToolkitTextSelectionPopupDestructorP(void) { ToolkitTestApplication application; - TextSelectionPopup* textSelectionPopup = new TextSelectionPopup; + TextSelectionPopup* textSelectionPopup = new TextSelectionPopup; delete textSelectionPopup; - DALI_TEST_CHECK( true ); + DALI_TEST_CHECK(true); END_TEST; } @@ -85,24 +90,78 @@ int UtcDaliToolkitTextSelectionPopupDestructorP(void) int UtcDaliToolkitTextSelectionPopupAssignmentOperatorP(void) { ToolkitTestApplication application; - TextSelectionPopup textSelectionPopup; - textSelectionPopup = TextSelectionPopup::New( NULL ); + TextSelectionPopup textSelectionPopup; + textSelectionPopup = TextSelectionPopup::New(NULL); TextSelectionPopup copy; copy = textSelectionPopup; - DALI_TEST_CHECK( copy == textSelectionPopup ); + DALI_TEST_CHECK(copy == textSelectionPopup); END_TEST; } int UtcDaliToolkitTextSelectionPopupDownCastP(void) { ToolkitTestApplication application; - TextSelectionPopup textSelectionPopup; - textSelectionPopup = TextSelectionPopup::New( NULL ); + TextSelectionPopup textSelectionPopup; + textSelectionPopup = TextSelectionPopup::New(NULL); + + TextSelectionPopup cast = TextSelectionPopup::DownCast(textSelectionPopup); + + DALI_TEST_CHECK(cast); + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupBackgroundBorderP(void) +{ + ToolkitTestApplication application; + TextSelectionPopup textSelectionPopup; + textSelectionPopup = TextSelectionPopup::New(NULL); - TextSelectionPopup cast = TextSelectionPopup::DownCast( textSelectionPopup ); + textSelectionPopup.SetProperty(TextSelectionPopup::Property::BACKGROUND_BORDER, + Property::Map().Add(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME)); - DALI_TEST_CHECK( cast ); + Property::Value value = textSelectionPopup.GetProperty(TextSelectionPopup::Property::BACKGROUND_BORDER); + + Property::Map map; + value.Get(map); + + Property::Value* returnValue = map.Find(Dali::Toolkit::ImageVisual::Property::URL); + DALI_TEST_CHECK(NULL != returnValue); + + if(returnValue) + { + std::string url; + returnValue->Get(url); + DALI_TEST_EQUALS(TEST_IMAGE_FILE_NAME, url, TEST_LOCATION); + } + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupBackgroundP(void) +{ + ToolkitTestApplication application; + TextSelectionPopup textSelectionPopup; + textSelectionPopup = TextSelectionPopup::New(NULL); + + textSelectionPopup.SetProperty(TextSelectionPopup::Property::BACKGROUND, + Property::Map().Add(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME)); + + Property::Value value = textSelectionPopup.GetProperty(TextSelectionPopup::Property::BACKGROUND); + + Property::Map map; + value.Get(map); + + Property::Value* returnValue = map.Find(Dali::Toolkit::ImageVisual::Property::URL); + DALI_TEST_CHECK(NULL != returnValue); + + if(returnValue) + { + std::string url; + returnValue->Get(url); + DALI_TEST_EQUALS(TEST_IMAGE_FILE_NAME, url, TEST_LOCATION); + } END_TEST; } @@ -111,32 +170,258 @@ int UtcDaliToolkitTextSelectionPopupDownCastP(void) int UtcDaliToolkitTextSelectionToolBarP(void) { - // Creates Toolbar, adds 2 options and a divider then resizes divider ToolkitTestApplication application; TextSelectionToolbar toolbar = TextSelectionToolbar::New(); - toolbar.SetProperty( Toolkit::TextSelectionToolbar::Property::MAX_SIZE, Size( 100.0f, 60.0f) ); + toolbar.SetProperty(Toolkit::TextSelectionToolbar::Property::MAX_SIZE, Size(100.0f, 60.0f)); Toolkit::PushButton option = Toolkit::PushButton::New(); - option.SetName( "test-option" ); - option.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); - toolbar.AddOption( option ); + option.SetProperty(Dali::Actor::Property::NAME, "test-option"); + option.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS); + toolbar.AddOption(option); Toolkit::Control divider = Toolkit::Control::New(); - divider.SetSize( 2.0f, 0.0f ); - divider.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); - toolbar.AddDivider( divider ); + divider.SetProperty(Actor::Property::SIZE, Vector2(2.0f, 0.0f)); + divider.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT); + toolbar.AddDivider(divider); Toolkit::PushButton option2 = Toolkit::PushButton::New(); - option2.SetName( "test-option-2" ); - option2.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); - toolbar.AddOption( option2 ); + option2.SetProperty(Dali::Actor::Property::NAME, "test-option-2"); + option2.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS); + toolbar.AddOption(option2); + + Size newSize = Size(3.0f, 0.0f); + toolbar.ResizeDividers(newSize); + + DALI_TEST_CHECK(toolbar); + END_TEST; +} + +int UtcDaliToolkitTextSelectionToolBarScrollBarP(void) +{ + // Creates Toolbar, adds 2 options and a divider then resizes divider + ToolkitTestApplication application; + + TextSelectionToolbar toolbar = TextSelectionToolbar::New(); + + toolbar.SetProperty(Toolkit::TextSelectionToolbar::Property::MAX_SIZE, Size(100.0f, 60.0f)); + + Toolkit::PushButton option = Toolkit::PushButton::New(); + option.SetProperty(Dali::Actor::Property::NAME, "test-option"); + option.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS); + toolbar.AddOption(option); + + // Add a scroll-bar + toolbar.SetProperty(Toolkit::TextSelectionToolbar::Property::ENABLE_SCROLL_BAR, true); + + bool enabled = toolbar.GetProperty(Toolkit::TextSelectionToolbar::Property::ENABLE_SCROLL_BAR); + DALI_TEST_CHECK(enabled); + + DALI_TEST_CHECK(toolbar); + END_TEST; +} + +int UtcDaliToolkitTextSelectionToolBarScrollView(void) +{ + // Configures the ScrollView within the TextSelectionToolbar + ToolkitTestApplication application; + + TextSelectionToolbar toolbar = TextSelectionToolbar::New(); + DALI_TEST_CHECK(toolbar); + application.GetScene().Add(toolbar); + + Property::Map map; + map["overshootEffectColor"] = Color::RED; + map["overshootSize"] = Vector2(50.0f, 50.f); + toolbar.SetProperty(Toolkit::TextSelectionToolbar::Property::SCROLL_VIEW, map); + + application.SendNotification(); + application.Render(); + + Actor actor = toolbar.FindChildByName("TextSelectionScrollView"); + DALI_TEST_CHECK(actor); + + ScrollView scrollView = ScrollView::DownCast(actor); + DALI_TEST_CHECK(scrollView); + + Vector4 color = scrollView.GetProperty(Toolkit::Scrollable::Property::OVERSHOOT_EFFECT_COLOR); + DALI_TEST_EQUALS(color, Color::RED, TEST_LOCATION); - Size newSize = Size(3.0f, 0.0f); - toolbar.ResizeDividers( newSize ); + Vector2 size = scrollView.GetProperty(Toolkit::Scrollable::Property::OVERSHOOT_SIZE); + DALI_TEST_EQUALS(size, Vector2(50.0f, 50.f), TEST_LOCATION); - DALI_TEST_CHECK( toolbar ); END_TEST; } + +int UtcDaliToolkitTextSelectionPopupIconProperties(void) +{ + ToolkitTestApplication application; + TextSelectionPopup popup = TextSelectionPopup::New(nullptr); + popup.SetProperty(TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE, "POPUP_CLIPBOARD_BUTTON_ICON_IMAGE"); + popup.SetProperty(TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE, "POPUP_CUT_BUTTON_ICON_IMAGE"); + popup.SetProperty(TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE, "POPUP_COPY_BUTTON_ICON_IMAGE"); + popup.SetProperty(TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE, "POPUP_PASTE_BUTTON_ICON_IMAGE"); + popup.SetProperty(TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE, "POPUP_SELECT_BUTTON_ICON_IMAGE"); + popup.SetProperty(TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE, "POPUP_SELECT_ALL_BUTTON_ICON_IMAGE"); + popup.SetProperty(TextSelectionPopup::Property::POPUP_PRESSED_IMAGE, "POPUP_PRESSED_IMAGE"); + + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_CLIPBOARD_BUTTON_ICON_IMAGE).Get(), "POPUP_CLIPBOARD_BUTTON_ICON_IMAGE", TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_CUT_BUTTON_ICON_IMAGE).Get(), "POPUP_CUT_BUTTON_ICON_IMAGE", TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_COPY_BUTTON_ICON_IMAGE).Get(), "POPUP_COPY_BUTTON_ICON_IMAGE", TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_PASTE_BUTTON_ICON_IMAGE).Get(), "POPUP_PASTE_BUTTON_ICON_IMAGE", TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_SELECT_BUTTON_ICON_IMAGE).Get(), "POPUP_SELECT_BUTTON_ICON_IMAGE", TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_SELECT_ALL_BUTTON_ICON_IMAGE).Get(), "POPUP_SELECT_ALL_BUTTON_ICON_IMAGE", TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_PRESSED_IMAGE).Get(), "POPUP_PRESSED_IMAGE", TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupSizeProperties(void) +{ + ToolkitTestApplication application; + TextSelectionPopup popup = TextSelectionPopup::New(nullptr); + + const Vector2 popupMaxSize(200.0f, 300.0f); + const Vector2 optionMaxSize(50.0f, 100.0f); + const Vector2 optionMinSize(10.0f, 10.0f); + const Vector2 optionDividerSize(5.0f, 5.0f); + const Vector4 optionDividerPadding(20.0f, 20.0f, 10.0f, 10.0f); + popup.SetProperty(TextSelectionPopup::Property::POPUP_MAX_SIZE, popupMaxSize); + popup.SetProperty(TextSelectionPopup::Property::OPTION_MAX_SIZE, optionMaxSize); + popup.SetProperty(TextSelectionPopup::Property::OPTION_MIN_SIZE, optionMinSize); + popup.SetProperty(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE, optionDividerSize); + popup.SetProperty(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING, optionDividerPadding); + + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_MAX_SIZE).Get(), popupMaxSize, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::OPTION_MAX_SIZE).Get(), optionMaxSize, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::OPTION_MIN_SIZE).Get(), optionMinSize, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::OPTION_DIVIDER_SIZE).Get(), optionDividerSize, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::OPTION_DIVIDER_PADDING).Get(), optionDividerPadding, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupFloatProperties(void) +{ + ToolkitTestApplication application; + TextSelectionPopup popup = TextSelectionPopup::New(nullptr); + + const float popupFadeInDuration = 5.0f; + const float popupFadeOutDuration = 10.0f; + const float popupPressedCornerRadius = 15.0f; + popup.SetProperty(TextSelectionPopup::Property::POPUP_FADE_IN_DURATION, popupFadeInDuration); + popup.SetProperty(TextSelectionPopup::Property::POPUP_FADE_OUT_DURATION, popupFadeOutDuration); + popup.SetProperty(TextSelectionPopup::Property::POPUP_PRESSED_CORNER_RADIUS, popupPressedCornerRadius); + + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_FADE_IN_DURATION).Get(), popupFadeInDuration, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_FADE_OUT_DURATION).Get(), popupFadeOutDuration, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_PRESSED_CORNER_RADIUS).Get(), popupPressedCornerRadius, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupColorProperties(void) +{ + ToolkitTestApplication application; + TextSelectionPopup popup = TextSelectionPopup::New(nullptr); + + popup.SetProperty(TextSelectionPopup::Property::POPUP_DIVIDER_COLOR, Color::RED); + popup.SetProperty(TextSelectionPopup::Property::POPUP_ICON_COLOR, Color::BLUE); + popup.SetProperty(TextSelectionPopup::Property::POPUP_PRESSED_COLOR, Color::BLACK); + + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_DIVIDER_COLOR).Get(), Color::RED, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_ICON_COLOR).Get(), Color::BLUE, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::POPUP_PRESSED_COLOR).Get(), Color::BLACK, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupScrollBarP(void) +{ + ToolkitTestApplication application; + TextSelectionPopup popup = TextSelectionPopup::New(nullptr); + DALI_TEST_CHECK(popup); + + popup.SetProperty(TextSelectionPopup::Property::ENABLE_SCROLL_BAR, true); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::ENABLE_SCROLL_BAR).Get(), true, TEST_LOCATION); + + popup.SetProperty(TextSelectionPopup::Property::ENABLE_SCROLL_BAR, false); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::ENABLE_SCROLL_BAR).Get(), false, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupLabelTextVisualP(void) +{ + ToolkitTestApplication application; + TextSelectionPopup popup = TextSelectionPopup::New(nullptr); + DALI_TEST_CHECK(popup); + + Property::Map textVisualMapSet; + + textVisualMapSet.Insert(TextVisual::Property::FONT_FAMILY, TEST_FONT_FAMILY); + textVisualMapSet.Insert(TextVisual::Property::POINT_SIZE, 50.f); + textVisualMapSet.Insert(TextVisual::Property::TEXT_COLOR, Color::RED); + + popup.SetProperty(TextSelectionPopup::Property::LABEL_TEXT_VISUAL, textVisualMapSet); + + Property::Map textVisualMapGet; + Property::Map styleMapGet; + + textVisualMapGet = popup.GetProperty(TextSelectionPopup::Property::LABEL_TEXT_VISUAL).Get(); + DALI_TEST_EQUALS(textVisualMapGet.Count(), 3u, TEST_LOCATION); + + Property::Value* returnValue; + + returnValue = textVisualMapGet.Find(TextVisual::Property::FONT_FAMILY); + DALI_TEST_CHECK(NULL != returnValue); + + if(returnValue) + { + std::string fontFamily; + returnValue->Get(fontFamily); + DALI_TEST_EQUALS(fontFamily, TEST_FONT_FAMILY, TEST_LOCATION); + } + + returnValue = textVisualMapGet.Find(TextVisual::Property::POINT_SIZE); + DALI_TEST_CHECK(NULL != returnValue); + + if(returnValue) + { + float pointSize; + returnValue->Get(pointSize); + DALI_TEST_EQUALS(pointSize, 50.0f, TEST_LOCATION); + } + + returnValue = textVisualMapGet.Find(TextVisual::Property::TEXT_COLOR); + DALI_TEST_CHECK(NULL != returnValue); + + if(returnValue) + { + Vector4 textColor; + returnValue->Get(textColor); + DALI_TEST_EQUALS(textColor, Color::RED, TEST_LOCATION); + } + + END_TEST; +} + +int UtcDaliToolkitTextSelectionPopupLabelProperties(void) +{ + ToolkitTestApplication application; + TextSelectionPopup popup = TextSelectionPopup::New(nullptr); + DALI_TEST_CHECK(popup); + + const Vector2 labelMinimumSize(100.0f, 50.0f); + const Vector4 labelPadding(10.0f, 20.0f, 30.0f, 40.0f); + + popup.SetProperty(TextSelectionPopup::Property::LABEL_MINIMUM_SIZE, labelMinimumSize); + popup.SetProperty(TextSelectionPopup::Property::LABEL_PADDING, labelPadding); + + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::LABEL_MINIMUM_SIZE).Get(), labelMinimumSize, TEST_LOCATION); + DALI_TEST_EQUALS(popup.GetProperty(TextSelectionPopup::Property::LABEL_PADDING).Get(), labelPadding, TEST_LOCATION); + + END_TEST; +} \ No newline at end of file