Exemple #1
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;
}
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 ) );
}
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 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 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 UtcDaliRipple2DEffectCustomValues()
{
  ToolkitTestApplication application;

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

  BitmapImage image = CreateBitmapImage();

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

  effect.SetAmplitude( 5.0f );
  effect.SetTime( 2.0f );

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

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

  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetAmplitudePropertyName().c_str(),
          5.0f ) );
  DALI_TEST_CHECK(
      application.GetGlAbstraction().CheckUniformValue(
          effect.GetTimePropertyName().c_str(),
          2.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 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;
}
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;
}
static void UtcDaliKeyInputFocusManagerSignalUnhandledKeyEvent()
{
  ToolkitTestApplication application;

  tet_infoline("UtcDaliKeyInputFocusManagerSignalUnhandledKeyEvent");

  SignalData data;
  SignalUnhandledKeyEventCallback callback( data );

  KeyInputFocusManager manager = KeyInputFocusManager::Get();
  manager.UnhandledKeyEventSignal().Connect( &callback, &SignalUnhandledKeyEventCallback::Callback );


  Integration::KeyEvent event("a", "a", 0, 0, 0, Integration::KeyEvent::Up);
  application.ProcessEvent(event);

  DALI_TEST_CHECK(data.functorCalled);
  DALI_TEST_CHECK(event.keyName == data.receivedKeyEvent.keyPressedName );
  DALI_TEST_CHECK(event.keyCode == data.receivedKeyEvent.keyCode);
  DALI_TEST_CHECK(event.keyString == data.receivedKeyEvent.keyPressed );
  DALI_TEST_CHECK(event.state == data.receivedKeyEvent.state );

  data.Reset();

  Integration::KeyEvent event2("v", "v", 0, 0, 0, Integration::KeyEvent::Up);
  application.ProcessEvent(event2);

  DALI_TEST_CHECK(data.functorCalled);
  DALI_TEST_CHECK(event2.keyName == data.receivedKeyEvent.keyPressedName );
  DALI_TEST_CHECK(event2.keyCode == data.receivedKeyEvent.keyCode);
  DALI_TEST_CHECK(event2.keyString == data.receivedKeyEvent.keyPressed );
}
Exemple #11
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 #12
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 UtcDaliBubbleEmitterSetBubbleScale(void)
{
  ToolkitTestApplication application;
  tet_infoline( " UtcDaliBubbleEmitterSetBubbleScale " );

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

  TestGlAbstraction& gl = application.GetGlAbstraction();

  Wait(application);

  float scaleValue;
  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uDynamicScale", scaleValue ) );
  DALI_TEST_EQUALS( scaleValue, 1.f, TEST_LOCATION );

  emitter.SetBubbleScale( 2.f );
  Wait(application);
  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uDynamicScale", scaleValue ) );
  DALI_TEST_EQUALS( scaleValue, 2.f, TEST_LOCATION );

  emitter.SetBubbleScale( 0.5f );
  Wait(application);
  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uDynamicScale", scaleValue ) );
  DALI_TEST_EQUALS( scaleValue, 0.5f, TEST_LOCATION );

  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;
}
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;
}
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);
}
// 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 UtcDaliRollLayoutConstraintDown(void)
{
  ToolkitTestApplication application;

  // Create the ItemView actor
  TestItemFactory factory;
  ItemView view = ItemView::New(factory);
  Vector3 vec(480.0f, 800.0f, 0.0f);
  RollLayoutPtr rollLayout = RollLayout::New();

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

  Stage::GetCurrent().Add(view);
  rollLayout->SetOrientation(ControlOrientation::Down);
  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));
  Stage::GetCurrent().Remove(view);
  END_TEST;
}
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;
}
Exemple #20
0
int UtcDaliMagnifierNew(void)
{
  ToolkitTestApplication application;

  Magnifier magnifier;
  DALI_TEST_CHECK( !magnifier );

  magnifier = Magnifier::New();
  DALI_TEST_CHECK( magnifier );

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

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

  END_TEST;
}
Exemple #21
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 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;
}
Exemple #23
0
int UtcDaliMagnifierSourcePosition(void)
{
  ToolkitTestApplication application;

  Stage stage = Stage::GetCurrent();

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

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

  Vector3 position( 100.0f, 200.0f, 300.0f );

  DALI_TEST_CHECK( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >() != position );

  view.SetProperty( Magnifier::Property::SOURCE_POSITION, position );
  application.SendNotification();
  application.Render();
  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >(), position, TEST_LOCATION );

  view.SetProperty( Magnifier::Property::SOURCE_POSITION, Vector3::ONE );
  application.SendNotification();
  application.Render();
  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::SOURCE_POSITION ).Get< Vector3 >(), Vector3::ONE, TEST_LOCATION );

  END_TEST;
}
Exemple #24
0
int UtcDaliMagnifierMagnificationFactor(void)
{
  ToolkitTestApplication application;

  Stage stage = Stage::GetCurrent();

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

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

  float magnificationFactor( 200.0f );

  DALI_TEST_CHECK( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >() != magnificationFactor );

  view.SetProperty( Magnifier::Property::MAGNIFICATION_FACTOR, magnificationFactor );
  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );

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

  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), magnificationFactor, TEST_LOCATION );

  view.SetProperty( Magnifier::Property::MAGNIFICATION_FACTOR, 1.0f );
  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), 1.0f, TEST_LOCATION );

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

  DALI_TEST_EQUALS( view.GetProperty( Magnifier::Property::MAGNIFICATION_FACTOR ).Get< float >(), 1.0f, TEST_LOCATION );

  END_TEST;
}
int UtcDaliControlRendererSetOnOffStage(void)
{
  ToolkitTestApplication application;
  tet_infoline( "UtcDaliControlRendererSetDepthIndex" );

  RendererFactory factory = RendererFactory::Get();
  Property::Map propertyMap;
  propertyMap.Insert("renderer-type", "color-renderer");
  propertyMap.Insert("blend-color", Color::BLUE);
  ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );

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

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

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

  controlRenderer.SetOffStage( actor );
  application.SendNotification();
  application.Render(0);
  DALI_TEST_CHECK( actor.GetRendererCount() == 0u );

  END_TEST;
}
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 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 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;
}
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;
}
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 );
}