[dali_1.2.52] Merge branch 'devel/master' 41/143841/1
authorRichard Huang <r.huang@samsung.com>
Fri, 11 Aug 2017 11:45:00 +0000 (12:45 +0100)
committerRichard Huang <r.huang@samsung.com>
Fri, 11 Aug 2017 11:45:00 +0000 (12:45 +0100)
Change-Id: I811aa7ca8b2be3b0c6432db80b9c3b968fd8755c

15 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSetConversion.cpp [changed mode: 0644->0755]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp
dali-toolkit/devel-api/controls/control-devel.h
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.h
dali-toolkit/internal/controls/slider/slider-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h
dali-toolkit/internal/text/character-set-conversion.cpp
dali-toolkit/internal/text/multi-language-support-impl.cpp
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

old mode 100644 (file)
new mode 100755 (executable)
index 2ec5233..3175baf
@@ -282,11 +282,14 @@ int UtcDaliTextCharacterSetConversionUtf8ToUtf32(void)
   ToolkitTestApplication application;
   tet_infoline(" UtcDaliTextCharacterSetConversionGetNumberOfUtf8Bytes");
 
+  char utf8_06[] = { -8, -7, -6, -5, -4, -3, -2, -1 }; // Invalid string
+
   unsigned int utf32_01[] = { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; // Hello World
   unsigned int utf32_02[] = { 0xA, 0x20, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0xA, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; // Hello World + CR and CR+LF
   unsigned int utf32_03[] = { 0x645, 0x631, 0x62D, 0x628, 0x627, 0x20, 0x628, 0x627, 0x644, 0x639, 0x627, 0x644, 0x645 }; // مرحبا بالعالم
   unsigned int utf32_04[] = { 0x939, 0x948, 0x932, 0x94B, 0x20, 0x935, 0x930, 0x94D, 0x932, 0x94D, 0x921 }; // हैलो वर्ल्ड
   unsigned int utf32_05[] = { 0x1F601, 0x20, 0x1F602, 0x20, 0x1F603, 0x20, 0x1F604 }; // Emojis
+  unsigned int utf32_06[] = { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; // Invalid string
 
   const Utf8ToUtf32Data data[] =
   {
@@ -315,8 +318,13 @@ int UtcDaliTextCharacterSetConversionUtf8ToUtf32(void)
       "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84",
       utf32_05,
     },
+    {
+      "Invalid text",
+      utf8_06,
+      utf32_06,
+    },
   };
-  const unsigned int numberOfTests = 5u;
+  const unsigned int numberOfTests = 6u;
 
   for( unsigned int index = 0u; index < numberOfTests; ++index )
   {
index 0d54096..d0a9d03 100644 (file)
@@ -265,6 +265,11 @@ void Impl::DummyControl::SetLayout( Property::Index visualIndex, Property::Map&
 
 void Impl::DummyControl::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
+  if ( mRelayoutCallback )
+  {
+    mRelayoutCallback( size );  // Execute callback if set
+  }
+
   Property::Map emptyMap;
 
   for( VisualIndices::iterator iter = mRegisteredVisualIndices.begin(); iter != mRegisteredVisualIndices.end() ; ++iter )
@@ -286,6 +291,12 @@ void Impl::DummyControl::OnRelayout( const Vector2& size, RelayoutContainer& con
   }
 }
 
+void Impl::DummyControl::SetRelayoutCallback( RelayoutCallbackFunc callback  )
+{
+  mRelayoutCallback = callback;
+}
+
+
 DummyControl DummyControl::New( bool override )
 {
   DummyControl control;
index 7b43bd0..d0387d9 100644 (file)
@@ -21,6 +21,9 @@
 // INTERNAL INCLUDES
 #include <dali-toolkit/dali-toolkit.h>
 
+// EXTERNAL INCLUDES
+#include <functional>
+
 namespace Dali
 {
 
@@ -132,10 +135,14 @@ class DummyControl : public Toolkit::DummyControlImpl
 {
 public:
 
+  typedef std::function<void( Size )> RelayoutCallbackFunc;
+
   static Toolkit::DummyControl New();
 
   void SetLayout( Property::Index visualIndex, Property::Map& map );
 
+  void SetRelayoutCallback( RelayoutCallbackFunc callback );
+
 private:
 
   DummyControl();
@@ -200,6 +207,8 @@ public:
   bool keyInputFocusLost;
 
   Property::Map mLayouts;
+  RelayoutCallbackFunc mRelayoutCallback;
+
 };
 
 } // namespace Impl
index e8198ca..31909d9 100644 (file)
@@ -30,6 +30,8 @@
 #include <sstream>
 #include <unistd.h>
 
+#include "dummy-control.h"
+
 using namespace Dali;
 using namespace Toolkit;
 
@@ -831,6 +833,7 @@ int UtcDaliImageViewSetImageOffstageP(void)
 }
 
 bool gResourceReadySignalFired = false;
+Vector3 gNaturalSize;
 
 void ResourceReadySignal( Control control )
 {
@@ -1354,3 +1357,52 @@ int UtcDaliImageViewReplaceImage(void)
 
   END_TEST;
 }
+
+void OnRelayoutOverride( Size size )
+{
+  gNaturalSize = size; // Size Relayout is using
+}
+
+int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
+{
+  ToolkitTestApplication application;
+
+  // Check ImageView with background and main image, to ensure both visuals are marked as loaded
+  ImageView imageView = ImageView::New( TEST_IMAGE_1 );
+  imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+  DummyControl dummyControl = DummyControl::New( true );
+  Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+  dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+
+  dummyControl.Add( imageView );
+  dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
+  Stage::GetCurrent().Add( dummyControl );
+
+  application.SendNotification();
+  application.Render();
+
+  // loading started, this waits for the loader thread for max 30 seconds
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
+
+  gNaturalSize = Vector3::ZERO;
+
+  imageView.SetImage(gImage_600_RGB);
+
+  // Waiting for resourceReady so SendNotifcation not called here.
+
+  // loading started, this waits for the loader thread for max 30 seconds
+  DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+  // Trigger a potential relayout
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
+
+  END_TEST;
+}
index 8957dd6..6083bc2 100644 (file)
@@ -971,15 +971,6 @@ int UtcDaliKeyboardFocusManagerMoveFocusBackward(void)
   KeyboardFocusManager manager = KeyboardFocusManager::Get();
   DALI_TEST_CHECK(manager);
 
-  // Make history stack full
-  for(int i = 0 ; i < 31 ; i ++)
-  {
-    Actor actor = Actor::New();
-    actor.SetKeyboardFocusable(true);
-    Stage::GetCurrent().Add(actor);
-    manager.SetCurrentFocusActor(actor);
-  }
-
   // Create the first actor and add it to the stage
   Actor first = Actor::New();
   first.SetKeyboardFocusable(true);
@@ -990,11 +981,16 @@ int UtcDaliKeyboardFocusManagerMoveFocusBackward(void)
   second.SetKeyboardFocusable(true);
   Stage::GetCurrent().Add(second);
 
-  // Create the second actor and add it to the stage
+  // Create the third actor and add it to the stage
   Actor third = Actor::New();
   third.SetKeyboardFocusable(true);
   Stage::GetCurrent().Add(third);
 
+  // Create the fourth actor and add it to the stage
+  Actor fourth = Actor::New();
+  fourth.SetKeyboardFocusable(true);
+  Stage::GetCurrent().Add(fourth);
+
   // Check that the focus is set on the second actor
   DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
@@ -1007,24 +1003,45 @@ int UtcDaliKeyboardFocusManagerMoveFocusBackward(void)
   DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
 
+  // Check that the focus is set on the third  actor
+  DALI_TEST_CHECK(manager.SetCurrentFocusActor(fourth) == true);
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == fourth);
+
   // Move the focus backward
   manager.MoveFocusBackward();
 
-  // Check that it current focused actor is second actor
-  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
-
-  // Check that the focus is set on the third actor
-  DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
+  // Check that it current focused actor is third actor
   DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
 
   // Remove the second actor on stage
   second.Unparent();
 
+  // Reset the first actor
+  first.Unparent();
+  first.Reset();
+
   // Move the focus backward
   manager.MoveFocusBackward();
 
-  // Check that it current focused actor is first actor
-  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+  // Check that it current focused actor is third actor
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+
+  // Make history stack full
+  for(int i = 0 ; i < 31 ; i ++)
+  {
+    Actor actor = Actor::New();
+    actor.SetKeyboardFocusable(true);
+    Stage::GetCurrent().Add(actor);
+    manager.SetCurrentFocusActor(actor);
+  }
+
+  for(int i = 0 ; i < 31 ; i ++)
+  {
+    manager.MoveFocusBackward();
+  }
+
+  // Check that it current focused actor is not second actor
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() != second);
 
   END_TEST;
 }
index 233ef12..eb58f91 100644 (file)
@@ -123,6 +123,8 @@ typedef Signal<void ( Control ) > ResourceReadySignalType;
  * by a control are loaded and ready.
  * Most resources are only loaded when the control is placed on stage.
  *
+ * @note A RelayoutRequest is queued by Control before this signal is emitted
+ *
  * A callback of the following type may be connected:
  * @code
  *   void YourCallbackName( Control control );
index 7934109..72faf14 100644 (file)
@@ -64,8 +64,7 @@ DALI_TYPE_REGISTRATION_END()
 using namespace Dali;
 
 ImageView::ImageView()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
-  mRelayoutRequired(true)
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) )
 {
 }
 
@@ -117,6 +116,7 @@ void ImageView::SetImage( const Property::Map& map )
   mPropertyMap = map;
   mUrl.clear();
   mImage.Reset();
+
   Toolkit::Visual::Base visual =  Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap );
   // Don't set mVisual until it is ready and shown. Getters will still use current visual.
   if (!mVisual)
@@ -215,9 +215,6 @@ void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
   Control::OnRelayout( size, container );
 
-  // If visual is being replaced then mVisual will be the replacement visual even if not ready.
-  mVisual = DevelControl::GetVisual( *this, Toolkit::ImageView::Property::IMAGE );
-
   if( mVisual )
   {
     // Pass in an empty map which uses default transform values meaning our visual fills the control
@@ -228,11 +225,8 @@ void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
 
 void ImageView::OnResourceReady( Toolkit::Control control )
 {
-  if( mRelayoutRequired)
-  {
-    mRelayoutRequired = false;
-    RelayoutRequest();
-  }
+  // Visual ready so update visual attached to this ImageView, following call to RelayoutRequest will use this visual.
+  mVisual = DevelControl::GetVisual( *this, Toolkit::ImageView::Property::IMAGE );
 }
 
 ///////////////////////////////////////////////////////////
index dc449e9..f335ce7 100644 (file)
@@ -166,7 +166,6 @@ private:
   std::string      mUrl;          ///< the url for the image if the image came from a URL, empty otherwise
   Image            mImage;        ///< the Image if the image came from a Image, null otherwise
   Property::Map    mPropertyMap;  ///< the Property::Map if the image came from a Property::Map, empty otherwise
-  bool             mRelayoutRequired; ///< True if relayout is required, e.g. due to unreadiness
 };
 
 } // namespace Internal
index 213818a..275995d 100755 (executable)
@@ -1378,8 +1378,15 @@ Property::Value Slider::GetProperty( BaseObject* object, Property::Index propert
 
       case Toolkit::Slider::Property::MARKS:
       {
-        // TODO: Need to be able to return a PropertyArray
-        // value = sliderImpl.GetMarks();
+        Property::Value value1( Property::ARRAY );
+        Property::Array* markArray = value1.GetArray();
+
+        if( markArray )
+        {
+          *markArray = sliderImpl.GetMarks();
+        }
+
+        value = value1;
         break;
       }
 
index 5225c46..c3ebe62 100644 (file)
@@ -208,13 +208,13 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
     }
 
     // Push Current Focused Actor to FocusHistory
-    mFocusHistory.PushBack( &actor.GetBaseObject() );
+    mFocusHistory.push_back( actor );
 
     // Delete first element before add new element when Stack is full.
-    if( mFocusHistory.Count() > MAX_HISTORY_AMOUNT )
+    if( mFocusHistory.size() > MAX_HISTORY_AMOUNT )
     {
-       FocusStackIterator beginPos = mFocusHistory.Begin();
-       mFocusHistory.Erase( beginPos );
+       FocusStackIterator beginPos = mFocusHistory.begin();
+       mFocusHistory.erase( beginPos );
     }
 
     DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__);
@@ -249,28 +249,39 @@ Actor KeyboardFocusManager::GetCurrentFocusGroup()
 void KeyboardFocusManager::MoveFocusBackward()
 {
   // Find Pre Focused Actor when the list size is more than 1
-  if( mFocusHistory.Count() > 1 )
+  if( mFocusHistory.size() > 1 )
   {
     // Delete current focused actor in history
-    FocusStackIterator endPos = mFocusHistory.End();
-    endPos = mFocusHistory.Erase( --endPos );
+    mFocusHistory.pop_back();
 
-    // If pre-focused actors are not on stage, remove them in stack
-    while( !Dali::Actor::DownCast(BaseHandle(mFocusHistory[ mFocusHistory.Count() - 1 ])).OnStage() )
+    // If pre-focused actors are not on stage or deleted, remove them in stack
+    while( mFocusHistory.size() > 0 )
     {
-      endPos = mFocusHistory.Erase( --endPos );
-    }
-
-    // Get pre focused actor
-    BaseObject* object = mFocusHistory[ mFocusHistory.Count() - 1 ];
-    BaseHandle handle( object );
-    Actor preFocusedActor = Dali::Actor::DownCast( handle );
+      // Get pre focused actor
+      Actor target = mFocusHistory[ mFocusHistory.size() -1 ].GetHandle();
 
-    // Delete pre focused actor in history because it will pushed again by SetCurrentFocusActor()
-    mFocusHistory.Erase( --endPos );
+      // Impl of Actor is not null
+      if( target && target.OnStage() )
+      {
+        // Delete pre focused actor in history because it will pushed again by SetCurrentFocusActor()
+        mFocusHistory.pop_back();
+        SetCurrentFocusActor( target );
+        break;
+      }
+      else
+      {
+        // Target is empty handle or off stage. Erase from queue
+        mFocusHistory.pop_back();
+      }
+    }
 
-    SetCurrentFocusActor( preFocusedActor );
- }
+    // if there is no actor which can get focus, then push current focus actor in stack again
+    if( mFocusHistory.size() == 0 )
+    {
+      Actor currentFocusedActor = GetCurrentFocusActor();
+      mFocusHistory.push_back( currentFocusedActor );
+    }
+  }
 }
 
 bool KeyboardFocusManager::IsLayoutControl(Actor actor) const
index 7283b1e..049ce1f 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/base-object.h>
 #include <dali/devel-api/object/weak-handle.h>
+#include <dali/public-api/common/vector-wrapper.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
@@ -161,8 +162,8 @@ protected:
 
 private:
 
-  typedef Dali::Vector< Dali::BaseObject* > FocusStack; ///< Define Dali::Vector< Dali::BaseObject* > as FocusStack to contain focus history
-  typedef FocusStack::Iterator FocusStackIterator; ///< Define FocusStack::Iterator as FocusStackIterator to navigate FocusStack
+  typedef std::vector< WeakHandle< Actor > > FocusStack; ///< Define Dali::Vector< Dali::BaseObject* > as FocusStack to contain focus history
+  typedef FocusStack::iterator FocusStackIterator; ///< Define FocusStack::Iterator as FocusStackIterator to navigate FocusStack
 
   /**
    * Get configuration from StyleManager.
index bd72dc1..d79fbc3 100644 (file)
@@ -196,6 +196,13 @@ uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf3
         code |= *begin++ & 0x3fu;
         break;
       }
+
+      case U0:    // Invalid case
+      {
+        begin++;
+        *utf32++ = 0x20;    // Use white space
+        break;
+      }
     }
   }
 
index 020a5cb..fd1d8e4 100644 (file)
@@ -613,9 +613,8 @@ void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
           if( !isValidFont ) // (3)
           {
             // The given font has not been validated.
-            int validCharacterIndex = fontClient.GetGlyphIndex(cachedDefaultFontId, character );
 
-            if( isValidCachedDefaultFont && validCharacterIndex != 0u )
+            if( isValidCachedDefaultFont )
             {
               // Use the cached default font for the script if there is one.
               fontId = cachedDefaultFontId;
index 8607741..feac7cb 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 51;
+const unsigned int TOOLKIT_MICRO_VERSION = 52;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 9b15785..1e5587b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.2.51
+Version:    1.2.52
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT