Skip to content

Commit

Permalink
Use FEX_isVisible to check that views are actually visible, not just …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
moredip committed Dec 5, 2012
1 parent 917c44c commit afc7786
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Expand Up @@ -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
4 changes: 2 additions & 2 deletions example/Controls/features/ui_table.feature
Expand Up @@ -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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion gem/lib/frank-cucumber/core_frank_steps.rb
Expand Up @@ -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|
Expand Down
12 changes: 10 additions & 2 deletions gem/lib/frank-cucumber/frank_helper.rb
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit afc7786

Please sign in to comment.