calabash-cucumber 0.9.169.pre2 → 0.9.169.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +14 -1
- data/bin/calabash-ios-setup.rb +2 -4
- data/bin/calabash-ios-sim.rb +10 -40
- data/calabash-cucumber.gemspec +25 -22
- data/features-skeleton/support/01_launch.rb +1 -1
- data/lib/calabash-cucumber.rb +13 -1
- data/lib/calabash-cucumber/actions/instruments_actions.rb +0 -4
- data/lib/calabash-cucumber/actions/playback_actions.rb +0 -4
- data/lib/calabash-cucumber/core.rb +9 -16
- data/lib/calabash-cucumber/device.rb +11 -2
- data/lib/calabash-cucumber/environment_helpers.rb +4 -56
- data/lib/calabash-cucumber/ios7_operations.rb +4 -2
- data/lib/calabash-cucumber/keyboard_helpers.rb +6 -3
- data/lib/calabash-cucumber/launch/simulator_helper.rb +40 -386
- data/lib/calabash-cucumber/launch/simulator_launcher.rb +534 -0
- data/lib/calabash-cucumber/launcher.rb +172 -36
- data/lib/calabash-cucumber/operations.rb +3 -4
- data/lib/calabash-cucumber/playback_helpers.rb +15 -29
- data/lib/calabash-cucumber/rotation_helpers.rb +14 -10
- data/lib/calabash-cucumber/status_bar_helpers.rb +5 -1
- data/lib/calabash-cucumber/uia.rb +6 -12
- data/lib/calabash-cucumber/utils/logging.rb +97 -0
- data/lib/calabash-cucumber/utils/plist_buddy.rb +178 -0
- data/lib/calabash-cucumber/utils/simulator_accessibility.rb +250 -0
- data/lib/calabash-cucumber/utils/xctools.rb +95 -0
- data/lib/calabash-cucumber/version.rb +197 -2
- data/lib/calabash-cucumber/wait_helpers.rb +16 -20
- data/scripts/.irbrc +11 -6
- data/scripts/com.example.plist +0 -0
- data/scripts/launch.rb +1 -1
- data/spec/bin/calabash_ios_sim_spec.rb +24 -0
- data/spec/launcher_spec.rb +76 -0
- data/spec/logging_spec.rb +38 -0
- data/spec/plist_buddy_spec.rb +99 -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 +1 -0
- 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 +18 -0
- data/spec/simulator_accessibility_spec.rb +144 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/xctools_spec.rb +58 -0
- metadata +120 -34
@@ -2,11 +2,14 @@ require 'calabash-cucumber/core'
|
|
2
2
|
require 'calabash-cucumber/tests_helpers'
|
3
3
|
require 'calabash-cucumber/playback_helpers'
|
4
4
|
require 'calabash-cucumber/environment_helpers'
|
5
|
+
require 'calabash-cucumber/utils/logging'
|
5
6
|
|
6
7
|
module Calabash
|
7
8
|
module Cucumber
|
8
9
|
module KeyboardHelpers
|
10
|
+
|
9
11
|
include Calabash::Cucumber::TestsHelpers
|
12
|
+
include Calabash::Cucumber::Logging
|
10
13
|
|
11
14
|
KEYPLANE_NAMES = {
|
12
15
|
:small_letters => 'small-letters',
|
@@ -740,8 +743,8 @@ module Calabash
|
|
740
743
|
# the first responder will be the +UITextField+ or +UITextView+ instance
|
741
744
|
# that is associated with the visible keyboard.
|
742
745
|
#
|
743
|
-
# returns +
|
744
|
-
# the first responder.
|
746
|
+
# returns +empty string+ if no +textField+ or +textView+ elements are found to be
|
747
|
+
# the first responder.
|
745
748
|
#
|
746
749
|
# raises an exception if there is no visible keyboard
|
747
750
|
def _text_from_first_responder
|
@@ -752,7 +755,7 @@ module Calabash
|
|
752
755
|
return res.first unless res.empty?
|
753
756
|
end
|
754
757
|
#noinspection RubyUnnecessaryReturnStatement
|
755
|
-
return
|
758
|
+
return ""
|
756
759
|
end
|
757
760
|
|
758
761
|
end
|
@@ -1,407 +1,61 @@
|
|
1
1
|
require 'sim_launcher'
|
2
|
-
require 'json'
|
3
|
-
require 'run_loop'
|
4
|
-
require 'net/http'
|
5
|
-
require 'cfpropertylist'
|
6
2
|
|
7
3
|
module Calabash
|
8
4
|
module Cucumber
|
9
5
|
|
6
|
+
# this module has been replaced by Simulator Launcher
|
7
|
+
#
|
8
|
+
# @deprecated Use the SimulatorLauncher class instead
|
9
|
+
# @since 0.9.169
|
10
10
|
module SimulatorHelper
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
def self.relaunch(path, sdk = nil, version = 'iphone', args = nil)
|
27
|
-
|
28
|
-
app_bundle_path = app_bundle_or_raise(path)
|
29
|
-
ensure_connectivity(app_bundle_path, sdk, version, args)
|
30
|
-
|
31
|
-
end
|
32
|
-
|
12
|
+
# quits the simulator
|
13
|
+
#
|
14
|
+
# this has been deprecated, but it appears in legacy launch hooks
|
15
|
+
#
|
16
|
+
# use this pattern instead:
|
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
|
+
# @deprecated use the SimulatorLauncher.new().stop instead
|
33
26
|
def self.stop
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
def self.derived_data_dir_for_project
|
39
|
-
dir = project_dir
|
40
|
-
xcode_workspace_name = ''
|
41
|
-
info_plist = Dir.glob(DEFAULT_DERIVED_DATA_INFO).find { |plist_file|
|
42
|
-
begin
|
43
|
-
plist = CFPropertyList::List.new(:file => plist_file)
|
44
|
-
hash = CFPropertyList.native_types(plist.value)
|
45
|
-
ws_dir = File.dirname(hash['WorkspacePath']).downcase
|
46
|
-
p_dir = dir.downcase
|
47
|
-
if (p_dir.include? ws_dir)
|
48
|
-
xcode_workspace_name = ws_dir.split('/').last
|
49
|
-
end
|
50
|
-
ws_dir == p_dir
|
51
|
-
rescue
|
52
|
-
false
|
53
|
-
end
|
54
|
-
}
|
55
|
-
|
56
|
-
if not info_plist.nil?
|
57
|
-
return File.dirname(info_plist)
|
58
|
-
else
|
59
|
-
res = Dir.glob("#{dir}/*.xcodeproj")
|
60
|
-
if res.empty?
|
61
|
-
raise "Unable to find *.xcodeproj in #{dir}"
|
62
|
-
elsif res.count > 1
|
63
|
-
raise "Unable to found several *.xcodeproj in #{dir}: #{res}"
|
64
|
-
end
|
65
|
-
|
66
|
-
xcode_proj_name = res.first.split(".xcodeproj")[0]
|
67
|
-
|
68
|
-
xcode_proj_name = File.basename(xcode_proj_name)
|
69
|
-
|
70
|
-
build_dirs = Dir.glob("#{DERIVED_DATA}/*").find_all do |xc_proj|
|
71
|
-
File.basename(xc_proj).start_with?(xcode_proj_name)
|
72
|
-
end
|
73
|
-
|
74
|
-
if (build_dirs.count == 0 && !xcode_workspace_name.empty?)
|
75
|
-
# check for directory named "workspace-{deriveddirectoryrandomcharacters}"
|
76
|
-
build_dirs = Dir.glob("#{DERIVED_DATA}/*").find_all do |xc_proj|
|
77
|
-
File.basename(xc_proj).downcase.start_with?(xcode_workspace_name)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# todo analyze `self.derived_data_dir_for_project` to see if it contains dead code
|
82
|
-
# todo assuming this is not dead code, the documentation around derived data for project needs to be updated
|
83
|
-
|
84
|
-
if (build_dirs.count == 0)
|
85
|
-
msg = ["Unable to find your built app."]
|
86
|
-
msg << "This means that Calabash can't automatically launch iOS simulator."
|
87
|
-
msg << "Searched in Xcode 4.x default: #{DEFAULT_DERIVED_DATA_INFO}"
|
88
|
-
msg << ""
|
89
|
-
msg << "To fix there are a couple of options:\n"
|
90
|
-
msg << "Option 1) Make sure you are running this command from your project directory, "
|
91
|
-
msg << "i.e., the directory containing your .xcodeproj file."
|
92
|
-
msg << "In Xcode, build your calabash target for simulator."
|
93
|
-
msg << "Check that your app can be found in\n #{File.expand_path("~/Library/Developer/Xcode/DerivedData")}"
|
94
|
-
msg << "\n\nOption 2). In features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
95
|
-
msg << "the path where Xcode has built your Calabash target."
|
96
|
-
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
97
|
-
raise msg.join("\n")
|
98
|
-
|
99
|
-
elsif (build_dirs.count > 1)
|
100
|
-
msg = ["Unable to auto detect APP_BUNDLE_PATH."]
|
101
|
-
msg << "You have several projects with the same name: #{xcode_proj_name} in #{DERIVED_DATA}:\n"
|
102
|
-
msg << build_dirs.join("\n")
|
103
|
-
|
104
|
-
msg << "\nThis means that Calabash can't automatically launch iOS simulator."
|
105
|
-
msg << "Searched in Xcode 4.x default: #{DEFAULT_DERIVED_DATA_INFO}"
|
106
|
-
msg << "\nIn features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
107
|
-
msg << "the path where Xcode has built your Calabash target."
|
108
|
-
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
109
|
-
raise msg.join("\n")
|
27
|
+
unless ENV['CALABASH_NO_DEPRECATION'] == '1'
|
28
|
+
if RUBY_VERSION < '2.0'
|
29
|
+
stack = Kernel.caller()[1..6].join("\n")
|
110
30
|
else
|
111
|
-
|
112
|
-
puts "Found potential build dir: #{build_dirs.first}"
|
113
|
-
puts "Checking..."
|
114
|
-
end
|
115
|
-
return build_dirs.first
|
31
|
+
stack = Kernel.caller(0, 6)[1..-1].join("\n")
|
116
32
|
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def self.project_dir
|
121
|
-
File.expand_path(ENV['PROJECT_DIR'] || Dir.pwd)
|
122
|
-
end
|
123
|
-
|
124
|
-
def self.detect_app_bundle(path=nil,device_build_dir='iPhoneSimulator')
|
125
|
-
begin
|
126
|
-
app_bundle_or_raise(path,device_build_dir)
|
127
|
-
rescue =>e
|
128
|
-
nil
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def self.app_bundle_or_raise(path=nil, device_build_dir='iPhoneSimulator')
|
133
|
-
bundle_path = nil
|
134
|
-
path = File.expand_path(path) if path
|
135
|
-
|
136
|
-
if path and not File.directory?(path)
|
137
|
-
raise "Unable to find .app bundle at #{path}. It should be an .app directory."
|
138
|
-
elsif path
|
139
|
-
bundle_path = path
|
140
|
-
elsif xamarin_project?
|
141
|
-
bundle_path = bundle_path_from_xamarin_project(device_build_dir)
|
142
|
-
unless bundle_path
|
143
|
-
msg = ["Detected Xamarin project, but did not detect built app linked with Calabash"]
|
144
|
-
msg << "You should build your project from Xamarin Studio"
|
145
|
-
msg << "Make sure you build for Simulator and that you're using the Calabash components"
|
146
|
-
raise msg.join("\n")
|
147
|
-
end
|
148
|
-
if FULL_CONSOLE_OUTPUT
|
149
|
-
puts("-"*37)
|
150
|
-
puts "Auto detected APP_BUNDLE_PATH:\n\n"
|
151
|
-
|
152
|
-
puts "APP_BUNDLE_PATH=#{preferred_dir || sim_dirs[0]}\n\n"
|
153
|
-
puts "Please verify!"
|
154
|
-
puts "If this is wrong please set it as APP_BUNDLE_PATH in features/support/01_launch.rb\n"
|
155
|
-
puts("-"*37)
|
156
|
-
end
|
157
|
-
else
|
158
|
-
dd_dir = derived_data_dir_for_project
|
159
|
-
sim_dirs = Dir.glob(File.join(dd_dir, "Build", "Products", "*-iphonesimulator", "*.app"))
|
160
|
-
if sim_dirs.empty?
|
161
|
-
msg = ["Unable to auto detect APP_BUNDLE_PATH."]
|
162
|
-
msg << "Have you built your app for simulator?"
|
163
|
-
msg << "Searched dir: #{dd_dir}/Build/Products"
|
164
|
-
msg << "Please build your app from Xcode"
|
165
|
-
msg << "You should build the -cal target."
|
166
|
-
msg << ""
|
167
|
-
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb"
|
168
|
-
msg << "This should point to the location of your built app linked with calabash.\n"
|
169
|
-
raise msg.join("\n")
|
170
|
-
end
|
171
|
-
preferred_dir = find_preferred_dir(sim_dirs)
|
172
|
-
if preferred_dir.nil?
|
173
|
-
msg = ["Error... Unable to find APP_BUNDLE_PATH."]
|
174
|
-
msg << "Cannot find a built app that is linked with calabash.framework"
|
175
|
-
msg << "Please build your app from Xcode"
|
176
|
-
msg << "You should build your calabash target."
|
177
|
-
msg << ""
|
178
|
-
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb"
|
179
|
-
msg << "This should point to the location of your built app linked with calabash.\n"
|
180
|
-
raise msg.join("\n")
|
181
|
-
end
|
182
|
-
if FULL_CONSOLE_OUTPUT
|
183
|
-
puts("-"*37)
|
184
|
-
puts "Auto detected APP_BUNDLE_PATH:\n\n"
|
185
|
-
|
186
|
-
puts "APP_BUNDLE_PATH=#{preferred_dir || sim_dirs[0]}\n\n"
|
187
|
-
puts "Please verify!"
|
188
|
-
puts "If this is wrong please set it as APP_BUNDLE_PATH in features/support/01_launch.rb\n"
|
189
|
-
puts("-"*37)
|
190
|
-
end
|
191
|
-
bundle_path = sim_dirs[0]
|
192
|
-
end
|
193
|
-
bundle_path
|
194
|
-
end
|
195
|
-
|
196
|
-
def self.xamarin_project?
|
197
|
-
xamarin_ios_csproj_path != nil
|
198
|
-
end
|
199
|
-
|
200
|
-
def self.xamarin_ios_csproj_path
|
201
|
-
solution_path = Dir['*.sln'].first
|
202
|
-
if solution_path
|
203
|
-
project_dir = Dir.pwd
|
204
|
-
else
|
205
|
-
solution_path = Dir[File.join('..','*.sln')].first
|
206
|
-
project_dir = File.expand_path('..') if solution_path
|
207
|
-
end
|
208
|
-
return nil unless project_dir
|
209
|
-
|
210
|
-
ios_project_dir = Dir[File.join(project_dir,'*.iOS')].first
|
211
|
-
return ios_project_dir if ios_project_dir && File.directory?(ios_project_dir)
|
212
|
-
# ios_project_dir does not exist
|
213
|
-
# Detect case where there is no such sub directory
|
214
|
-
# (i.e. iOS only Xamarin project)
|
215
|
-
bin_dir = File.join(project_dir, 'bin')
|
216
|
-
if xamarin_ios_bin_dir?(bin_dir)
|
217
|
-
return project_dir ## Looks like iOS bin dir is here
|
218
|
-
end
|
219
|
-
|
220
|
-
sub_dirs = Dir[File.join(project_dir,'*')].select {|dir| File.directory?(dir)}
|
221
|
-
|
222
|
-
sub_dirs.find do |sub_dir|
|
223
|
-
contains_csproj = Dir[File.join(sub_dir,'*.csproj')].first
|
224
|
-
contains_csproj && xamarin_ios_bin_dir?(File.join(sub_dir,'bin'))
|
225
|
-
end
|
226
|
-
|
227
|
-
end
|
228
|
-
|
229
|
-
def self.xamarin_ios_bin_dir?(bin_dir)
|
230
|
-
File.directory?(bin_dir) &&
|
231
|
-
(File.directory?(File.join(bin_dir,'iPhoneSimulator')) ||
|
232
|
-
File.directory?(File.join(bin_dir,'iPhone')))
|
233
|
-
end
|
234
|
-
|
235
|
-
def self.bundle_path_from_xamarin_project(device_build_dir='iPhoneSimulator')
|
236
|
-
ios_project_path = xamarin_ios_csproj_path
|
237
|
-
conf_glob = File.join(ios_project_path,'bin',device_build_dir,'*')
|
238
|
-
built_confs = Dir[conf_glob]
|
239
|
-
|
240
|
-
calabash_build = built_confs.find {|path| File.basename(path) == 'Calabash'}
|
241
|
-
debug_build = built_confs.find {|path| File.basename(path) == 'Debug'}
|
242
|
-
|
243
|
-
bundle_path = [calabash_build, debug_build, *built_confs].find do |path|
|
244
|
-
next unless path && File.directory?(path)
|
245
|
-
app_dir = Dir[File.join(path,'*.app')].first
|
246
|
-
app_dir && linked_with_calabash?(app_dir)
|
247
|
-
end
|
248
|
-
|
249
|
-
Dir[File.join(bundle_path,'*.app')].first if bundle_path
|
250
|
-
end
|
251
|
-
|
252
|
-
def self.linked_with_calabash?(d)
|
253
|
-
skipped_formats = [".png", ".jpg", ".jpeg", ".plist", ".nib", ".lproj"]
|
254
|
-
dir = File.expand_path(d)
|
255
33
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
34
|
+
msgs = ['The Calabash::Cucumber::SimulatorHelper module has been replaced.',
|
35
|
+
'Please replace:',
|
36
|
+
'',
|
37
|
+
' Calabash::Cucumber::SimulatorHelper.stop',
|
38
|
+
'',
|
39
|
+
'with this:',
|
40
|
+
'',
|
41
|
+
' launcher = Calabash::Cucumber::Launcher.new',
|
42
|
+
' launcher.simulator_launcher.stop',
|
43
|
+
'',
|
44
|
+
'The stack trace below will show you the line number you need to change.']
|
260
45
|
|
261
|
-
|
262
|
-
out = `otool #{dir}/#{file} -o 2> /dev/null | grep CalabashServer`
|
263
|
-
return true if /CalabashServer/.match(out)
|
264
|
-
end
|
46
|
+
msg = "deprecated '0.9.169' - #{msgs.join("\n")}\n#{stack}"
|
265
47
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
def self.find_preferred_dir(sim_dirs)
|
271
|
-
sim_dirs.find do |d|
|
272
|
-
linked_with_calabash?(d)
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
def self.ensure_connectivity(app_bundle_path, sdk, version, args = nil)
|
277
|
-
begin
|
278
|
-
max_retry_count = (ENV['MAX_CONNECT_RETRY'] || DEFAULT_SIM_RETRY).to_i
|
279
|
-
timeout = (ENV['CONNECT_TIMEOUT'] || DEFAULT_SIM_WAIT).to_i
|
280
|
-
retry_count = 0
|
281
|
-
connected = false
|
282
|
-
|
283
|
-
if FULL_CONSOLE_OUTPUT
|
284
|
-
puts "Waiting at most #{timeout} seconds for simulator (CONNECT_TIMEOUT)"
|
285
|
-
puts "Retrying at most #{max_retry_count} times (MAX_CONNECT_RETRY)"
|
286
|
-
end
|
287
|
-
|
288
|
-
until connected do
|
289
|
-
raise "MAX_RETRIES" if retry_count == max_retry_count
|
290
|
-
retry_count += 1
|
291
|
-
if FULL_CONSOLE_OUTPUT
|
292
|
-
puts "(#{retry_count}.) Start Simulator #{sdk}, #{version}, for #{app_bundle_path}"
|
293
|
-
end
|
294
|
-
begin
|
295
|
-
Timeout::timeout(timeout, TimeoutErr) do
|
296
|
-
simulator = launch(app_bundle_path, sdk, version, args)
|
297
|
-
until connected
|
298
|
-
begin
|
299
|
-
connected = (ping_app == '405')
|
300
|
-
if connected
|
301
|
-
server_version = get_version
|
302
|
-
if server_version
|
303
|
-
if FULL_CONSOLE_OUTPUT
|
304
|
-
p server_version
|
305
|
-
end
|
306
|
-
unless version_check(server_version)
|
307
|
-
msgs = ["You're running an older version of Calabash server with a newer client",
|
308
|
-
"Client:#{Calabash::Cucumber::VERSION}",
|
309
|
-
"Server:#{server_version}",
|
310
|
-
"Minimum server version #{Calabash::Cucumber::FRAMEWORK_VERSION}",
|
311
|
-
"Update recommended:",
|
312
|
-
"https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version"
|
313
|
-
]
|
314
|
-
raise msgs.join("\n")
|
315
|
-
end
|
316
|
-
else
|
317
|
-
connected = false
|
318
|
-
end
|
319
|
-
end
|
320
|
-
rescue Exception => e
|
321
|
-
|
322
|
-
ensure
|
323
|
-
sleep 1 unless connected
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|
327
|
-
rescue TimeoutErr => e
|
328
|
-
puts 'Timed out... Retrying'
|
329
|
-
stop
|
330
|
-
end
|
48
|
+
begin
|
49
|
+
STDERR.puts "\033[34m\nWARN: #{msg}\033[0m"
|
50
|
+
rescue
|
51
|
+
STDERR.puts "\nWARN: #{msg}"
|
331
52
|
end
|
332
|
-
rescue RuntimeError => e
|
333
|
-
p e
|
334
|
-
msg = "Unable to make connection to Calabash Server at #{ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/"}\n"
|
335
|
-
msg << "Make sure you've' linked correctly with calabash.framework and set Other Linker Flags.\n"
|
336
|
-
msg << "Make sure you don't have a firewall blocking traffic to #{ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/"}.\n"
|
337
|
-
raise msg
|
338
53
|
end
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
def self.launch(app_bundle_path, sdk, version, args = nil)
|
343
|
-
simulator = SimLauncher::Simulator.new
|
344
|
-
simulator.launch_ios_app(app_bundle_path, sdk, version)
|
54
|
+
simulator = SimLauncher::Simulator.new()
|
55
|
+
simulator.quit_simulator
|
345
56
|
simulator
|
346
57
|
end
|
347
58
|
|
348
|
-
def self.ping_app
|
349
|
-
url = URI.parse(ENV['DEVICE_ENDPOINT']|| "http://localhost:37265/")
|
350
|
-
if FULL_CONSOLE_OUTPUT
|
351
|
-
puts "Ping #{url}..."
|
352
|
-
end
|
353
|
-
http = Net::HTTP.new(url.host, url.port)
|
354
|
-
res = http.start do |sess|
|
355
|
-
sess.request Net::HTTP::Get.new url.path
|
356
|
-
end
|
357
|
-
status = res.code
|
358
|
-
begin
|
359
|
-
http.finish if http and http.started?
|
360
|
-
rescue
|
361
|
-
|
362
|
-
end
|
363
|
-
status
|
364
|
-
end
|
365
|
-
|
366
|
-
def self.get_version
|
367
|
-
endpoint = ENV['DEVICE_ENDPOINT']|| "http://localhost:37265"
|
368
|
-
endpoint += "/" unless endpoint.end_with? "/"
|
369
|
-
url = URI.parse("#{endpoint}version")
|
370
|
-
|
371
|
-
if FULL_CONSOLE_OUTPUT
|
372
|
-
puts "Fetch version #{url}..."
|
373
|
-
end
|
374
|
-
begin
|
375
|
-
body = Net::HTTP.get_response(url).body
|
376
|
-
res = JSON.parse(body)
|
377
|
-
if res['iOS_version']
|
378
|
-
@ios_version = res['iOS_version']
|
379
|
-
end
|
380
|
-
res
|
381
|
-
rescue
|
382
|
-
nil
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
def self.ios_version
|
387
|
-
unless @ios_version
|
388
|
-
get_version
|
389
|
-
end
|
390
|
-
@ios_version
|
391
|
-
end
|
392
|
-
|
393
|
-
def self.ios_major_version
|
394
|
-
v = ios_version
|
395
|
-
if v
|
396
|
-
v.split(".")[0]
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
def self.version_check(version)
|
401
|
-
server_version = version["version"]
|
402
|
-
Calabash::Cucumber::FRAMEWORK_VERSION == server_version
|
403
|
-
end
|
404
59
|
end
|
405
|
-
|
406
60
|
end
|
407
61
|
end
|