calabash-cucumber 0.10.0.pre1 → 0.10.0.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/features/step_definitions/calabash_steps.rb +1 -1
- data/lib/calabash-cucumber/actions/instruments_actions.rb +15 -4
- data/lib/calabash-cucumber/actions/playback_actions.rb +12 -3
- data/lib/calabash-cucumber/connection.rb +3 -0
- data/lib/calabash-cucumber/connection_helpers.rb +4 -0
- data/lib/calabash-cucumber/core.rb +637 -83
- data/lib/calabash-cucumber/date_picker.rb +148 -29
- data/lib/calabash-cucumber/device.rb +160 -3
- data/lib/calabash-cucumber/environment_helpers.rb +91 -46
- data/lib/calabash-cucumber/failure_helpers.rb +40 -0
- data/lib/calabash-cucumber/http_helpers.rb +9 -2
- data/lib/calabash-cucumber/ibase.rb +136 -17
- data/lib/calabash-cucumber/ios7_operations.rb +13 -9
- data/lib/calabash-cucumber/ipad_1x_2x.rb +103 -48
- data/lib/calabash-cucumber/keyboard_helpers.rb +253 -144
- data/lib/calabash-cucumber/keychain_helpers.rb +46 -32
- data/lib/calabash-cucumber/launch/simulator_helper.rb +13 -12
- data/lib/calabash-cucumber/launch/simulator_launcher.rb +111 -78
- data/lib/calabash-cucumber/launcher.rb +265 -25
- data/lib/calabash-cucumber/map.rb +24 -22
- data/lib/calabash-cucumber/operations.rb +4 -160
- data/lib/calabash-cucumber/playback_helpers.rb +26 -0
- data/lib/calabash-cucumber/query_helpers.rb +12 -0
- data/lib/calabash-cucumber/rotation_helpers.rb +64 -8
- data/lib/calabash-cucumber/status_bar_helpers.rb +40 -3
- data/lib/calabash-cucumber/tests_helpers.rb +43 -14
- data/lib/calabash-cucumber/uia.rb +93 -9
- data/lib/calabash-cucumber/utils/logging.rb +30 -16
- data/lib/calabash-cucumber/utils/plist_buddy.rb +18 -19
- data/lib/calabash-cucumber/utils/simulator_accessibility.rb +41 -30
- data/lib/calabash-cucumber/utils/xctools.rb +31 -21
- data/lib/calabash-cucumber/version.rb +98 -2
- data/lib/calabash-cucumber/wait_helpers.rb +257 -77
- data/staticlib/calabash.framework.zip +0 -0
- metadata +64 -231
- data/.gitignore +0 -17
- data/CHANGES.txt +0 -1
- data/Gemfile +0 -4
- data/Rakefile +0 -72
- data/calabash-cucumber.gemspec +0 -36
- data/epl-v10.html +0 -261
- data/lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64 +0 -51
- data/lib/calabash-cucumber/resources/cell_swipe_ios4_iphone.base64 +0 -51
- data/lib/calabash-cucumber/resources/cell_swipe_ios5_ipad.base64 +0 -74
- data/lib/calabash-cucumber/resources/cell_swipe_ios5_iphone.base64 +0 -74
- data/lib/calabash-cucumber/resources/double_tap_ios5_ipad.base64 +0 -15
- data/lib/calabash-cucumber/resources/double_tap_ios5_iphone.base64 +0 -15
- data/lib/calabash-cucumber/resources/double_tap_ios6_ipad.base64 +0 -22
- data/lib/calabash-cucumber/resources/double_tap_ios6_iphone.base64 +0 -22
- data/lib/calabash-cucumber/resources/pan_ios5_ipad.base64 +0 -199
- data/lib/calabash-cucumber/resources/pan_ios5_iphone.base64 +0 -199
- data/lib/calabash-cucumber/resources/pan_ios6_ipad.base64 +0 -206
- data/lib/calabash-cucumber/resources/pan_ios6_iphone.base64 +0 -206
- data/lib/calabash-cucumber/resources/pinch_in_ios4_ipad.base64 +0 -104
- data/lib/calabash-cucumber/resources/pinch_in_ios4_iphone.base64 +0 -104
- data/lib/calabash-cucumber/resources/pinch_in_ios5_ipad.base64 +0 -144
- data/lib/calabash-cucumber/resources/pinch_in_ios5_iphone.base64 +0 -144
- data/lib/calabash-cucumber/resources/pinch_in_ios6_ipad.base64 +0 -70
- data/lib/calabash-cucumber/resources/pinch_in_ios6_iphone.base64 +0 -70
- data/lib/calabash-cucumber/resources/pinch_out_ios5_ipad.base64 +0 -207
- data/lib/calabash-cucumber/resources/pinch_out_ios5_iphone.base64 +0 -207
- data/lib/calabash-cucumber/resources/pinch_out_ios6_ipad.base64 +0 -96
- data/lib/calabash-cucumber/resources/pinch_out_ios6_iphone.base64 +0 -96
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_ipad.base64 +0 -2
- data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_iphone.base64 +0 -2
- data/lib/calabash-cucumber/resources/swipe_down_ios5_ipad.base64 +0 -18
- data/lib/calabash-cucumber/resources/swipe_down_ios5_iphone.base64 +0 -31
- data/lib/calabash-cucumber/resources/swipe_down_ios6_ipad.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_down_ios6_iphone.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_ipad.base64 +0 -15
- data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_iphone.base64 +0 -15
- data/lib/calabash-cucumber/resources/swipe_left_ios4_ipad.base64 +0 -18
- data/lib/calabash-cucumber/resources/swipe_left_ios4_iphone.base64 +0 -18
- data/lib/calabash-cucumber/resources/swipe_left_ios5_ipad.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_left_ios5_iphone.base64 +0 -34
- data/lib/calabash-cucumber/resources/swipe_left_ios6_ipad.base64 +0 -28
- data/lib/calabash-cucumber/resources/swipe_left_ios6_iphone.base64 +0 -28
- data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_ipad.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_iphone.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_ios4_ipad.base64 +0 -13
- data/lib/calabash-cucumber/resources/swipe_right_ios4_iphone.base64 +0 -13
- data/lib/calabash-cucumber/resources/swipe_right_ios5_ipad.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_ios5_iphone.base64 +0 -17
- data/lib/calabash-cucumber/resources/swipe_right_ios6_ipad.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_right_ios6_iphone.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_up_ios5_ipad.base64 +0 -34
- data/lib/calabash-cucumber/resources/swipe_up_ios5_iphone.base64 +0 -28
- data/lib/calabash-cucumber/resources/swipe_up_ios6_ipad.base64 +0 -25
- data/lib/calabash-cucumber/resources/swipe_up_ios6_iphone.base64 +0 -25
- data/lib/calabash-cucumber/resources/touch_done_ios4_ipad.base64 +0 -7
- data/lib/calabash-cucumber/resources/touch_done_ios4_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_done_ios5_ipad.base64 +0 -7
- data/lib/calabash-cucumber/resources/touch_done_ios5_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios5_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios5_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios6_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_hold_ios6_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios4_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios4_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios5_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios5_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios7_ipad.base64 +0 -9
- data/lib/calabash-cucumber/resources/touch_ios7_iphone.base64 +0 -9
- data/lib/calabash-cucumber/resources/wheel_down_ios4_ipad.base64 +0 -159
- data/lib/calabash-cucumber/resources/wheel_down_ios4_iphone.base64 +0 -159
- data/lib/calabash-cucumber/resources/wheel_down_ios5_ipad.base64 +0 -156
- data/lib/calabash-cucumber/resources/wheel_down_ios5_iphone.base64 +0 -156
- data/lib/calabash-cucumber/resources/wheel_up_ios4_ipad.base64 +0 -166
- data/lib/calabash-cucumber/resources/wheel_up_ios4_iphone.base64 +0 -166
- data/lib/calabash-cucumber/resources/wheel_up_ios5_ipad.base64 +0 -156
- data/lib/calabash-cucumber/resources/wheel_up_ios5_iphone.base64 +0 -156
- data/scripts/EmptyAppHack.app/Default-568h@2x.png +0 -0
- data/scripts/EmptyAppHack.app/Default.png +0 -0
- data/scripts/EmptyAppHack.app/Default@2x.png +0 -0
- data/scripts/EmptyAppHack.app/EmptyAppHack +0 -0
- data/scripts/EmptyAppHack.app/Info.plist +0 -0
- data/scripts/EmptyAppHack.app/PkgInfo +0 -1
- data/scripts/EmptyAppHack.app/en.lproj/InfoPlist.strings +0 -0
- data/scripts/com.example.plist +0 -0
- data/scripts/data/.GlobalPreferences.plist +0 -0
- data/scripts/reset_simulator.scpt +0 -0
- data/spec/bin/calabash_ios_sim_spec.rb +0 -24
- data/spec/launcher_spec.rb +0 -166
- data/spec/logging_spec.rb +0 -38
- data/spec/plist_buddy_spec.rb +0 -99
- data/spec/resources/enable-accessibility/6.1/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.0.3-64/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.0.3/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.1-64/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/7.1/.gitkeep +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Default-568h@2x.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Info.plist +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/LPSimpleExample-cal +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/PkgInfo +0 -1
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/InfoPlist.strings +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first@2x.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second@2x.png +0 -0
- data/spec/resources/plist_buddy/com.example.plist +0 -0
- data/spec/resources/plist_buddy/com.testing.plist +0 -18
- data/spec/simulator_accessibility_spec.rb +0 -206
- data/spec/spec_helper.rb +0 -31
- data/spec/version_spec.rb +0 -13
- data/spec/xctools_spec.rb +0 -58
@@ -4,22 +4,19 @@ require 'calabash-cucumber/actions/instruments_actions'
|
|
4
4
|
require 'calabash-cucumber/actions/playback_actions'
|
5
5
|
require 'calabash-cucumber/environment_helpers'
|
6
6
|
|
7
|
-
# todo deprecate the Calabash::Cucumber::IOS7Operations
|
8
|
-
|
9
|
-
# WARNING: this entire module is deprecated
|
10
|
-
# references functions that do not exist
|
11
|
-
# should be removed
|
12
7
|
module Calabash
|
13
8
|
module Cucumber
|
9
|
+
|
10
|
+
# @deprecated The methods in this module have all been deprecated.
|
11
|
+
#
|
12
|
+
# All the methods have abstracted to actions/instruments_actions.rb.
|
14
13
|
module IOS7Operations
|
15
14
|
include Calabash::Cucumber::UIA
|
16
15
|
include Calabash::Cucumber::EnvironmentHelpers
|
17
16
|
|
17
|
+
# todo deprecate the Calabash::Cucumber::IOS7Operations
|
18
18
|
|
19
|
-
#
|
20
|
-
#
|
21
|
-
# abstracted into <tt>actions/instruments_actions.rb</tt> - actions that
|
22
|
-
# can be performed under instruments
|
19
|
+
# @!visibility private
|
23
20
|
def touch_ios7(options)
|
24
21
|
ui_query = options[:query]
|
25
22
|
offset = options[:offset]
|
@@ -32,6 +29,7 @@ module Calabash
|
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
32
|
+
# @!visibility private
|
35
33
|
def swipe_ios7(options)
|
36
34
|
ui_query = options[:query]
|
37
35
|
offset = options[:offset]
|
@@ -45,6 +43,7 @@ module Calabash
|
|
45
43
|
end
|
46
44
|
end
|
47
45
|
|
46
|
+
# @!visibility private
|
48
47
|
def pinch_ios7(in_or_out, options)
|
49
48
|
ui_query = options[:query]
|
50
49
|
offset = options[:offset]
|
@@ -59,6 +58,7 @@ module Calabash
|
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
61
|
+
# @!visibility private
|
62
62
|
def pan_ios7(from, to, options={})
|
63
63
|
from_result = find_and_normalize_or_raise from
|
64
64
|
to_result = find_and_normalize_or_raise to
|
@@ -68,6 +68,7 @@ module Calabash
|
|
68
68
|
[to_result]
|
69
69
|
end
|
70
70
|
|
71
|
+
# @!visibility private
|
71
72
|
def double_tap_ios7(options)
|
72
73
|
ui_query = options[:query]
|
73
74
|
offset = options[:offset]
|
@@ -81,6 +82,7 @@ module Calabash
|
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
85
|
+
# @!visibility private
|
84
86
|
def two_finger_tap_ios7(options)
|
85
87
|
ui_query = options[:query]
|
86
88
|
offset = options[:offset]
|
@@ -94,6 +96,7 @@ module Calabash
|
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
99
|
+
# @!visibility private
|
97
100
|
def flick_ios7(options, delta)
|
98
101
|
ui_query = options[:query]
|
99
102
|
offset = options[:offset]
|
@@ -107,6 +110,7 @@ module Calabash
|
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
113
|
+
# @!visibility private
|
110
114
|
def touch_hold_ios7(options)
|
111
115
|
ui_query = options[:query]
|
112
116
|
offset = options[:offset]
|
@@ -6,31 +6,75 @@ require 'calabash-cucumber/uia'
|
|
6
6
|
|
7
7
|
module Calabash
|
8
8
|
module Cucumber
|
9
|
+
# Contains methods for interacting with the iPad.
|
9
10
|
module IPad
|
10
11
|
|
12
|
+
# @!visibility private
|
13
|
+
# Provides methods to interact with the 1x and 2x buttons that appear
|
14
|
+
# when an iPhone-only app is emulated on an iPad. Calabash cannot
|
15
|
+
# interact with these apps in 2x mode because the touch coordinates
|
16
|
+
# cannot be reliably translated from normal iPhone dimensions to the
|
17
|
+
# emulated dimensions.
|
18
|
+
#
|
19
|
+
# On iOS < 7, an app _remembered_ its last 1x/2x scale so when it
|
20
|
+
# reopened the previous scale would be the same as when it closed. This
|
21
|
+
# meant you could manually set the scale once to 1x and never have to
|
22
|
+
# interact with the scale button again.
|
23
|
+
#
|
24
|
+
# On iOS > 7, the default behavior is that all emulated apps open at 2x
|
25
|
+
# regardless of their previous scale.
|
26
|
+
#
|
27
|
+
# @note In order to use this class, you must allow Calabash to launch
|
28
|
+
# your app with instruments.
|
11
29
|
class Emulation
|
30
|
+
|
12
31
|
include Calabash::Cucumber::FailureHelpers
|
13
32
|
include Calabash::Cucumber::HTTPHelpers
|
14
33
|
include Calabash::Cucumber::QueryHelpers
|
15
34
|
include Calabash::Cucumber::UIA
|
16
35
|
|
17
|
-
#
|
36
|
+
# @!visibility private
|
37
|
+
#
|
38
|
+
# Maintainers: when adding a localization, please notice that
|
18
39
|
# the keys and values are semantically reversed.
|
19
40
|
#
|
20
41
|
# you should read the hash as:
|
21
42
|
#
|
22
|
-
#
|
23
|
-
#
|
43
|
+
# ```
|
44
|
+
# :emulated_1x <= what button is showing when the app is emulated at 2X?
|
45
|
+
# :emulated_2x <= what button is showing when the app is emulated at 1X?
|
46
|
+
# ```
|
24
47
|
IPAD_1X_2X_BUTTON_LABELS = {
|
25
48
|
:en => {:emulated_1x => '2X',
|
26
49
|
:emulated_2x => '1X'}
|
27
50
|
}
|
28
51
|
|
52
|
+
# @!visibility private
|
53
|
+
# @!attribute [r] scale
|
54
|
+
# The current 1X or 2X scale represented as a Symbol.
|
55
|
+
#
|
56
|
+
# @return [Symbol] Returns this emulation's scale. Will be one of
|
57
|
+
# `{:emulated_1x | :emulated_2x}`.
|
29
58
|
attr_reader :scale
|
59
|
+
|
60
|
+
# @!visibility private
|
61
|
+
# @!attribute [r] lang_code
|
62
|
+
# The Apple compatible language code for determining the accessibility
|
63
|
+
# label of the 1X and 2X buttons.
|
64
|
+
#
|
65
|
+
# @return [Symbol] Returns the language code of this emulation.
|
30
66
|
attr_reader :lang_code
|
31
67
|
|
68
|
+
# @!visibility private
|
69
|
+
# A private instance variable for storing this emulation's 1X/2X button
|
70
|
+
# names. The value will be set at runtime based on the language code
|
71
|
+
# that is passed the initializer.
|
32
72
|
@button_names_hash = nil
|
33
73
|
|
74
|
+
# @!visibility private
|
75
|
+
# Creates a new Emulation.
|
76
|
+
# @param [Symbol] lang_code an Apple compatible language code
|
77
|
+
# @return [Emulation] Returns an emulation that is ready for action!
|
34
78
|
def initialize (lang_code=:en)
|
35
79
|
@button_names_hash = IPAD_1X_2X_BUTTON_LABELS[lang_code]
|
36
80
|
if @button_names_hash.nil?
|
@@ -41,6 +85,7 @@ module Calabash
|
|
41
85
|
@scale = _internal_ipad_emulation_scale
|
42
86
|
end
|
43
87
|
|
88
|
+
# @!visibility private
|
44
89
|
def tap_ipad_scale_button
|
45
90
|
key = @scale
|
46
91
|
name = @button_names_hash[key]
|
@@ -54,6 +99,7 @@ module Calabash
|
|
54
99
|
end
|
55
100
|
|
56
101
|
private
|
102
|
+
# @!visibility private
|
57
103
|
def _internal_ipad_emulation_scale
|
58
104
|
hash = @button_names_hash
|
59
105
|
val = nil
|
@@ -81,36 +127,40 @@ module Calabash
|
|
81
127
|
|
82
128
|
end
|
83
129
|
|
84
|
-
#
|
130
|
+
# Ensures that iPhone apps emulated on an iPad are displayed at scale.
|
85
131
|
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
# we've tried).
|
132
|
+
# @note It is recommended that clients call this `ensure_ipad_emulation_1x`
|
133
|
+
# instead of this method.
|
89
134
|
#
|
90
|
-
#
|
135
|
+
# @note If this is not an iPhone app emulated on an iPad, then calling
|
136
|
+
# this method has no effect.
|
91
137
|
#
|
92
|
-
#
|
138
|
+
# @note In order to use this method, you must allow Calabash to launch
|
139
|
+
# your app with instruments.
|
93
140
|
#
|
94
|
-
#
|
141
|
+
# Starting in iOS 7, iPhone apps emulated on the iPad always launch at 2x.
|
142
|
+
# calabash cannot currently interact with such apps in 2x mode (trust us,
|
143
|
+
# we've tried).
|
95
144
|
#
|
96
|
-
#
|
145
|
+
# @see #ensure_ipad_emulation_1x
|
97
146
|
#
|
98
|
-
#
|
99
|
-
#
|
147
|
+
# @param [Symbol] scale the desired scale - must be `:emulated_1x` or
|
148
|
+
# `:emulated_2x`
|
100
149
|
#
|
101
|
-
# the
|
150
|
+
# @param [Hash] opts optional arguments to control the interaction with
|
151
|
+
# the 1X/2X buttons
|
102
152
|
#
|
103
|
-
#
|
104
|
-
#
|
153
|
+
# @option opts [Symbol] :lang_code (:en) an Apple compatible
|
154
|
+
# language code
|
155
|
+
# @option opts [Symbol] :wait_after_touch (0.4) how long to
|
156
|
+
# wait _after_ the scale button is touched
|
105
157
|
#
|
106
|
-
#
|
107
|
-
# this function has no effect.
|
158
|
+
# @return [void]
|
108
159
|
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
# * the 'scale' button cannot be touched
|
160
|
+
# @raise [RuntimeError] If the app was not launched with instruments.
|
161
|
+
# @raise [RuntimeError] If an invalid `scale` is passed.
|
162
|
+
# @raise [RuntimeError] If an unknown language code is passed.
|
163
|
+
# @raise [RuntimeError] If the scale button cannot be touched.
|
114
164
|
def ensure_ipad_emulation_scale(scale, opts={})
|
115
165
|
return unless iphone_app_emulated_on_ipad?
|
116
166
|
|
@@ -139,44 +189,49 @@ module Calabash
|
|
139
189
|
|
140
190
|
end
|
141
191
|
|
142
|
-
#
|
192
|
+
# Ensures that iPhone apps emulated on an iPad are displayed at `1X`.
|
143
193
|
#
|
144
|
-
#
|
145
|
-
#
|
194
|
+
# @note If this is not an iPhone app emulated on an iPad, then calling
|
195
|
+
# this method has no effect.
|
146
196
|
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
# unless @calabash_launcher.calabash_no_launch?
|
150
|
-
# @calabash_launcher.relaunch
|
151
|
-
# @calabash_launcher.calabash_notify(self)
|
152
|
-
# # ensure emulated apps are at 1x
|
153
|
-
# ensure_ipad_emulation_1x
|
154
|
-
# end
|
155
|
-
# # do other stuff to prepare the test environment
|
156
|
-
# end
|
197
|
+
# @note In order to use this method, you must allow Calabash to launch
|
198
|
+
# your app with instruments.
|
157
199
|
#
|
158
|
-
#
|
200
|
+
# Starting in iOS 7, iPhone apps emulated on the iPad always launch at 2x.
|
201
|
+
# calabash cannot currently interact with such apps in 2x mode (trust us,
|
202
|
+
# we've tried).
|
159
203
|
#
|
160
|
-
#
|
161
|
-
#
|
204
|
+
# @example Here is an example of how to use this function in your `Before` launch hooks.
|
205
|
+
# Before do |scenario|
|
206
|
+
# @calabash_launcher = Calabash::Cucumber::Launcher.new
|
207
|
+
# unless @calabash_launcher.calabash_no_launch?
|
208
|
+
# @calabash_launcher.relaunch
|
209
|
+
# @calabash_launcher.calabash_notify(self)
|
210
|
+
# # ensure emulated apps are at 1x
|
211
|
+
# ensure_ipad_emulation_1x
|
212
|
+
# end
|
213
|
+
# # do other stuff to prepare the test environment
|
214
|
+
# end
|
162
215
|
#
|
163
|
-
# the
|
216
|
+
# @param [Hash] opts optional arguments to control the interaction with
|
217
|
+
# the 1X/2X buttons
|
164
218
|
#
|
165
|
-
#
|
166
|
-
#
|
219
|
+
# @option opts [Symbol] :lang_code (:en) an Apple compatible
|
220
|
+
# language code
|
221
|
+
# @option opts [Symbol] :wait_after_touch (0.4) how long to
|
222
|
+
# wait _after_ the scale button is touched
|
167
223
|
#
|
168
|
-
#
|
169
|
-
# this function has no effect.
|
224
|
+
# @return [void]
|
170
225
|
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
# * the 'scale' button cannot be touched
|
226
|
+
# @raise [RuntimeError] If the app was not launched with instruments.
|
227
|
+
# @raise [RuntimeError] If an unknown language code is passed.
|
228
|
+
# @raise [RuntimeError] If the scale button cannot be touched.
|
175
229
|
def ensure_ipad_emulation_1x(opts={})
|
176
230
|
ensure_ipad_emulation_scale(:emulated_1x, opts)
|
177
231
|
end
|
178
232
|
|
179
233
|
private
|
234
|
+
# @!visibility private
|
180
235
|
# ensures iPhone apps running on an iPad are emulated at 2X
|
181
236
|
#
|
182
237
|
# you should never need to call this function - calabash cannot interact
|
@@ -6,11 +6,45 @@ require 'calabash-cucumber/utils/logging'
|
|
6
6
|
|
7
7
|
module Calabash
|
8
8
|
module Cucumber
|
9
|
+
# Collection of methods for interacting with the keyboard.
|
10
|
+
#
|
11
|
+
# There are two environmental variables you can use to control the speed of
|
12
|
+
# typing. We've gone to great lengths to provide the fastest keyboard
|
13
|
+
# entry possible.
|
14
|
+
#
|
15
|
+
# If you are having trouble with skipped or are receiving JSON octet
|
16
|
+
# errors when typing, you might be able to resolve the problems by slowing
|
17
|
+
# down the rate of typing.
|
18
|
+
#
|
19
|
+
# Example: Use keyboard_enter_char + :wait_after_char.
|
20
|
+
#
|
21
|
+
# ```
|
22
|
+
# str.each_char do |char|
|
23
|
+
# # defaults to 0.05 seconds
|
24
|
+
# keyboard_enter_char(char, `{wait_after_char:0.5}`)
|
25
|
+
# end
|
26
|
+
# ```
|
27
|
+
#
|
28
|
+
# Example: Use keyboard_enter_char + POST_ENTER_KEYBOARD
|
29
|
+
#
|
30
|
+
# ```
|
31
|
+
# $ POST_ENTER_KEYBOARD=0.1 bundle exec cucumber
|
32
|
+
# str.each_char do |char|
|
33
|
+
# # defaults to 0.05 seconds
|
34
|
+
# keyboard_enter_char(char)
|
35
|
+
# end
|
36
|
+
# ```
|
37
|
+
#
|
38
|
+
# @note
|
39
|
+
# We have an exhaustive set of keyboard related test.s The API is reasonably
|
40
|
+
# stable. We are fighting against known bugs in Apple's UIAutomation. You
|
41
|
+
# should only need to fall back to the examples below in unusual situations.
|
9
42
|
module KeyboardHelpers
|
10
43
|
|
11
44
|
include Calabash::Cucumber::TestsHelpers
|
12
45
|
include Calabash::Cucumber::Logging
|
13
46
|
|
47
|
+
# @!visibility private
|
14
48
|
KEYPLANE_NAMES = {
|
15
49
|
:small_letters => 'small-letters',
|
16
50
|
:capital_letters => 'capital-letters',
|
@@ -19,7 +53,8 @@ module Calabash
|
|
19
53
|
:numbers_and_punctuation_alternate => 'numbers-and-punctuation-alternate'
|
20
54
|
}
|
21
55
|
|
22
|
-
|
56
|
+
# @!visibility private
|
57
|
+
# noinspection RubyStringKeysInHashInspection
|
23
58
|
UIA_SUPPORTED_CHARS = {
|
24
59
|
'Delete' => '\b',
|
25
60
|
'Return' => '\n'
|
@@ -32,17 +67,19 @@ module Calabash
|
|
32
67
|
#'More' => nil,
|
33
68
|
}
|
34
69
|
|
35
|
-
|
36
|
-
#
|
70
|
+
# @!visibility private
|
71
|
+
# Returns a query string for detecting a keyboard.
|
37
72
|
def _qstr_for_keyboard
|
38
73
|
"view:'UIKBKeyplaneView'"
|
39
74
|
end
|
40
75
|
|
41
|
-
#
|
76
|
+
# Returns true if a docked keyboard is visible.
|
77
|
+
#
|
78
|
+
# A docked keyboard is pinned to the bottom of the view.
|
42
79
|
#
|
43
|
-
#
|
80
|
+
# Keyboards on the iPhone and iPod are docked.
|
44
81
|
#
|
45
|
-
#
|
82
|
+
# @return [Boolean] if a keyboard is visible and docked.
|
46
83
|
def docked_keyboard_visible?
|
47
84
|
res = query(_qstr_for_keyboard).first
|
48
85
|
return false if res.nil?
|
@@ -67,12 +104,12 @@ module Calabash
|
|
67
104
|
|
68
105
|
end
|
69
106
|
|
70
|
-
#
|
107
|
+
# Returns true if an undocked keyboard is visible.
|
71
108
|
#
|
72
|
-
#
|
109
|
+
# A undocked keyboard is floats in the middle of the view.
|
73
110
|
#
|
74
|
-
#
|
75
|
-
# iPhone and iPod are
|
111
|
+
# @return [Boolean] Returns false if the device is not an iPad; all
|
112
|
+
# keyboards on the iPhone and iPod are docked.
|
76
113
|
def undocked_keyboard_visible?
|
77
114
|
return false if device_family_iphone?
|
78
115
|
|
@@ -82,28 +119,39 @@ module Calabash
|
|
82
119
|
not docked_keyboard_visible?
|
83
120
|
end
|
84
121
|
|
85
|
-
#
|
122
|
+
# Returns true if a split keyboard is visible.
|
86
123
|
#
|
87
|
-
#
|
124
|
+
# A split keyboard is floats in the middle of the view and is split to
|
88
125
|
# allow faster thumb typing
|
89
126
|
#
|
90
|
-
#
|
91
|
-
#
|
127
|
+
# @return [Boolean] Returns false if the device is not an iPad; all
|
128
|
+
# keyboards on the Phone and iPod are docked and not split.
|
92
129
|
def split_keyboard_visible?
|
93
130
|
return false if device_family_iphone?
|
94
131
|
query("view:'UIKBKeyView'").count > 0 and
|
95
132
|
element_does_not_exist(_qstr_for_keyboard)
|
96
133
|
end
|
97
134
|
|
98
|
-
#
|
135
|
+
# Returns true if there is a visible keyboard.
|
136
|
+
#
|
137
|
+
# @return [Boolean] Returns true if there is a visible keyboard.
|
99
138
|
def keyboard_visible?
|
100
139
|
docked_keyboard_visible? or undocked_keyboard_visible? or split_keyboard_visible?
|
101
140
|
end
|
102
141
|
|
103
|
-
#
|
104
|
-
# seconds
|
142
|
+
# Waits for a keyboard to appear and once it does appear waits for
|
143
|
+
# `:post_timeout` seconds.
|
144
|
+
#
|
145
|
+
# @see Calabash::Cucumber::WaitHelpers#wait_for for other options this
|
146
|
+
# method can handle.
|
105
147
|
#
|
106
|
-
#
|
148
|
+
# @param [Hash] opts controls the `wait_for` behavior
|
149
|
+
# @option opts [String] :timeout_message ('keyboard did not appear')
|
150
|
+
# Controls the message that appears in the exception.
|
151
|
+
# @option opts [Number] :post_timeout (0.3) Controls how long to wait
|
152
|
+
# _after_ the keyboard has appeared.
|
153
|
+
#
|
154
|
+
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] if no keyboard appears
|
107
155
|
def wait_for_keyboard(opts={})
|
108
156
|
default_opts = {:timeout_message => 'keyboard did not appear',
|
109
157
|
:post_timeout => 0.3}
|
@@ -113,37 +161,47 @@ module Calabash
|
|
113
161
|
end
|
114
162
|
end
|
115
163
|
|
116
|
-
#
|
164
|
+
# @deprecated 0.9.163 replaced with `wait_for_keyboard`
|
165
|
+
# @see #wait_for_keyboard
|
117
166
|
def await_keyboard
|
118
167
|
_deprecated('0.9.163', "use 'wait_for_keyboard' instead", :warn)
|
119
168
|
wait_for_keyboard
|
120
169
|
end
|
121
170
|
|
171
|
+
# @!visibility private
|
122
172
|
# returns an array of possible ipad keyboard modes
|
123
173
|
def _ipad_keyboard_modes
|
124
174
|
[:docked, :undocked, :split]
|
125
175
|
end
|
126
176
|
|
127
|
-
#
|
177
|
+
# Returns the keyboard mode.
|
178
|
+
#
|
179
|
+
# @example How to use in a wait_* function.
|
180
|
+
# wait_for do
|
181
|
+
# ipad_keyboard_mode({:raise_on_no_visible_keyboard => false}) == :split
|
182
|
+
# end
|
128
183
|
#
|
184
|
+
# ```
|
129
185
|
# keyboard is pinned to bottom of the view #=> :docked
|
130
186
|
# keyboard is floating in the middle of the view #=> :undocked
|
131
187
|
# keyboard is floating and split #=> :split
|
132
|
-
#
|
188
|
+
# no keyboard and :raise_on_no_visible_keyboard == false #=> :unknown
|
189
|
+
# ```
|
133
190
|
#
|
134
|
-
#
|
191
|
+
# @raise [RuntimeError] if the device under test is not an iPad.
|
135
192
|
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
193
|
+
# @raise [RuntimeError] if `:raise_on_no_visible_keyboard` is truthy and
|
194
|
+
# no keyboard is visible.
|
195
|
+
# @param [Hash] opts controls the runtime behavior.
|
196
|
+
# @option opts [Boolean] :raise_on_no_visible_keyboard (true) set to false
|
197
|
+
# if you don't want to raise an error.
|
198
|
+
# @return [Symbol] Returns one of `{:docked | :undocked | :split | :unknown}`
|
141
199
|
def ipad_keyboard_mode(opts = {})
|
142
200
|
raise 'the keyboard mode does not exist on the iphone or ipod' if device_family_iphone?
|
143
201
|
|
144
202
|
default_opts = {:raise_on_no_visible_keyboard => true}
|
145
|
-
|
146
|
-
if
|
203
|
+
merged_opts = default_opts.merge(opts)
|
204
|
+
if merged_opts[:raise_on_no_visible_keyboard]
|
147
205
|
screenshot_and_raise 'there is no visible keyboard' unless keyboard_visible?
|
148
206
|
return :docked if docked_keyboard_visible?
|
149
207
|
return :undocked if undocked_keyboard_visible?
|
@@ -156,15 +214,18 @@ module Calabash
|
|
156
214
|
end
|
157
215
|
end
|
158
216
|
|
159
|
-
#
|
217
|
+
# @!visibility private
|
218
|
+
# Ensures that there is a keyboard to enter text.
|
160
219
|
#
|
161
|
-
#
|
162
|
-
#
|
220
|
+
# @note
|
221
|
+
# *IMPORTANT* will always raise an error when the keyboard is split and
|
222
|
+
# there is no `run_loop`; i.e. UIAutomation is not available.
|
163
223
|
#
|
164
|
-
#
|
165
|
-
#
|
166
|
-
#
|
167
|
-
#
|
224
|
+
# @param [Hash] opts controls screenshot-ing and error raising conditions
|
225
|
+
# @option opts [Boolean] :screenshot (true) raise with a screenshot if
|
226
|
+
# a keyboard cannot be ensured
|
227
|
+
# @option opts [Boolean] :skip (false) skip any checking (a nop) - used
|
228
|
+
# when iterating over keyplanes for keys
|
168
229
|
def _ensure_can_enter_text(opts={})
|
169
230
|
default_opts = {:screenshot => true,
|
170
231
|
:skip => false}
|
@@ -191,23 +252,37 @@ module Calabash
|
|
191
252
|
end
|
192
253
|
end
|
193
254
|
|
194
|
-
#
|
255
|
+
# Use keyboard to enter a character.
|
195
256
|
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
199
|
-
#
|
257
|
+
# @note
|
258
|
+
# IMPORTANT: Use the `POST_ENTER_KEYBOARD` environmental variable
|
259
|
+
# to slow down the typing; adds a wait after each character is touched.
|
260
|
+
# this can fix problems where the typing is too fast and characters are
|
261
|
+
# skipped.
|
200
262
|
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
# * 'Return'
|
263
|
+
# @note
|
264
|
+
# There are several special 'characters', some of which do not appear on
|
265
|
+
# all keyboards; e.g. `Delete`, `Return`.
|
205
266
|
#
|
206
|
-
#
|
207
|
-
#
|
267
|
+
# @note
|
268
|
+
# Since 0.9.163, this method accepts a Hash as the second parameter. The
|
269
|
+
# previous second parameter was a Boolean that controlled whether or not
|
270
|
+
# to screenshot on errors.
|
208
271
|
#
|
209
|
-
#
|
210
|
-
#
|
272
|
+
# @see #keyboard_enter_text
|
273
|
+
#
|
274
|
+
# @note
|
275
|
+
# You should prefer to call `keyboard_enter_text`.
|
276
|
+
#
|
277
|
+
# @raise [RuntimeError] if there is no visible keyboard
|
278
|
+
# @raise [RuntimeError] if the keyboard (layout) is not supported
|
279
|
+
#
|
280
|
+
# @param [String] chr the character to type
|
281
|
+
# @param [Hash] opts options to control the behavior of the method
|
282
|
+
# @option opts [Boolean] :should_screenshot (true) whether or not to
|
283
|
+
# screenshot on errors
|
284
|
+
# @option opts [Float] :wait_after_char ('POST_ENTER_KEYBOARD' or 0.05)
|
285
|
+
# how long to wait after a character is typed.
|
211
286
|
def keyboard_enter_char(chr, opts={})
|
212
287
|
unless opts.is_a?(Hash)
|
213
288
|
msg = "you should no longer pass a boolean as the second arg; pass {:should_screenshot => '#{opts}'} hash instead"
|
@@ -248,6 +323,7 @@ module Calabash
|
|
248
323
|
uia_type_string(code, '')
|
249
324
|
end
|
250
325
|
end
|
326
|
+
# noinspection RubyStringKeysInHashInspection
|
251
327
|
res = {'results' => []}
|
252
328
|
else
|
253
329
|
res = http({:method => :post, :path => 'keyboard'},
|
@@ -274,9 +350,10 @@ module Calabash
|
|
274
350
|
res['results']
|
275
351
|
end
|
276
352
|
|
277
|
-
#
|
353
|
+
# Uses the keyboard to enter text.
|
278
354
|
#
|
279
|
-
#
|
355
|
+
# @param [String] text the text to type.
|
356
|
+
# @raise [RuntimeError] if the text cannot be typed.
|
280
357
|
def keyboard_enter_text(text)
|
281
358
|
_ensure_can_enter_text
|
282
359
|
if uia_available?
|
@@ -294,17 +371,21 @@ module Calabash
|
|
294
371
|
end
|
295
372
|
end
|
296
373
|
|
297
|
-
#
|
374
|
+
# Touches the keyboard action key.
|
375
|
+
#
|
376
|
+
# The action key depends on the keyboard. Some examples include:
|
298
377
|
#
|
299
|
-
# the +action+ key depends on the keyboard. some examples include:
|
300
378
|
# * Return
|
301
379
|
# * Next
|
302
380
|
# * Go
|
303
381
|
# * Join
|
304
382
|
# * Search
|
305
383
|
#
|
306
|
-
#
|
307
|
-
#
|
384
|
+
# @note
|
385
|
+
# Not all keyboards have an action key. For example, numeric keyboards
|
386
|
+
# do not have an action key.
|
387
|
+
#
|
388
|
+
# @raise [RuntimeError] if the text cannot be typed.
|
308
389
|
def tap_keyboard_action_key
|
309
390
|
if uia_available?
|
310
391
|
uia_type_string '\n', '', false
|
@@ -313,24 +394,30 @@ module Calabash
|
|
313
394
|
end
|
314
395
|
end
|
315
396
|
|
316
|
-
#
|
397
|
+
# @deprecated 0.10.0 replaced with `tap_keyboard_action_key`
|
398
|
+
# @see #tap_keyboard_action_key
|
399
|
+
#
|
400
|
+
# Touches the keyboard action key.
|
317
401
|
#
|
318
|
-
#
|
402
|
+
# The action key depends on the keyboard. Some examples include:
|
319
403
|
#
|
320
|
-
# some examples include:
|
321
404
|
# * Return
|
322
405
|
# * Next
|
323
406
|
# * Go
|
324
407
|
# * Join
|
325
408
|
# * Search
|
326
409
|
#
|
327
|
-
#
|
328
|
-
#
|
410
|
+
# @note
|
411
|
+
# Not all keyboards have an action key. For example, numeric keyboards
|
412
|
+
# do not have an action key.
|
413
|
+
#
|
414
|
+
# @raise [RuntimeError] if the text cannot be typed.
|
329
415
|
def done
|
330
416
|
tap_keyboard_action_key
|
331
417
|
end
|
332
418
|
|
333
|
-
#
|
419
|
+
# @!visibility private
|
420
|
+
# Returns the current keyplane.
|
334
421
|
def _current_keyplane
|
335
422
|
kp_arr = _do_keyplane(
|
336
423
|
lambda { query("view:'UIKBKeyplaneView'", 'keyplane', 'componentName') },
|
@@ -338,15 +425,20 @@ module Calabash
|
|
338
425
|
kp_arr.first.downcase
|
339
426
|
end
|
340
427
|
|
341
|
-
#
|
428
|
+
# @!visibility private
|
429
|
+
# Searches the available keyplanes for chr and if it is found, types it.
|
430
|
+
#
|
431
|
+
# This is a recursive function.
|
342
432
|
#
|
343
|
-
#
|
433
|
+
# @note
|
434
|
+
# Use the `KEYPLANE_SEARCH_STEP_PAUSE` variable to control how quickly
|
435
|
+
# the next keyplane is searched. Increase this value if you encounter
|
436
|
+
# problems with missed keystrokes.
|
344
437
|
#
|
345
|
-
#
|
346
|
-
#
|
347
|
-
# if you encounter problems with missed keystrokes.
|
438
|
+
# @note
|
439
|
+
# When running under instruments, this method is not called.
|
348
440
|
#
|
349
|
-
#
|
441
|
+
# @raise [RuntimeError] if the char cannot be found
|
350
442
|
def _search_keyplanes_and_enter_char(chr, visited=Set.new)
|
351
443
|
cur_kp = _current_keyplane
|
352
444
|
begin
|
@@ -387,9 +479,10 @@ module Calabash
|
|
387
479
|
end
|
388
480
|
end
|
389
481
|
|
390
|
-
#
|
482
|
+
# @!visibility private
|
483
|
+
# Process a keyplane.
|
391
484
|
#
|
392
|
-
#
|
485
|
+
# @raise [RuntimeError] if there is no visible keyplane
|
393
486
|
def _do_keyplane(kbtree_proc, keyplane_proc)
|
394
487
|
desc = query("view:'UIKBKeyplaneView'", 'keyplane')
|
395
488
|
fail('No keyplane (UIKBKeyplaneView keyplane)') if desc.empty?
|
@@ -404,16 +497,19 @@ module Calabash
|
|
404
497
|
end
|
405
498
|
end
|
406
499
|
|
407
|
-
#
|
500
|
+
# @!visibility private
|
501
|
+
# Returns a query string for finding the iPad 'Hide keyboard' button.
|
408
502
|
def _query_uia_hide_keyboard_button
|
409
503
|
"uia.keyboard().buttons()['Hide keyboard']"
|
410
504
|
end
|
411
505
|
|
412
|
-
#
|
413
|
-
# for the keyboard to disappear
|
506
|
+
# Dismisses a iPad keyboard by touching the 'Hide keyboard' button and waits
|
507
|
+
# for the keyboard to disappear.
|
414
508
|
#
|
415
|
-
#
|
416
|
-
# key does not exist on the iPhone or iPod
|
509
|
+
# @note
|
510
|
+
# the dismiss keyboard key does not exist on the iPhone or iPod
|
511
|
+
#
|
512
|
+
# @raise [RuntimeError] if the device is not an iPad
|
417
513
|
def dismiss_ipad_keyboard
|
418
514
|
screenshot_and_raise 'cannot dismiss keyboard on iphone' if device_family_iphone?
|
419
515
|
|
@@ -429,13 +525,16 @@ module Calabash
|
|
429
525
|
end
|
430
526
|
end
|
431
527
|
|
432
|
-
#
|
528
|
+
# @!visibility private
|
529
|
+
# Returns the activation point of the iPad keyboard mode key.
|
433
530
|
#
|
434
|
-
#
|
531
|
+
# The mode key is also known as the 'Hide keyboard' key.
|
435
532
|
#
|
436
|
-
#
|
437
|
-
#
|
438
|
-
#
|
533
|
+
# @note
|
534
|
+
# This is only available when running under instruments.
|
535
|
+
#
|
536
|
+
# @raise [RuntimeError] when the device is not an iPad
|
537
|
+
# @raise [RuntimeError] the app was not launched with instruments
|
439
538
|
def _point_for_ipad_keyboard_mode_key
|
440
539
|
raise 'the keyboard mode does not exist on the on the iphone' if device_family_iphone?
|
441
540
|
raise 'cannot detect keyboard mode key without launching with instruments' unless uia_available?
|
@@ -445,26 +544,24 @@ module Calabash
|
|
445
544
|
|
446
545
|
# this did not work.
|
447
546
|
#size = res['value']['size']
|
448
|
-
#{:x => (origin['x']
|
547
|
+
#{:x => (origin['x'] (size['width']/2)), :y => (origin['y'] (size['height']/2))}
|
449
548
|
end
|
450
549
|
|
451
|
-
|
452
|
-
#
|
453
|
-
# the iPad
|
550
|
+
# @!visibility private
|
551
|
+
# Returns a query string for touching one of the options that appears when
|
552
|
+
# the iPad mode key is touched and held.
|
454
553
|
#
|
455
|
-
#
|
554
|
+
# The mode key is also know as the 'Hide keyboard' key.
|
456
555
|
#
|
457
|
-
#
|
458
|
-
#
|
459
|
-
# mode :docked | :undocked | :skipped
|
556
|
+
# @note
|
557
|
+
# This is only available when running outside of instruments.
|
460
558
|
#
|
461
|
-
#
|
462
|
-
#
|
559
|
+
# @param [Symbol] top_or_bottom can be one of `{:top | :bottom}`
|
560
|
+
# @param [Symbol] mode `{:docked | :undocked | :skipped}`
|
463
561
|
#
|
464
|
-
#
|
465
|
-
#
|
466
|
-
#
|
467
|
-
# * it is passed invalid arguments
|
562
|
+
# @raise [RuntimeError] the device is not an iPad
|
563
|
+
# @raise [RuntimeError] the app was not launched with instruments
|
564
|
+
# @raise [RuntimeError] the method is passed invalid arguments
|
468
565
|
def _query_for_touch_for_keyboard_mode_option(top_or_bottom, mode)
|
469
566
|
raise 'the keyboard mode does not exist on the iphone' if device_family_iphone?
|
470
567
|
|
@@ -492,12 +589,15 @@ module Calabash
|
|
492
589
|
"label marked:'#{mark}'"
|
493
590
|
end
|
494
591
|
|
495
|
-
#
|
592
|
+
# @!visibility private
|
593
|
+
# Returns a query for touching the iPad keyboard mode key.
|
496
594
|
#
|
497
|
-
#
|
595
|
+
# The mode key is also know as the 'Hide keyboard' key.
|
498
596
|
#
|
499
|
-
#
|
500
|
-
# available
|
597
|
+
# @note
|
598
|
+
# This is only available when running outside of instruments. Use
|
599
|
+
# ` _point_for_ipad_keyboard_mode_key` when the app is _not_ launched
|
600
|
+
# with instruments.
|
501
601
|
#
|
502
602
|
# raises an error when
|
503
603
|
# * the device is not an iPad
|
@@ -512,12 +612,13 @@ module Calabash
|
|
512
612
|
"#{qstr} index:#{idx}"
|
513
613
|
end
|
514
614
|
|
515
|
-
#
|
516
|
-
# the
|
615
|
+
# @!visibility private
|
616
|
+
# Touches the bottom option on the popup dialog that is presented when the
|
617
|
+
# the iPad keyboard `mode` key is touched and held.
|
517
618
|
#
|
518
|
-
#
|
619
|
+
# The `mode` key is also know as the 'Hide keyboard' key.
|
519
620
|
#
|
520
|
-
#
|
621
|
+
# The `mode` key allows the user to undock, dock, or split the keyboard.
|
521
622
|
def _touch_bottom_keyboard_mode_row
|
522
623
|
mode = ipad_keyboard_mode
|
523
624
|
if uia_available?
|
@@ -534,12 +635,12 @@ module Calabash
|
|
534
635
|
2.times { sleep(0.5) }
|
535
636
|
end
|
536
637
|
|
537
|
-
#
|
538
|
-
# the iPad keyboard
|
638
|
+
# Touches the top option on the popup dialog that is presented when the
|
639
|
+
# the iPad keyboard mode key is touched and held.
|
539
640
|
#
|
540
|
-
#
|
641
|
+
# The `mode` key is also know as the 'Hide keyboard' key.
|
541
642
|
#
|
542
|
-
#
|
643
|
+
# The `mode` key allows the user to undock, dock, or split the keyboard.
|
543
644
|
def _touch_top_keyboard_mode_row
|
544
645
|
mode = ipad_keyboard_mode
|
545
646
|
if uia_available?
|
@@ -558,16 +659,15 @@ module Calabash
|
|
558
659
|
2.times { sleep(0.5) }
|
559
660
|
end
|
560
661
|
|
561
|
-
#
|
662
|
+
# Ensures that the iPad keyboard is docked.
|
562
663
|
#
|
563
|
-
#
|
664
|
+
# Docked means the keyboard is pinned to bottom of the view.
|
564
665
|
#
|
565
|
-
#
|
566
|
-
#
|
666
|
+
# If the device is not an iPad, this is behaves like a call to
|
667
|
+
# `wait_for_keyboard`.
|
567
668
|
#
|
568
|
-
#
|
569
|
-
#
|
570
|
-
# * the +docked+ keyboard cannot be achieved
|
669
|
+
# @raise [RuntimeError] if there is no visible keyboard
|
670
|
+
# @raise [RuntimeError] a docked keyboard was not achieved
|
571
671
|
def ensure_docked_keyboard
|
572
672
|
wait_for_keyboard
|
573
673
|
|
@@ -597,16 +697,18 @@ module Calabash
|
|
597
697
|
end
|
598
698
|
|
599
699
|
|
600
|
-
#
|
700
|
+
# Ensures that the iPad keyboard is undocked.
|
601
701
|
#
|
602
|
-
#
|
702
|
+
# Undocked means the keyboard is floating in the middle of the view.
|
603
703
|
#
|
604
|
-
#
|
605
|
-
#
|
704
|
+
# If the device is not an iPad, this is behaves like a call to
|
705
|
+
# `wait_for_keyboard`.
|
606
706
|
#
|
607
|
-
#
|
608
|
-
#
|
609
|
-
#
|
707
|
+
# If the device is not an iPad, this is behaves like a call to
|
708
|
+
# `wait_for_keyboard`.
|
709
|
+
#
|
710
|
+
# @raise [RuntimeError] if there is no visible keyboard
|
711
|
+
# @raise [RuntimeError] an undocked keyboard was not achieved
|
610
712
|
def ensure_undocked_keyboard
|
611
713
|
wait_for_keyboard()
|
612
714
|
|
@@ -641,17 +743,19 @@ module Calabash
|
|
641
743
|
end
|
642
744
|
|
643
745
|
|
644
|
-
#
|
746
|
+
# Ensures that the iPad keyboard is split.
|
645
747
|
#
|
646
|
-
#
|
748
|
+
# Split means the keyboard is floating in the middle of the view and is
|
647
749
|
# split into two sections to enable faster thumb typing.
|
648
750
|
#
|
649
|
-
#
|
650
|
-
#
|
751
|
+
# If the device is not an iPad, this is behaves like a call to
|
752
|
+
# `wait_for_keyboard`.
|
651
753
|
#
|
652
|
-
#
|
653
|
-
#
|
654
|
-
#
|
754
|
+
# If the device is not an iPad, this is behaves like a call to
|
755
|
+
# `wait_for_keyboard`.
|
756
|
+
#
|
757
|
+
# @raise [RuntimeError] if there is no visible keyboard
|
758
|
+
# @raise [RuntimeError] a split keyboard was not achieved
|
655
759
|
def ensure_split_keyboard
|
656
760
|
wait_for_keyboard
|
657
761
|
|
@@ -672,6 +776,7 @@ module Calabash
|
|
672
776
|
_wait_for_keyboard_in_mode(:split)
|
673
777
|
end
|
674
778
|
|
779
|
+
# @!visibility private
|
675
780
|
def _wait_for_keyboard_in_mode(mode, opts={})
|
676
781
|
default_opts = {:post_timeout => 1.0}
|
677
782
|
opts = default_opts.merge(opts)
|
@@ -695,13 +800,16 @@ module Calabash
|
|
695
800
|
end
|
696
801
|
end
|
697
802
|
|
698
|
-
#
|
699
|
-
# e.g. the keyboard on
|
803
|
+
# Used for detecting keyboards that are not normally visible to calabash;
|
804
|
+
# e.g. the keyboard on the `MFMailComposeViewController`
|
700
805
|
#
|
701
|
-
#
|
702
|
-
#
|
806
|
+
# @note
|
807
|
+
# IMPORTANT this should only be used when the app does not respond to
|
808
|
+
# `keyboard_visible?`.
|
703
809
|
#
|
704
|
-
#
|
810
|
+
# @see #keyboard_visible?
|
811
|
+
#
|
812
|
+
# @raise [RuntimeError] if the app was not launched with instruments
|
705
813
|
def uia_keyboard_visible?
|
706
814
|
unless uia_available?
|
707
815
|
screenshot_and_raise 'only available if there is a run_loop i.e. the app was launched with Instruments'
|
@@ -710,13 +818,16 @@ module Calabash
|
|
710
818
|
not res.eql?(':nil')
|
711
819
|
end
|
712
820
|
|
713
|
-
#
|
714
|
-
# e.g. the keyboard on
|
821
|
+
# Waits for a keyboard that is not normally visible to calabash;
|
822
|
+
# e.g. the keyboard on `MFMailComposeViewController`.
|
823
|
+
#
|
824
|
+
# @note
|
825
|
+
# IMPORTANT this should only be used when the app does not respond to
|
826
|
+
# `keyboard_visible?`.
|
715
827
|
#
|
716
|
-
#
|
717
|
-
# <tt>keyboard_visible?</tt>
|
828
|
+
# @see #keyboard_visible?
|
718
829
|
#
|
719
|
-
#
|
830
|
+
# @raise [RuntimeError] if the app was not launched with instruments
|
720
831
|
def uia_wait_for_keyboard(opts={})
|
721
832
|
unless uia_available?
|
722
833
|
screenshot_and_raise 'only available if there is a run_loop i.e. the app was launched with Instruments'
|
@@ -735,18 +846,16 @@ module Calabash
|
|
735
846
|
end
|
736
847
|
end
|
737
848
|
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
# returns the the text in the first responder
|
849
|
+
# @!visibility private
|
850
|
+
# Returns the the text in the first responder.
|
742
851
|
#
|
743
|
-
#
|
852
|
+
# The first responder will be the UITextField or UITextView instance
|
744
853
|
# that is associated with the visible keyboard.
|
745
854
|
#
|
746
|
-
#
|
855
|
+
# Teturns empty string if no textField or textView elements are found to be
|
747
856
|
# the first responder.
|
748
857
|
#
|
749
|
-
#
|
858
|
+
# @raise [RuntimeError] if there is no visible keyboard
|
750
859
|
def _text_from_first_responder
|
751
860
|
raise 'there must be a visible keyboard' unless keyboard_visible?
|
752
861
|
|
@@ -755,7 +864,7 @@ module Calabash
|
|
755
864
|
return res.first unless res.empty?
|
756
865
|
end
|
757
866
|
#noinspection RubyUnnecessaryReturnStatement
|
758
|
-
return
|
867
|
+
return ''
|
759
868
|
end
|
760
869
|
|
761
870
|
end
|