lib/calabash-cucumber/keyboard_helpers.rb in calabash-cucumber-0.9.151 vs lib/calabash-cucumber/keyboard_helpers.rb in calabash-cucumber-0.9.152
- old
+ new
@@ -12,41 +12,69 @@
:numbers_and_punctuation => "numbers-and-punctuation",
:first_alternate => "first-alternate",
:numbers_and_punctuation_alternate => "numbers-and-punctuation-alternate"
}
+
+ IOS7_SUPPORTED_CHARS = {
+ 'Dictation' => nil,
+ 'Shift' => nil,
+ 'Delete' => '\b',
+ 'International' => nil,
+ 'More' => nil,
+ 'Return' => '\n'
+ }
#Possible values
# 'Dictation'
# 'Shift'
# 'Delete'
# 'International'
# 'More'
# 'Return'
def keyboard_enter_char(chr, should_screenshot=true)
#map(nil, :keyboard, load_playback_data("touch_done"), chr)
- res = http({:method => :post, :path => 'keyboard'},
- {:key => chr, :events => load_playback_data("touch_done")})
- res = JSON.parse(res)
- if res['outcome'] != 'SUCCESS'
- msg = "Keyboard enter failed failed because: #{res['reason']}\n#{res['details']}"
- if should_screenshot
- screenshot_and_raise msg
+ if ios7?
+ if chr.length == 1
+ uia_type_string chr
else
- raise msg
+ code = IOS7_SUPPORTED_CHARS[chr]
+ if code
+ uia_type_string code
+ else
+ raise "Char #{chr} is not yet supported in iOS7"
+ end
end
+ else
+ res = http({:method => :post, :path => 'keyboard'},
+ {:key => chr, :events => load_playback_data("touch_done")})
+ res = JSON.parse(res)
+ if res['outcome'] != 'SUCCESS'
+ msg = "Keyboard enter failed failed because: #{res['reason']}\n#{res['details']}"
+ if should_screenshot
+ screenshot_and_raise msg
+ else
+ raise msg
+ end
+ end
end
+
if ENV['POST_ENTER_KEYBOARD']
w = ENV['POST_ENTER_KEYBOARD'].to_f
if w > 0
sleep(w)
end
end
res['results']
end
def done
- keyboard_enter_char "Return"
+ if ios7?
+ uia_type_string '\n'
+ else
+ keyboard_enter_char "Return"
+ end
+
end
def current_keyplane
kp_arr = _do_keyplane(
@@ -92,17 +120,22 @@
sleep(0.3)
end
def keyboard_enter_text(text)
fail("No visible keyboard") if element_does_not_exist("view:'UIKBKeyplaneView'")
-
- text.each_char do |ch|
- begin
- keyboard_enter_char(ch, false)
- rescue
- search_keyplanes_and_enter_char(ch)
+ if ios7?
+ uia_type_string(text)
+ else
+ text.each_char do |ch|
+ begin
+ keyboard_enter_char(ch, false)
+ rescue
+ search_keyplanes_and_enter_char(ch)
+ end
end
end
+
+
end
def _do_keyplane(kbtree_proc, keyplane_proc)
desc = query("view:'UIKBKeyplaneView'", "keyplane")