Skip to content

Commit

Permalink
Merge branch 'joemasilotti-navigation-titles'
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBuckley committed Jun 13, 2014
2 parents 84877fe + a946a1f commit 5fb4312
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gem/lib/frank-cucumber/core_frank_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

Then /^I should see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
quote = get_selector_quote(expected_mark)
check_element_exists( "navigationItemView marked:#{quote}#{expected_mark}#{quote}" )
quoted_text = "#{quote}#{expected_mark}#{quote}"
navigation_title_exists_with_text("#{quoted_text}").should be_true, "expected to see a navigation bar titled #{quoted_text}"
end

Then /^I wait to see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
quote = get_selector_quote(expected_mark)
wait_until( :message => "waited to see a navigation bar titled #{quote}#{expected_mark}#{quote}" ) {
element_exists( "navigationItemView marked:#{quote}#{expected_mark}#{quote}" )
}
Then /^I wait to see a navigation bar titled "([^\"]*)"$/ do |expected_title|

This comment has been minimized.

Copy link
@oradyvan

oradyvan Jul 21, 2014

quoted_text is missing here. I would add something like this:

quote = get_selector_quote(expected_title)
quoted_text = "#{quote}#{expected_title}#{quote}"
wait_until(message: "waited to see a navigation bar titled #{quoted_text}") do
navigation_title_with_text_exists(expected_title)
end
end

Then /^I wait to not see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
Expand Down
39 changes: 39 additions & 0 deletions gem/lib/frank-cucumber/frank_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ def view_with_mark_exists(expected_mark)
element_exists( "view marked:#{quote}#{expected_mark}#{quote}" )
end

# Indicate whether the title of the navigation bar matches the expected title.
# @param [String] expected_title the expected title of the navigation bar
# @return [Boolean]
def navigation_title_with_text_exists(expected_title)

This comment has been minimized.

Copy link
@oradyvan

oradyvan Jul 21, 2014

Please, add this line right here:

quote = get_selector_quote(expected_title)
quoted_text = "#{quote}#{expected_title}#{quote}"

navFrame = frankly_map('view:"UINavigationBar"', 'frame').first
navCenter = navFrame["size"]["width"] / 2.0

frame = frankly_map("view:'UINavigationBar' view:'UINavigationItemView' marked:#{quoted_text}", 'frame').first
return false unless frame && frame["origin"] && frame["size"]

left = frame["origin"]["x"]
right = frame["origin"]["x"] + frame["size"]["width"]
return false unless left && right && left < right

(left < navCenter) && (navCenter < right)
end

# Assert whether there are any views in the current view heirarchy which contain the specified accessibility label.
# @param [String] expected_mark the expected accessibility label
# @raise an rspec exception if the assertion fails
Expand All @@ -173,6 +192,26 @@ def check_view_with_mark_does_not_exist(expected_mark)
check_element_does_not_exist( "view marked:#{quote}#{expected_mark}#{quote}" )
end

# Assert the title of the navigation bar.
# @param [String] expected_title the expected title of the navigation bar
# @raise an rspec exception if the assertion fails
# @raise an rspec exception if the navigation bar and its subview `UINavigationItemView` cannot be found
# @raise an rspec exception if the `UINavigationItemView` does not cover the center x of the navigation bar
def check_navigation_title_with_text_exists(expected_title)

This comment has been minimized.

Copy link
@oradyvan

oradyvan Jul 21, 2014

Please, add this line right here:

quote = get_selector_quote(expected_title)
quoted_text = "#{quote}#{expected_title}#{quote}"

navFrame = frankly_map('view:"UINavigationBar"', 'frame').first
navCenter = navFrame["size"]["width"] / 2.0

frame = frankly_map("view:'UINavigationBar' view:'UINavigationItemView' marked:#{quoted_text}", 'frame').first
raise "Could not find navigation bar with title (#{expected_title})" unless frame && frame["origin"] && frame["size"]

left = frame["origin"]["x"]
right = frame["origin"]["x"] + frame["size"]["width"]
raise "Expected title (#{expected_title}) not in center of navigation bar" unless left && right && left < right

((left < navCenter) && (navCenter < right)).should be_true, "Could not find navigation title in center of navigation bar matching text (#{expected_title})"
end

# Waits for any of the specified selectors to match a view.
#
Expand Down

1 comment on commit 5fb4312

@oradyvan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guys, please take a look at my in-line comments for this merge. Looks like it is broken for steps that expect navigation title to exist.

Please sign in to comment.