lib/briar/email.rb in briar-0.0.7 vs lib/briar/email.rb in briar-0.0.8

- old
+ new

@@ -10,11 +10,11 @@ def email_body query("view:'MFComposeTextContentView'", :text) end def email_body_contains? (text) - if gestalt.is_ios6? + if device.ios6? warn 'WARN: iOS6 detected - cannot test for email body text https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion' else !query("view:'MFComposeTextContentView' {text LIKE '*#{text}*'}").empty? end end @@ -22,19 +22,19 @@ def email_subject query("view:'MFComposeSubjectView'", :text).first end def email_subject_is? (text) - if gestalt.is_ios6? + if device.ios6? warn 'WARN: iOS6 detected - cannot test for email subject text https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion' else email_subject.eql? text end end def email_subject_has_text_like? (text) - if gestalt.is_ios6? + if device.ios6? warn 'WARN: iOS6 detected - cannot test for email subject text https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion' else !query("view:'MFComposeSubjectView' {text LIKE '*#{text}*'}").empty? end end @@ -42,11 +42,11 @@ def email_to query("view:'_MFMailRecipientTextField'", :text).first end def email_to_field_is? (text) - if gestalt.is_ios6? + if device.ios6? warn 'WARN: iOS6 detected - cannot test for email to field https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion' else email_to.eql? text end end @@ -70,30 +70,36 @@ def is_ios5_mail_view query("layoutContainerView descendant view:'MFMailComposeView'").count == 1 end def is_ios6_mail_view - gestalt.is_ios6? + device.ios6? end - def should_see_mail_view (opts={:wait => true}) - wait = opts[:wait] - wait_for_animation if wait || wait == nil - unless is_ios5_mail_view || is_ios6_mail_view - screenshot_and_raise 'expected to see email view' + def should_see_mail_view (timeout=1.0) + if device.ios6? + screenshot_and_raise 'iOS6 detected - cannot test for email viewhttps://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion' end + + msg = "waited for '#{timeout}' seconds but did not see email compose view" + wait_for(:timeout => timeout, + :retry_frequency => 0.2, + :post_timeout => 0.1, + :timeout_message => msg ) do + is_ios5_mail_view + end end def device_can_send_email - return true if gestalt.is_simulator? + return true if device.simulator? backdoor('calabash_backdoor_configured_for_mail:', 'ignorable').eql? 'YES' end def delete_draft_and_wait_for (view_id) - if gestalt.is_ios6? + if device.ios6? warn_about_ios6_email_view else - should_see_mail_view({:wait => false}) + should_see_mail_view touch_navbar_item 'Cancel' wait_for_animation touch_transition("button marked:'Delete Draft'", "view marked:'#{view_id}'", {:timeout=>TOUCH_TRANSITION_TIMEOUT,