From c2165f210c3b4612a90c7315b0e2a3d0aea0f266 Mon Sep 17 00:00:00 2001 From: Sam Ward Date: Thu, 13 Mar 2014 18:28:12 +0000 Subject: [PATCH] Added `wait_for_nothing_visible_to_be_animating` helper which checks for views that are animating and are also `FEX_isVisible`. This resolves the issues with the UIRefreshControl (Issue #266). --- gem/lib/frank-cucumber/frank_helper.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gem/lib/frank-cucumber/frank_helper.rb b/gem/lib/frank-cucumber/frank_helper.rb index 050f8ce2..c3a13f9f 100644 --- a/gem/lib/frank-cucumber/frank_helper.rb +++ b/gem/lib/frank-cucumber/frank_helper.rb @@ -18,6 +18,7 @@ module Frank module Cucumber # * {#wait_for_element_to_exist} # * {#wait_for_element_to_exist_and_then_touch_it} # * {#wait_for_nothing_to_be_animating} + # * {#wait_for_nothing_visible_to_be_animating} # * {#app_exec} # # == Configuring the Frank driver @@ -230,6 +231,24 @@ def wait_for_nothing_to_be_animating( timeout = false ) end end + # Waits for there to be no frank visible views which are animating + # + # @param timeout [Number] number of seconds to wait for nothing to be animating before timeout out. Defaults to {WaitHelper::TIMEOUT} + # + # Raises an exception if there were still visible views animating after {timeout} seconds. + def wait_for_nothing_visible_to_be_animating( timeout = false ) + + wait_until :timeout => timeout do + + visibleViews = frankly_map( 'view', 'FEX_isVisible' ) + animatingViews = frankly_map( 'view','isAnimating' ) + + hash = visibleViews.zip( animatingViews ) + + visibleAnimatingViews = hash.select { | visibleView, animatingView | visibleView && animatingView } + visibleAnimatingViews.empty? + end + end # Checks that the specified selector matches at least one view, and that at least one of the matched # views has an isHidden property set to false