Increased test coverage on TextLabel and TextField 31/38331/3
authorRichard Underhill <r.underhill@partner.samsung.com>
Thu, 16 Apr 2015 14:26:05 +0000 (15:26 +0100)
committerRichard Underhill <r.underhill@partner.samsung.com>
Mon, 20 Apr 2015 14:15:34 +0000 (07:15 -0700)
Change-Id: I5bddb6dcbb6c8090815b94a2151b44b5d3ebd239
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp

index 9069525..da5c595 100644 (file)
@@ -38,6 +38,7 @@ namespace
 
 const char* const PROPERTY_NAME_RENDERING_BACKEND = "rendering-backend";
 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholder-text";
+const char* const PROPERTY_NAME_TEXT = "text";
 const char* const PROPERTY_NAME_FONT_FAMILY = "font-family";
 const char* const PROPERTY_NAME_FONT_STYLE = "font-style";
 const char* const PROPERTY_NAME_POINT_SIZE = "point-size";
@@ -52,43 +53,128 @@ const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decoration-bounding-b
 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontal-alignment";
 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "vertical-alignment";
 
-static bool gObjectCreatedCallBackCalled;
+} // namespace
 
-static void TestCallback(BaseHandle handle)
+int UtcDaliToolkitTextFieldConstructorP(void)
 {
-  gObjectCreatedCallBackCalled = true;
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
+  TextField textField;
+  DALI_TEST_CHECK( !textField );
+  END_TEST;
 }
 
-} // namespace
+int UtcDaliToolkitTextFieldNewP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldNewP");
+  TextField textField = TextField::New();
+  DALI_TEST_CHECK( textField );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextFieldDownCastP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
+  TextField textField1 = TextField::New();
+  BaseHandle object( textField1 );
+
+  TextField textField2 = TextField::DownCast( object );
+  DALI_TEST_CHECK( textField2 );
+
+  TextField textField3 = DownCast< TextField >( object );
+  DALI_TEST_CHECK( textField3 );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextFieldDownCastN(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
+  BaseHandle uninitializedObject;
+  TextField textField1 = TextField::DownCast( uninitializedObject );
+  DALI_TEST_CHECK( !textField1 );
+
+  TextField textField2 = DownCast< TextField >( uninitializedObject );
+  DALI_TEST_CHECK( !textField2 );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextFieldCopyConstructorP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
+  TextField textField = TextField::New();
+  textField.SetProperty( TextField::Property::TEXT, "Test" );
+
+  TextField copy( textField );
+  DALI_TEST_CHECK( copy );
+  DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
+  TextField textField = TextField::New();
+  textField.SetProperty( TextField::Property::TEXT, "Test" );
+
+  TextField copy = textField;
+  DALI_TEST_CHECK( copy );
+  DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
+  END_TEST;
+}
+
+int UtcDaliTextFieldNewP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldNewP");
+  TextField textField = TextField::New();
+  DALI_TEST_CHECK( textField );
+  END_TEST;
+}
 
-int UtcDaliTextFieldNew(void)
+int UtcDaliTextFieldGetPropertyN(void)
 {
   ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldGetPropertyN");
   TextField field = TextField::New();
   DALI_TEST_CHECK( field );
 
-  //Additional check to ensure object is created by checking if it's registered
-  ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
-  DALI_TEST_CHECK( registry );
-
-  gObjectCreatedCallBackCalled = false;
-  registry.ObjectCreatedSignal().Connect(&TestCallback);
+  bool assert = false;
+  try
+  {
+    Property::Value value = field.GetProperty<bool>( 0 );
+  }
+  catch ( ... )
+  {
+    assert = true;
+  }
+  if ( assert )
   {
-    TextField field = TextField::New();
+    tet_result(TET_PASS);
+  }
+  else
+  {
+    tet_result(TET_FAIL);
   }
-  DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
   END_TEST;
 }
 
-int UtcDaliTextFieldGetSetProperty(void)
+// Positive test case for a method
+int UtcDaliTextFieldGetPropertyP(void)
 {
   ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
   TextField field = TextField::New();
   DALI_TEST_CHECK( field );
 
   // Check Property Indices are correct
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextField::Property::RENDERING_BACKEND );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
+  DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
@@ -102,6 +188,16 @@ int UtcDaliTextFieldGetSetProperty(void)
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
+  END_TEST;
+}
+
+// Positive test case for a method
+int UtcDaliTextFieldSetPropertyP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
+  TextField field = TextField::New();
+  DALI_TEST_CHECK( field );
 
   // Check exceed policy
   field.SetProperty( TextField::Property::EXCEED_POLICY, TextField::EXCEED_POLICY_CLIP );
@@ -128,14 +224,54 @@ int UtcDaliTextFieldGetSetProperty(void)
   // Check that the Alignment properties can be correctly set
   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN" );
   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "BEGIN", TEST_LOCATION );
-  field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "TOP" );
-  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "TOP", TEST_LOCATION );
+  field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
+  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
+
+  // Set text
+  field.SetProperty( TextField::Property::TEXT, "Setting Text" );
+
+  // Set placeholder text (currently not implemented)
+  field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Text" );
+
+  // Set Grab Handle image
+  field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "" );
+
+  END_TEST;
+}
+
+// Negative test case for a method
+int UtcDaliTextFieldSetPropertyN(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldSetPropertyN");
+  TextField field = TextField::New();
+  DALI_TEST_CHECK( field );
+
+  bool assert = false;
+  try
+  {
+    field.SetProperty( 0, true );
+  }
+  catch ( ... )
+  {
+    assert = true;
+  }
+  if ( assert )
+  {
+    tet_result(TET_PASS);
+  }
+  else
+  {
+    tet_result(TET_FAIL);
+  }
   END_TEST;
 }
 
-int utcDaliTextFieldBasicRender(void)
+// Positive Basic Text Renderer test
+int utcDaliTextFieldBasicRenderP(void)
 {
   ToolkitTestApplication application;
+  tet_infoline("UtcDaliToolkitTextFieldBasicRenderP");
   TextField field = TextField::New();
   DALI_TEST_CHECK( field );
 
@@ -155,9 +291,13 @@ int utcDaliTextFieldBasicRender(void)
   END_TEST;
 }
 
-int utcDaliTextFieldAtlasRender(void)
+// Positive Atlas Text Renderer test
+int utcDaliTextFieldAtlasRenderP(void)
 {
   ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
+  StyleManager styleManager = StyleManager::Get();
+  styleManager.RequestDefaultTheme();
   TextField field = TextField::New();
   DALI_TEST_CHECK( field );
 
index 3365605..f38404e 100644 (file)
@@ -49,38 +49,114 @@ const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadow-offset";
 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadow-color";
 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underline-enabled";
 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underline-color";
+const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underline-height";
 
-static bool gObjectCreatedCallBackCalled;
+} // namespace
 
-static void TestCallback(BaseHandle handle)
+int UtcDaliToolkitTextLabelConstructorP(void)
 {
-  gObjectCreatedCallBackCalled = true;
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
+  TextLabel textLabel;
+  DALI_TEST_CHECK( !textLabel );
+  END_TEST;
 }
 
-} // namespace
+int UtcDaliToolkitTextLabelNewP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelNewP");
+  TextLabel textLabel = TextLabel::New( "Test Text" );
+  DALI_TEST_CHECK( textLabel );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextLabelDownCastP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
+  TextLabel textLabel1 = TextLabel::New();
+  BaseHandle object( textLabel1 );
+
+  TextLabel textLabel2 = TextLabel::DownCast( object );
+  DALI_TEST_CHECK( textLabel2 );
+
+  TextLabel textLabel3 = DownCast< TextLabel >( object );
+  DALI_TEST_CHECK( textLabel3 );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextLabelDownCastN(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
+  BaseHandle uninitializedObject;
+  TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
+  DALI_TEST_CHECK( !textLabel1 );
 
-int UtcDaliTextLabelNew(void)
+  TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
+  DALI_TEST_CHECK( !textLabel2 );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextLabelCopyConstructorP(void)
 {
   ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
+  TextLabel textLabel = TextLabel::New();
+  textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
+
+  TextLabel copy( textLabel );
+  DALI_TEST_CHECK( copy );
+  DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
+  TextLabel textLabel = TextLabel::New();
+  textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
+
+  TextLabel copy = textLabel;
+  DALI_TEST_CHECK( copy );
+  DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextLabelGetPropertyN(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelGetPropertyN");
   TextLabel label = TextLabel::New("Test Text");
   DALI_TEST_CHECK( label );
 
-  //Additional check to ensure object is created by checking if it's registered
-  ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
-  DALI_TEST_CHECK( registry );
-
-  gObjectCreatedCallBackCalled = false;
-  registry.ObjectCreatedSignal().Connect(&TestCallback);
+  bool assert = false;
+  try
+  {
+    Property::Value value = label.GetProperty<bool>( 0 );
+  }
+  catch ( ... )
+  {
+    assert = true;
+  }
+  if ( assert )
   {
-    TextLabel label = TextLabel::New("Test Text");
+    tet_result(TET_PASS);
+  }
+  else
+  {
+    tet_result(TET_FAIL);
   }
-  DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
   END_TEST;
 }
 
-int UtcDaliTextLabelGetSetProperty(void)
+// Positive test case for a method
+int UtcDaliToolkitTextLabelGetPropertyP(void)
 {
   ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
   TextLabel label = TextLabel::New("Test Text");
   DALI_TEST_CHECK( label );
 
@@ -98,6 +174,7 @@ int UtcDaliTextLabelGetSetProperty(void)
   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
+  DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
 
   // Check label defaults are correct
   DALI_TEST_EQUALS( label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
@@ -105,6 +182,43 @@ int UtcDaliTextLabelGetSetProperty(void)
   DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2::ZERO, TEST_LOCATION );
   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Vector4::ZERO, TEST_LOCATION );
   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), false, TEST_LOCATION );
+  DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 0.0f, TEST_LOCATION );
+  END_TEST;
+}
+
+int UtcDaliToolkitTextLabelSetPropertyN(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelSetPropertyN");
+  TextLabel label = TextLabel::New("Test Text");
+  DALI_TEST_CHECK( label );
+
+  bool assert = false;
+  try
+  {
+    label.SetProperty( 0, true );
+  }
+  catch ( ... )
+  {
+    assert = true;
+  }
+  if ( assert )
+  {
+    tet_result(TET_PASS);
+  }
+  else
+  {
+    tet_result(TET_FAIL);
+  }
+  END_TEST;
+}
+
+int UtcDaliToolkitTextLabelSetPropertyP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
+  TextLabel label = TextLabel::New("Test Text");
+  DALI_TEST_CHECK( label );
 
   // Check that text can be correctly reset
   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
@@ -127,6 +241,12 @@ int UtcDaliTextLabelGetSetProperty(void)
   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
+  label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
+  DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, TEST_LOCATION );
+
+  // Check that text color can be properly set
+  label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
+  DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
 
   // Toggle multi-line
   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
@@ -134,9 +254,10 @@ int UtcDaliTextLabelGetSetProperty(void)
   END_TEST;
 }
 
-int utcDaliTextlabelBasicRender(void)
+int UtcDaliToolkitTextlabelBasicRenderP(void)
 {
   ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelBasicRenderP");
   TextLabel label = TextLabel::New("Test Text");
   DALI_TEST_CHECK( label );
 
@@ -157,9 +278,10 @@ int utcDaliTextlabelBasicRender(void)
   END_TEST;
 }
 
-int utcDaliTextlabelAtlasRender(void)
+int UtcDaliToolkitTextlabelAtlasRenderP(void)
 {
   ToolkitTestApplication application;
+  tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
   TextLabel label = TextLabel::New("Test Text");
   DALI_TEST_CHECK( label );