Fix for TextSelectionToolbar overshootEffectColor styling
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextSelectionPopup.cpp
index 2cee1b5..dc7fcc7 100644 (file)
 using namespace Dali;
 using namespace Toolkit;
 
+namespace
+{
+
+const char* TEST_IMAGE_FILE_NAME = "selection-popup-border.9.png";
+
+}
+
 void dali_textselectionpopup_startup(void)
 {
   test_return_value = TET_UNDEF;
@@ -107,11 +114,37 @@ int UtcDaliToolkitTextSelectionPopupDownCastP(void)
   END_TEST;
 }
 
+int UtcDaliToolkitTextSelectionPopupBackgroundBorderP(void)
+{
+  ToolkitTestApplication application;
+  TextSelectionPopup textSelectionPopup;
+  textSelectionPopup = TextSelectionPopup::New( NULL );
+
+  textSelectionPopup.SetProperty( TextSelectionPopup::Property::BACKGROUND_BORDER,
+                                  Property::Map().Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) );
+
+  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;
+}
+
 // TextSelectionToolBar is used TextSelectionPopup, below tests it individually
 
 int UtcDaliToolkitTextSelectionToolBarP(void)
 {
-
   // Creates Toolbar, adds 2 options and a divider then resizes divider
   ToolkitTestApplication application;
 
@@ -140,3 +173,60 @@ int UtcDaliToolkitTextSelectionToolBarP(void)
   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.SetName( "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<bool>( 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 );
+  Stage::GetCurrent().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<Vector4>( Toolkit::Scrollable::Property::OVERSHOOT_EFFECT_COLOR );
+  DALI_TEST_EQUALS( color, Color::RED, TEST_LOCATION );
+
+  Vector2 size = scrollView.GetProperty<Vector2>( Toolkit::Scrollable::Property::OVERSHOOT_SIZE );
+  DALI_TEST_EQUALS( size, Vector2(50.0f, 50.f), TEST_LOCATION );
+
+  END_TEST;
+}
+