lib/briar/email.rb in briar-0.1.2 vs lib/briar/email.rb in briar-0.1.3.b1
- old
+ new
@@ -7,11 +7,11 @@
return true if device.ios5?
uia_available?
end
def email_not_testable?
- not email_testable?()
+ not email_testable?
end
def warn_about_no_ios5_email_view
warn 'WARN: iOS > 5 detected - cannot test for email views on iOS simulator or devices unless we use UIAutomation'
end
@@ -78,14 +78,10 @@
def is_ios5_mail_view
query("layoutContainerView descendant view:'MFMailComposeView'").count == 1
end
- def is_ios6_mail_view
- warn 'WARN: deprecated 0.0.9'
- end
-
def should_see_mail_view (opts = {:timeout => BRIAR_WAIT_TIMEOUT,
:email_view_mark => 'compose email'})
{:timeout => BRIAR_WAIT_TIMEOUT, :email_view_mark => 'compose email'}.merge!(opts)
@@ -95,15 +91,16 @@
return
end
timeout = opts[:timeout]
msg = "waited for '#{timeout}' seconds but did not see email compose view"
+ #noinspection RubyParenthesesAfterMethodCallInspection
dev = device()
email_view_mark = opts[:email_view_mark]
wait_for(:timeout => timeout,
- :retry_frequency => BRIAR_RETRY_FREQ,
- :post_timeout => BRIAR_POST_TIMEOUT,
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
:timeout_message => msg) do
if dev.ios5?
is_ios5_mail_view
else
view_exists? email_view_mark
@@ -134,10 +131,11 @@
opts = default_opts.merge(opts)
# does a wait for iOS > 5 + uia available
should_see_mail_view opts
+ #noinspection RubyParenthesesAfterMethodCallInspection
device = device()
if device.ios5?
touch_navbar_item_and_wait_for_view 'Cancel', 'Delete Draft'
step_pause
@@ -155,28 +153,66 @@
end
timeout = BRIAR_WAIT_TIMEOUT * 2
msg = "waited for '#{timeout}' seconds but did not see cancel button"
wait_for(:timeout => timeout,
- :retry_frequency => BRIAR_RETRY_FREQ,
- :post_timeout => BRIAR_POST_TIMEOUT,
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
:timeout_message => msg) do
uia_element_exists?(:view, marked: 'Cancel')
end
uia_tap_mark('Cancel')
msg = "waited for '#{timeout}' seconds but did not see dismiss email action sheet"
wait_for(:timeout => timeout,
- :retry_frequency => BRIAR_RETRY_FREQ,
- :post_timeout => BRIAR_POST_TIMEOUT,
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
:timeout_message => msg) do
uia_element_exists?(:view, marked: 'Delete Draft')
end
uia_tap_mark('Delete Draft')
wait_for_view_to_disappear 'compose email'
end
step_pause
+ end
+
+ def uia_touch_email_to (opts={})
+ default_opts = {:await_keyboard => true}
+ opts = default_opts.merge(opts)
+
+ if uia_not_available?
+ screenshot_and_raise 'UIA needs to be available'
+ end
+
+ res = uia_query(:view, marked: 'To:').first
+ rect = res['rect']
+ point = {:x => rect['x'] + (2 * rect['width']),
+ :y => rect['y']}
+ uia_touch_with_options(point)
+ uia_await_keyboard if opts[:await_keyboard]
+ end
+
+ def uia_set_email_to(addresses, opts={})
+ default_opts = {:await_keyboard => true}
+ opts = default_opts.merge(opts)
+ uia_touch_email_to opts
+ addresses.each do |addr|
+ uia_type_string addr
+ uia_enter
+ step_pause
+ end
+ end
+
+ def uia_touch_send_email
+ uia_tap_mark('Send')
+ end
+
+ def uia_send_email_to(addresses, opts={})
+ default_opts = {:await_keyboard => true}
+ opts = default_opts.merge(opts)
+ uia_set_email_to addresses, opts
+ uia_touch_send_email
end
end
end