From afc77866207a740b02ea1f3ab3341669e899a45c Mon Sep 17 00:00:00 2001 From: Pete Hodgson Date: Tue, 4 Dec 2012 17:24:32 -0800 Subject: [PATCH] Use FEX_isVisible to check that views are actually visible, not just in the hierarchy This has become more important with iOS 6, since some standard UI components (such as table view cells) are being 'removed' from the UI by setting isHidden to true, without actually removing them from the heirarchy. --- .../step_definitions/table_deletion_steps.rb | 10 +++++----- example/Controls/features/ui_table.feature | 4 ++-- gem/lib/frank-cucumber/core_frank_steps.rb | 2 +- gem/lib/frank-cucumber/frank_helper.rb | 12 ++++++++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/example/Controls/features/step_definitions/table_deletion_steps.rb b/example/Controls/features/step_definitions/table_deletion_steps.rb index 9f5b65b8..662180d0 100644 --- a/example/Controls/features/step_definitions/table_deletion_steps.rb +++ b/example/Controls/features/step_definitions/table_deletion_steps.rb @@ -10,21 +10,21 @@ end When /^I should see the confirm deletion button$/ do - check_element_exists("view:'UITableViewCellDeleteConfirmationControl'") + check_element_exists_and_is_visible("view:'UITableViewCellDeleteConfirmationControl'") end When /^I should not see the confirm deletion button$/ do - check_element_does_not_exist("view:'UITableViewCellDeleteConfirmationControl'") + check_element_does_not_exist_or_is_not_visible("view:'UITableViewCellDeleteConfirmationControl'") end Then /^I should not see an "(.*?)" button$/ do |button_mark| - check_element_does_not_exist("button marked:'#{button_mark}'") + check_element_does_not_exist_or_is_not_visible("button marked:'#{button_mark}'") end Then /^I should see an "(.*?)" button$/ do |button_mark| - check_element_exists("button marked:'#{button_mark}'") + check_element_exists_and_is_visible("button marked:'#{button_mark}'") end Then /^I should not see a "(.*?)" button$/ do |button_mark| - check_element_does_not_exist("button marked:'#{button_mark}'") + check_element_does_not_exist_or_is_not_visible("button marked:'#{button_mark}'") end diff --git a/example/Controls/features/ui_table.feature b/example/Controls/features/ui_table.feature index cdeb7792..0797c038 100644 --- a/example/Controls/features/ui_table.feature +++ b/example/Controls/features/ui_table.feature @@ -23,7 +23,7 @@ Scenario: delete with swipe And I should see "Moe" Scenario: delete with edit mode - When I touch "Edit" + When I put the table in edit mode And I touch the delete edit control for the table view cell "Moe" Then I should see the confirm deletion button @@ -44,7 +44,7 @@ Scenario: delete with swipe ends edit mode Then I should not see a "Done" button Scenario: deleting in edit mode does not end edit mode - When I touch "Edit" + When I put the table in edit mode Then I should see a "Done" button And I should not see an "Edit" button diff --git a/gem/lib/frank-cucumber/core_frank_steps.rb b/gem/lib/frank-cucumber/core_frank_steps.rb index 0d9d9b5e..0aff8ba4 100644 --- a/gem/lib/frank-cucumber/core_frank_steps.rb +++ b/gem/lib/frank-cucumber/core_frank_steps.rb @@ -48,7 +48,7 @@ Then /^I should not see "([^\"]*)"$/ do |expected_mark| quote = get_selector_quote(expected_mark) - check_element_does_not_exist("view marked:#{quote}#{expected_mark}#{quote}") + check_element_does_not_exist_or_is_not_visible("view marked:#{quote}#{expected_mark}#{quote}") end Then /I should see the following:/ do |table| diff --git a/gem/lib/frank-cucumber/frank_helper.rb b/gem/lib/frank-cucumber/frank_helper.rb index 82936f2e..63d3fdb7 100644 --- a/gem/lib/frank-cucumber/frank_helper.rb +++ b/gem/lib/frank-cucumber/frank_helper.rb @@ -103,6 +103,10 @@ def check_element_exists( selector ) element_exists( selector ).should be_true end + def check_element_exists_and_is_visible( selector ) + element_is_not_hidden( selector ).should be_true + end + # Assert whether there are no views in the current view heirarchy which match the specified selector. # @param [String] selector a view selector. # @raise an rspec exception if the assertion fails @@ -111,6 +115,10 @@ def check_element_does_not_exist( selector ) element_exists( selector ).should be_false end + def check_element_does_not_exist_or_is_not_visible( selector ) + element_is_not_hidden( selector ).should be_false + end + # Indicate whether there are any views in the current view heirarchy which contain the specified accessibility label. # @param [String] expected_mark the expected accessibility label # @return [Boolean] @@ -201,8 +209,8 @@ def wait_for_nothing_to_be_animating( timeout = false ) # # a better name for this method would be element_exists_and_is_not_hidden def element_is_not_hidden(selector) - matches = frankly_map( selector, 'isHidden' ) - matches.delete(true) + matches = frankly_map( selector, 'FEX_isVisible' ) + matches.delete(false) !matches.empty? end