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; }
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 ); }
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; }
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 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; }
// 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; }
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 ); }
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; }
// Negative test for Max Characters reached signal. int utcDaliTextFieldMaxCharactersReachedN(void) { ToolkitTestApplication application; tet_infoline(" utcDaliTextFieldMaxCharactersReachedN"); TextField field = TextField::New(); DALI_TEST_CHECK( field ); Stage::GetCurrent().Add( field ); const int maxNumberOfCharacters = 3; field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters ); field.SetKeyInputFocus(); gMaxCharactersCallBackCalled = false; field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback); application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); DALI_TEST_CHECK( !gMaxCharactersCallBackCalled ); END_TEST; }
int UtcDaliControlImplOnGestureMethods(void) { ToolkitTestApplication application; // Check gesture actually happens { DummyControl dummy = DummyControl::New(true); dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); // Render and notify a couple of times application.SendNotification(); application.Render(); application.SendNotification(); application.Render(); DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation()); dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) ); DALI_TEST_CHECK( dummyImpl.pinchCalled == false ); Integration::PinchGestureEvent pinch(Gesture::Started); pinch.scale = 10.0f; pinch.speed = 50.0f; pinch.centerPoint = Vector2(20.0f, 20.0f); application.ProcessEvent(pinch); DALI_TEST_CHECK( dummyImpl.pinchCalled == true ); DALI_TEST_CHECK( dummyImpl.panCalled == false ); Integration::PanGestureEvent pan(Gesture::Possible); pan.previousPosition = Vector2(10.0f, 20.0f); pan.currentPosition = Vector2(20.0f, 20.0f); pan.timeDelta = 10; pan.numberOfTouches = 1u; application.ProcessEvent(pan); pan.state = Gesture::Started; application.ProcessEvent(pan); DALI_TEST_CHECK( dummyImpl.panCalled == true ); DALI_TEST_CHECK( dummyImpl.tapCalled == false ); Integration::TapGestureEvent tap(Gesture::Possible); tap.numberOfTaps = 1u; tap.numberOfTouches = 1u; tap.point = Vector2(50.0f, 50.0f); application.ProcessEvent(tap); tap.state = Gesture::Started; application.ProcessEvent(tap); DALI_TEST_CHECK( dummyImpl.tapCalled == true ); DALI_TEST_CHECK( dummyImpl.longPressCalled == false ); Integration::LongPressGestureEvent longPress(Gesture::Possible); longPress.numberOfTouches = 1u; longPress.point = Vector2(50.0f, 50.0f); application.ProcessEvent(longPress); longPress.state = Gesture::Started; application.ProcessEvent(longPress); DALI_TEST_CHECK( dummyImpl.longPressCalled == true ); longPress.state = Gesture::Finished; application.ProcessEvent(longPress); Stage::GetCurrent().Remove(dummy); } // Ensure full code coverage { DummyControl dummy = DummyControl::New(); dummy.SetSize( Vector3(100.0f, 100.0f, 100.0f) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); // Render and notify a couple of times application.SendNotification(); application.Render(); application.SendNotification(); application.Render(); DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation()); dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) ); DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f ); Integration::PinchGestureEvent pinch(Gesture::Started); pinch.scale = 10.0f; pinch.speed = 50.0f; pinch.centerPoint = Vector2(20.0f, 20.0f); application.ProcessEvent(pinch); // Render and notify a couple of times application.SendNotification(); application.Render(); application.SendNotification(); application.Render(); DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f ); Integration::PanGestureEvent pan(Gesture::Possible); pan.previousPosition = Vector2(10.0f, 20.0f); pan.currentPosition = Vector2(20.0f, 20.0f); pan.timeDelta = 10; pan.numberOfTouches = 1u; application.ProcessEvent(pan); pan.state = Gesture::Started; application.ProcessEvent(pan); Integration::TapGestureEvent tap(Gesture::Possible); tap.numberOfTaps = 1u; tap.numberOfTouches = 1u; tap.point = Vector2(50.0f, 50.0f); application.ProcessEvent(tap); tap.state = Gesture::Started; application.ProcessEvent(tap); Integration::LongPressGestureEvent longPress(Gesture::Possible); longPress.numberOfTouches = 1u; longPress.point = Vector2(50.0f, 50.0f); application.ProcessEvent(longPress); longPress.state = Gesture::Started; application.ProcessEvent(longPress); longPress.state = Gesture::Finished; application.ProcessEvent(longPress); Stage::GetCurrent().Remove(dummy); } END_TEST; }
int utcDaliTextFieldEvent02(void) { ToolkitTestApplication application; tet_infoline(" utcDaliTextFieldEvent02"); // Checks if the right number of actors are created. TextField field = TextField::New(); field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); DALI_TEST_CHECK( field ); Stage::GetCurrent().Add( field ); field.SetSize( 300.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(); // Check there are the expected number of children ( active layer, offscreen root actor, and the offscreen image actor DALI_TEST_EQUALS( field.GetChildCount(), 3u, TEST_LOCATION ); Actor layer = field.GetChildAt( 0u ); DALI_TEST_CHECK( layer.IsLayer() ); Actor offscreenRoot = field.GetChildAt( 1u ); DALI_TEST_CHECK( offscreenRoot.IsLayer() ); DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor. Actor offscreenImage = field.GetChildAt( 2u ); ImageActor imageActor = ImageActor::DownCast( offscreenImage ); DALI_TEST_CHECK( imageActor ); // Create a tap event to touch the text field. application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); // Render and notify application.SendNotification(); application.Render(); DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor. DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor. // Now the text field has the focus, so it can handle the key events. application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); application.Render(); // Checks the cursor and the renderer have been created. DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor. DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer ImageActor cursor = ImageActor::DownCast( layer.GetChildAt( 0u ) ); DALI_TEST_CHECK( cursor ); CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) ); DALI_TEST_CHECK( camera ); Renderer renderer = offscreenRoot.GetChildAt( 1u ).GetRendererAt( 0u ); DALI_TEST_CHECK( renderer ); // Move the cursor and check the position changes. Vector3 position1 = cursor.GetCurrentPosition(); application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); application.Render(); Vector3 position2 = cursor.GetCurrentPosition(); DALI_TEST_CHECK( position2.x < position1.x ); application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); application.Render(); Vector3 position3 = cursor.GetCurrentPosition(); DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1. // Send some taps and check the cursor positions. // Try to tap at the beginning. application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) ); // Render and notify application.SendNotification(); application.Render(); // Cursor position should be the same than position1. Vector3 position4 = cursor.GetCurrentPosition(); DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2. // Tap away from the start position. application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) ); application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) ); // Render and notify application.SendNotification(); application.Render(); Vector3 position5 = cursor.GetCurrentPosition(); DALI_TEST_CHECK( position5.x > position4.x ); // Remove all the text. application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) ); field.SetProperty( TextField::Property::TEXT, "" ); // Render and notify application.SendNotification(); application.Render(); // Cursor position should be the same than position2. Vector3 position6 = cursor.GetCurrentPosition(); DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2. // Should not be a renderer. DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only. END_TEST; }
int utcDaliTextFieldEvent01(void) { ToolkitTestApplication application; tet_infoline(" utcDaliTextFieldEvent01"); // Creates a tap event. After creating a tap event the text field should // have the focus and add text with key events should be possible. TextField field = TextField::New(); DALI_TEST_CHECK( field ); Stage::GetCurrent().Add( field ); field.SetSize( 300.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(); // Add a key event but as the text field has not the focus it should do nothing. application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); application.Render(); DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION ); // Create a tap event to touch the text field. application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) ); // Render and notify application.SendNotification(); application.Render(); // Now the text field has the focus, so it can handle the key events. application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); application.Render(); DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION ); // Create a second text field and send key events to it. TextField field2 = TextField::New(); field2.SetParentOrigin( ParentOrigin::TOP_LEFT ); field2.SetAnchorPoint( AnchorPoint::TOP_LEFT ); field2.SetSize( 100.f, 100.f ); field2.SetPosition( 100.f, 100.f ); Stage::GetCurrent().Add( field2 ); // Render and notify application.SendNotification(); application.Render(); // Create a tap event on the second text field. application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) ); // Render and notify application.SendNotification(); application.Render(); // The second text field has the focus. It should handle the key events. application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) ); // Render and notify application.SendNotification(); application.Render(); // Check the text has been added to the second text field. DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION ); END_TEST; }
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 ); }
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 ); }