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-ScrollBar.cpp;h=ff46053b0bb902029a3f177d689aa88cb6a26bc4;hp=ea50a3035c772a223b50da1823998a3a2f3456d0;hb=b514a4671789bee2f03b0177393b9a21f62ac2c3;hpb=7011817795c4ae23533c8e920929c02718d04d79 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp index ea50a30..ff46053 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollBar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -20,7 +20,6 @@ #include #include #include -#include using namespace Dali; using namespace Toolkit; @@ -40,48 +39,6 @@ namespace const int RENDER_FRAME_INTERVAL = 16; ///< Duration of each frame in ms. (at approx 60FPS) -// 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. * @@ -143,25 +100,29 @@ static void OnScrollPositionIntervalReached( float position ) gOnScrollPositionIntervalReachedSignalCalled = true; } -static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames) +static Vector2 PerformGestureSwipe(ToolkitTestApplication& application, Vector2 start, Vector2 direction, int frames, uint32_t start_time) { gOnPanFinishedCalled = false; // Now do a pan starting from (start) and heading (direction) - Vector2 pos(start); - SendPan(application, Gesture::Possible, pos); - SendPan(application, Gesture::Started, pos); + Vector2 pos( start + ( direction * 15 ) ); + uint32_t time = start_time; + + TestStartPan( application, start, pos, time ); + Wait(application); for(int i = 0; i < frames; i++) { pos += direction; // Move in this direction - SendPan(application, Gesture::Continuing, pos); + time += RENDER_FRAME_INTERVAL; + TestMovePan( application, pos, time); Wait(application); } pos += direction; // Move in this direction. - SendPan(application, Gesture::Finished, pos); + time += RENDER_FRAME_INTERVAL; + TestEndPan(application, pos, time ); Wait(application); return pos; @@ -470,6 +431,11 @@ int UtcDaliToolkitScrollBarSetScrollIndicatorP(void) DALI_TEST_CHECK( indicator != scrollBar.GetScrollIndicator() ); DALI_TEST_CHECK( newIndicator == scrollBar.GetScrollIndicator() ); + // Check that the new control indicator is successfully set + Control controlIndicator = Control::New(); + scrollBar.SetScrollIndicator(controlIndicator); + + DALI_TEST_CHECK( controlIndicator == Control::DownCast( scrollBar.GetScrollIndicator() ) ); END_TEST; } @@ -692,6 +658,20 @@ int UtcDaliToolkitScrollBarGetScrollPositionIntervalsP(void) DALI_TEST_EQUALS( positionIntervals[8], results[8], TEST_LOCATION ); DALI_TEST_EQUALS( positionIntervals[9], results[9], TEST_LOCATION ); + Property::Array resultArray = scrollBar.GetProperty(Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS); + + DALI_TEST_EQUALS( positionIntervals.Count(), resultArray.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[0], resultArray[0].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[1], resultArray[1].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[2], resultArray[2].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[3], resultArray[3].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[4], resultArray[4].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[5], resultArray[5].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[6], resultArray[6].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[7], resultArray[7].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[8], resultArray[8].Get(), TEST_LOCATION ); + DALI_TEST_EQUALS( positionIntervals[9], resultArray[9].Get(), TEST_LOCATION ); + END_TEST; } @@ -1383,6 +1363,307 @@ int UtcDaliToolkitScrollBarHideIndicatorN(void) END_TEST; } +int UtcDaliToolkitScrollBarActionShowIndicator(void) +{ + ToolkitTestApplication application; + + // Create a scroll bar + ScrollBar scrollBar = ScrollBar::New(); + DALI_TEST_CHECK( scrollBar ); + + Stage::GetCurrent().Add( scrollBar ); + + Actor indicator = scrollBar.GetScrollIndicator(); + DALI_TEST_CHECK( indicator ); + + // Get the default duration to hide the indicator + float duration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION ); + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( duration > 0.0f ); + + // Make the indicator invisible + indicator.SetOpacity(0.0f); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is invisible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION ); + + // Do the "ShowIndicator" action + Property::Map emptyMap; + scrollBar.DoAction( "ShowIndicator", emptyMap ); + + // Wait for the specified duration + Wait(application, duration * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now visible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollBarActionHideIndicator(void) +{ + ToolkitTestApplication application; + + // Create a scroll bar + ScrollBar scrollBar = ScrollBar::New(); + DALI_TEST_CHECK( scrollBar ); + + Stage::GetCurrent().Add( scrollBar ); + + Actor indicator = scrollBar.GetScrollIndicator(); + DALI_TEST_CHECK( indicator ); + + // Get the default duration to hide the indicator + float duration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_HIDE_DURATION ); + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( duration > 0.0f ); + + // Make the indicator visible + indicator.SetOpacity(1.0f); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is visible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Do the "HideIndicator" action + Property::Map emptyMap; + scrollBar.DoAction( "HideIndicator", emptyMap ); + + // Wait for the specified duration + Wait(application, duration * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now invisible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollBarActionShowTransientIndicator(void) +{ + ToolkitTestApplication application; + + // Create a scroll bar + ScrollBar scrollBar = ScrollBar::New(); + DALI_TEST_CHECK( scrollBar ); + + Stage::GetCurrent().Add( scrollBar ); + + Actor indicator = scrollBar.GetScrollIndicator(); + DALI_TEST_CHECK( indicator ); + + // Get the default duration to hide the indicator + float duration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION ); + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( duration > 0.0f ); + + // Make the indicator invisible + indicator.SetOpacity(0.0f); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is invisible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION ); + + // Do the "ShowIndicator" action + Property::Map emptyMap; + scrollBar.DoAction( "ShowTransientIndicator", emptyMap ); + + // Wait for the specified duration + Wait(application, duration * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now visible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Get the default duration to hide the indicator + float hideDuration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_HIDE_DURATION ); + float transientDuration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION ); + float totalVisibleDuration = hideDuration + transientDuration; + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( totalVisibleDuration > 0.0f ); + + // Wait for the specified duration + Wait(application, totalVisibleDuration * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now invisible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollBarActionShowTransientIndicatorImmediate(void) +{ + ToolkitTestApplication application; + + // Create a scroll bar + ScrollBar scrollBar = ScrollBar::New(); + DALI_TEST_CHECK( scrollBar ); + + Stage::GetCurrent().Add( scrollBar ); + + Actor indicator = scrollBar.GetScrollIndicator(); + DALI_TEST_CHECK( indicator ); + + // Make the indicator invisible + indicator.SetOpacity(0.0f); + + // Don't use a show animation; the indicator should appear immediately + scrollBar.SetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION, 0.0f ); + float duration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION ); + DALI_TEST_EQUALS( duration, 0.0f, TEST_LOCATION ); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Do the "ShowIndicator" action + Property::Map emptyMap; + scrollBar.DoAction( "ShowTransientIndicator", emptyMap ); + + // Wait for the specified duration + Wait(application); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now visible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Get the default duration to hide the indicator + float hideDuration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_HIDE_DURATION ); + float transientDuration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION ); + float totalVisibleDuration = hideDuration + transientDuration; + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( totalVisibleDuration > 0.0f ); + + // Wait for the specified duration + Wait(application, totalVisibleDuration * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now invisible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliToolkitScrollBarActionShowTransientIndicatorDuringHide(void) +{ + ToolkitTestApplication application; + + // Create a scroll bar + ScrollBar scrollBar = ScrollBar::New(); + DALI_TEST_CHECK( scrollBar ); + + Stage::GetCurrent().Add( scrollBar ); + + Actor indicator = scrollBar.GetScrollIndicator(); + DALI_TEST_CHECK( indicator ); + + // Get the default duration to hide the indicator + float duration = scrollBar.GetIndicatorHideDuration(); + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( duration > 0.0f ); + + // Make the indicator visible + indicator.SetOpacity(1.0f); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is visible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Hide the indicator + scrollBar.HideIndicator(); + + // Wait for half the specified duration + Wait(application, duration * 0.5f * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now partially hidden + DALI_TEST_CHECK( indicator.GetCurrentOpacity() < 1.0f ); + + // Now interrupt the Hide with a DoAction( "ShowTransientIndicator" ) + + // Get the default duration to hide the indicator + duration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_SHOW_DURATION ); + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( duration > 0.0f ); + + // Do the "ShowIndicator" action + Property::Map emptyMap; + scrollBar.DoAction( "ShowTransientIndicator", emptyMap ); + + // Wait for the specified duration + Wait(application, duration * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now visible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 1.0f, TEST_LOCATION ); + + // Get the default duration to hide the indicator + float hideDuration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_HIDE_DURATION ); + float transientDuration = scrollBar.GetProperty( ScrollBar::Property::INDICATOR_TRANSIENT_DURATION ); + float totalVisibleDuration = hideDuration + transientDuration; + + // Check that the default duration is greater than 0 + DALI_TEST_CHECK( totalVisibleDuration > 0.0f ); + + // Wait for the specified duration + Wait(application, totalVisibleDuration * 1000); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Check that the indicator is now invisible + DALI_TEST_EQUALS( indicator.GetCurrentOpacity(), 0.0f, TEST_LOCATION ); + + END_TEST; +} + int UtcDaliToolkitScrollBarPanFinishedSignalP(void) { ToolkitTestApplication application; @@ -1434,7 +1715,7 @@ int UtcDaliToolkitScrollBarPanFinishedSignalP(void) application.Render(); // Perform a swipe gesture on the indicator - PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 1, 500); DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION ); DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION ); @@ -1470,7 +1751,7 @@ int UtcDaliToolkitScrollBarPanFinishedSignalN(void) application.Render(); // Perform a vertical swipe gesture on the indicator when there is no source object set on the scroll bar - PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 500); DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION ); // Create a source actor that owns the scroll properties required by the scroll bar @@ -1496,12 +1777,12 @@ int UtcDaliToolkitScrollBarPanFinishedSignalN(void) application.Render(); // Perform a swipe gesture on the scroll bar but not on the indicator - PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 780.0f), Vector2(Vector2::YAXIS * -1.0f), 20, 2000); DALI_TEST_EQUALS( gOnPanFinishedCalled, false, TEST_LOCATION ); DALI_TEST_EQUALS( panFinished, false, TEST_LOCATION ); // Perform a swipe gesture on the indicator - PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20); + PerformGestureSwipe(application, Vector2(1.0f, 1.0f), Vector2(Vector2::YAXIS * 1.0f), 20, 4000); DALI_TEST_EQUALS( gOnPanFinishedCalled, true, TEST_LOCATION ); DALI_TEST_EQUALS( panFinished, true, TEST_LOCATION );