calabash-cucumber 0.10.0.pre1 → 0.10.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- 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,7 +4,7 @@ module Calabash
|
|
4
4
|
module Cucumber
|
5
5
|
# KeychainHelpers provide a helpers to access the iOS keychain.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# ### Simulator Note
|
8
8
|
#
|
9
9
|
# When running on the simulator, the keychain is *not* sandboxed between
|
10
10
|
# applications like it is on a real device. These methods will return
|
@@ -12,18 +12,19 @@ module Calabash
|
|
12
12
|
# result in strange behavior if you aren't expecting it.
|
13
13
|
#
|
14
14
|
# @see http://goo.gl/JrFJMM Details about why some operations report
|
15
|
-
#
|
15
|
+
# `FAILURE` and what can be done on the client side mitigate.
|
16
16
|
#
|
17
17
|
# @see https://github.com/soffes/sskeychain SSKeychain
|
18
18
|
module KeychainHelpers
|
19
19
|
|
20
20
|
|
21
|
-
#
|
22
|
-
#
|
21
|
+
# @!visibility private
|
22
|
+
# Sends appropriately-configured `GET` request to the `keychain` server
|
23
|
+
# endpoint. Do not call this function directly; use one of the helper
|
23
24
|
# functions provided.
|
24
25
|
#
|
25
|
-
# @see keychain_accounts
|
26
|
-
# @see keychain_account_for_service
|
26
|
+
# @see #keychain_accounts
|
27
|
+
# @see #keychain_account_for_service
|
27
28
|
# @return [Array<Hash>] contents of the iOS keychain
|
28
29
|
# @param [Hash] options
|
29
30
|
# @raise [RuntimeError] if http request does not report success
|
@@ -37,18 +38,20 @@ module Calabash
|
|
37
38
|
res['results']
|
38
39
|
end
|
39
40
|
|
40
|
-
#
|
41
|
+
# Asks the keychain for all of the account records.
|
41
42
|
#
|
42
|
-
# The hash keys are defined by the
|
43
|
+
# The hash keys are defined by the `SSKeychain` library.
|
43
44
|
#
|
44
45
|
# @see https://github.com/soffes/sskeychain SSKeychain
|
45
46
|
#
|
46
47
|
# The following keys are the most commonly useful:
|
47
48
|
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
49
|
+
# ```
|
50
|
+
# svce #=> the service
|
51
|
+
# acct #=> the account (often a username)
|
52
|
+
# cdat #=> the creation date
|
53
|
+
# mdat #=> the last-modified date
|
54
|
+
# ```
|
52
55
|
#
|
53
56
|
# @raise [RuntimeError] if http request does not report success
|
54
57
|
# @return [Array<Hash>] of all account records saved in the iOS keychain.
|
@@ -56,43 +59,47 @@ module Calabash
|
|
56
59
|
_keychain_get
|
57
60
|
end
|
58
61
|
|
59
|
-
#
|
60
|
-
# filtered by
|
62
|
+
# Returns an list of all account records saved in the iOS keychain
|
63
|
+
# filtered by `service`.
|
61
64
|
#
|
62
|
-
# @see keychain_accounts
|
65
|
+
# @see #keychain_accounts
|
63
66
|
#
|
67
|
+
# @param [String] service the service whose accounts you are requesting
|
68
|
+
# @return [Array<Hash>] a list all account records filtered by `service`.
|
64
69
|
# @raise [RuntimeError] if http request does not report success
|
65
70
|
def keychain_accounts_for_service(service)
|
66
71
|
_keychain_get({:service => service})
|
67
72
|
end
|
68
73
|
|
69
|
-
#
|
74
|
+
# Ask the keychain for an account password.
|
70
75
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
76
|
+
# @note
|
77
|
+
# **IMPORTANT**
|
78
|
+
# On the XTC, the password cannot returned as plain text.
|
79
|
+
# When using this keychain_password in your steps you can condition on
|
80
|
+
# the XTC environment using `xamarin_test_cloud?`
|
75
81
|
#
|
76
|
-
# @see Calabash::Cucumber::EnvironmentHelpers
|
82
|
+
# @see Calabash::Cucumber::EnvironmentHelpers#xamarin_test_cloud?
|
77
83
|
#
|
78
84
|
# @raise [RuntimeError] if http request does not report success
|
79
|
-
# @raise [RuntimeError] if
|
85
|
+
# @raise [RuntimeError] if `service` and `account` pair does not contain
|
80
86
|
# a password
|
81
87
|
#
|
82
|
-
# @return [String,Array<Hash>] password stored in keychain for
|
83
|
-
# and
|
88
|
+
# @return [String,Array<Hash>] password stored in keychain for `service`
|
89
|
+
# and `account`. *NB* on the XTC this returns an Array with one Hash.
|
84
90
|
def keychain_password(service, account)
|
85
91
|
_keychain_get({:service => service, :account => account}).first
|
86
92
|
end
|
87
93
|
|
88
|
-
#
|
89
|
-
#
|
94
|
+
# @!visibility private
|
95
|
+
# Sends appropriately-configured `POST` request to the `keychain` server
|
96
|
+
# endpoint. Do not call this function directly; use one of the helper
|
90
97
|
# functions provided.
|
91
98
|
#
|
92
|
-
# @see keychain_clear
|
93
|
-
# @see keychain_clear_accounts_for_service
|
94
|
-
# @see keychain_delete_password
|
95
|
-
# @see keychain_set_password
|
99
|
+
# @see #keychain_clear
|
100
|
+
# @see #keychain_clear_accounts_for_service
|
101
|
+
# @see #keychain_delete_password
|
102
|
+
# @see #keychain_set_password
|
96
103
|
#
|
97
104
|
# @return [nil]
|
98
105
|
# @raise [RuntimeError] if http request does not report success
|
@@ -118,8 +125,9 @@ module Calabash
|
|
118
125
|
_keychain_post
|
119
126
|
end
|
120
127
|
|
121
|
-
# Clear all entries in the keychain restricted to a single
|
128
|
+
# Clear all entries in the keychain restricted to a single `service`.
|
122
129
|
#
|
130
|
+
# @param [String] service filters which accounts should be cleared.
|
123
131
|
# @return [nil]
|
124
132
|
#
|
125
133
|
# @raise [RuntimeError] if http request does not report success
|
@@ -127,9 +135,12 @@ module Calabash
|
|
127
135
|
_keychain_post({:service => service})
|
128
136
|
end
|
129
137
|
|
130
|
-
# Delete a single keychain record for the given
|
138
|
+
# Delete a single keychain record for the given `service` and `account`
|
131
139
|
# pair.
|
132
140
|
#
|
141
|
+
# @param [String] service filters which accounts should be cleared.
|
142
|
+
# @param [String] account filters which account to clear
|
143
|
+
#
|
133
144
|
# @raise [RuntimeError] if http request does not report success
|
134
145
|
def keychain_delete_password(service, account)
|
135
146
|
_keychain_post(:service => service, :account => account)
|
@@ -137,6 +148,9 @@ module Calabash
|
|
137
148
|
|
138
149
|
# Set the password for a given service and account pair.
|
139
150
|
#
|
151
|
+
# @param [String] service which service to update
|
152
|
+
# @param [String] account which account to update
|
153
|
+
# @param [String] password which password to set
|
140
154
|
# @return nil
|
141
155
|
#
|
142
156
|
# @raise [RuntimeError] if http request does not report success
|
@@ -3,26 +3,27 @@ require 'sim_launcher'
|
|
3
3
|
module Calabash
|
4
4
|
module Cucumber
|
5
5
|
|
6
|
-
#
|
6
|
+
# This module has been replaced by Simulator Launcher
|
7
7
|
#
|
8
|
-
# @deprecated Use the SimulatorLauncher class instead
|
9
|
-
# @since 0.9.169
|
8
|
+
# @deprecated 0.9.169 Use the SimulatorLauncher class instead.
|
10
9
|
module SimulatorHelper
|
11
10
|
|
12
|
-
#
|
11
|
+
# Quits the simulator.
|
13
12
|
#
|
14
|
-
#
|
13
|
+
# This has been deprecated, but it appears in legacy launch hooks.
|
15
14
|
#
|
16
|
-
#
|
15
|
+
# Use this pattern instead:
|
17
16
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
17
|
+
# ```
|
18
|
+
# at_exit do
|
19
|
+
# launcher = Calabash::Cucumber::Launcher.new
|
20
|
+
# if launcher.simulator_target?
|
21
|
+
# launcher.simulator_launcher.stop unless launcher.calabash_no_stop?
|
23
22
|
# end
|
23
|
+
# end
|
24
|
+
# ```
|
24
25
|
#
|
25
|
-
# @deprecated
|
26
|
+
# @deprecated 0.9.169 replaced with SimulatorLauncher.new().stop
|
26
27
|
def self.stop
|
27
28
|
unless ENV['CALABASH_NO_DEPRECATION'] == '1'
|
28
29
|
if RUBY_VERSION < '2.0'
|
@@ -7,50 +7,76 @@ require 'calabash-cucumber/utils/logging'
|
|
7
7
|
module Calabash
|
8
8
|
module Cucumber
|
9
9
|
|
10
|
-
#
|
10
|
+
# Acts as a bridge to the sim_launcher SimLauncher and SdkDetector classes.
|
11
|
+
#
|
12
|
+
# Runtime Environmental Variables
|
13
|
+
#
|
14
|
+
# * `PROJECT_DIR` (ENV['PWD']) - the path to the .xcproject directory
|
15
|
+
# * `DEVICE_ENDPOINT` (http://localhost:37265/) - the ip:port of the
|
16
|
+
# device under test
|
17
|
+
# * `CALABASH_VERSION_PATH` (version) - the path to server version route
|
18
|
+
# * `MAX_CONNECT_RETRY` (2) the number of times retry
|
19
|
+
# establishing a connection to the server.
|
20
|
+
# * `CONNECT_TIMEOUT` (30) how long to wait for the server before timing
|
21
|
+
# out
|
22
|
+
#
|
11
23
|
class SimulatorLauncher
|
12
24
|
include Calabash::Cucumber::Logging
|
13
25
|
|
14
|
-
#
|
15
|
-
# embedded calabash server
|
16
|
-
# todo is duplicated in Launcher class - consider exceptions.rb module
|
26
|
+
# Custom error indicating a timeout in launching and connecting to the
|
27
|
+
# embedded calabash server.
|
28
|
+
# @todo This is duplicated in Launcher class - consider exceptions.rb module.
|
17
29
|
class TimeoutErr < RuntimeError
|
18
30
|
end
|
19
31
|
|
20
|
-
#
|
32
|
+
# @!visibility private
|
33
|
+
# The file path to the default Xcode DerivedData directory.
|
21
34
|
DERIVED_DATA = File.expand_path('~/Library/Developer/Xcode/DerivedData')
|
22
35
|
|
23
|
-
#
|
36
|
+
# @!visibility private
|
37
|
+
# REGEX for finding application Info.plist.
|
24
38
|
DEFAULT_DERIVED_DATA_INFO = File.expand_path("#{DERIVED_DATA}/*/info.plist")
|
25
39
|
|
26
|
-
#
|
27
|
-
#
|
40
|
+
# @!visibility private
|
41
|
+
# If `CONNECT_TIMEOUT` is not set, wait this long for the app to launch
|
42
|
+
# in the simulator before retrying.
|
28
43
|
DEFAULT_SIM_WAIT = 30
|
29
44
|
|
30
|
-
#
|
45
|
+
# If `MAX_CONNECT_RETRY` is not set, try to launch the app this many times
|
31
46
|
# in the simulator before giving up
|
32
47
|
DEFAULT_SIM_RETRY = 2
|
33
48
|
|
34
|
-
#
|
49
|
+
# @!visibility private
|
50
|
+
# An instance of Calabash::Cucumber::Device.
|
35
51
|
attr_accessor :device
|
36
52
|
|
37
|
-
#
|
53
|
+
# @!visibility private
|
54
|
+
# An instance of SimLauncher::Simulator.
|
38
55
|
attr_accessor :simulator
|
39
56
|
|
40
|
-
#
|
57
|
+
# @!visibility private
|
58
|
+
# An instance of SimLauncher::SdkDetector.
|
41
59
|
attr_accessor :sdk_detector
|
42
60
|
|
43
|
-
#
|
44
|
-
# launch
|
61
|
+
# @!visibility private
|
62
|
+
# The launch args passed from Calabash::Cucumber::Launcher to the launch
|
63
|
+
# and relaunch methods.
|
45
64
|
attr_accessor :launch_args
|
46
65
|
|
47
|
-
#
|
66
|
+
# Creates a new instance an sets the :simulator and :sdk_detector attributes.
|
48
67
|
def initialize
|
49
68
|
@simulator = SimLauncher::Simulator.new
|
50
69
|
@sdk_detector = SimLauncher::SdkDetector.new()
|
51
70
|
end
|
52
71
|
|
53
|
-
#
|
72
|
+
# Stops (quits) the simulator.
|
73
|
+
def stop
|
74
|
+
self.simulator.quit_simulator
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# @!visibility private
|
79
|
+
# Uses heuristics to deduce the derived data directory for the project
|
54
80
|
# so the path to the app bundle (.app) can be detected.
|
55
81
|
# @return [String] absolute path to derived data directory
|
56
82
|
# @raise [RuntimeError] if the derived data directory cannot be found
|
@@ -134,21 +160,25 @@ module Calabash
|
|
134
160
|
end
|
135
161
|
end
|
136
162
|
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
163
|
+
# @!visibility private
|
164
|
+
# Returns the absolute path to the project directory.
|
165
|
+
#
|
166
|
+
# Unless `PROJECT_DIR` is defined, returns the absolute path to the current
|
167
|
+
# directory.
|
168
|
+
#
|
140
169
|
# @return [String] absolute path to the project directory
|
141
|
-
# todo migrate PROJECT_DIR to environment_helpers.rb
|
170
|
+
# @todo migrate `PROJECT_DIR` to environment_helpers.rb
|
142
171
|
def project_dir
|
143
172
|
File.expand_path(ENV['PROJECT_DIR'] || Dir.pwd)
|
144
173
|
end
|
145
174
|
|
146
|
-
#
|
175
|
+
# @!visibility private
|
176
|
+
# Attempts to deduce the app bundle path
|
147
177
|
# @param [String] path NEEDS DOCUMENTATION
|
148
178
|
# @param [String] device_build_dir NEEDS DOCUMENTATION
|
149
|
-
# @return [String] absolute path to app bundle (.app)
|
150
|
-
#
|
151
|
-
# todo methods should not use 2 optional arguments
|
179
|
+
# @return [String] absolute path to app bundle (.app) or `nil` if the
|
180
|
+
# app bundle cannot be found.
|
181
|
+
# @todo methods should not use 2 optional arguments
|
152
182
|
def detect_app_bundle(path=nil,device_build_dir='iPhoneSimulator')
|
153
183
|
begin
|
154
184
|
app_bundle_or_raise(path,device_build_dir)
|
@@ -157,12 +187,13 @@ module Calabash
|
|
157
187
|
end
|
158
188
|
end
|
159
189
|
|
160
|
-
#
|
190
|
+
# @!visibility private
|
191
|
+
# Attempts to deduce the path the to the app bundle (.app).
|
161
192
|
# @param [String] path NEEDS DOCUMENTATION
|
162
193
|
# @param [String] device_build_dir NEEDS DOCUMENTATION
|
163
194
|
# @return [String] absolute path to app bundle (.app)
|
164
195
|
# @raise [RuntimeError] if app bundle (.app) cannot be found
|
165
|
-
# todo methods should not use 2 optional arguments
|
196
|
+
# @todo methods should not use 2 optional arguments
|
166
197
|
def app_bundle_or_raise(path=nil, device_build_dir='iPhoneSimulator')
|
167
198
|
path = File.expand_path(path) if path
|
168
199
|
|
@@ -226,13 +257,15 @@ module Calabash
|
|
226
257
|
bundle_path
|
227
258
|
end
|
228
259
|
|
229
|
-
#
|
230
|
-
#
|
260
|
+
# @!visibility private
|
261
|
+
# Is this a Xamarin IDE project?
|
262
|
+
# @return [Boolean] true if the project is a Xamarin IDE project
|
231
263
|
def xamarin_project?
|
232
264
|
xamarin_ios_csproj_path != nil
|
233
265
|
end
|
234
266
|
|
235
|
-
#
|
267
|
+
# @!visibility private
|
268
|
+
# Path to the Xamarin IDE project.
|
236
269
|
# @return [String] absolute path to the Xamarin IDE project
|
237
270
|
def xamarin_ios_csproj_path
|
238
271
|
solution_path = Dir['*.sln'].first
|
@@ -268,20 +301,22 @@ module Calabash
|
|
268
301
|
|
269
302
|
end
|
270
303
|
|
271
|
-
#
|
272
|
-
#
|
304
|
+
# @!visibility private
|
305
|
+
# Is this the Xamarin iOS bin directory?
|
306
|
+
# @return [Boolean] true if this is the Xamarin iOS bin directory
|
273
307
|
def xamarin_ios_bin_dir?(bin_dir)
|
274
308
|
File.directory?(bin_dir) &&
|
275
309
|
(File.directory?(File.join(bin_dir,'iPhoneSimulator')) ||
|
276
310
|
File.directory?(File.join(bin_dir,'iPhone')))
|
277
311
|
end
|
278
312
|
|
279
|
-
#
|
280
|
-
#
|
313
|
+
# @!visibility private
|
314
|
+
# Attempts to deduce the path to the app bundle path (*.app) using
|
315
|
+
# heuristics and checking for executables linked with the Calabash server.
|
281
316
|
#
|
282
317
|
# @param [String] device_build_dir NEEDS DOCUMENTATION
|
283
|
-
# @return [String] absolute path the app bundle .app
|
284
|
-
#
|
318
|
+
# @return [String] absolute path the app bundle .app or `nil` if the
|
319
|
+
# the app bundle cannot be found.
|
285
320
|
def bundle_path_from_xamarin_project(device_build_dir='iPhoneSimulator')
|
286
321
|
ios_project_path = xamarin_ios_csproj_path
|
287
322
|
conf_glob = File.join(ios_project_path,'bin',device_build_dir,'*')
|
@@ -299,11 +334,12 @@ module Calabash
|
|
299
334
|
Dir[File.join(bundle_path,'*.app')].first if bundle_path
|
300
335
|
end
|
301
336
|
|
302
|
-
#
|
337
|
+
# @!visibility private
|
338
|
+
# Searches `d` for a file linked with Calabash server.
|
303
339
|
# @param [String] d path to a directory
|
304
|
-
# @return [Boolean] true
|
340
|
+
# @return [Boolean] true if there is a file that is linked with the
|
305
341
|
# Calabash server
|
306
|
-
# todo why are we not grep'ing for executable files? see server_version_from_bundle
|
342
|
+
# @todo why are we not grep'ing for executable files? see server_version_from_bundle
|
307
343
|
def linked_with_calabash?(d)
|
308
344
|
skipped_formats = ['.png', '.jpg', '.jpeg', '.plist', '.nib', '.lproj']
|
309
345
|
dir = File.expand_path(d)
|
@@ -322,28 +358,30 @@ module Calabash
|
|
322
358
|
false
|
323
359
|
end
|
324
360
|
|
325
|
-
#
|
326
|
-
#
|
327
|
-
# @return [
|
328
|
-
# linked with Calabash server
|
361
|
+
# !@visibility private
|
362
|
+
# Finds the preferred(?) directory.
|
363
|
+
# @return [String] The first path in `sim_dirs` that contains a binary
|
364
|
+
# linked with Calabash server. Returns `nil` if there is no path in
|
365
|
+
# `sim_dirs` that contains a binary linked with Calabash server.
|
329
366
|
# @param [Array<String>] sim_dirs eke! why sim_dirs? why not a list of any directories?
|
330
|
-
# todo find_preferred_dir is a bad name - preferred for what?
|
331
|
-
# todo sim_dirs arg is a bad name - we can be iterating over any directory
|
367
|
+
# @todo find_preferred_dir is a bad name - preferred for what?
|
368
|
+
# @todo sim_dirs arg is a bad name - we can be iterating over any directory
|
332
369
|
def find_preferred_dir(sim_dirs)
|
333
370
|
sim_dirs.find do |d|
|
334
371
|
linked_with_calabash?(d)
|
335
372
|
end
|
336
373
|
end
|
337
374
|
|
338
|
-
|
339
|
-
#
|
375
|
+
# !@visibility private
|
376
|
+
# Ping the version route of the calabash server embedded in the app,
|
340
377
|
#
|
341
|
-
#
|
378
|
+
# @note
|
379
|
+
# Has the side effect of setting self.device attribute if successful.
|
342
380
|
#
|
343
381
|
# @return [String] returns the server status - '200' is a success
|
344
|
-
# todo migrate DEVICE_ENDPOINT to environment_helpers
|
345
|
-
# todo migrate CALABASH_VERSION_PATH to environment_helpers
|
346
|
-
# todo this is an exact duplicate of Launcher ping method
|
382
|
+
# @todo migrate DEVICE_ENDPOINT to environment_helpers
|
383
|
+
# @todo migrate CALABASH_VERSION_PATH to environment_helpers
|
384
|
+
# @todo this is an exact duplicate of Launcher ping method
|
347
385
|
def ping_app
|
348
386
|
url = URI.parse(ENV['DEVICE_ENDPOINT']|| 'http://localhost:37265/')
|
349
387
|
if full_console_logging?
|
@@ -374,21 +412,23 @@ module Calabash
|
|
374
412
|
status
|
375
413
|
end
|
376
414
|
|
377
|
-
#
|
415
|
+
# @!visibility private
|
416
|
+
# Attempts to connect to launch the app and connect to the embedded
|
378
417
|
# calabash server.
|
379
418
|
#
|
380
|
-
#
|
419
|
+
# @note To change the number of times launching is attempted set
|
420
|
+
# `MAX_CONNECT_RETRY`.
|
381
421
|
#
|
382
|
-
#
|
422
|
+
# @note To change the relaunch timeout set `CONNECT_TIMEOUT`.
|
383
423
|
#
|
384
424
|
# @param [String] app_bundle_path path to the .app that should be launched
|
385
425
|
# @param [String] sdk 6.0.3, 6.1. if nil latest SDK will be used
|
386
|
-
# @param [String] device_family {iphone | ipad}
|
426
|
+
# @param [String] device_family `{iphone | ipad}`
|
387
427
|
# @param [Hash] args eke! not used (see todo)
|
388
428
|
#
|
389
429
|
# @raise [TimeoutErr] if app cannot be launched in the simulator
|
390
|
-
# todo nearly a duplicate of Launcher ensure_connectivity
|
391
|
-
# todo args was originally intended to be the args passed to the application @ launch
|
430
|
+
# @todo nearly a duplicate of Launcher ensure_connectivity
|
431
|
+
# @todo args was originally intended to be the args passed to the application @ launch
|
392
432
|
def ensure_connectivity(app_bundle_path, sdk, device_family, args = nil)
|
393
433
|
begin
|
394
434
|
# todo should get the retry could from the args
|
@@ -439,12 +479,14 @@ module Calabash
|
|
439
479
|
end
|
440
480
|
end
|
441
481
|
|
442
|
-
#
|
482
|
+
# @!visibility private
|
483
|
+
# Launches the app.
|
484
|
+
#
|
443
485
|
# @param [String] app_bundle_path path to the .app that should be launched
|
444
486
|
# @param [String] sdk 6.0.3, 6.1. if nil latest SDK will be used
|
445
|
-
# @param [String] device_family {iphone | ipad}
|
446
|
-
# @param [Hash] args eke! not used
|
447
|
-
# todo args was originally intended to be the args passed to the application @ launch
|
487
|
+
# @param [String] device_family `{iphone | ipad}`
|
488
|
+
# @param [Hash] args eke! not used
|
489
|
+
# @todo args was originally intended to be the args passed to the application @ launch
|
448
490
|
def launch(app_bundle_path, sdk, device_family, args = nil)
|
449
491
|
# cached but not used
|
450
492
|
self.launch_args = args
|
@@ -455,15 +497,16 @@ module Calabash
|
|
455
497
|
simulator
|
456
498
|
end
|
457
499
|
|
458
|
-
#
|
500
|
+
# @!visibility private
|
501
|
+
# Relaunches the app in the simulator.
|
459
502
|
#
|
460
503
|
# @param [String] app_path the path to the .app
|
461
504
|
# @param [String] sdk eg. 6.0.3, 6.1
|
462
505
|
# @param [Hash] args the only option we are interested in is :device
|
463
506
|
#
|
464
|
-
# todo args was originally intended to be the args passed to the application @ launch
|
465
|
-
# todo it is _very_ likely that args[:app] == app_path so we might be able
|
466
|
-
#
|
507
|
+
# @todo args was originally intended to be the args passed to the application @ launch
|
508
|
+
# @todo it is _very_ likely that args[:app] == app_path so we might be able
|
509
|
+
# to eliminate an argument
|
467
510
|
def relaunch(app_path, sdk, args)
|
468
511
|
app_bundle_path = app_bundle_or_raise(app_path)
|
469
512
|
|
@@ -488,30 +531,21 @@ module Calabash
|
|
488
531
|
ensure_connectivity(app_bundle_path, _sdk, device_family, args)
|
489
532
|
end
|
490
533
|
|
491
|
-
#
|
492
|
-
def stop
|
493
|
-
self.simulator.quit_simulator
|
494
|
-
end
|
495
|
-
|
496
|
-
|
497
|
-
# @deprecated Calabash::Cucumber::Launcher.launcher.device instance methods
|
498
|
-
# @since 0.9.169
|
534
|
+
# @deprecated 0.9.169 Calabash::Cucumber::Launcher.launcher.device instance methods
|
499
535
|
# @raise [NotImplementedError] no longer implemented
|
500
536
|
def get_version
|
501
537
|
_deprecated('0.9.169', 'use an instance Device class instead', :warn)
|
502
538
|
raise(NotImplementedError, 'this method has been deprecated')
|
503
539
|
end
|
504
540
|
|
505
|
-
# @deprecated Calabash::Cucumber::Launcher.launcher.device instance methods
|
506
|
-
# @since 0.9.169
|
541
|
+
# @deprecated 0.9.169 Calabash::Cucumber::Launcher.launcher.device instance methods
|
507
542
|
# @raise [NotImplementedError] no longer implemented
|
508
543
|
def ios_version
|
509
544
|
_deprecated('0.9.169', 'use an instance Device class instead', :warn)
|
510
545
|
raise(NotImplementedError, 'this method has been deprecated')
|
511
546
|
end
|
512
547
|
|
513
|
-
# @deprecated use Calabash::Cucumber::Launcher.launcher.ios_major_version
|
514
|
-
# @since 0.9.169
|
548
|
+
# @deprecated 0.9.169 use Calabash::Cucumber::Launcher.launcher.ios_major_version
|
515
549
|
# @raise [NotImplementedError] no longer implemented
|
516
550
|
def ios_major_version
|
517
551
|
_deprecated('0.9.169', 'use an instance Device class instead', :warn)
|
@@ -521,8 +555,7 @@ module Calabash
|
|
521
555
|
|
522
556
|
# noinspection RubyUnusedLocalVariable
|
523
557
|
|
524
|
-
# @deprecated version checking is done in Launcher
|
525
|
-
# @since 0.9.169
|
558
|
+
# @deprecated 0.9.169 version checking is done in Launcher
|
526
559
|
# @raise [NotImplementedError] no longer implemented
|
527
560
|
def version_check(version)
|
528
561
|
_deprecated('0.9.169', 'check is now done in Launcher', :warn)
|