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-ScrollView.cpp;h=1a88abb58a1878b9c309ff006aaa096eea9dd462;hp=61fba598f0adc1e32ea2a5fd10ecc678ea88f75e;hb=a8d60282f49c906206c1ffb2f2425800b914d109;hpb=d43575da616e1370372b1331f47dce36dc4ac145 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index 61fba59..1a88abb 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -44,10 +45,24 @@ static void TestCallback(BaseHandle handle) gObjectCreatedCallBackCalled = true; } +struct CallbackFunctor +{ + CallbackFunctor(bool* callbackFlag) + : mCallbackFlag( callbackFlag ) + { + } + + void operator()() + { + *mCallbackFlag = true; + } + bool* mCallbackFlag; +}; const int MILLISECONDS_PER_SECOND = 1000; const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) const int RENDER_ANIMATION_TEST_DURATION_MS = 1000; ///< 1000ms to test animation + const int RENDER_DELAY_SCROLL = 1000; ///< duration to wait for any scroll to complete. // For Clamp Signal testing... @@ -235,8 +250,8 @@ static float TestOvershootSnapDuration(ToolkitTestApplication &application, Scro int timeToReachOrigin = -1; for(int i = 0;i(ScrollView::Property::OVERSHOOT_X); - float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + float overshootXValue = DevelHandle::GetCurrentProperty( scrollView, ScrollView::Property::OVERSHOOT_X ); + float overshootYValue = DevelHandle::GetCurrentProperty( scrollView, ScrollView::Property::OVERSHOOT_Y ); if(overshootXValue == 0.0f && overshootYValue == 0.0f) { break; @@ -311,10 +326,10 @@ int UtcDaliScrollViewDestructorP(void) END_TEST; } -int UtcDaliToolkitScrollViewNewP(void) +int UtcDaliToolkitScrollViewNewP1(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliToolkitScrollViewNewP"); + tet_infoline(" UtcDaliToolkitScrollViewNewP1"); ScrollView scrollView; @@ -341,6 +356,25 @@ int UtcDaliToolkitScrollViewNewP(void) END_TEST; } +int UtcDaliToolkitScrollViewNewP2(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewNewP2 - create thru type registry"); + + ScrollView scrollView; + DALI_TEST_CHECK( !scrollView ); + + TypeRegistry typeRegistry = TypeRegistry::Get(); + TypeInfo scrollViewType = typeRegistry.GetTypeInfo("ScrollView"); + BaseHandle handle = scrollViewType.CreateInstance(); + DALI_TEST_CHECK( handle ); + + scrollView = ScrollView::DownCast(handle); + DALI_TEST_CHECK( scrollView ); + + END_TEST; +} + int UtcDaliToolkitScrollViewDownCastP(void) { ToolkitTestApplication application; @@ -394,6 +428,9 @@ int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void) scrollView.SetWrapMode(true); + Property::Value wrapMode = scrollView.GetProperty( Toolkit::ScrollView::Property::WRAP_ENABLED ); + DALI_TEST_EQUALS( wrapMode.Get(), true, TEST_LOCATION ); + const Vector2 target = Vector2(50.0f, 50.0f); const Vector2 target2 = Vector2(150.0f, 150.0f); @@ -403,7 +440,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithDirectionBiasP(void) scrollView.ScrollTo( target2, 0.25f, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); scrollView.ScrollTo( target, 0.0f ); Wait(application, RENDER_DELAY_SCROLL); @@ -472,7 +509,7 @@ int UtcDaliToolkitScrollViewScrollToPositionWithAlphaFunctionAndDirectionBiasP(v scrollView.ScrollTo( target2, 0.25f, AlphaFunction::LINEAR, Dali::Toolkit::DirectionBiasLeft, Dali::Toolkit::DirectionBiasLeft ); Wait(application, RENDER_DELAY_SCROLL); - DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), Vector2::ZERO, TEST_LOCATION ); + DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); scrollView.ScrollTo( target, 0.0f ); Wait(application, RENDER_DELAY_SCROLL); @@ -785,7 +822,7 @@ int UtcDaliToolkitScrollViewSignalsStartComplete(void) END_TEST; } -int UtcDaliToolkitScrollViewSignalsUpdate(void) +int UtcDaliToolkitScrollViewSignalsUpdate01(void) { ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate"); @@ -812,7 +849,7 @@ int UtcDaliToolkitScrollViewSignalsUpdate(void) scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate ); scrollView.ScrollCompletedSignal().Connect( &OnScrollComplete ); - ImageActor image = CreateSolidColorActor( Color::RED ); + Actor image = Actor::New(); image.SetSize(stageSize); image.SetParentOrigin(ParentOrigin::TOP_LEFT); image.SetAnchorPoint(AnchorPoint::TOP_LEFT); @@ -845,6 +882,73 @@ int UtcDaliToolkitScrollViewSignalsUpdate(void) END_TEST; } +int UtcDaliToolkitScrollViewSignalsUpdate02(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliToolkitScrollViewSignalsUpdate"); + + gOnScrollStartCalled = false; + gOnScrollUpdateCalled = false; + gOnScrollCompleteCalled = false; + + ScrollView scrollView = ScrollView::New(); + Stage::GetCurrent().Add( scrollView ); + Vector2 stageSize = Stage::GetCurrent().GetSize(); + scrollView.SetSize(stageSize); + scrollView.SetParentOrigin(ParentOrigin::TOP_LEFT); + scrollView.SetAnchorPoint(AnchorPoint::TOP_LEFT); + + // Position rulers. + RulerPtr rulerX = new DefaultRuler(); + RulerPtr rulerY = new DefaultRuler(); + rulerX->SetDomain( RulerDomain(0.0f, 1000.0f, false) ); + rulerY->SetDomain( RulerDomain(0.0f, 1000.0f, false) ); + scrollView.SetRulerX(rulerX); + scrollView.SetRulerY(rulerY); + Dali::ConnectionTracker tracker; + bool scrollStarted=false; + bool scrollUpdated=false; + bool scrollCompleted=false; + DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollStarted", CallbackFunctor(&scrollStarted) )); + DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollUpdated", CallbackFunctor(&scrollUpdated) )); + DALI_TEST_CHECK(scrollView.ConnectSignal( &tracker, "scrollCompleted", CallbackFunctor(&scrollCompleted) )); + + Actor image = Actor::New(); + image.SetSize(stageSize); + image.SetParentOrigin(ParentOrigin::TOP_LEFT); + image.SetAnchorPoint(AnchorPoint::TOP_LEFT); + scrollView.Add(image); + + Wait(application); + + // Do a pan starting from 100,100 and moving down diagonally. + Vector2 pos(100.0f, 100.0f); + SendPan(application, Gesture::Possible, pos); + SendPan(application, Gesture::Started, pos); + pos.x += 5.0f; + pos.y += 5.0f; + Wait(application, 100); + + for(int i = 0;i<20;i++) + { + SendPan(application, Gesture::Continuing, pos); + pos.x += 5.0f; + pos.y += 5.0f; + Wait(application); + } + + SendPan(application, Gesture::Finished, pos); + Wait(application, RENDER_DELAY_SCROLL); + + DALI_TEST_CHECK(scrollStarted); + DALI_TEST_CHECK(scrollUpdated); + DALI_TEST_CHECK(scrollCompleted); + + Stage::GetCurrent().Remove( scrollView ); + + END_TEST; +} + static Vector2 PerformGestureDiagonalSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, bool finish = true) { gOnScrollStartCalled = false; @@ -1095,6 +1199,11 @@ int UtcDaliToolkitScrollViewOvershoot(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); scrollView.SetOvershootEnabled(true); + + Vector2 overshootSize = Vector2(100.0f,100.0f); + scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize ); + DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get(), overshootSize, TEST_LOCATION ); + Stage::GetCurrent().Add( scrollView ); Vector2 stageSize = Stage::GetCurrent().GetSize(); scrollView.SetSize(stageSize); @@ -1118,9 +1227,9 @@ int UtcDaliToolkitScrollViewOvershoot(void) // 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch) Vector2 currentPos = Vector2(100.0f, 100.0f); currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false); - float overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); - Vector2 positionValue = scrollView.GetProperty(ScrollView::Property::SCROLL_POSITION); + float overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X ); + float overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y ); + Vector2 positionValue = DevelHandle::GetCurrentProperty< Vector2 >( scrollView, ScrollView::Property::SCROLL_POSITION ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(positionValue, Vector2::ZERO, TEST_LOCATION); @@ -1317,15 +1426,15 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void) // Scroll page in NW (-20,-20 pixels), then check that overshoot should be 0. (don't release touch) Vector2 currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 20, false); - float overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - float overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + float overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X ); + float overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 0.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 0.0f, TEST_LOCATION); // Scroll page further in NW (-105,-105 pixels), then check that overshoot should be around 0.5. (don't release touch) currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 105, false); - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X ); + overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y ); // The overshoot value is a 0.0f - 1.0f ranged value of the amount overshot related to the maximum overshoot. // EG. If we move 105, max overshoot is 50, then we overshot 50 / 105. float correctOvershootValue = 50.0f / 105.f; @@ -1334,8 +1443,8 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void) // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch) currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false); - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X ); + overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); @@ -1344,15 +1453,15 @@ int UtcDaliToolkitScrollViewSetMaxOvershootP(void) Wait(application); // Check that overshoot should be now around 0.8. - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X ); + overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_CHECK(overshootXValue > 0.79f && overshootXValue < 0.81f); DALI_TEST_CHECK(overshootYValue > 0.79f && overshootYValue < 0.81f); // Scroll page further in NW (-30,-30 pixels), then check that overshoot should be now 1.0. (don't release touch) currentPos = PerformGestureDiagonalSwipe(application, OVERSHOOT_START_SCROLL_POSITION, Vector2(1.0f, 1.0f), 30, false); - overshootXValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_X); - overshootYValue = scrollView.GetProperty(ScrollView::Property::OVERSHOOT_Y); + overshootXValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_X ); + overshootYValue = DevelHandle::GetCurrentProperty< float >( scrollView, ScrollView::Property::OVERSHOOT_Y ); DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION); DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION); @@ -2285,6 +2394,9 @@ int UtcDaliToolkitScrollViewConstraintsWrap(void) Wait(application, RENDER_DELAY_SCROLL); DALI_TEST_EQUALS( scrollView.GetCurrentScrollPosition(), target2, TEST_LOCATION ); + scrollView.Remove(a); + Wait(application); + END_TEST; }