Skip to content
Browse files

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.
  • Loading branch information...
1 parent 917c44c commit afc77866207a740b02ea1f3ab3341669e899a45c @moredip committed Dec 4, 2012
View
10 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
View
4 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
View
2 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|
View
12 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

0 comments on commit afc7786

Please sign in to comment.
Something went wrong with that request. Please try again.