static void UtcDaliPushButtonPressed()
{
    ToolkitTestApplication application;
    tet_infoline(" UtcDaliPushButtonPressed");

    PushButton pushButton = PushButton::New();
    pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
    pushButton.SetPosition( 240, 400 );
    pushButton.SetSize( 100, 100 );

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

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

    gPushButtonPressed = false;

    // connect to its touch signal
    pushButton.PressedSignal().Connect( &PushButtonPressed );

    Dali::Integration::TouchEvent eventDown;
    eventDown.AddPoint( pointDownInside );

    // flush the queue and render once
    application.SendNotification();
    application.Render();
    application.ProcessEvent( eventDown );

    DALI_TEST_CHECK( gPushButtonPressed );
}
Exemple #2
0
int UtcDaliMagnifierSetSourceActorP(void)
{
  ToolkitTestApplication application;

  Stage stage = Stage::GetCurrent();

  Magnifier view = Magnifier::New();
  stage.Add( view );

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

  RenderTaskList renderTaskList = stage.GetRenderTaskList();
  DALI_TEST_CHECK( renderTaskList.GetTaskCount() > 1 );

  Actor actor = Actor::New();
  stage.Add( actor );
  DALI_TEST_CHECK( stage.GetRenderTaskList().GetTask( 1 ).GetSourceActor() != actor );

  view.SetSourceActor( actor );

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

  DALI_TEST_EQUALS( stage.GetRenderTaskList().GetTask( 1 ).GetSourceActor(), actor, TEST_LOCATION );

  END_TEST;
}
Exemple #3
0
int UtcDaliMagnifierFrameVisibility(void)
{
  ToolkitTestApplication application;

  Stage stage = Stage::GetCurrent();

  Magnifier view = Magnifier::New();
  stage.Add( view );

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

  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );

  view.SetProperty( Magnifier::Property::FRAME_VISIBILITY, false );
  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), false, TEST_LOCATION );

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

  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), false, TEST_LOCATION );

  view.SetProperty( Magnifier::Property::FRAME_VISIBILITY, true );
  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );

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

  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::FRAME_VISIBILITY ).Get< bool >(), true, TEST_LOCATION );

  END_TEST;
}
int UtcDaliControlImplStyleChange(void)
{
  ToolkitTestApplication application;

  DummyControl dummy = DummyControl::New( true );
  DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());

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

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

  // Add a Control and normal Actor as children
  DummyControl dummyChild = DummyControl::New();
  dummy.Add(dummyChild);

  Actor actor = Actor::New();
  dummy.Add(actor);

  DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, false, TEST_LOCATION );
  StyleChange styleChange;
  styleChange.defaultFontChange = true;
  Dali::StyleMonitor styleMonitor = application.GetAdaptor().GetToolkitStyleMonitor();
  styleMonitor.EmitStyleChangeSignal(styleChange);

  DALI_TEST_EQUALS( dummyImpl.styleChangeCalled, true, TEST_LOCATION );

  Stage::GetCurrent().Remove(dummy);
  END_TEST;
}
Exemple #5
0
int utcDaliTextFieldEvent03(void)
{
  ToolkitTestApplication application;
  tet_infoline(" utcDaliTextFieldEvent03");

  // Checks if the highlight actor is created.

  TextField field = TextField::New();
  DALI_TEST_CHECK( field );

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

  field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
  field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
  field.SetSize( 30.f, 50.f );
  field.SetParentOrigin( ParentOrigin::TOP_LEFT );
  field.SetAnchorPoint( AnchorPoint::TOP_LEFT );

  // Avoid a crash when core load gl resources.
  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );

  // Render and notify
  application.SendNotification();
  application.Render();

  // Tap first to get the focus.
  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );

  // Render and notify
  application.SendNotification();
  application.Render();

  // Double tap to select a word.
  application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
  application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );

  // Render and notify
  application.SendNotification();
  application.Render();

  // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
  Actor offscreenRoot = field.GetChildAt( 1u );
  DALI_TEST_CHECK( offscreenRoot.IsLayer() );

  CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
  DALI_TEST_CHECK( camera );

  Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u );
  DALI_TEST_CHECK( renderer );

  Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
  DALI_TEST_CHECK( highlight );

  END_TEST;
}
// Positive test case for a method
int UtcDaliDisplacementEffectTestSetProperty(void)
{
  ToolkitTestApplication application;
  tet_infoline("UtcDaliDisplacementEffectTestSetProperty");

  Toolkit::DisplacementEffect effect = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::DISPLACED);
  DALI_TEST_CHECK( effect );

  ImageActor actor = ImageActor::New( Image::New(TEST_IMAGE_FILE_NAME) );
  actor.SetSize( 100.0f, 100.0f );
  actor.SetShaderEffect( effect );
  Stage::GetCurrent().Add( actor );

  Toolkit::DisplacementEffect effect2 = Toolkit::DisplacementEffect::New(Toolkit::DisplacementEffect::FIXED);
  DALI_TEST_CHECK( effect );

  ImageActor actor2 = ImageActor::New( Image::New(TEST_IMAGE_FILE_NAME) );
  actor2.SetSize( 100.0f, 100.0f );
  actor2.SetShaderEffect( effect2 );
  Stage::GetCurrent().Add( actor2 );

  Vector3 testVector3 = Vector3(45.0f, 55.0f, 65.0f);
  float testFloat = 0.623f;
  effect.SetLightDirection(testVector3);
  effect.SetAmbientLightColorProperty(testVector3);
  effect.SetDiffuseLightColorProperty(testVector3);
  effect.SetStateProperty(testFloat);
  effect.SetLightingMultiplierProperty(testFloat);
  effect.SetHeightScaleProperty(testFloat);

  effect2.SetFixedNormalProperty(testVector3);

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

  DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetLightDirectionPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
  DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetAmbientLightColorPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
  DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetDiffuseLightColorPropertyName() ) ).Get<Vector3>(), testVector3, TEST_LOCATION );
  DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetStatePropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
  DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetLightingMultiplierPropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );
  DALI_TEST_EQUALS( effect.GetProperty( effect.GetPropertyIndex( effect.GetHeightScalePropertyName().c_str() ) ).Get<float>(), testFloat, TEST_LOCATION );

  Vector3 normalizedVector3(testVector3);
  normalizedVector3.Normalize();
  DALI_TEST_EQUALS( effect2.GetProperty( effect2.GetPropertyIndex( effect2.GetFixedNormalPropertyName() ) ).Get<Vector3>(), normalizedVector3, TEST_LOCATION );
  END_TEST;
}
int UtcDaliControlImplTouchEvent(void)
{
  ToolkitTestApplication application;

  {
    DummyControl dummy = DummyControl::New( true );
    DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());

    dummy.SetSize(100.0f, 100.0f);
    dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
    Stage::GetCurrent().Add(dummy);

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

    DALI_TEST_EQUALS( dummyImpl.touchEventCalled, false, TEST_LOCATION );
    Integration::TouchEvent touchEvent(1);
    TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
    touchEvent.AddPoint(point);
    application.ProcessEvent(touchEvent);
    DALI_TEST_EQUALS( dummyImpl.touchEventCalled, true, TEST_LOCATION );

    Stage::GetCurrent().Remove(dummy);
  }

  // Ensure full code coverage
  {
    DummyControl dummy = DummyControl::New();

    dummy.SetSize(100.0f, 100.0f);
    dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
    Stage::GetCurrent().Add(dummy);

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

    Integration::TouchEvent touchEvent(1);
    TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
    touchEvent.AddPoint(point);
    application.ProcessEvent(touchEvent);

    Stage::GetCurrent().Remove(dummy);
  }
  END_TEST;
}
Exemple #8
0
// Positive test for the text-changed signal.
int utcDaliTextFieldTextChangedP(void)
{
  ToolkitTestApplication application;
  tet_infoline(" utcDaliTextFieldTextChangedP");
  TextField field = TextField::New();
  DALI_TEST_CHECK( field );

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

  field.TextChangedSignal().Connect(&TestTextChangedCallback);

  gTextChangedCallBackCalled = false;
  field.SetProperty( TextField::Property::TEXT, "ABC" );
  DALI_TEST_CHECK( gTextChangedCallBackCalled );

  application.SendNotification();

  field.SetKeyInputFocus();

  gTextChangedCallBackCalled = false;
  application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
  DALI_TEST_CHECK( gTextChangedCallBackCalled );

  END_TEST;
}
Exemple #9
0
// 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 );

  field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );

  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );

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

  try
  {
    // Render some text with the shared atlas backend
    field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
    application.SendNotification();
    application.Render();
  }
  catch( ... )
  {
    tet_result(TET_FAIL);
  }
  END_TEST;
}
int UtcDaliConfirmationPopupTypeRegistryCreation(void)
{
  ToolkitTestApplication application;
  tet_infoline( " UtcDaliConfirmationPopupTypeRegistryCreation" );

  TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ConfirmationPopup" );
  DALI_TEST_CHECK( typeInfo )

  BaseHandle baseHandle = typeInfo.CreateInstance();
  DALI_TEST_CHECK( baseHandle )

  Toolkit::Popup popup = Toolkit::Popup::DownCast( baseHandle );
  popup.SetProperty( Popup::Property::ANIMATION_DURATION, 0.0f );

  Stage::GetCurrent().Add( popup );
  popup.SetDisplayState( Toolkit::Popup::SHOWN );

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

  // Check the popup is shown.
  DALI_TEST_EQUALS( popup.GetDisplayState(), Popup::SHOWN, TEST_LOCATION );

  END_TEST;
}
static void UtcDaliPushButtonSetLabelText()
{
    ToolkitTestApplication application;
    tet_infoline(" UtcDaliPushButtonSetLabelText");

    const std::string STR( "Hola!" );

    PushButton pushButton = PushButton::New();

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

    TextView textView;

    pushButton.SetLabelText( STR );

    textView = TextView::DownCast( pushButton.GetLabelText() );
    DALI_TEST_CHECK( STR == textView.GetText() );

    TextView text = TextView::New( STR );
    pushButton.SetLabelText( text );

    textView = TextView::DownCast( pushButton.GetLabelText() );
    DALI_TEST_CHECK( STR == textView.GetText() );
}
static void UtcDaliSwirlDefaultValuesEffect()
{
  ToolkitTestApplication application;

  Toolkit::SwirlEffect effect = Toolkit::SwirlEffect::New(true);
  DALI_TEST_CHECK( effect );

  BitmapImage image = CreateBitmapImage();

  ImageActor actor = ImageActor::New( image );
  actor.SetSize( 100.0f, 100.0f );
  actor.SetShaderEffect( effect );
  Stage::GetCurrent().Add( actor );

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

  // Gets converted to opengl viewport coordinates
  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetAnglePropertyName().c_str(),
          0.0f ) );

  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetCenterPropertyName().c_str(),
          Vector2(0.5f, 0.5f) ) );

  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetRadiusPropertyName().c_str(),
          1.0f ) );
}
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;
}
int UtcDaliTextInputSetAndGetFadeBoundary(void)
{
  tet_infoline("UtcDaliTextViewSetAndGetFadeBoundary: ");

  ToolkitTestApplication application;

  TextView::FadeBoundary fadeBoundary( PixelSize( 0 ), PixelSize( 20 ), PixelSize( 0 ), PixelSize( 10 ) );

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

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

  textInput.SetFadeBoundary( fadeBoundary );

  TextView::FadeBoundary fadeBoundary2 = textInput.GetFadeBoundary();

  DALI_TEST_EQUALS( fadeBoundary.mLeft, fadeBoundary2.mLeft, TEST_LOCATION );
  DALI_TEST_EQUALS( fadeBoundary.mRight, fadeBoundary2.mRight, TEST_LOCATION );
  DALI_TEST_EQUALS( fadeBoundary.mTop, fadeBoundary2.mTop, TEST_LOCATION );
  DALI_TEST_EQUALS( fadeBoundary.mBottom, fadeBoundary2.mBottom, TEST_LOCATION );
  END_TEST;
}
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;
}
int UtcDaliGaussianBlurViewFinishedSignalN(void)
{
  ToolkitTestApplication application;
  tet_infoline("UtcDaliGaussianBlurViewSetGetRenderTarget");

  Toolkit::GaussianBlurView view = Toolkit::GaussianBlurView::New(5, 1.5f, Pixel::RGB888, 0.5f, 0.5f, true);
  DALI_TEST_CHECK( view );

  view.SetParentOrigin(ParentOrigin::CENTER);
  view.SetSize(Stage::GetCurrent().GetSize());
  view.Add(Actor::New());
  Stage::GetCurrent().Add(view);
  view.Activate();

  TestCallback callback( view );
  DALI_TEST_CHECK( callback.mFinished == false );

  callback.Connect();

  view.Deactivate();
  application.SendNotification();

  // FinishedSignal is only for ActivateOnce()
  DALI_TEST_CHECK( callback.mFinished == false );

  END_TEST;
}
static void UtcDaliRippleCustomValuesEffect()
{
  ToolkitTestApplication application;

  Toolkit::RippleEffect effect = Toolkit::RippleEffect::New();
  DALI_TEST_CHECK( effect );

  BitmapImage image = CreateBitmapImage();

  ImageActor actor = ImageActor::New( image );
  actor.SetSize( 100.0f, 100.0f );

  effect.SetAmplitude( 0.5f );
  effect.SetCenter( Vector2( 10.0f, 10.0f ) );
  effect.SetTime( 2.0f );

  actor.SetShaderEffect( effect );
  Stage::GetCurrent().Add( actor );

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

  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetAmplitudePropertyName().c_str(),
          0.5f ) );
  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetCenterPropertyName().c_str(),
          Vector2( 10.0f, 10.0f ) ) );
  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetTimePropertyName().c_str(),
          2.0f ) );
}
static void UtcDaliShearEffectCustomValues()
{
  ToolkitTestApplication application;

  Toolkit::ShearEffect effect = Toolkit::ShearEffect::New();
  DALI_TEST_CHECK( effect );

  BitmapImage image = CreateBitmapImage();

  ImageActor actor = ImageActor::New( image );
  actor.SetSize( 100.0f, 100.0f );

  const float angleXAxis(10.0f);
  const float angleYAxis(22.5f);
  const Vector2 centerValue(50.0f, 100.0f);

  effect.SetAngleXAxis( angleXAxis );
  effect.SetAngleYAxis( angleYAxis );
  effect.SetCenter( centerValue );

  actor.SetShaderEffect(effect);
  Stage::GetCurrent().Add(actor);

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

  TestGlAbstraction& gl = application.GetGlAbstraction();
  DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleXAxisPropertyName().c_str(), angleXAxis ) );
  DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetAngleYAxisPropertyName().c_str(), angleYAxis ) );
  DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), ToScreenPosition(centerValue) ) );
}
int UtcDaliSpotCustomValuesEffect(void)
{
  ToolkitTestApplication application;

  Toolkit::SpotEffect effect = Toolkit::SpotEffect::New();
  DALI_TEST_CHECK( effect );

  BitmapImage image = CreateBitmapImage();

  ImageActor actor = ImageActor::New( image );
  actor.SetSize( 100.0f, 100.0f );

  effect.SetCenter( Vector2(480.0f, 800.0f) );
  effect.SetRadius( 5.0f );

  actor.SetShaderEffect( effect );
  Stage::GetCurrent().Add( actor );

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

  // Gets converted to opengl viewport coordinates
  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetCenterPropertyName().c_str(),
          Vector2(480.0f, 800.0f) ) );

  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetRadiusPropertyName().c_str(),
          5.0f ) );
  END_TEST;
}
static void UtcDaliIrisEffectCustomValues()
{
  ToolkitTestApplication application;

  Toolkit::IrisEffect effect = Toolkit::IrisEffect::New();
  DALI_TEST_CHECK( effect );

  BitmapImage image = CreateBitmapImage();

  ImageActor actor = ImageActor::New( image );
  actor.SetSize( 100.0f, 100.0f );

  const float radiusValue(23.0f);
  const Vector2 centerValue(0.2f, 0.7f);
  const float blendFactorValue(10.0f);

  effect.SetRadius( radiusValue );
  effect.SetCenter( centerValue );
  effect.SetBlendFactor( blendFactorValue );

  actor.SetShaderEffect(effect);
  Stage::GetCurrent().Add(actor);

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

  TestGlAbstraction& gl = application.GetGlAbstraction();
  DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetRadiusPropertyName().c_str(), radiusValue ) );
  DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetCenterPropertyName().c_str(), centerValue ) );
  DALI_TEST_CHECK( gl.CheckUniformValue( effect.GetBlendFactorPropertyName().c_str(), blendFactorValue ) );
}
int UtcDaliTextInputSetAndGetTextAlignment(void)
{
  ToolkitTestApplication application;

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

  textInput.SetTextAlignment(static_cast<Alignment::Type>( Alignment::HorizontalCenter) );
  application.SendNotification();
  application.Render();

  DALI_TEST_CHECK( static_cast<Alignment::Type>( Alignment::HorizontalCenter) & textInput.GetTextAlignment()) ;
  END_TEST;
}
int UtcDaliBubbleEmitterRestore(void)
{
  ToolkitTestApplication application;
  tet_infoline( " UtcDaliBubbleEmitterRestore " );

  Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
  BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 90, Vector2( 5.f, 10.f ));
  Actor root = emitter.GetRootActor();
  Stage::GetCurrent().Add( root );
  root.SetPosition( Vector3::ZERO );
  root.SetParentOrigin( ParentOrigin::CENTER );
  root.SetAnchorPoint( AnchorPoint::CENTER );

  Actor bubbleMesh = root.GetChildAt( 0 );
  Renderer renderer = bubbleMesh.GetRendererAt( 0 );
  DALI_TEST_CHECK( renderer );

  TestGlAbstraction& gl = application.GetGlAbstraction();

  float percentageValue;
  Vector4 startEndPosValue;

  Animation animation = Animation::New( 0.5f );
  emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) );

  Wait(application);

  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
  DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );

  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
  DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
  DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );

  animation.Play();
  Wait(application, 200);
  animation.Clear();

  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
  DALI_TEST_CHECK( percentageValue < 0.5f && percentageValue >= 0.4);

  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
  DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
  DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );

  emitter.Restore();
  application.SendNotification();
  application.Render();

  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
  DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );

  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
  DALI_TEST_EQUALS( startEndPosValue,  Vector4::ZERO, TEST_LOCATION );

  END_TEST;
}
int UtcDaliControlImplSizeAnimation(void)
{
  ToolkitTestApplication application;

  {
    DummyControl dummy = DummyControl::New( true );
    DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());

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

    DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
    Animation animation = Animation::New(1.0f);
    animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
    animation.Play();

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

    DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION );

    Stage::GetCurrent().Remove(dummy);
  }

  // Ensure full code coverage
  {
    DummyControl dummy = DummyControl::New();

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

    Animation animation = Animation::New(1.0f);
    animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
    animation.Play();

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

    Stage::GetCurrent().Remove(dummy);
  }
  END_TEST;
}
int UtcDaliControlImplKeyEvent(void)
{
  ToolkitTestApplication application;

  {
    DummyControl dummy = DummyControl::New( true );
    DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());

    Stage::GetCurrent().Add(dummy);
    dummy.SetKeyInputFocus();

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

    DALI_TEST_EQUALS( dummyImpl.keyEventCalled, false, TEST_LOCATION );
    Integration::KeyEvent keyEvent;
    application.ProcessEvent(keyEvent);
    DALI_TEST_EQUALS( dummyImpl.keyEventCalled, true, TEST_LOCATION );

    Stage::GetCurrent().Remove(dummy);
  }

  // Ensure full code coverage
  {
    DummyControl dummy = DummyControl::New();

    Stage::GetCurrent().Add(dummy);
    dummy.SetKeyInputFocus();

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

    Integration::KeyEvent keyEvent;
    application.ProcessEvent(keyEvent);

    Stage::GetCurrent().Remove(dummy);
  }
  END_TEST;
}
static void UtcDaliGridLayoutConstraintUp()
{
  ToolkitTestApplication application;

  // Create the ItemView actor
  TestItemFactory factory;
  ItemView view = ItemView::New(factory);
  Vector3 vec(480.0f, 800.0f, 0.0f);
  GridLayoutPtr gridLayout = GridLayout::New();
  gridLayout->SetNumberOfColumns(6);

  view.SetName("view actor");
  view.AddLayout(*gridLayout);
  view.SetSize(vec);

  Stage::GetCurrent().Add(view);
  gridLayout->SetOrientation(ControlOrientation::Up);
  view.ActivateLayout(0, vec, 0.0f);

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

  // render 10 frames
  for(int i = 0; i < 10; ++i)
  {
    application.Render(16); // 60hz frames
  }

  // Confirm: we have actors in the view and they are positioned some distance from the origin.
  int nonZeroCount = 0;
  int elementsFound = 0;
  for(unsigned int i = 0; i < 10; i++)
  {
    Actor testActor = view.GetItem(i);
    if (testActor)
    {
      elementsFound++;
      Vector3 pos = testActor.GetCurrentPosition();

      if (pos.LengthSquared() > 0.0f)
      {
        nonZeroCount++;
      }
    }
  }

  DALI_TEST_CHECK((elementsFound > 0) && (nonZeroCount == elementsFound));

  ItemLayoutPtr layout = gridLayout;
  layout->GetClosestOnScreenLayoutPosition(0, 0.0f, vec);
  int nextItem = layout->GetNextFocusItemID(0, 10, Dali::Toolkit::Control::Right, false);
  DALI_TEST_CHECK(nextItem == 1);

  Stage::GetCurrent().Remove(view);
}
Exemple #26
0
int UtcDaliMagnifierOnSizeSet(void)
{
  ToolkitTestApplication application;

  Magnifier view = Magnifier::New();

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

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

  Vector3 size( 200.0f, 300.0f, 0.0f );
  view.SetSize( size );

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

  DALI_TEST_EQUALS( view.GetCurrentSize(), size, TEST_LOCATION );

  END_TEST;
}
int UtcDaliControlRendererRemoveAndReset(void)
{
  ToolkitTestApplication application;
  tet_infoline( "intUtcDaliControlRendererRemoveAndReset" );

  RendererFactory factory = RendererFactory::Get();

  Actor actor = Actor::New();
  actor.SetSize(200.f, 200.f);
  Stage::GetCurrent().Add( actor );

  ControlRenderer imageRenderer;
  // test calling RemoveAndReset with an empty handle
  try
  {
    imageRenderer.RemoveAndReset( actor );
    tet_result(TET_PASS);
  }
  catch (DaliException& exception)
  {
    tet_result(TET_FAIL);
  }

  Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200));
  imageRenderer = factory.GetControlRenderer(image);
  DALI_TEST_CHECK( imageRenderer );

  imageRenderer.SetOnStage( actor );
  application.SendNotification();
  application.Render(0);
  DALI_TEST_CHECK( actor.GetRendererCount() == 1u );

  imageRenderer.RemoveAndReset( actor );
  application.SendNotification();
  application.Render(0);
  DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); // renderer is removed from actor
  DALI_TEST_CHECK( !imageRenderer ); // control renderer is reset

  END_TEST;
}
int UtcDaliTextInputSetMaxCharacterLength(void)
{
  ToolkitTestApplication application;

  tet_infoline("Testing Setting of max characters");

  const int maxChars = 4;
  const char* testChar  = "v";

  TextInput textInput = TextInput::New();  // create empty TextInput
  Stage::GetCurrent().Add(textInput);
  application.SendNotification();
  application.Render();

  textInput.SetMaxCharacterLength(maxChars);

  Integration::KeyEvent event(testChar, testChar, 0, 0, 0, Integration::KeyEvent::Down );

  std::string testString = "";

  tet_infoline("Starting editmode");
  textInput.SetEditable( true );

  tet_infoline("Sending Key Events");
  // Send max number of characters
  for (int i=0; i < maxChars; i++)
    {
      application.ProcessEvent(event);
      testString.append(testChar);
    }

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

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

  tet_infoline("Sending Key Event which exceeds max characters");

  application.ProcessEvent(event); // try to append additional character

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

  tet_infoline("Increase max characters limit");

  textInput.SetMaxCharacterLength(maxChars+1); // increment max characters by 1

  tet_infoline("Send character again which should now fit");
  application.ProcessEvent(event); // append additional character
  testString.append(testChar);

  DALI_TEST_EQUALS(testString,textInput.GetText(), TEST_LOCATION);
  END_TEST;
}
int UtcDaliControlImplChildAddAndRemove(void)
{
  ToolkitTestApplication application;

  {
    DummyControl dummy = DummyControl::New( true );
    Stage::GetCurrent().Add(dummy);
    DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());

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

    DALI_TEST_EQUALS( dummyImpl.childAddCalled, false, TEST_LOCATION );
    DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
    Actor actor = RenderableActor::New();
    dummy.Add(actor);
    DALI_TEST_EQUALS( dummyImpl.childAddCalled, true, TEST_LOCATION );
    DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );

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

    DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, false, TEST_LOCATION );
    dummy.Remove( actor );
    DALI_TEST_EQUALS( dummyImpl.childRemoveCalled, true, TEST_LOCATION );
    DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );

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

    Stage::GetCurrent().Remove(dummy);
  }

  // Ensure full code coverage
  {
    DummyControl dummy = DummyControl::New();
    Stage::GetCurrent().Add(dummy);

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

    DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );
    Actor actor = RenderableActor::New();
    dummy.Add(actor);
    DALI_TEST_EQUALS( dummy.GetChildCount(), 1u, TEST_LOCATION );

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

    dummy.Remove( actor );
    DALI_TEST_EQUALS( dummy.GetChildCount(), 0u, TEST_LOCATION );

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

    Stage::GetCurrent().Remove(dummy);
  }
  END_TEST;
}
int UtcDaliControlImplStageConnection(void)
{
  ToolkitTestApplication application;

  {
    DummyControl dummy = DummyControl::New( true );
    DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());

    DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, false, TEST_LOCATION );
    Stage::GetCurrent().Add(dummy);
    application.Render();
    application.SendNotification();
    DALI_TEST_EQUALS( dummyImpl.stageConnectionCalled, true, TEST_LOCATION );

    DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, false, TEST_LOCATION );
    Stage::GetCurrent().Remove(dummy);
    application.Render();
    application.SendNotification();
    DALI_TEST_EQUALS( dummyImpl.stageDisconnectionCalled, true, TEST_LOCATION );
  }

  // Ensure full code coverage
  {
    unsigned int stageChildren = Stage::GetCurrent().GetLayer(0).GetChildCount();
    DummyControl dummy = DummyControl::New();

    DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
    Stage::GetCurrent().Add(dummy);
    application.Render();
    application.SendNotification();
    DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren + 1, TEST_LOCATION );

    Stage::GetCurrent().Remove(dummy);
    application.Render();
    application.SendNotification();
    DALI_TEST_EQUALS( Stage::GetCurrent().GetLayer(0).GetChildCount(), stageChildren, TEST_LOCATION );
  }
  END_TEST;
}