Esempio n. 1
0
int UtcDaliTextInputTextSelection(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing Text Selection");

  const std::string initialString = "initial text";

  TextInput textInput = TextInput::New();
  textInput.SetInitialText( initialString );

  Stage::GetCurrent().Add(textInput);
  application.SendNotification();
  application.Render();

  textInput.SetEditable( true );

  tet_infoline("Testing IsTextSelected negative");
  DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);

  textInput.SelectText(1,7);
  DALI_TEST_EQUALS( true, textInput.IsTextSelected(), TEST_LOCATION);

  textInput.DeSelectText();
  DALI_TEST_EQUALS( false, textInput.IsTextSelected(), TEST_LOCATION);
  END_TEST;
}
Esempio n. 2
0
int UtcDaliTextInputExceedMaxCharacters(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing Max characters is obeyed when inputting key events ");

  TextInput textInput = TextInput::New();  // create empty TextInput

  Stage::GetCurrent().Add(textInput);
  textInput.SetMaxCharacterLength(4);
  textInput.SetInitialText("");
  textInput.SetEditable(true);

  application.SendNotification();
  application.Render();

  Integration::KeyEvent eventA("a", "a", 0, 0, 0, Integration::KeyEvent::Down );
  Integration::KeyEvent eventB("b", "b", 0, 0, 0, Integration::KeyEvent::Down );

  application.ProcessEvent(eventA);
  application.ProcessEvent(eventB);
  application.ProcessEvent(eventA);
  application.ProcessEvent(eventB);

  application.ProcessEvent(eventA);
  application.ProcessEvent(eventB);

  tet_printf( "Get text result : %s\n", textInput.GetText().c_str());

  DALI_TEST_EQUALS("abab",textInput.GetText(), TEST_LOCATION); // Get text which should be only 4 characters
  END_TEST;
}
Esempio n. 3
0
int UtcDaliTextInputSetEditableAndIsEditable(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing SetEditable And IsEditable");

  const std::string initialString = "initial text";

  TextInput textInput = TextInput::New();  // create empty TextInput
  textInput.SetInitialText( initialString );

  Stage::GetCurrent().Add(textInput);
  application.SendNotification();
  application.Render();

  bool editableStateFalse ( false );
  bool editableStateTrue ( true );

  textInput.SetEditable ( editableStateFalse );
  application.SendNotification();
  application.Render();
  DALI_TEST_EQUALS( editableStateFalse, textInput.IsEditable() , TEST_LOCATION);

  textInput.SetEditable ( editableStateTrue );
  application.SendNotification();
  application.Render();
  DALI_TEST_EQUALS( editableStateTrue, textInput.IsEditable() , TEST_LOCATION);
  END_TEST;
}
Esempio n. 4
0
int UtcDaliTextInputSetAndGetPlaceholderText(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing Setting of PlaceholderText");

  const std::string initialString = "initial text";
  const std::string placeholderString = "placeholder";

  TextInput textInput = TextInput::New();  // create empty TextInput

  tet_infoline("Testing TextInput is empty at creation ");

  DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);

  tet_infoline("Set placeholder text");

  textInput.SetPlaceholderText( placeholderString );

  tet_infoline("Testing TextInput contains placeholder text");

  DALI_TEST_EQUALS( placeholderString , textInput.GetPlaceholderText(), TEST_LOCATION);

  tet_infoline("Set initial text which should replace placeholder text");

  textInput.SetInitialText( initialString );

  tet_infoline("Testing TextInput contains initial text when placeholder text set");

  DALI_TEST_EQUALS( initialString,textInput.GetText(), TEST_LOCATION);
  END_TEST;
}
Esempio n. 5
0
int UtcDaliTextInputGetMarkupText(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing retrieval of Markup text after style set");

  const std::string markup = "<i>Text with italic style</i>" ;
  const std::string teststring = "Text with italic style";

  TextInput textInput = TextInput::New();

  tet_infoline("Set initial text");

  textInput.SetInitialText( teststring );

  tet_infoline("Check initial text");
  DALI_TEST_EQUALS( teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be empty

  TextStyle style;
  style.SetItalics( true );

  tet_infoline("Apply style to TextInput");
  textInput.ApplyStyleToAll( style );

  tet_infoline("Retreive Markup Text");
  const std::string retreivedMarkupString = textInput.GetMarkupText();

  tet_infoline("Test Retreived text and Markup text match");
  DALI_TEST_EQUALS( retreivedMarkupString , retreivedMarkupString, TEST_LOCATION);
  END_TEST;
}
Esempio n. 6
0
int UtcDaliTextInputGetNumberOfCharacters(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing Getting number of characters");

  const std::string initialString = "initial text";
  const std::string newInitialString = "initial text new";

  TextInput textInput = TextInput::New();  // create empty TextInput

  textInput.SetInitialText( initialString );

  tet_infoline("Testing TextInput contains correct number of characters ");

  DALI_TEST_EQUALS( initialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);

  tet_infoline("Testing TextInput contains correct number of characters second phase ");

  textInput.SetInitialText( newInitialString );

  DALI_TEST_EQUALS( newInitialString.size() , textInput.GetNumberOfCharacters(), TEST_LOCATION);
  END_TEST;
}
Esempio n. 7
0
int UtcDaliTextInputSetTextSelectable(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing SetTextSelectable and IsTextSelectable");

  const std::string initialString = "initial text";

  TextInput textInput = TextInput::New();
  textInput.SetInitialText( initialString );

  tet_infoline("Testing SetTextSelectable");
  textInput.SetTextSelectable();
  DALI_TEST_EQUALS( true, textInput.IsTextSelectable() , TEST_LOCATION);
  textInput.SetTextSelectable( false );
  DALI_TEST_EQUALS( false, textInput.IsTextSelectable() , TEST_LOCATION);
  END_TEST;
}
Esempio n. 8
0
// Positive test case for a method
int UtcDaliTextInputGetText(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing GetText");

  const std::string teststring = "test";

  TextInput textInput = TextInput::New();  // create empty TextInput

  DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION); // Get text which should be empty

  textInput.SetInitialText(teststring);

  DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be test string

  END_TEST;
}
Esempio n. 9
0
int UtcDaliTextInputSetAndGetHeightExceedPolicy(void)
{
  ToolkitTestApplication application;

  tet_infoline("UtcDaliTextInputSetAndGetHeightExceedPolicy: ");

  const TextView::ExceedPolicy EXCEED_POLICIES[] = { TextView::Original, TextView::Fade, TextView::ShrinkToFit };
  const unsigned int NUM_EXCEED_POLICIES = sizeof( EXCEED_POLICIES ) / sizeof( unsigned int );

  TextInput textInput = TextInput::New();
  textInput.SetInitialText( "Hello world!" );

  for( unsigned int epIndex = 0; epIndex < NUM_EXCEED_POLICIES; ++epIndex )
  {
    textInput.SetHeightExceedPolicy( EXCEED_POLICIES[epIndex] );

    DALI_TEST_EQUALS( textInput.GetHeightExceedPolicy(), EXCEED_POLICIES[epIndex], TEST_LOCATION );
  }
  END_TEST;
}
Esempio n. 10
0
int UtcDaliTextInputScroll(void)
{
  tet_infoline("UtcDaliTextInputScroll: ");
  ToolkitTestApplication application;

  // Avoids the frame buffer texture to throw an exception.
  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );

  TextInput view = TextInput::New();
  view.SetMultilinePolicy( TextView::SplitByNewLineChar );
  view.SetWidthExceedPolicy( TextView::Original );
  view.SetHeightExceedPolicy( TextView::Original );
  view.SetTextAlignment( static_cast<Toolkit::Alignment::Type>( Toolkit::Alignment::HorizontalCenter | Toolkit::Alignment::VerticalCenter ) );
  view.SetInitialText( "Hello world! This is a scroll test." );
  view.SetSize( 100.f, 100.f );
  view.SetSnapshotModeEnabled( false );

  Stage::GetCurrent().Add( view );

  application.SendNotification();
  application.Render();

  DALI_TEST_CHECK( !view.IsScrollEnabled() ); // Scroll should be disabled by default.

  view.SetScrollEnabled( true );

  DALI_TEST_CHECK( view.IsScrollEnabled() );
  DALI_TEST_CHECK( view.IsSnapshotModeEnabled() ); // Scroll should enable snapshot mode.

  view.SetScrollPosition( Vector2( 400.f, 400.f ) );

  application.SendNotification();
  application.Render();

  const Vector2& scrollPosition = view.GetScrollPosition();
  DALI_TEST_EQUALS( scrollPosition, Vector2( 149.153656f, 0.f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
  END_TEST;
}
Esempio n. 11
0
// Positive test case for a method
int UtcDaliTextInputSetInitialText(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing Setting of Initial Text");

  const std::string teststring = "test";

  TextInput textInput = TextInput::New();  // create empty TextInput

  tet_infoline("Testing TextInput is empty at creation ");

  DALI_TEST_EQUALS("",textInput.GetText(), TEST_LOCATION);

  tet_infoline("Set text to TextInput");

  textInput.SetInitialText(teststring);

  tet_infoline("Test TextInput contains set text");

  DALI_TEST_EQUALS(teststring,textInput.GetText(), TEST_LOCATION);
  END_TEST;
}