Merge "Add U0 case to Utf8ToUtf32" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 4 Aug 2017 14:08:08 +0000 (14:08 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 4 Aug 2017 14:08:08 +0000 (14:08 +0000)
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
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/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

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 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 7a86660..8607741 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 = 50;
+const unsigned int TOOLKIT_MICRO_VERSION = 51;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 9258cde..9b15785 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.2.50
+Version:    1.2.51
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT