lib/briar/bars/navbar.rb in briar-0.0.8 vs lib/briar/bars/navbar.rb in briar-0.0.9
- old
+ new
@@ -21,12 +21,17 @@
def navbar_has_back_button?
!query('navigationItemButtonView').empty?
end
def should_see_navbar_back_button
- unless navbar_has_back_button?
- screenshot_and_raise 'there is no navigation bar back button'
+ timeout = BRIAR_WAIT_TIMEOUT * 2.0
+ msg = "waited for '#{timeout}' seconds but did not see navbar back button"
+ wait_for(:timeout => timeout,
+ :retry_frequency => 0.2,
+ :post_timeout => 0.1,
+ :timeout_message => msg) do
+ navbar_has_back_button?
end
end
def should_not_see_navbar_back_button
if navbar_has_back_button?
@@ -39,21 +44,47 @@
def index_of_navbar_button (name)
titles = query('navigationButton', AL)
titles.index(name)
end
- def should_see_navbar_button (name)
- idx = index_of_navbar_button name
- if idx.nil?
- screenshot_and_raise "there should be a navbar button named '#{name}'"
+ def should_see_navbar_button (name, is_ui_button=false)
+ if is_ui_button
+ qstr = "button marked:'#{name}' parent navigationBar"
+ timeout = BRIAR_WAIT_TIMEOUT
+ msg = "waited for '#{timeout}' seconds but did not see '#{name}' in navigation bar"
+ wait_for(:timeout => timeout,
+ :retry_frequency => 0.2,
+ :post_timeout => 0.1,
+ :timeout_message => msg) do
+ element_exists qstr
+ end
+ else
+ idx = index_of_navbar_button name
+ if idx.nil?
+ # check to see if it is a ui button
+ should_see_navbar_button(name, true)
+ end
end
end
- def should_not_see_navbar_button (name)
- idx = index_of_navbar_button name
- unless idx.nil?
- screenshot_and_raise "i should not see a navbar button named #{name}"
+
+ def should_not_see_navbar_button (name, is_ui_button=false)
+ if is_ui_button
+ qstr = "button marked:'#{name}' parent navigationBar"
+ timeout = 1.0
+ msg = "waited for '#{timeout}' seconds but i still see '#{name}' in navigation bar"
+ wait_for(:timeout => timeout,
+ :retry_frequency => 0.2,
+ :post_timeout => 0.1,
+ :timeout_message => msg) do
+ element_does_not_exist qstr
+ end
+ else
+ idx = index_of_navbar_button name
+ unless idx.nil?
+ screenshot_and_raise "i should not see a navbar button named #{name}"
+ end
end
end
def date_is_in_navbar (date)
with_leading = date.strftime('%a %b %d')
@@ -80,12 +111,12 @@
not query('navigationItemButtonView first').empty?
end
touch_transition('navigationItemButtonView first',
"view marked:'#{view}'",
- {:timeout=>TOUCH_TRANSITION_TIMEOUT,
- :retry_frequency=>TOUCH_TRANSITION_RETRY_FREQ})
+ {:timeout => TOUCH_TRANSITION_TIMEOUT,
+ :retry_frequency => TOUCH_TRANSITION_RETRY_FREQ})
step_pause
end
def touch_navbar_item(item_name, wait_for_view_id=nil)
wait_for(:timeout => 1.0,
@@ -111,18 +142,23 @@
def touch_navbar_item_and_wait_for_view(item_name, view_id)
touch_navbar_item item_name, view_id
end
-
def navbar_has_title? (title)
- sleep(0.2)
- query('navigationItemView', AL).include?(title)
+ all_items = query("navigationItemView marked:'#{title}'")
+ button_items = query('navigationItemButtonView')
+ non_button_items = all_items.delete_if { |item| button_items.include?(item) }
+ !non_button_items.empty?
end
- def should_see_navbar_with_title(title)
- unless navbar_has_title? title
- screenshot_and_raise "after waiting, i did not see navbar with title #{title}"
+ def should_see_navbar_with_title(title, timeout=BRIAR_WAIT_TIMEOUT)
+ msg = "waited for '#{timeout}' seconds but i did not see #{title} in navbar"
+ wait_for(:timeout => timeout,
+ :retry_frequency => 0.2,
+ :post_timeout => 0.1,
+ :timeout_message => msg) do
+ navbar_has_title? title
end
end
def navbar_should_have_title(title)