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
@@ -2,29 +2,36 @@
|
|
2
2
|
module Calabash
|
3
3
|
module Cucumber
|
4
4
|
|
5
|
-
#
|
5
|
+
# Internal logging methods for the calabash-ios gem.
|
6
6
|
module Logging
|
7
7
|
|
8
|
-
#
|
8
|
+
# @!visibility private
|
9
|
+
# Has full console logging been enabled?
|
9
10
|
#
|
10
|
-
#
|
11
|
+
# The return value is controlled by the `CALABASH_FULL_CONSOLE_OUTPUT`
|
12
|
+
# environment variable.
|
13
|
+
#
|
14
|
+
# This is considered one level above debug logging - maybe we should call
|
11
15
|
# the info log level.
|
12
16
|
#
|
13
|
-
# @return [Boolean]
|
14
|
-
# '1'
|
17
|
+
# @return [Boolean] Returns `true` if full logging has been enabled.
|
15
18
|
def full_console_logging?
|
16
19
|
ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
|
17
20
|
end
|
18
21
|
|
19
|
-
#
|
22
|
+
# @!visibility private
|
23
|
+
# Has debug logging been enabled?
|
24
|
+
#
|
25
|
+
# The return value is controlled by the `DEBUG` environment variable.
|
20
26
|
#
|
21
|
-
# @return [Boolean]
|
27
|
+
# @return [Boolean] Returns `true` if debug logging has been enabled.
|
22
28
|
def debug_logging?
|
23
29
|
ENV['DEBUG'] == '1'
|
24
30
|
end
|
25
31
|
|
26
|
-
#
|
32
|
+
# Prints a blue warning message.
|
27
33
|
# @param [String] msg the message to print
|
34
|
+
# @return [void]
|
28
35
|
def calabash_warn(msg)
|
29
36
|
begin
|
30
37
|
warn "\033[34m\nWARN: #{msg}\033[0m"
|
@@ -33,8 +40,9 @@ module Calabash
|
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
36
|
-
#
|
43
|
+
# Prints a green info message.
|
37
44
|
# @param [String] msg the message to print
|
45
|
+
# @return [void]
|
38
46
|
def calabash_info(msg)
|
39
47
|
begin
|
40
48
|
puts "\033[32m\nINFO: #{msg}\033[0m"
|
@@ -43,27 +51,33 @@ module Calabash
|
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
46
|
-
#
|
54
|
+
# @!visibility private
|
55
|
+
# Controls printing of deprecation warnings.
|
47
56
|
#
|
48
|
-
#
|
57
|
+
# To inhibit deprecation message set this to '1'
|
49
58
|
#
|
50
|
-
#
|
59
|
+
# Inhibiting deprecation messages is not recommend.
|
51
60
|
CALABASH_NO_DEPRECATION = ENV['CALABASH_NO_DEPRECATION'] || '0'
|
52
61
|
|
53
|
-
#
|
54
|
-
#
|
62
|
+
# @!visibility private
|
63
|
+
# Have deprecation warnings been turned off?
|
64
|
+
#
|
65
|
+
# The return value is controlled but the `CALABASH_NO_DEPRECATION`
|
66
|
+
# environment variable.
|
55
67
|
def no_deprecation_warnings?
|
56
68
|
ENV['CALABASH_NO_DEPRECATION'] == '1'
|
57
69
|
end
|
58
70
|
|
59
|
-
#
|
71
|
+
# @!visibility private
|
72
|
+
# Prints a deprecated message that includes the line number.
|
60
73
|
#
|
61
|
-
#
|
74
|
+
# If deprecation warns have been turned off this method does nothing.
|
62
75
|
#
|
63
76
|
# @param [String] version indicates when the feature was deprecated
|
64
77
|
# @param [String] msg deprecation message (possibly suggesting alternatives)
|
65
78
|
# @param [Symbol] type { :warn | :pending } - :pending will raise a
|
66
79
|
# cucumber pending exception
|
80
|
+
# @return [void]
|
67
81
|
def _deprecated(version, msg, type)
|
68
82
|
allowed = [:pending, :warn]
|
69
83
|
unless allowed.include?(type)
|
@@ -5,17 +5,17 @@ module Calabash
|
|
5
5
|
|
6
6
|
include Calabash::Cucumber::Logging
|
7
7
|
|
8
|
-
#
|
8
|
+
# @!visibility private
|
9
|
+
# A module for reading and writing property list values.
|
9
10
|
module PlistBuddy
|
10
11
|
|
11
|
-
#
|
12
|
+
# Reads key from file and returns the result.
|
12
13
|
# @param [String] key the key to inspect (may not be nil or empty)
|
13
14
|
# @param [String] file the plist to read
|
14
15
|
# @param [Hash] opts options for controlling execution
|
15
16
|
# @option opts [Boolean] :verbose (false) controls log level
|
16
|
-
# @return [
|
17
|
-
# @
|
18
|
-
# @raise [ArgumentError] if nil or empty +key+
|
17
|
+
# @return [String] the value of the key
|
18
|
+
# @raise [ArgumentError] if nil or empty key
|
19
19
|
def plist_read(key, file, opts={})
|
20
20
|
if key.nil? or key.length == 0
|
21
21
|
raise(ArgumentError, "key '#{key}' must not be nil or empty")
|
@@ -29,18 +29,17 @@ module Calabash
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
#
|
32
|
+
# Checks if the key exists in plist.
|
33
33
|
# @param [String] key the key to inspect (may not be nil or empty)
|
34
34
|
# @param [String] file the plist to read
|
35
35
|
# @param [Hash] opts options for controlling execution
|
36
36
|
# @option opts [Boolean] :verbose (false) controls log level
|
37
|
-
# @return [Boolean] true
|
37
|
+
# @return [Boolean] true if the key exists in plist file
|
38
38
|
def plist_key_exists?(key, file, opts={})
|
39
39
|
plist_read(key, file, opts) != nil
|
40
|
-
|
41
40
|
end
|
42
41
|
|
43
|
-
#
|
42
|
+
# Replaces or creates the value of key in the file.
|
44
43
|
#
|
45
44
|
# @param [String] key the key to set (may not be nil or empty)
|
46
45
|
# @param [String] type the plist type (used only when adding a value)
|
@@ -48,8 +47,8 @@ module Calabash
|
|
48
47
|
# @param [String] file the plist to read
|
49
48
|
# @param [Hash] opts options for controlling execution
|
50
49
|
# @option opts [Boolean] :verbose (false) controls log level
|
51
|
-
# @return [Boolean] true
|
52
|
-
# @raise [ArgumentError] if nil or empty
|
50
|
+
# @return [Boolean] true if the operation was successful
|
51
|
+
# @raise [ArgumentError] if nil or empty key
|
53
52
|
def plist_set(key, type, value, file, opts={})
|
54
53
|
default_opts = {:verbose => false}
|
55
54
|
merged = default_opts.merge(opts)
|
@@ -72,7 +71,7 @@ module Calabash
|
|
72
71
|
res == ''
|
73
72
|
end
|
74
73
|
|
75
|
-
|
74
|
+
private
|
76
75
|
|
77
76
|
# returns the path to the PlistBuddy executable
|
78
77
|
# @return [String] path to PlistBuddy
|
@@ -80,14 +79,14 @@ module Calabash
|
|
80
79
|
'/usr/libexec/PlistBuddy'
|
81
80
|
end
|
82
81
|
|
83
|
-
#
|
82
|
+
# Executes cmd as a shell command and returns the result.
|
84
83
|
#
|
85
84
|
# @param [String] cmd shell command to execute
|
86
85
|
# @param [Hash] opts options for controlling execution
|
87
86
|
# @option opts [Boolean] :verbose (false) controls log level
|
88
87
|
# @return [Boolean] if command was successful
|
89
|
-
# @return [String] if :print'ing result, the value of the key
|
90
|
-
#
|
88
|
+
# @return [String] if :print'ing result, the value of the key - if there
|
89
|
+
# is an error, the output from stderr
|
91
90
|
def execute_plist_cmd(cmd, opts={})
|
92
91
|
default_opts = {:verbose => false}
|
93
92
|
merged = default_opts.merge(opts)
|
@@ -108,7 +107,7 @@ module Calabash
|
|
108
107
|
res
|
109
108
|
end
|
110
109
|
|
111
|
-
#
|
110
|
+
# Composes a PlistBuddy command that can be executed as a shell command.
|
112
111
|
#
|
113
112
|
# @param [Symbol] type should be one of [:print, :set, :add]
|
114
113
|
#
|
@@ -119,9 +118,9 @@ module Calabash
|
|
119
118
|
#
|
120
119
|
# @param [String] file the plist file to interact with (must exist)
|
121
120
|
#
|
122
|
-
# @raise [RuntimeError] if
|
123
|
-
# @raise [ArgumentError] when invalid
|
124
|
-
# @raise [ArgumentError] when
|
121
|
+
# @raise [RuntimeError] if file does not exist
|
122
|
+
# @raise [ArgumentError] when invalid type is passed
|
123
|
+
# @raise [ArgumentError] when args_hash does not include required key/value pairs
|
125
124
|
#
|
126
125
|
# @return [String] a shell-ready PlistBuddy command
|
127
126
|
def build_plist_cmd(type, args_hash, file)
|
@@ -6,39 +6,42 @@ require 'cfpropertylist'
|
|
6
6
|
module Calabash
|
7
7
|
module Cucumber
|
8
8
|
|
9
|
-
# methods for
|
9
|
+
# Public methods for common simulator tasks and private methods for
|
10
|
+
# enabling accessibility on the simulator.
|
10
11
|
module SimulatorAccessibility
|
11
12
|
|
12
13
|
include Calabash::Cucumber::XcodeTools
|
13
14
|
include Calabash::Cucumber::PlistBuddy
|
14
15
|
|
15
|
-
#
|
16
|
+
# Quits the iOS Simulator.
|
16
17
|
#
|
17
18
|
# ATM there can only be only simulator open at a time, so simply doing
|
18
19
|
# what the sim_launcher gem does:
|
19
20
|
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
21
|
+
# ```
|
22
|
+
# def quit_simulator
|
23
|
+
# `echo 'application "iPhone Simulator" quit' | osascript`
|
24
|
+
# end
|
25
|
+
# ```
|
23
26
|
#
|
24
27
|
# works. I am not sure if we will ever be able to launch more than one
|
25
28
|
# simulator, but in case we can, this method will quit the simulator
|
26
|
-
# that is indicated by
|
29
|
+
# that is indicated by `xcode-select` or `DEVELOPER_DIR`.
|
27
30
|
def quit_simulator
|
28
31
|
dev_dir = xcode_developer_dir
|
29
32
|
system "/usr/bin/osascript -e 'tell application \"#{dev_dir}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app\" to quit'"
|
30
33
|
end
|
31
34
|
|
32
|
-
#
|
35
|
+
# Launches the iOS Simulator indicated by `xcode-select` or `DEVELOPER_DIR`.
|
33
36
|
def launch_simulator
|
34
37
|
dev_dir = xcode_developer_dir
|
35
38
|
system "open -a \"#{dev_dir}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app\""
|
36
39
|
end
|
37
40
|
|
38
|
-
#
|
41
|
+
# Resets the simulator content and settings. It is analogous to touching
|
39
42
|
# the menu item.
|
40
43
|
#
|
41
|
-
#
|
44
|
+
# It works by deleting the following directories:
|
42
45
|
#
|
43
46
|
# * ~/Library/Application Support/iPhone Simulator/Library
|
44
47
|
# * ~/Library/Application Support/iPhone Simulator/Library/<sdk>[-64]
|
@@ -78,10 +81,11 @@ module Calabash
|
|
78
81
|
end
|
79
82
|
end
|
80
83
|
|
81
|
-
#
|
84
|
+
# @!visibility private
|
85
|
+
# Enables accessibility on any existing iOS Simulator by adjusting the
|
82
86
|
# simulator's Library/Preferences/com.apple.Accessibility.plist contents.
|
83
87
|
#
|
84
|
-
#
|
88
|
+
# A simulator 'exists' if has an Application Support directory. for
|
85
89
|
# example, the 6.1, 7.0.3-64, and 7.1 simulators exist if the following
|
86
90
|
# directories are present:
|
87
91
|
#
|
@@ -89,15 +93,15 @@ module Calabash
|
|
89
93
|
# ~/Library/Application Support/iPhone Simulator/Library/7.0.3-64
|
90
94
|
# ~/Library/Application Support/iPhone Simulator/Library/7.1
|
91
95
|
#
|
92
|
-
#
|
96
|
+
# A simulator is 'possible' if the SDK is available in the Xcode version.
|
93
97
|
#
|
94
|
-
#
|
98
|
+
# This method merges (uniquely) the possible and existing SDKs.
|
95
99
|
#
|
96
|
-
#
|
100
|
+
# This method also hides the AXInspector.
|
97
101
|
#
|
98
102
|
# @param [Hash] opts controls the behavior of the method
|
99
103
|
# @option opts [Boolean] :verbose controls logging output
|
100
|
-
# @return [Boolean] true
|
104
|
+
# @return [Boolean] true if enabling accessibility worked on all sdk
|
101
105
|
# directories
|
102
106
|
def enable_accessibility_on_simulators(opts={})
|
103
107
|
possible = possible_simulator_support_sdk_dirs
|
@@ -111,17 +115,18 @@ module Calabash
|
|
111
115
|
|
112
116
|
@private
|
113
117
|
|
114
|
-
#
|
115
|
-
#
|
118
|
+
# @!visibility private
|
119
|
+
# Enables accessibility on the simulator indicated by `sim_app_support_sdk_dir.`
|
116
120
|
#
|
117
|
-
#
|
121
|
+
# @note This will quit the simulator.
|
118
122
|
#
|
123
|
+
# @example
|
119
124
|
# path = '/6.1'
|
120
125
|
# enable_accessibility_in_sdk_dir(path)
|
121
126
|
#
|
122
|
-
#
|
127
|
+
# This method also hides the AXInspector.
|
123
128
|
#
|
124
|
-
#
|
129
|
+
# If the Library/Preferences/com.apple.Accessibility.plist does not exist
|
125
130
|
# this method will create a Library/Preferences/com.apple.Accessibility.plist
|
126
131
|
# that (oddly) the Simulator will _not_ overwrite.
|
127
132
|
#
|
@@ -132,7 +137,7 @@ module Calabash
|
|
132
137
|
#
|
133
138
|
# @param [Hash] opts controls the behavior of the method
|
134
139
|
# @option opts [Boolean] :verbose controls logging output
|
135
|
-
# @return [Boolean]
|
140
|
+
# @return [Boolean] if the plist exists and the plist was successfully
|
136
141
|
# updated.
|
137
142
|
def enable_accessibility_in_sdk_dir(sim_app_support_sdk_dir, opts={})
|
138
143
|
default_opts = {:verbose => false}
|
@@ -182,7 +187,8 @@ module Calabash
|
|
182
187
|
end
|
183
188
|
|
184
189
|
|
185
|
-
#
|
190
|
+
# @!visibility private
|
191
|
+
# A hash table of the accessibility properties that control whether or not
|
186
192
|
# accessibility is enabled and whether the AXInspector is visible.
|
187
193
|
# @return [Hash] table of accessibility properties found in the
|
188
194
|
# Library/Preferences/com.apple.Accessibility.plist
|
@@ -220,22 +226,25 @@ module Calabash
|
|
220
226
|
}
|
221
227
|
end
|
222
228
|
|
223
|
-
#
|
229
|
+
# @!visibility private
|
230
|
+
# The absolute path to the iPhone Simulator Application Support directory.
|
224
231
|
# @return [String] absolute path
|
225
232
|
def simulator_app_support_dir
|
226
233
|
File.expand_path('~/Library/Application Support/iPhone Simulator')
|
227
234
|
end
|
228
235
|
|
229
|
-
#
|
236
|
+
# @!visibility private
|
237
|
+
# The absolute path to the SDK's com.apple.Accessibility.plist file.
|
230
238
|
# @param [String] sdk_dir base path the SDK directory
|
231
239
|
# @return [String] an absolute path
|
232
240
|
def plist_path_with_sdk_dir(sdk_dir)
|
233
241
|
File.expand_path("#{sdk_dir}/Library/Preferences/com.apple.Accessibility.plist")
|
234
242
|
end
|
235
243
|
|
236
|
-
#
|
244
|
+
# @!visibility private
|
245
|
+
# Returns a list of absolute paths the existing simulator directories.
|
237
246
|
#
|
238
|
-
#
|
247
|
+
# A simulator 'exists' if has an Application Support directory. for
|
239
248
|
# example, the 6.1, 7.0.3-64, and 7.1 simulators exist if the following
|
240
249
|
# directories are present:
|
241
250
|
#
|
@@ -251,13 +260,14 @@ module Calabash
|
|
251
260
|
}
|
252
261
|
end
|
253
262
|
|
254
|
-
#
|
263
|
+
# @!visibility private
|
264
|
+
# Returns a list of possible SDKs per Xcode version.
|
255
265
|
#
|
256
|
-
#
|
266
|
+
# It is not enough to ask for the available sdks because of the new 64-bit
|
257
267
|
# variants that started to appear Xcode 5 and the potential for patch level
|
258
268
|
# versions.
|
259
269
|
#
|
260
|
-
#
|
270
|
+
# Unfortunately, this method will need be maintained per Xcode version.
|
261
271
|
#
|
262
272
|
# @return [Array<String>] ex. ['6.1', '7.1', '7.0.3', '7.0.3-64']
|
263
273
|
def possible_simulator_sdks
|
@@ -290,7 +300,8 @@ module Calabash
|
|
290
300
|
(available - ['7.0']).uniq.sort
|
291
301
|
end
|
292
302
|
|
293
|
-
#
|
303
|
+
# @!visibility private
|
304
|
+
# Return absolute paths to possible simulator support sdk dirs.
|
294
305
|
#
|
295
306
|
# these directories may or may not exist
|
296
307
|
# @return [Array<String>] an array of absolute paths
|
@@ -3,15 +3,21 @@ require 'open3'
|
|
3
3
|
module Calabash
|
4
4
|
module Cucumber
|
5
5
|
|
6
|
-
#
|
6
|
+
# @!visibility private
|
7
|
+
# Methods for interacting with the xcode tools.
|
7
8
|
module XcodeTools
|
8
9
|
|
9
|
-
#
|
10
|
+
# Returns the path to the current developer directory.
|
10
11
|
#
|
12
|
+
# From the man pages:
|
13
|
+
#
|
14
|
+
# ```
|
11
15
|
# $ man xcode-select
|
12
16
|
# DEVELOPER_DIR
|
13
|
-
# Overrides the active developer directory. When DEVELOPER_DIR is set,
|
14
|
-
# will be used instead of the system-wide active developer
|
17
|
+
# Overrides the active developer directory. When DEVELOPER_DIR is set,
|
18
|
+
# its value will be used instead of the system-wide active developer
|
19
|
+
# directory.
|
20
|
+
#```
|
15
21
|
#
|
16
22
|
# @return [String] path to current developer directory
|
17
23
|
def xcode_developer_dir
|
@@ -21,17 +27,22 @@ module Calabash
|
|
21
27
|
`xcode-select --print-path`.chomp
|
22
28
|
end
|
23
29
|
|
24
|
-
#
|
30
|
+
# Returns the path to the current developer `usr/bin` directory.
|
25
31
|
# @return [String] path to the current xcode binaries
|
26
32
|
def xcode_bin_dir
|
27
|
-
"#{xcode_developer_dir}/usr/bin"
|
33
|
+
File.expand_path("#{xcode_developer_dir}/usr/bin")
|
28
34
|
end
|
29
35
|
|
30
|
-
#
|
36
|
+
# Method for interacting with instruments.
|
37
|
+
#
|
38
|
+
# @example Getting the path to instruments.
|
39
|
+
# instruments #=> /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
|
40
|
+
#
|
41
|
+
# @example Getting a the version of instruments.
|
42
|
+
# instruments(:version) #=> 5.1.1
|
31
43
|
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# instruments(:sims) #=> < list of known simulators >
|
44
|
+
# @example Getting list of known simulators.
|
45
|
+
# instruments(:sims) #=> < list of known simulators >
|
35
46
|
#
|
36
47
|
# @param [String] cmd controls the return value. currently accepts nil,
|
37
48
|
# :sims, and :version as valid parameters
|
@@ -58,15 +69,17 @@ module Calabash
|
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
61
|
-
#
|
72
|
+
# Does the instruments `version` accept the -s flag?
|
62
73
|
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
74
|
+
# @example
|
75
|
+
# instruments_supports_hyphen_s?('4.6.3') => false
|
76
|
+
# instruments_supports_hyphen_s?('5.0.2') => true
|
77
|
+
# instruments_supports_hyphen_s?('5.1') => true
|
66
78
|
#
|
67
|
-
# @param [String] version
|
68
|
-
#
|
69
|
-
#
|
79
|
+
# @param [String] version (instruments(:version))
|
80
|
+
# a major.minor[.patch] version string
|
81
|
+
#
|
82
|
+
# @return [Boolean] true if the version is >= 5.*
|
70
83
|
def instruments_supports_hyphen_s?(version=instruments(:version))
|
71
84
|
tokens = version.split('.')
|
72
85
|
return false if tokens[0].to_i < 5
|
@@ -74,10 +87,7 @@ module Calabash
|
|
74
87
|
true
|
75
88
|
end
|
76
89
|
|
77
|
-
#
|
78
|
-
#
|
79
|
-
# $ instruments -s devices
|
80
|
-
#
|
90
|
+
# Returns a list of installed simulators by calling `$ instruments -s devices`.
|
81
91
|
# and parsing the output
|
82
92
|
# @return [Array<String>] an array of simulator names suitable for passing
|
83
93
|
# to instruments or xcodebuild
|