Visual replacements logic updated
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-PushButton.cpp
index 57b39a5..7ea83bc 100644 (file)
@@ -48,6 +48,7 @@ void utc_dali_toolkit_pushbutton_cleanup(void)
 namespace
 {
 static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
 namespace
 {
 static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+static const char* TEST_IMAGE_TWO = TEST_RESOURCE_DIR "/icon-delete.jpg";
 
 static const Vector2 INSIDE_TOUCH_POINT_POSITON  = Vector2( 240, 400 );
 static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS  = Vector3( 200, 360, 0 );
 
 static const Vector2 INSIDE_TOUCH_POINT_POSITON  = Vector2( 240, 400 );
 static const Vector3 BUTTON_POSITON_TO_GET_INSIDE_TOUCH_EVENTS  = Vector3( 200, 360, 0 );
@@ -1816,3 +1817,37 @@ int UtcDaliPushButtonSetDisabledSelectedImageWithActorDeprecatedP(void)
 
   END_TEST;
 }
 
   END_TEST;
 }
+
+int UtcDaliPushButtonReplaceButtonImageP2(void)
+{
+  tet_infoline("Set button image then replace with new image and query url");
+
+  ToolkitTestApplication application;
+
+  ResourceImage setImage = ResourceImage::New( TEST_IMAGE_ONE );
+  DALI_TEST_CHECK(setImage);
+
+  Actor imgActorSet = ImageView::New(setImage);
+  DALI_TEST_CHECK(imgActorSet);
+
+  PushButton pushButton = PushButton::New();
+  pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, TEST_IMAGE_TWO );
+
+
+  Stage::GetCurrent().Add( pushButton );
+
+  pushButton.SetButtonImage( imgActorSet );
+  application.SendNotification();
+  application.Render();
+
+  tet_infoline("Get button image before it has been able to load");
+
+  ImageView imageView = ImageView::DownCast(pushButton.GetButtonImage());
+
+  ResourceImage getImage = ResourceImage::DownCast( imageView.GetImage() );
+
+  tet_infoline("Check if url matches last assignment even if not loaded yet");
+  DALI_TEST_EQUALS( getImage.GetUrl(), setImage.GetUrl() , TEST_LOCATION );
+
+  END_TEST;
+}