calabash-cucumber 0.18.2 → 0.19.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/calabash-ios +0 -16
- data/bin/calabash-ios-build.rb +0 -86
- data/bin/calabash-ios-helpers.rb +0 -65
- data/bin/calabash-ios-setup.rb +5 -119
- data/bin/calabash-ios-sim.rb +0 -37
- data/bin/frank-calabash +0 -1
- data/doc/calabash-ios-help.txt +0 -8
- data/dylibs/libCalabashDyn.dylib +0 -0
- data/dylibs/libCalabashDynSim.dylib +0 -0
- data/features-skeleton/support/01_launch.rb +3 -4
- data/features/step_definitions/calabash_steps.rb +1 -7
- data/lib/calabash-cucumber.rb +1 -2
- data/lib/calabash-cucumber/actions/instruments_actions.rb +2 -3
- data/lib/calabash-cucumber/core.rb +97 -101
- data/lib/calabash-cucumber/device.rb +5 -118
- data/lib/calabash-cucumber/environment.rb +109 -5
- data/lib/calabash-cucumber/environment_helpers.rb +4 -66
- data/lib/calabash-cucumber/http/http.rb +114 -0
- data/lib/calabash-cucumber/http_helpers.rb +3 -1
- data/lib/calabash-cucumber/ipad_1x_2x.rb +5 -7
- data/lib/calabash-cucumber/keyboard_helpers.rb +0 -44
- data/lib/calabash-cucumber/launcher.rb +425 -808
- data/lib/calabash-cucumber/logging.rb +2 -74
- data/lib/calabash-cucumber/operations.rb +0 -2
- data/lib/calabash-cucumber/rotation_helpers.rb +2 -82
- data/lib/calabash-cucumber/status_bar_helpers.rb +2 -8
- data/lib/calabash-cucumber/store/preferences.rb +2 -1
- data/lib/calabash-cucumber/uia.rb +4 -9
- data/lib/calabash-cucumber/version.rb +2 -2
- data/lib/calabash-cucumber/wait_helpers.rb +0 -2
- data/staticlib/calabash.framework.zip +0 -0
- data/staticlib/libFrankCalabash.a +0 -0
- metadata +13 -143
- data/lib/calabash-cucumber/actions/playback_actions.rb +0 -109
- data/lib/calabash-cucumber/deprecated.rb +0 -34
- data/lib/calabash-cucumber/launch/simulator_helper.rb +0 -62
- data/lib/calabash-cucumber/launch/simulator_launcher.rb +0 -617
- data/lib/calabash-cucumber/playback_helpers.rb +0 -225
- 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/lib/calabash-cucumber/utils/logging.rb +0 -111
- data/lib/calabash-cucumber/utils/plist_buddy.rb +0 -45
- data/lib/calabash-cucumber/utils/simulator_accessibility.rb +0 -334
- data/lib/calabash-cucumber/utils/xctools.rb +0 -101
- data/scripts/.irbrc +0 -64
- data/scripts/launch.rb +0 -48
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'calabash-cucumber/playback_helpers'
|
2
|
-
require 'calabash-cucumber/connection_helpers'
|
3
|
-
require 'calabash-cucumber/query_helpers'
|
4
|
-
|
5
|
-
# @!visibility private
|
6
|
-
class Calabash::Cucumber::PlaybackActions
|
7
|
-
include Calabash::Cucumber::PlaybackHelpers
|
8
|
-
include Calabash::Cucumber::ConnectionHelpers
|
9
|
-
include Calabash::Cucumber::QueryHelpers
|
10
|
-
|
11
|
-
# @!visibility private
|
12
|
-
def touch(options)
|
13
|
-
playback('touch', options)
|
14
|
-
end
|
15
|
-
|
16
|
-
# @!visibility private
|
17
|
-
def double_tap(options)
|
18
|
-
playback('double_tap', options)
|
19
|
-
end
|
20
|
-
|
21
|
-
# @!visibility private
|
22
|
-
def two_finger_tap(*args)
|
23
|
-
raise error_message('two_finger_tap')
|
24
|
-
end
|
25
|
-
|
26
|
-
# @!visibility private
|
27
|
-
def flick(*args)
|
28
|
-
raise error_message('flick')
|
29
|
-
end
|
30
|
-
|
31
|
-
# @!visibility private
|
32
|
-
def touch_hold(options)
|
33
|
-
playback('touch_hold', options)
|
34
|
-
end
|
35
|
-
|
36
|
-
# @!visibility private
|
37
|
-
def swipe(dir, options={})
|
38
|
-
current_orientation = options[:status_bar_orientation].to_sym
|
39
|
-
if current_orientation == :left
|
40
|
-
case dir
|
41
|
-
when :left then
|
42
|
-
dir = :down
|
43
|
-
when :right then
|
44
|
-
dir = :up
|
45
|
-
when :up then
|
46
|
-
dir = :left
|
47
|
-
when :down then
|
48
|
-
dir = :right
|
49
|
-
else
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
if current_orientation == :right
|
54
|
-
case dir
|
55
|
-
when :left then
|
56
|
-
dir = :up
|
57
|
-
when :right then
|
58
|
-
dir = :down
|
59
|
-
when :up then
|
60
|
-
dir = :right
|
61
|
-
when :down then
|
62
|
-
dir = :left
|
63
|
-
else
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
if current_orientation == :up
|
68
|
-
case dir
|
69
|
-
when :left then
|
70
|
-
dir = :right
|
71
|
-
when :right then
|
72
|
-
dir = :left
|
73
|
-
when :up then
|
74
|
-
dir = :down
|
75
|
-
when :down then
|
76
|
-
dir = :up
|
77
|
-
else
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
playback("swipe_#{dir}", options)
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
# @!visibility private
|
86
|
-
def pan(from,to,options={})
|
87
|
-
interpolate 'pan', options.merge(:start => from, :end => to)
|
88
|
-
end
|
89
|
-
|
90
|
-
# @!visibility private
|
91
|
-
def pinch(in_out,options)
|
92
|
-
file = "pinch_in"
|
93
|
-
if in_out==:out
|
94
|
-
file = "pinch_out"
|
95
|
-
end
|
96
|
-
playback(file, options)
|
97
|
-
end
|
98
|
-
|
99
|
-
# @!visibility private
|
100
|
-
def send_app_to_background(secs)
|
101
|
-
raise 'Not implemented when running without instruments / UIA'
|
102
|
-
end
|
103
|
-
|
104
|
-
private
|
105
|
-
# @!visibility private
|
106
|
-
def error_message(gesture)
|
107
|
-
"Gesture: '#{gesture}' not supported unless running with instruments."
|
108
|
-
end
|
109
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'run_loop'
|
2
|
-
require 'calabash-cucumber/utils/logging'
|
3
|
-
|
4
|
-
module Calabash
|
5
|
-
module Cucumber
|
6
|
-
|
7
|
-
include Calabash::Cucumber::Logging
|
8
|
-
|
9
|
-
# @!visibility private
|
10
|
-
def self.const_missing(const_name)
|
11
|
-
if const_name == :FRAMEWORK_VERSION
|
12
|
-
_deprecated('0.9.169', 'FRAMEWORK_VERSION has been deprecated - there is no replacement', :warn)
|
13
|
-
return nil
|
14
|
-
end
|
15
|
-
raise(NameError, "uninitialized constant Calabash::Cucumber::#{const_name}")
|
16
|
-
end
|
17
|
-
|
18
|
-
# A model of a release version that can be used to compare two version.
|
19
|
-
#
|
20
|
-
# Calabash tries very hard to comply with Semantic Versioning rules. However,
|
21
|
-
# the semantic versioning spec is incompatible with RubyGem's patterns for
|
22
|
-
# pre-release gems.
|
23
|
-
#
|
24
|
-
# > "But returning to the practical: No release version of SemVer is compatible with Rubygems." - _David Kellum_
|
25
|
-
#
|
26
|
-
# Calabash version numbers will be in the form `<major>.<minor>.<patch>[.pre<N>]`.
|
27
|
-
#
|
28
|
-
# @see http://semver.org/
|
29
|
-
# @see http://gravitext.com/2012/07/22/versioning.html
|
30
|
-
class Version < RunLoop::Version
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'sim_launcher'
|
2
|
-
|
3
|
-
module Calabash
|
4
|
-
module Cucumber
|
5
|
-
|
6
|
-
# This module has been replaced by Simulator Launcher
|
7
|
-
#
|
8
|
-
# @deprecated 0.9.169 Use the SimulatorLauncher class instead.
|
9
|
-
module SimulatorHelper
|
10
|
-
|
11
|
-
# Quits the simulator.
|
12
|
-
#
|
13
|
-
# This has been deprecated, but it appears in legacy launch hooks.
|
14
|
-
#
|
15
|
-
# Use this pattern instead:
|
16
|
-
#
|
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?
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
# ```
|
25
|
-
#
|
26
|
-
# @deprecated 0.9.169 replaced with SimulatorLauncher.new().stop
|
27
|
-
def self.stop
|
28
|
-
unless ENV['CALABASH_NO_DEPRECATION'] == '1'
|
29
|
-
if RUBY_VERSION < '2.0'
|
30
|
-
stack = Kernel.caller()[1..6].join("\n")
|
31
|
-
else
|
32
|
-
stack = Kernel.caller(0, 6)[1..-1].join("\n")
|
33
|
-
end
|
34
|
-
|
35
|
-
msgs = ['The Calabash::Cucumber::SimulatorHelper module has been replaced.',
|
36
|
-
'Please replace:',
|
37
|
-
'',
|
38
|
-
' Calabash::Cucumber::SimulatorHelper.stop',
|
39
|
-
'',
|
40
|
-
'with this:',
|
41
|
-
'',
|
42
|
-
' launcher = Calabash::Cucumber::Launcher.new',
|
43
|
-
' launcher.simulator_launcher.stop',
|
44
|
-
'',
|
45
|
-
'The stack trace below will show you the line number you need to change.']
|
46
|
-
|
47
|
-
msg = "deprecated '0.9.169' - #{msgs.join("\n")}\n#{stack}"
|
48
|
-
|
49
|
-
begin
|
50
|
-
STDERR.puts "\033[34m\nWARN: #{msg}\033[0m"
|
51
|
-
rescue
|
52
|
-
STDERR.puts "\nWARN: #{msg}"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
simulator = SimLauncher::Simulator.new()
|
56
|
-
simulator.quit_simulator
|
57
|
-
simulator
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,617 +0,0 @@
|
|
1
|
-
require 'sim_launcher'
|
2
|
-
require 'json'
|
3
|
-
require 'net/http'
|
4
|
-
require 'cfpropertylist'
|
5
|
-
require 'calabash-cucumber/utils/logging'
|
6
|
-
require 'run_loop'
|
7
|
-
|
8
|
-
module Calabash
|
9
|
-
module Cucumber
|
10
|
-
|
11
|
-
# Acts as a bridge to the sim_launcher SimLauncher and SdkDetector classes.
|
12
|
-
#
|
13
|
-
# Runtime Environmental Variables
|
14
|
-
#
|
15
|
-
# * `PROJECT_DIR` (ENV['PWD']) - the path to the .xcproject directory
|
16
|
-
# * `DEVICE_ENDPOINT` (http://localhost:37265/) - the ip:port of the
|
17
|
-
# device under test
|
18
|
-
# * `CALABASH_VERSION_PATH` (version) - the path to server version route
|
19
|
-
# * `MAX_CONNECT_RETRY` (2) the number of times retry
|
20
|
-
# establishing a connection to the server.
|
21
|
-
# * `CONNECT_TIMEOUT` (30) how long to wait for the server before timing
|
22
|
-
# out
|
23
|
-
#
|
24
|
-
class SimulatorLauncher
|
25
|
-
include Calabash::Cucumber::Logging
|
26
|
-
|
27
|
-
# Custom error indicating a timeout in launching and connecting to the
|
28
|
-
# embedded calabash server.
|
29
|
-
# @todo This is duplicated in Launcher class - consider errors.rb module.
|
30
|
-
class TimeoutErr < RuntimeError
|
31
|
-
end
|
32
|
-
|
33
|
-
# @!visibility private
|
34
|
-
# The file path to the default Xcode DerivedData directory.
|
35
|
-
DERIVED_DATA = File.expand_path('~/Library/Developer/Xcode/DerivedData')
|
36
|
-
|
37
|
-
# @!visibility private]
|
38
|
-
# The file path to the default Xcode preferences plist.
|
39
|
-
XCODE_PREFS = File.expand_path('~/Library/Preferences/com.apple.dt.Xcode.plist')
|
40
|
-
|
41
|
-
# @!visibility private
|
42
|
-
# REGEX for finding application Info.plist.
|
43
|
-
DEFAULT_DERIVED_DATA_INFO = File.expand_path("#{DERIVED_DATA}/*/info.plist")
|
44
|
-
|
45
|
-
# @!visibility private
|
46
|
-
# If `CONNECT_TIMEOUT` is not set, wait this long for the app to launch
|
47
|
-
# in the simulator before retrying.
|
48
|
-
DEFAULT_SIM_WAIT = 30
|
49
|
-
|
50
|
-
# If `MAX_CONNECT_RETRY` is not set, try to launch the app this many times
|
51
|
-
# in the simulator before giving up
|
52
|
-
DEFAULT_SIM_RETRY = 2
|
53
|
-
|
54
|
-
# @!visibility private
|
55
|
-
# An instance of Calabash::Cucumber::Device.
|
56
|
-
attr_accessor :device
|
57
|
-
|
58
|
-
# @!visibility private
|
59
|
-
# An instance of SimLauncher::Simulator.
|
60
|
-
attr_accessor :simulator
|
61
|
-
|
62
|
-
# @!visibility private
|
63
|
-
# An instance of SimLauncher::SdkDetector.
|
64
|
-
attr_accessor :sdk_detector
|
65
|
-
|
66
|
-
# @!visibility private
|
67
|
-
# The launch args passed from Calabash::Cucumber::Launcher to the launch
|
68
|
-
# and relaunch methods.
|
69
|
-
attr_accessor :launch_args
|
70
|
-
|
71
|
-
# Creates a new instance an sets the :simulator and :sdk_detector attributes.
|
72
|
-
def initialize
|
73
|
-
@simulator = SimLauncher::Simulator.new
|
74
|
-
@sdk_detector = SimLauncher::SdkDetector.new()
|
75
|
-
end
|
76
|
-
|
77
|
-
# Stops (quits) the simulator.
|
78
|
-
def stop
|
79
|
-
RunLoop::SimControl.new.quit_sim
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
# @!visibility private
|
84
|
-
# Uses heuristics to deduce the derived data directory for the project
|
85
|
-
# so the path to the app bundle (.app) can be detected.
|
86
|
-
# @return [String] absolute path to derived data directory
|
87
|
-
# @raise [RuntimeError] if the derived data directory cannot be found
|
88
|
-
def derived_data_dir_for_project
|
89
|
-
dir = project_dir
|
90
|
-
xcode_workspace_name = ''
|
91
|
-
info_plist = Dir.glob(DEFAULT_DERIVED_DATA_INFO).find { |plist_file|
|
92
|
-
begin
|
93
|
-
plist = CFPropertyList::List.new(:file => plist_file)
|
94
|
-
hash = CFPropertyList.native_types(plist.value)
|
95
|
-
ws_dir = File.dirname(hash['WorkspacePath']).downcase
|
96
|
-
p_dir = dir.downcase
|
97
|
-
if p_dir.include? ws_dir
|
98
|
-
xcode_workspace_name = ws_dir.split('/').last
|
99
|
-
end
|
100
|
-
ws_dir == p_dir
|
101
|
-
rescue
|
102
|
-
false
|
103
|
-
end
|
104
|
-
}
|
105
|
-
|
106
|
-
return File.dirname(info_plist) unless info_plist.nil?
|
107
|
-
|
108
|
-
res = Dir.glob("#{dir}/*.xcodeproj")
|
109
|
-
if res.empty?
|
110
|
-
raise "Unable to find *.xcodeproj in #{dir}"
|
111
|
-
elsif res.count > 1
|
112
|
-
raise "Unable to found several *.xcodeproj in #{dir}: #{res}"
|
113
|
-
end
|
114
|
-
|
115
|
-
xcode_proj_name = res.first.split('.xcodeproj')[0]
|
116
|
-
|
117
|
-
xcode_proj_name = File.basename(xcode_proj_name)
|
118
|
-
|
119
|
-
build_dirs = Dir.glob("#{DERIVED_DATA}/*").find_all do |xc_proj|
|
120
|
-
File.basename(xc_proj).start_with?(xcode_proj_name)
|
121
|
-
end
|
122
|
-
|
123
|
-
if build_dirs.count == 0 && !xcode_workspace_name.empty?
|
124
|
-
# check for directory named "workspace-{deriveddirectoryrandomcharacters}"
|
125
|
-
build_dirs = Dir.glob("#{DERIVED_DATA}/*").find_all do |xc_proj|
|
126
|
-
File.basename(xc_proj).downcase.start_with?(xcode_workspace_name)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# todo analyze `derived_data_dir_for_project` to see if it contains dead code
|
131
|
-
# todo assuming this is not dead code, the documentation around derived data for project needs to be updated
|
132
|
-
|
133
|
-
if build_dirs.count == 0
|
134
|
-
msg = ['Unable to find your built app.']
|
135
|
-
msg << "This means that Calabash can't automatically launch iOS simulator."
|
136
|
-
msg << "Searched in Xcode 4.x default: #{DEFAULT_DERIVED_DATA_INFO}"
|
137
|
-
msg << ''
|
138
|
-
msg << "To fix there are a couple of options:\n"
|
139
|
-
msg << 'Option 1) Make sure you are running this command from your project directory, '
|
140
|
-
msg << 'i.e., the directory containing your .xcodeproj file.'
|
141
|
-
msg << 'In Xcode, build your calabash target for simulator.'
|
142
|
-
msg << "Check that your app can be found in\n #{DERIVED_DATA}"
|
143
|
-
msg << "\n\nOption 2). In features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
144
|
-
msg << 'the path where Xcode has built your Calabash target.'
|
145
|
-
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
146
|
-
raise msg.join("\n")
|
147
|
-
|
148
|
-
elsif build_dirs.count > 1
|
149
|
-
msg = ['Unable to auto detect APP_BUNDLE_PATH.']
|
150
|
-
msg << "You have several projects with the same name: #{xcode_proj_name} in #{DERIVED_DATA}:\n"
|
151
|
-
msg << build_dirs.join("\n")
|
152
|
-
|
153
|
-
msg << "\nThis means that Calabash can't automatically launch iOS simulator."
|
154
|
-
msg << "Searched in Xcode 4.x default: #{DEFAULT_DERIVED_DATA_INFO}"
|
155
|
-
msg << "\nIn features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
156
|
-
msg << 'the path where Xcode has built your Calabash target.'
|
157
|
-
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
158
|
-
raise msg.join("\n")
|
159
|
-
else
|
160
|
-
if full_console_logging?
|
161
|
-
puts "Found potential build dir: #{build_dirs.first}"
|
162
|
-
puts 'Checking...'
|
163
|
-
end
|
164
|
-
build_dirs.first
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
# @!visibility private
|
169
|
-
# Returns the absolute build path to the project directory.
|
170
|
-
#
|
171
|
-
# @return [String] absolute path to the projects build directory
|
172
|
-
def build_output_dir_for_project
|
173
|
-
xcode_temp_prefs = File.join(project_dir, '.cal_xcode_prefs')
|
174
|
-
FileUtils.cp(XCODE_PREFS, xcode_temp_prefs)
|
175
|
-
`plutil -convert xml1 "#{xcode_temp_prefs}"`
|
176
|
-
|
177
|
-
plist = CFPropertyList::List.new(:file => xcode_temp_prefs)
|
178
|
-
hash = CFPropertyList.native_types(plist.value)
|
179
|
-
|
180
|
-
if hash.has_key?('IDESharedBuildFolderName')
|
181
|
-
build_folder_name = hash['IDESharedBuildFolderName']
|
182
|
-
output_dir = "#{DERIVED_DATA}/#{build_folder_name}/Products"
|
183
|
-
elsif hash.has_key?('IDECustomBuildProductsPath')
|
184
|
-
products_path = hash['IDECustomBuildProductsPath']
|
185
|
-
File.join(project_dir, products_path)
|
186
|
-
else
|
187
|
-
output_dir = derived_data_dir_for_project
|
188
|
-
end
|
189
|
-
|
190
|
-
FileUtils.rm(xcode_temp_prefs)
|
191
|
-
|
192
|
-
output_dir
|
193
|
-
end
|
194
|
-
|
195
|
-
# @!visibility private
|
196
|
-
# Returns the absolute path to the project directory.
|
197
|
-
#
|
198
|
-
# Unless `PROJECT_DIR` is defined, returns the absolute path to the current
|
199
|
-
# directory.
|
200
|
-
#
|
201
|
-
# @return [String] absolute path to the project directory
|
202
|
-
# @todo migrate `PROJECT_DIR` to environment_helpers.rb
|
203
|
-
def project_dir
|
204
|
-
File.expand_path(ENV['PROJECT_DIR'] || Dir.pwd)
|
205
|
-
end
|
206
|
-
|
207
|
-
# @!visibility private
|
208
|
-
# Attempts to deduce the app bundle path
|
209
|
-
# @param [String] path NEEDS DOCUMENTATION
|
210
|
-
# @param [String] device_build_dir NEEDS DOCUMENTATION
|
211
|
-
# @return [String] absolute path to app bundle (.app) or `nil` if the
|
212
|
-
# app bundle cannot be found.
|
213
|
-
# @todo methods should not use 2 optional arguments
|
214
|
-
def detect_app_bundle(path=nil,device_build_dir='iPhoneSimulator')
|
215
|
-
begin
|
216
|
-
app_bundle_or_raise(path,device_build_dir)
|
217
|
-
rescue
|
218
|
-
nil
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
# @!visibility private
|
223
|
-
# Attempts to deduce the path the to the app bundle (.app).
|
224
|
-
# @param [String] path NEEDS DOCUMENTATION
|
225
|
-
# @param [String] device_build_dir NEEDS DOCUMENTATION
|
226
|
-
# @return [String] absolute path to app bundle (.app)
|
227
|
-
# @raise [RuntimeError] if app bundle (.app) cannot be found
|
228
|
-
# @todo methods should not use 2 optional arguments
|
229
|
-
def app_bundle_or_raise(path=nil, device_build_dir='iPhoneSimulator')
|
230
|
-
path = File.expand_path(path) if path
|
231
|
-
|
232
|
-
if path and not File.directory?(path)
|
233
|
-
raise "Unable to find .app bundle at #{path}. It should be an .app directory."
|
234
|
-
elsif path
|
235
|
-
bundle_path = path
|
236
|
-
elsif xamarin_project?
|
237
|
-
bundle_path = bundle_path_from_xamarin_project(device_build_dir)
|
238
|
-
unless bundle_path
|
239
|
-
msg = ['Detected Xamarin project, but did not detect built app linked with Calabash']
|
240
|
-
msg << 'You should build your project from Xamarin Studio'
|
241
|
-
msg << "Make sure you build for Simulator and that you're using the Calabash components"
|
242
|
-
raise msg.join("\n")
|
243
|
-
end
|
244
|
-
else
|
245
|
-
search_dir = build_output_dir_for_project || DERIVED_DATA
|
246
|
-
bundle_path = select_most_recent_bundle(search_dir)
|
247
|
-
|
248
|
-
if bundle_path.nil?
|
249
|
-
raise RuntimeError,
|
250
|
-
%Q{
|
251
|
-
Unable to auto detect a .app that is linked Calabash.
|
252
|
-
|
253
|
-
Searched: #{search_dir}
|
254
|
-
|
255
|
-
Have you built your app for simulator?
|
256
|
-
|
257
|
-
Please build your app from Xcode
|
258
|
-
|
259
|
-
Alternatively, specify APP in features/support/01_launch.rb
|
260
|
-
or as an environment variable:
|
261
|
-
|
262
|
-
$ APP=/path/to/Your.app bundle exec cucumber
|
263
|
-
}
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
Calabash::Cucumber.log_debug("Auto detected app at path:")
|
268
|
-
Calabash::Cucumber.log_debug(bundle_path)
|
269
|
-
Calabash::Cucumber.log_debug("If this is incorrect, set the APP variable")
|
270
|
-
bundle_path
|
271
|
-
end
|
272
|
-
|
273
|
-
# @!visibility private
|
274
|
-
# Is this a Xamarin IDE project?
|
275
|
-
# @return [Boolean] true if the project is a Xamarin IDE project
|
276
|
-
def xamarin_project?
|
277
|
-
xamarin_ios_csproj_path != nil
|
278
|
-
end
|
279
|
-
|
280
|
-
# @!visibility private
|
281
|
-
# Path to the Xamarin IDE project.
|
282
|
-
# @return [String] absolute path to the Xamarin IDE project
|
283
|
-
def xamarin_ios_csproj_path
|
284
|
-
solution_path = Dir['*.sln'].first
|
285
|
-
|
286
|
-
project_dir = nil
|
287
|
-
if solution_path
|
288
|
-
project_dir = Dir.pwd
|
289
|
-
else
|
290
|
-
solution_path = Dir[File.join('..','*.sln')].first
|
291
|
-
if solution_path
|
292
|
-
project_dir = File.expand_path('..')
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
return nil unless project_dir
|
297
|
-
|
298
|
-
ios_project_dir = Dir[File.join(project_dir,'*.iOS')].first
|
299
|
-
return ios_project_dir if ios_project_dir && File.directory?(ios_project_dir)
|
300
|
-
# ios_project_dir does not exist
|
301
|
-
# Detect case where there is no such sub directory
|
302
|
-
# (i.e. iOS only Xamarin project)
|
303
|
-
bin_dir = File.join(project_dir, 'bin')
|
304
|
-
if xamarin_ios_bin_dir?(bin_dir)
|
305
|
-
return project_dir ## Looks like iOS bin dir is here
|
306
|
-
end
|
307
|
-
|
308
|
-
sub_dirs = Dir[File.join(project_dir,'*')].select {|dir| File.directory?(dir)}
|
309
|
-
|
310
|
-
sub_dirs.find do |sub_dir|
|
311
|
-
contains_csproj = Dir[File.join(sub_dir,'*.csproj')].first
|
312
|
-
contains_csproj && xamarin_ios_bin_dir?(File.join(sub_dir,'bin'))
|
313
|
-
end
|
314
|
-
|
315
|
-
end
|
316
|
-
|
317
|
-
# @!visibility private
|
318
|
-
# Is this the Xamarin iOS bin directory?
|
319
|
-
# @return [Boolean] true if this is the Xamarin iOS bin directory
|
320
|
-
def xamarin_ios_bin_dir?(bin_dir)
|
321
|
-
File.directory?(bin_dir) &&
|
322
|
-
(File.directory?(File.join(bin_dir,'iPhoneSimulator')) ||
|
323
|
-
File.directory?(File.join(bin_dir,'iPhone')))
|
324
|
-
end
|
325
|
-
|
326
|
-
# @!visibility private
|
327
|
-
# Attempts to deduce the path to the app bundle path (*.app) using
|
328
|
-
# heuristics and checking for executables linked with the Calabash server.
|
329
|
-
#
|
330
|
-
# @param [String] device_build_dir NEEDS DOCUMENTATION
|
331
|
-
# @return [String] absolute path the app bundle .app or `nil` if the
|
332
|
-
# the app bundle cannot be found.
|
333
|
-
def bundle_path_from_xamarin_project(device_build_dir='iPhoneSimulator')
|
334
|
-
ios_project_path = xamarin_ios_csproj_path
|
335
|
-
conf_glob = File.join(ios_project_path,'bin',device_build_dir,'*')
|
336
|
-
built_confs = Dir[conf_glob]
|
337
|
-
|
338
|
-
calabash_build = built_confs.find {|path| File.basename(path) == 'Calabash'}
|
339
|
-
debug_build = built_confs.find {|path| File.basename(path) == 'Debug'}
|
340
|
-
|
341
|
-
bundle_path = [calabash_build, debug_build, *built_confs].find do |path|
|
342
|
-
next unless path && File.directory?(path)
|
343
|
-
app_dir = Dir[File.join(path,'*.app')].first
|
344
|
-
app_dir && linked_with_calabash?(app_dir)
|
345
|
-
end
|
346
|
-
|
347
|
-
Dir[File.join(bundle_path,'*.app')].first if bundle_path
|
348
|
-
end
|
349
|
-
|
350
|
-
# @!visibility private
|
351
|
-
# Searches `d` for a file linked with Calabash server.
|
352
|
-
# @param [String] d path to a directory
|
353
|
-
# @return [Boolean] true if there is a file that is linked with the
|
354
|
-
# Calabash server
|
355
|
-
# @todo why are we not grep'ing for executable files? see server_version_from_bundle
|
356
|
-
def linked_with_calabash?(d)
|
357
|
-
skipped_formats = ['.png', '.jpg', '.jpeg', '.plist', '.nib', '.lproj']
|
358
|
-
dir = File.expand_path(d)
|
359
|
-
|
360
|
-
# For every file on that .app directory
|
361
|
-
Dir.entries(d).each do |file|
|
362
|
-
# If this is an asset or any of those skipped formats, skip it.
|
363
|
-
next if skipped_formats.include? File.extname(file)
|
364
|
-
|
365
|
-
# If its not, try to run otool against that file, check whether we are linked against calabash framework.
|
366
|
-
out = `otool "#{dir}/#{file}" -o 2> /dev/null | grep CalabashServer`
|
367
|
-
return true if /CalabashServer/.match(out)
|
368
|
-
end
|
369
|
-
|
370
|
-
# Defaulted to false
|
371
|
-
false
|
372
|
-
end
|
373
|
-
|
374
|
-
# !@visibility private
|
375
|
-
# Finds the preferred(?) directory.
|
376
|
-
# @return [String] The first path in `sim_dirs` that contains a binary
|
377
|
-
# linked with Calabash server. Returns `nil` if there is no path in
|
378
|
-
# `sim_dirs` that contains a binary linked with Calabash server.
|
379
|
-
# @param [Array<String>] sim_dirs eke! why sim_dirs? why not a list of any directories?
|
380
|
-
# @todo find_preferred_dir is a bad name - preferred for what?
|
381
|
-
# @todo sim_dirs arg is a bad name - we can be iterating over any directory
|
382
|
-
def find_preferred_dir(sim_dirs)
|
383
|
-
sim_dirs.find do |d|
|
384
|
-
linked_with_calabash?(d)
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
# !@visibility private
|
389
|
-
# Ping the version route of the calabash server embedded in the app,
|
390
|
-
#
|
391
|
-
# @note
|
392
|
-
# Has the side effect of setting self.device attribute if successful.
|
393
|
-
#
|
394
|
-
# @return [String] returns the server status - '200' is a success
|
395
|
-
# @todo migrate DEVICE_ENDPOINT to environment_helpers
|
396
|
-
# @todo migrate CALABASH_VERSION_PATH to environment_helpers
|
397
|
-
# @todo this is an exact duplicate of Launcher ping method
|
398
|
-
def ping_app
|
399
|
-
url = URI.parse(ENV['DEVICE_ENDPOINT']|| 'http://localhost:37265/')
|
400
|
-
if full_console_logging?
|
401
|
-
puts "Ping #{url}..."
|
402
|
-
end
|
403
|
-
|
404
|
-
http = Net::HTTP.new(url.host, url.port)
|
405
|
-
res = http.start do |sess|
|
406
|
-
# noinspection RubyResolve
|
407
|
-
sess.request Net::HTTP::Get.new(ENV['CALABASH_VERSION_PATH'] || 'version')
|
408
|
-
end
|
409
|
-
|
410
|
-
status = res.code
|
411
|
-
begin
|
412
|
-
http.finish if http and http.started?
|
413
|
-
rescue
|
414
|
-
# nop
|
415
|
-
end
|
416
|
-
|
417
|
-
if status == '200'
|
418
|
-
version_body = JSON.parse(res.body)
|
419
|
-
self.device = Calabash::Cucumber::Device.new(url, version_body)
|
420
|
-
end
|
421
|
-
|
422
|
-
if full_console_logging?
|
423
|
-
puts "ping status = '#{status}'"
|
424
|
-
end
|
425
|
-
status
|
426
|
-
end
|
427
|
-
|
428
|
-
# @!visibility private
|
429
|
-
# Attempts to connect to launch the app and connect to the embedded
|
430
|
-
# calabash server.
|
431
|
-
#
|
432
|
-
# @note To change the number of times launching is attempted set
|
433
|
-
# `MAX_CONNECT_RETRY`.
|
434
|
-
#
|
435
|
-
# @note To change the relaunch timeout set `CONNECT_TIMEOUT`.
|
436
|
-
#
|
437
|
-
# @param [String] app_bundle_path path to the .app that should be launched
|
438
|
-
# @param [String] sdk 6.0.3, 6.1. if nil latest SDK will be used
|
439
|
-
# @param [String] device_family `{iphone | ipad}`
|
440
|
-
# @param [Hash] args eke! not used (see todo)
|
441
|
-
#
|
442
|
-
# @raise [TimeoutErr] if app cannot be launched in the simulator
|
443
|
-
# @todo nearly a duplicate of Launcher ensure_connectivity
|
444
|
-
# @todo args was originally intended to be the args passed to the application @ launch
|
445
|
-
def ensure_connectivity(app_bundle_path, sdk, device_family, args = nil)
|
446
|
-
begin
|
447
|
-
# todo should get the retry could from the args
|
448
|
-
# todo should migrate MAX_CONNECT_RETRY to environment_helpers
|
449
|
-
max_retry_count = (ENV['MAX_CONNECT_RETRY'] || DEFAULT_SIM_RETRY).to_i
|
450
|
-
# todo should get the timeout from the args
|
451
|
-
# todo should migrate CONNECT_TIMEOUT to environment helpers
|
452
|
-
timeout = (ENV['CONNECT_TIMEOUT'] || DEFAULT_SIM_WAIT).to_i
|
453
|
-
retry_count = 0
|
454
|
-
connected = false
|
455
|
-
|
456
|
-
if full_console_logging?
|
457
|
-
puts "Waiting at most #{timeout} seconds for simulator (CONNECT_TIMEOUT)"
|
458
|
-
puts "Retrying at most #{max_retry_count} times (MAX_CONNECT_RETRY)"
|
459
|
-
end
|
460
|
-
|
461
|
-
until connected do
|
462
|
-
raise 'MAX_RETRIES' if retry_count == max_retry_count
|
463
|
-
retry_count += 1
|
464
|
-
if full_console_logging?
|
465
|
-
puts "(#{retry_count}.) Start Simulator #{sdk}, #{device_family}, for #{app_bundle_path}"
|
466
|
-
end
|
467
|
-
begin
|
468
|
-
Timeout::timeout(timeout, TimeoutErr) do
|
469
|
-
launch(app_bundle_path, sdk, device_family, args)
|
470
|
-
until connected
|
471
|
-
begin
|
472
|
-
connected = (ping_app == '200')
|
473
|
-
break if connected
|
474
|
-
ensure
|
475
|
-
sleep 1 unless connected
|
476
|
-
end
|
477
|
-
end
|
478
|
-
end
|
479
|
-
rescue TimeoutErr => e
|
480
|
-
puts 'Timed out... Retrying'
|
481
|
-
stop
|
482
|
-
end
|
483
|
-
end
|
484
|
-
rescue RuntimeError => e
|
485
|
-
p e
|
486
|
-
msg = "Unable to make connection to Calabash Server at #{ENV['DEVICE_ENDPOINT']|| 'http://localhost:37265/'}\n"
|
487
|
-
msg << "Make sure you've' linked correctly with calabash.framework and set Other Linker Flags.\n"
|
488
|
-
msg << "Make sure you don't have a firewall blocking traffic to #{ENV['DEVICE_ENDPOINT']|| 'http://localhost:37265/'}.\n"
|
489
|
-
raise msg
|
490
|
-
end
|
491
|
-
end
|
492
|
-
|
493
|
-
# @!visibility private
|
494
|
-
# Launches the app.
|
495
|
-
#
|
496
|
-
# @param [String] app_bundle_path path to the .app that should be launched
|
497
|
-
# @param [String] sdk 6.0.3, 6.1. if nil latest SDK will be used
|
498
|
-
# @param [String] device_family `{iphone | ipad}`
|
499
|
-
# @param [Hash] args eke! not used
|
500
|
-
# @todo args was originally intended to be the args passed to the application @ launch
|
501
|
-
def launch(app_bundle_path, sdk, device_family, args = nil)
|
502
|
-
# cached but not used
|
503
|
-
self.launch_args = args
|
504
|
-
# launch arguments (eg. -NSShowNonLocalizedStrings) are not being passed
|
505
|
-
# to sim_launcher
|
506
|
-
# https://github.com/calabash/calabash-ios/issues/363
|
507
|
-
self.simulator.launch_ios_app(app_bundle_path, sdk, device_family)
|
508
|
-
simulator
|
509
|
-
end
|
510
|
-
|
511
|
-
# @!visibility private
|
512
|
-
# Relaunches the app in the simulator.
|
513
|
-
#
|
514
|
-
# @param [String] app_path the path to the .app
|
515
|
-
# @param [String] sdk eg. 6.0.3, 6.1
|
516
|
-
# @param [Hash] args the only option we are interested in is :device
|
517
|
-
#
|
518
|
-
# @todo args was originally intended to be the args passed to the application @ launch
|
519
|
-
# @todo it is _very_ likely that args[:app] == app_path so we might be able
|
520
|
-
# to eliminate an argument
|
521
|
-
def relaunch(app_path, sdk, args)
|
522
|
-
app_bundle_path = app_bundle_or_raise(app_path)
|
523
|
-
|
524
|
-
if sdk.nil?
|
525
|
-
# iOS 7 requires launching with instruments, so we _must_ launch with
|
526
|
-
# the first SDK that is _not_ iOS 7
|
527
|
-
_sdk = self.sdk_detector.available_sdk_versions.reverse.find { |x| !x.start_with?('7') }
|
528
|
-
else
|
529
|
-
# use SDK_VERSION to specify a different version
|
530
|
-
# as of Xcode 5.0.2, the min supported simulator version is iOS 6
|
531
|
-
_sdk = sdk
|
532
|
-
end
|
533
|
-
|
534
|
-
if args[:device]
|
535
|
-
device_family = args[:device].to_s
|
536
|
-
else
|
537
|
-
device_family = 'iphone'
|
538
|
-
end
|
539
|
-
|
540
|
-
self.launch_args = args
|
541
|
-
|
542
|
-
ensure_connectivity(app_bundle_path, _sdk, device_family, args)
|
543
|
-
end
|
544
|
-
|
545
|
-
# @deprecated 0.9.169 Calabash::Cucumber::Launcher.launcher.device instance methods
|
546
|
-
# @raise [NotImplementedError] no longer implemented
|
547
|
-
def get_version
|
548
|
-
_deprecated('0.9.169', 'use an instance Device class instead', :warn)
|
549
|
-
raise(NotImplementedError, 'this method has been deprecated')
|
550
|
-
end
|
551
|
-
|
552
|
-
# @deprecated 0.9.169 Calabash::Cucumber::Launcher.launcher.device instance methods
|
553
|
-
# @raise [NotImplementedError] no longer implemented
|
554
|
-
def ios_version
|
555
|
-
_deprecated('0.9.169', 'use an instance Device class instead', :warn)
|
556
|
-
raise(NotImplementedError, 'this method has been deprecated')
|
557
|
-
end
|
558
|
-
|
559
|
-
# @deprecated 0.9.169 use Calabash::Cucumber::Launcher.launcher.ios_major_version
|
560
|
-
# @raise [NotImplementedError] no longer implemented
|
561
|
-
def ios_major_version
|
562
|
-
_deprecated('0.9.169', 'use an instance Device class instead', :warn)
|
563
|
-
raise(NotImplementedError, 'this method has been deprecated')
|
564
|
-
end
|
565
|
-
|
566
|
-
|
567
|
-
# noinspection RubyUnusedLocalVariable
|
568
|
-
|
569
|
-
# @deprecated 0.9.169 version checking is done in Launcher
|
570
|
-
# @raise [NotImplementedError] no longer implemented
|
571
|
-
def version_check(version)
|
572
|
-
_deprecated('0.9.169', 'check is now done in Launcher', :warn)
|
573
|
-
raise(NotImplementedError, 'this method has been deprecated and will be removed')
|
574
|
-
end
|
575
|
-
|
576
|
-
private
|
577
|
-
|
578
|
-
# @!visibility private
|
579
|
-
def app(bundle_path)
|
580
|
-
RunLoop::App.new(bundle_path)
|
581
|
-
end
|
582
|
-
|
583
|
-
# @!visibility private
|
584
|
-
def lipo(bundle_path)
|
585
|
-
RunLoop::Lipo.new(bundle_path)
|
586
|
-
end
|
587
|
-
|
588
|
-
# @!visibility private
|
589
|
-
def collect_app_bundles(base_dir)
|
590
|
-
bundles = []
|
591
|
-
|
592
|
-
Dir.glob("#{base_dir}/**/*.app") do |bundle|
|
593
|
-
next if !RunLoop::App.valid?(bundle)
|
594
|
-
|
595
|
-
lipo = lipo(bundle)
|
596
|
-
arches = lipo.info
|
597
|
-
if arches.include?("x86_64") || arches.include?("i386")
|
598
|
-
app = app(bundle)
|
599
|
-
if app.calabash_server_version
|
600
|
-
bundles << bundle
|
601
|
-
end
|
602
|
-
end
|
603
|
-
end
|
604
|
-
|
605
|
-
bundles
|
606
|
-
end
|
607
|
-
|
608
|
-
# @!visibility private
|
609
|
-
def select_most_recent_bundle(base_dir)
|
610
|
-
bundles = collect_app_bundles(base_dir)
|
611
|
-
bundles.max do |a, b|
|
612
|
-
File.mtime(a) <=> File.mtime(b)
|
613
|
-
end
|
614
|
-
end
|
615
|
-
end
|
616
|
-
end
|
617
|
-
end
|