Adding tests for checkbox
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-CheckBoxButton.cpp
index f5a2a7c..07b810f 100644 (file)
@@ -33,27 +33,6 @@ bool CheckBoxButtonClicked( Button button )
   return true;
 }
 
-Image CreateSolidColorImage( const Vector4& color, unsigned int width, unsigned int height )
-{
-  BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 );
-
-  // Create the image
-  PixelBuffer* pixbuf = imageData.GetBuffer();
-  unsigned int size = width * height;
-
-  for( size_t i = 0; i < size; i++ )
-    {
-      pixbuf[i*4+0] = 0xFF * color.r;
-      pixbuf[i*4+1] = 0xFF * color.g;
-      pixbuf[i*4+2] = 0xFF * color.b;
-      pixbuf[i*4+3] = 0xFF * color.a;
-    }
-
-  imageData.Update();
-
-  return imageData;
-}
-
 } // namespace
 
 void checkbox_button_startup(void)
@@ -141,94 +120,6 @@ int UtcDaliCheckBoxButtonDownCastN(void)
   END_TEST;
 }
 
-int UtcDaliCheckBoxButtonSetBackgroundImageP(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliCheckBoxButtonSetBackgroundImageP");
-
-  Image image = CreateSolidColorImage( Color::RED, 10, 10 );
-  ImageActor imageActor = CreateSolidColorActor( Color::RED );
-  imageActor.SetSize( 20, 20 );
-
-  CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
-  checkBoxButton.SetBackgroundImage( image );
-
-  DALI_TEST_CHECK( checkBoxButton.GetBackgroundImage() );
-
-  checkBoxButton.SetBackgroundImage( imageActor );
-
-  DALI_TEST_CHECK( checkBoxButton.GetBackgroundImage() );
-
-  END_TEST;
-}
-
-int UtcDaliCheckBoxButtonSetSelectedImageP(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliCheckBoxButtonSetSelectedImageP");
-
-  Image image = CreateSolidColorImage( Color::RED, 10, 10 );
-  ImageActor imageActor = CreateSolidColorActor( Color::RED );
-  imageActor.SetSize( 20, 20 );
-
-  CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
-  checkBoxButton.SetSelectedImage( image );
-
-  DALI_TEST_CHECK( checkBoxButton.GetSelectedImage() );
-
-  checkBoxButton.SetSelectedImage( imageActor );
-
-  DALI_TEST_CHECK( checkBoxButton.GetSelectedImage() );
-
-  END_TEST;
-}
-
-int UtcDaliCheckBoxButtonSetDisabledBackgroundImageP(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliCheckBoxButtonSetDisabledBackgroundImageP");
-
-  Image image = CreateSolidColorImage( Color::RED, 10, 10 );
-  ImageActor imageActor = CreateSolidColorActor( Color::RED );
-  imageActor.SetSize( 20, 20 );
-
-  CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
-  checkBoxButton.SetDisabledBackgroundImage( image );
-
-  DALI_TEST_CHECK( checkBoxButton.GetDisabledBackgroundImage() );
-
-  checkBoxButton.SetDisabledBackgroundImage( imageActor );
-
-  DALI_TEST_CHECK( checkBoxButton.GetDisabledBackgroundImage() );
-
-  END_TEST;
-}
-
-int UtcDaliCheckBoxButtonSetDisabledSelectedImageP(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliCheckBoxButtonSetDisabledSelectedImageP");
-
-  Image image = CreateSolidColorImage( Color::RED, 10, 10 );
-  ImageActor imageActor = CreateSolidColorActor( Color::RED );
-  imageActor.SetSize( 20, 20 );
-
-  CheckBoxButton checkBoxButton = CheckBoxButton::New();
-
-  checkBoxButton.SetDisabledSelectedImage( image );
-
-  DALI_TEST_CHECK( checkBoxButton.GetDisabledSelectedImage() );
-
-  checkBoxButton.SetDisabledSelectedImage( imageActor );
-
-  DALI_TEST_CHECK( checkBoxButton.GetDisabledSelectedImage() );
-
-  END_TEST;
-}
-
 int UtcDaliCheckBoxButtonSetGetSelected(void)
 {
   ToolkitTestApplication application;
@@ -257,51 +148,58 @@ int UtcDaliCheckBoxButtonSetGetSelected(void)
   END_TEST;
 }
 
-int UtcDaliCheckBoxButtonSetImages(void)
+int UtcDaliCheckBoxSetLabelP(void)
 {
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliCheckBoxButtonSetImages");
+  TestApplication application;
+
+  CheckBoxButton checkBox = CheckBoxButton::New();
 
-  Actor imageActor;
+  Property::Map propertyMap;
+  propertyMap.Insert("text",  "activate");
+  checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
 
-  Image image01 = CreateSolidColorImage( Color::RED, 10, 10 );
-  ImageActor imageActor01 = CreateSolidColorActor( Color::RED );
-  imageActor01.SetSize( 20, 20 );
+  DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
 
-  Image image02 = CreateSolidColorImage( Color::RED, 30, 30 );
-  ImageActor imageActor02 = CreateSolidColorActor( Color::RED );
-  imageActor02.SetSize( 40, 40 );
-  imageActor02.SetName( "imageActor02" );
+  END_TEST;
+}
 
-  Image image03 = CreateSolidColorImage( Color::RED, 50, 50 );
-  ImageActor imageActor03 = CreateSolidColorActor( Color::RED );
-  imageActor03.SetSize( 60, 60 );
+int UtcDaliCheckBoxSetLabelDisabledP(void)
+{
+  TestApplication application;
 
-  Image image04 = CreateSolidColorImage( Color::RED, 70, 70 );
-  ImageActor imageActor04 = CreateSolidColorActor( Color::RED );
-  imageActor04.SetSize( 80, 80 );
+  CheckBoxButton checkBox = CheckBoxButton::New();
+  Stage::GetCurrent().Add( checkBox );
 
-  Vector3 size;
-  CheckBoxButton checkBoxButton = CheckBoxButton::New();
-  checkBoxButton.SetName( "UtcDaliCheckBoxButtonSetImages" );
-  Stage::GetCurrent().Add( checkBoxButton );
+  checkBox.SetSize( Vector2( 20.0f, 20.0f ) );
+  checkBox.SetDisabledBackgroundImage( "Image.jpg" );
 
   application.SendNotification();
   application.Render();
 
-  // Just check if check box button size changes when a bigger image is set.
+  Property::Map propertyMap;
+  propertyMap.Insert("text",  "activate");
+  checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
 
-  checkBoxButton.SetBackgroundImage( image01 );
+  checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
 
-  application.SendNotification();
-  application.Render();
+  DALI_TEST_CHECK(  checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
+  DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
+
+  END_TEST;
+}
+
+int UtcDaliCheckBoxSettingDisabled(void)
+{
+  ToolkitTestApplication application;
+
+  CheckBoxButton checkBox = CheckBoxButton::New();
 
-  size = checkBoxButton.GetCurrentSize();
+  checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
+  DALI_TEST_CHECK(  checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
 
-  DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
-  DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
+  checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), false);
 
-  checkBoxButton.SetBackgroundImage( imageActor01 );
+  DALI_TEST_CHECK(  !checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
 
   END_TEST;
 }