コード例 #1
0
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 );
}
コード例 #2
0
ファイル: utc-Dali-BaseHandle.cpp プロジェクト: mettalla/dali
int UtcDaliBaseHandleConnectSignal(void)
{
  TestApplication application;
  tet_infoline("Testing Dali::BaseHandle::ConnectSignal");

  gTouchCallBackCalled = false;

  // get the root layer
  Actor actor = Actor::New();
  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
  actor.SetPosition( 240, 400 );
  actor.SetSize( 100, 100 );

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

  DALI_TEST_CHECK( gTouchCallBackCalled == false );

  // connect to its touch signal
  actor.ConnectSignal( &application, "touched", TestCallback() );

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

  // simulate a touch event
  Dali::TouchPoint point( 0, TouchPoint::Down, 240, 400  );
  Dali::Integration::TouchEvent event;
  event.AddPoint( point );
  application.ProcessEvent( event );

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

  DALI_TEST_CHECK( application.GetConnectionCount() > 0 );
  DALI_TEST_CHECK( gTouchCallBackCalled == true );

  gTouchCallBackCalled = false;
  application.DisconnectAll();

  // simulate another touch event
  application.ProcessEvent( event );

  DALI_TEST_CHECK( gTouchCallBackCalled == false );
  END_TEST;
}
コード例 #3
0
static void UtcDaliPushButtonInterruptEventWhenInsensitive()
{
    ToolkitTestApplication application;
    tet_infoline(" UtcDaliPushButtonInterruptEventWhenInsensitive");

    // * Creates an actor which contains a button.
    // * The size of the actor is bigger than the button.
    // * The button's boundary is contained in the actor's one.
    Actor actor = Actor::New();
    TETButton tetButton= Toolkit::TETButton::New();

    actor.SetName( "Actor" );
    tetButton.SetName( "TETButton" );

    actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
    actor.SetPosition( 0, 0 );
    actor.SetSize( 400, 800 );

    tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
    tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
    tetButton.SetPosition( 240, 400 );
    tetButton.SetSize( 100, 100 );

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

    // * Actor's touch event is connected to a callback function
    //   and this callback function consumes the event.
    actor.TouchedSignal().Connect( &TestCallback );

    // * Button's pressed signal is connected to a callback function
    //   which also consumes the event.
    // * Changes the sensitiveness of the button to false.
    TETButtonPressed tetButtonPressed( actor, TETButtonPressed::SENSITIVENESS );
    tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback );

    // Initializes TET state.
    gOnTouchPointInterrupted = false;
    tetButton.SetSensitive( true );

    Dali::Integration::TouchEvent event;

    // TET starts.

    // Test a down point inside the button which is also consumed by the actor, and an up point
    // consumed only by the actor.  gOnTouchPointInterrupted should be true (Button receives an
    // interrupt event.

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

    // A down event is sent inside the button's boundary.

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownInside );

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

    // An up event is sent outside the button's boundary but inside the actor's one.

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpOutside );

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

    DALI_TEST_CHECK( gOnTouchPointInterrupted );

    // Test a down point inside the button which is also consumed by the actor, and a motion point
    // consumed only by the actor.  gOnTouchPointInterrupted should be true (Button receives an
    // interrupt event.

    // Initializes TET state.
    gOnTouchPointInterrupted = false;
    actor.SetSensitive( true );
    tetButton.SetSensitive( true );

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

    // A down event is sent inside the button's boundary.

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownInside );

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

    // A motion event is sent outside the button's boundary but inside the actor's one.

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointMotionOut );

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

    DALI_TEST_CHECK( gOnTouchPointInterrupted );

    // Test a down point inside the button which is also consumed by the actor, and an up point
    // also inside the button and consumed by the actor.  gOnTouchPointInterrupted should be false.

    // Initializes TET state.
    gOnTouchPointInterrupted = false;
    actor.SetSensitive( true );
    tetButton.SetSensitive( true );

    // A down event is sent inside the button's boundary.

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownInside );

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

    actor.SetSensitive( true );
    // An up event is sent inside the button's boundary.

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpInside );

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

    DALI_TEST_CHECK( !gOnTouchPointInterrupted );
}
コード例 #4
0
static void UtcDaliPushButtonToggled()
{
    ToolkitTestApplication application;
    tet_infoline(" UtcDaliPushButtonToggled");

    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();

    // connect to its touch signal
    pushButton.ToggledSignal().Connect( &PushButtonToggled );

    Dali::Integration::TouchEvent event;

    // Test1. No toggle button.

    gPushButtonToggleState = false;
    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownInside );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpInside );
    application.ProcessEvent( event );

    DALI_TEST_CHECK( !gPushButtonToggleState );

    // Set toggle property.
    pushButton.SetToggleButton( true );

    // Test2. Touch point down and up inside the button twice.
    gPushButtonToggleState = false;
    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownInside );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpInside );
    application.ProcessEvent( event );

    DALI_TEST_CHECK( gPushButtonToggleState );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownInside );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpInside );
    application.ProcessEvent( event );

    DALI_TEST_CHECK( !gPushButtonToggleState );

    // Test3. Touch point down and up outside the button.

    gPushButtonToggleState = false;
    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownOutside );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpOutside );
    application.ProcessEvent( event );

    DALI_TEST_CHECK( !gPushButtonToggleState );

    // Test4. Touch point down inside and up outside the button.

    gPushButtonToggleState = false;
    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownInside );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointLeave );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpOutside );
    application.ProcessEvent( event );

    DALI_TEST_CHECK( !gPushButtonToggleState );

    // Test5. Touch point down outside and up inside the button.

    gPushButtonToggleState = false;
    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointDownOutside );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointEnter );
    application.ProcessEvent( event );

    event = Dali::Integration::TouchEvent();
    event.AddPoint( pointUpInside );
    application.ProcessEvent( event );

    DALI_TEST_CHECK( !gPushButtonToggleState );
}