Fix a bug where NativeImage::GetUrl() was always returning empty string 73/95773/1
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 4 Nov 2016 13:18:46 +0000 (13:18 +0000)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Fri, 4 Nov 2016 13:18:46 +0000 (13:18 +0000)
Change-Id: Ifcf2d78f126aa80daebaefd50e60178c28e41ec1

automated-tests/src/dali/utc-Dali-NinePatchImages.cpp
dali/internal/event/images/nine-patch-image-impl.cpp
dali/internal/event/images/nine-patch-image-impl.h
dali/internal/event/images/resource-image-impl.h

index b055451..86eb06c 100644 (file)
@@ -144,7 +144,8 @@ NinePatchImage CustomizeNinePatch( TestApplication& application,
   Integration::ResourcePointer resourcePtr(bitmap);
   platform.SetSynchronouslyLoadedResource( resourcePtr );
 
-  Image image = ResourceImage::New( "blah.#.png" );
+  std::string url( "blah.#.png" );
+  Image image = ResourceImage::New( url );
 
   tet_infoline("Assign image to image rendering actor");
   Actor actor = CreateRenderableActor( image );
@@ -153,6 +154,8 @@ NinePatchImage CustomizeNinePatch( TestApplication& application,
   tet_infoline("Downcast Image to a nine-patch image\n");
   NinePatchImage ninePatchImage = NinePatchImage::DownCast( image );
 
+  DALI_TEST_EQUALS( url, ninePatchImage.GetUrl(), TEST_LOCATION );
+
   return ninePatchImage;
 
 }
@@ -170,9 +173,13 @@ int UtcDaliNinePatchImageNew(void)
   DALI_TEST_CHECK( !image );
 
   // initialise handle
-  image = NinePatchImage::New( "blah.#.png" );
+  std::string url("blah.#.png");
+  image = NinePatchImage::New( url );
 
   DALI_TEST_CHECK( image );
+
+  DALI_TEST_EQUALS( url, image.GetUrl(), TEST_LOCATION );
+
   END_TEST;
 }
 
index 7bbcef1..e165330 100644 (file)
@@ -177,6 +177,7 @@ NinePatchImage::NinePatchImage( const std::string& filename )
 : ResourceImage(),
   mParsedBorder(false)
 {
+  mUrl = filename;
   ThreadLocalStorage& tls = ThreadLocalStorage::Get();
   mResourceClient = &tls.GetResourceClient();
 
@@ -275,6 +276,11 @@ Internal::BufferImagePtr NinePatchImage::CreateCroppedBufferImage()
   return cropped;
 }
 
+const std::string& NinePatchImage::GetUrl() const
+{
+  return mUrl;
+}
+
 void NinePatchImage::Connect()
 {
   if( !mTicket )
index 3508821..1d14916 100644 (file)
@@ -114,6 +114,12 @@ public:
    */
   static bool IsNinePatchUrl( const std::string& url );
 
+private: // from ResourceImage
+
+  /**
+   * @copydoc ResourceImage::GetUrl()
+   */
+  virtual const std::string& GetUrl() const;
 
 protected: // From Resource
   /**
@@ -138,6 +144,7 @@ private:
 private:
   ResourceClient*               mResourceClient;
   Integration::BitmapPtr        mBitmap;
+  std::string                   mUrl;
   StretchRanges                 mStretchPixelsX;  //< The horizontal stretchable pixels in the cropped image space
   StretchRanges                 mStretchPixelsY;  //< The vertical stretchable pixels in the cropped image space
   Rect<int>                     mChildRectangle;
index 642d3c1..aeac5b9 100644 (file)
@@ -93,8 +93,9 @@ public:
 
   /**
    * @copydoc Dali::ResourceImage::GetUrl()
+   * virtual so deriving class can override it
    */
-  const std::string& GetUrl() const;
+  virtual const std::string& GetUrl() const;
 
   /**
    * @copydoc Dali::ResourceImage::Reload()