X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ItemView.cpp;h=8be97fe288055033134ed46b78a6858d577aeb8b;hp=b1fd832249b4c30016575d93eece2775fd3a1813;hb=0b98fd2bb35714d1b888ca2de530f8d6be8050f8;hpb=42492df08f8a079da70931292aebb56e1252641d diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index b1fd832..8be97fe 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -22,8 +22,10 @@ // Need to override adaptor classes for toolkit test harness, so include // test harness headers before dali headers. #include - #include +#include +#include + using namespace Dali; using namespace Toolkit; @@ -59,6 +61,48 @@ static void OnLayoutActivated() gOnLayoutActivatedCalled = true; } +// Generate a PanGestureEvent to send to Core +Integration::PanGestureEvent GeneratePan( + Gesture::State state, + const Vector2& previousPosition, + const Vector2& currentPosition, + unsigned long timeDelta, + unsigned int numberOfTouches = 1) +{ + Integration::PanGestureEvent pan(state); + + pan.previousPosition = previousPosition; + pan.currentPosition = currentPosition; + pan.timeDelta = timeDelta; + pan.numberOfTouches = numberOfTouches; + + return pan; +} + +/** + * Helper to generate PanGestureEvent + * + * @param[in] application Application instance + * @param[in] state The Gesture State + * @param[in] pos The current position of touch. + */ +static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos) +{ + static Vector2 last; + + if( (state == Gesture::Started) || + (state == Gesture::Possible) ) + { + last.x = pos.x; + last.y = pos.y; + } + + application.ProcessEvent(GeneratePan(state, last, pos, RENDER_FRAME_INTERVAL)); + + last.x = pos.x; + last.y = pos.y; +} + /* * Simulate time passed by. * @@ -926,3 +970,126 @@ int UtcDaliItemViewSetGetProperty(void) END_TEST; } + +int UtcDaliItemViewOvershootVertical(void) +{ + ToolkitTestApplication application; + Dali::Stage stage = Dali::Stage::GetCurrent(); + + // Create the ItemView actor + TestItemFactory factory; + ItemView view = ItemView::New(factory); + + // Create a grid layout and add it to ItemView + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::GRID ); + view.AddLayout(*gridLayout); + stage.Add(view); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(stage.GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), true, TEST_LOCATION ); + + view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) ); + + Wait(application); + + // Do a pan starting from 100,100 and moving down + Vector2 pos(100.0f, 100.0f); + SendPan(application, Gesture::Possible, pos); + SendPan(application, Gesture::Started, pos); + pos.y += 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + SendPan(application, Gesture::Continuing, pos); + pos.y += 5.0f; + Wait(application); + } + + SendPan(application, Gesture::Finished, pos); + Wait(application, 100); + + // Do a pan starting from 100,100 and moving up + pos = Vector2(100.0f, 300.0f); + SendPan(application, Gesture::Possible, pos); + SendPan(application, Gesture::Started, pos); + pos.y -= 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + SendPan(application, Gesture::Continuing, pos); + pos.y -= 5.0f; + Wait(application); + } + + SendPan(application, Gesture::Finished, pos); + Wait(application, 100); + END_TEST; +} + +int UtcDaliItemViewOvershootHorizontal(void) +{ + ToolkitTestApplication application; + Dali::Stage stage = Dali::Stage::GetCurrent(); + + // Create the ItemView actor + TestItemFactory factory; + ItemView view = ItemView::New(factory); + + // Create a grid layout and add it to ItemView + ItemLayoutPtr gridLayout = DefaultItemLayout::New( DefaultItemLayout::SPIRAL ); + view.AddLayout(*gridLayout); + stage.Add(view); + + // Activate the grid layout so that the items will be created and added to ItemView + Vector3 stageSize(stage.GetSize()); + view.ActivateLayout(0, stageSize, 0.5f); + + view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, true ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), true, TEST_LOCATION ); + + view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, Vector2(30, 30) ); + + Wait(application); + + // Do a pan starting from 100,100 and moving left + Vector2 pos(100.0f, 100.0f); + SendPan(application, Gesture::Possible, pos); + SendPan(application, Gesture::Started, pos); + pos.x -= 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + SendPan(application, Gesture::Continuing, pos); + pos.x -= 5.0f; + Wait(application); + } + + SendPan(application, Gesture::Finished, pos); + Wait(application, 100); + + // Do a pan starting from 100,100 and moving right + pos = Vector2(100.0f, 100.0f); + SendPan(application, Gesture::Possible, pos); + SendPan(application, Gesture::Started, pos); + pos.x += 5.0f; + Wait(application, 100); + + for(int i = 0;i<200;i++) + { + SendPan(application, Gesture::Continuing, pos); + pos.x += 5.0f; + Wait(application); + } + + SendPan(application, Gesture::Finished, pos); + Wait(application, 100); + + END_TEST; +}