run_loop 2.1.10 → 2.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1d5ec2c34563d9302dd2ea711a02542f391cdb1
4
- data.tar.gz: 0559160c9bba7c824d069f8b1f90819328033691
3
+ metadata.gz: e9ebbfcb0e62aedb6823bf0d20769d04a655e231
4
+ data.tar.gz: 5e155942b7249c597f43aaa0eea71d571d325778
5
5
  SHA512:
6
- metadata.gz: 46181f7467e976ef0f53d874b5145de368055be6d3fac52e6e872c1f28a1a39f9c04de92df0b4bcbfce270ef6b1438f1c1f590246cd51bc796c32acf54ec8c9b
7
- data.tar.gz: e11a8e89c0a0ee501a961342d6e71705a3ebc9d1788d8ee23adc2fadeb4ac1ea321e44390df8517e753b81535eefe6332084ae63de9786ea24a9e613871a38b1
6
+ metadata.gz: e26d30623d4fd37530c2413032e27b8d23c497b1ff58564a338d2c764d927aff5b43fadfc3f0f09c8f6aa5bd82a4964508fbc9a582f30ef9fd6652aeea21670d
7
+ data.tar.gz: 4cad181f7d717ec8842b4bd0f64c6906597eefa2bd91a214625021eee0b2b6ed120e24e32efcf50095073ff08a16fea432e298959db7e9e825e0610fc3a0e7ba
data/lib/run_loop/core.rb CHANGED
@@ -279,7 +279,7 @@ Logfile: #{log_file}
279
279
 
280
280
  RunLoop::Logging.log_debug(logger, "Launching took #{Time.now-before_instruments_launch} seconds")
281
281
 
282
- dylib_path = self.dylib_path_from_options(merged_options)
282
+ dylib_path = RunLoop::DylibInjector.dylib_path_from_options(merged_options)
283
283
 
284
284
  if dylib_path
285
285
  if device.physical_device?
@@ -313,26 +313,6 @@ Logfile: #{log_file}
313
313
  true
314
314
  end
315
315
 
316
- # Extracts the value of :inject_dylib from options Hash.
317
- # @param options [Hash] arguments passed to {RunLoop.run}
318
- # @return [String, nil] If the options contains :inject_dylibs and it is a
319
- # path to a dylib that exists, return the path. Otherwise return nil or
320
- # raise an error.
321
- # @raise [RuntimeError] If :inject_dylib points to a path that does not exist.
322
- # @raise [ArgumentError] If :inject_dylib is not a String.
323
- def self.dylib_path_from_options(options)
324
- inject_dylib = options.fetch(:inject_dylib, nil)
325
- return nil if inject_dylib.nil?
326
- unless inject_dylib.is_a? String
327
- raise ArgumentError, "Expected :inject_dylib to be a path to a dylib, but found '#{inject_dylib}'"
328
- end
329
- dylib_path = File.expand_path(inject_dylib)
330
- unless File.exist?(dylib_path)
331
- raise "Cannot load dylib. The file '#{dylib_path}' does not exist."
332
- end
333
- dylib_path
334
- end
335
-
336
316
  # Returns the a default simulator to target. This default needs to be one
337
317
  # that installed by default in the current Xcode version.
338
318
  #
@@ -365,7 +345,6 @@ Logfile: #{log_file}
365
345
  end
366
346
  end
367
347
 
368
-
369
348
  def self.create_uia_pipe(repl_path)
370
349
  begin
371
350
  Timeout::timeout(5, RunLoop::TimeoutError) do
@@ -13,6 +13,7 @@ module RunLoop
13
13
  include RunLoop::Encoding
14
14
 
15
15
  require "run_loop/cache"
16
+ require "run_loop/dylib_injector"
16
17
 
17
18
  class HTTPError < RuntimeError; end
18
19
 
@@ -78,6 +79,11 @@ module RunLoop
78
79
  app = app_details[:app]
79
80
  bundle_id = app_details[:bundle_id]
80
81
 
82
+ # process name and dylib path
83
+ dylib_injection_details = Client.details_for_dylib_injection(device,
84
+ options,
85
+ app_details)
86
+
81
87
  if device.simulator? && app
82
88
  core_sim = RunLoop::CoreSimulator.new(device, app, :xcode => xcode)
83
89
  if reset_options
@@ -120,7 +126,8 @@ $ xcrun security find-identity -v -p codesigning
120
126
  launcher_options = {
121
127
  code_sign_identity: code_sign_identity,
122
128
  device_agent_install_timeout: install_timeout,
123
- shutdown_device_agent_before_launch: shutdown_before_launch
129
+ shutdown_device_agent_before_launch: shutdown_before_launch,
130
+ dylib_injection_details: dylib_injection_details
124
131
  }
125
132
 
126
133
  xcuitest = RunLoop::DeviceAgent::Client.new(bundle_id, device,
@@ -135,7 +142,7 @@ $ xcrun security find-identity -v -p codesigning
135
142
  :code_sign_identity => code_sign_identity,
136
143
  :launcher => cbx_launcher.name,
137
144
  :launcher_pid => xcuitest.launcher_pid,
138
- :launcher_options => launcher_options
145
+ :launcher_options => xcuitest.launcher_options
139
146
  }
140
147
  RunLoop::Cache.default.write(cache)
141
148
  end
@@ -168,6 +175,52 @@ $ xcrun security find-identity -v -p codesigning
168
175
  end
169
176
  end
170
177
 
178
+ def self.details_for_dylib_injection(device, options, app_details)
179
+ dylib_path = RunLoop::DylibInjector.dylib_path_from_options(options)
180
+
181
+ return nil if !dylib_path
182
+
183
+ if device.physical_device?
184
+ raise ArgumentError, %Q[
185
+
186
+ Detected :inject_dylib option when targeting a physical device:
187
+
188
+ #{device}
189
+
190
+ Injecting the Calabash iOS Server is not supported on physical devices.
191
+
192
+ ]
193
+ end
194
+
195
+ app = app_details[:app]
196
+ bundle_id = app_details[:bundle_id]
197
+
198
+ details = { dylib_path: dylib_path }
199
+
200
+ if !app
201
+ # Special case handling of the Settings.app
202
+ if bundle_id == "com.apple.Preferences"
203
+ details[:process_name] = "Preferences"
204
+ else
205
+ raise ArgumentError, %Q[
206
+
207
+ Detected :inject_dylib option, but the target application is a bundle identifier:
208
+
209
+ app: #{bundle_id}
210
+
211
+ To use dylib injection, you must provide a path to an .app bundle.
212
+
213
+ ]
214
+ end
215
+ else
216
+ details[:process_name] = app.executable_name
217
+ end
218
+ details
219
+ end
220
+
221
+ =begin
222
+ INSTANCE METHODS
223
+ =end
171
224
  attr_reader :bundle_id, :device, :cbx_launcher, :launcher_options, :launcher_pid
172
225
 
173
226
  # @!visibility private
@@ -461,8 +514,8 @@ Query must contain at least one of these keys:
461
514
  end
462
515
 
463
516
  # @!visibility private
464
- def spring_board_alert
465
- request = request("springBoardAlert")
517
+ def springboard_alert
518
+ request = request("springboard-alert")
466
519
  client = http_client(http_options)
467
520
  response = client.get(request)
468
521
  hash = expect_300_response(response)
@@ -470,8 +523,8 @@ Query must contain at least one of these keys:
470
523
  end
471
524
 
472
525
  # @!visibility private
473
- def spring_board_alert_visible?
474
- !spring_board_alert.empty?
526
+ def springboard_alert_visible?
527
+ !springboard_alert.empty?
475
528
  end
476
529
 
477
530
  # @!visibility private
@@ -1146,9 +1199,6 @@ $ tail -1000 -F #{cbx_launcher.class.log_file}
1146
1199
 
1147
1200
  # @!visibility private
1148
1201
  def launch_aut(bundle_id = @bundle_id)
1149
- client = http_client(http_options)
1150
- request = request("session", {:bundleID => bundle_id})
1151
-
1152
1202
  # This check needs to be done _before_ the DeviceAgent is launched.
1153
1203
  if device.simulator?
1154
1204
  # Yes, we could use iOSDeviceManager to check, I dont understand the
@@ -1181,6 +1231,8 @@ Please install it.
1181
1231
  end
1182
1232
 
1183
1233
  retries = 5
1234
+ client = http_client(http_options)
1235
+ request = request("session", {:bundleID => bundle_id})
1184
1236
 
1185
1237
  begin
1186
1238
  response = client.post(request)
@@ -1188,6 +1240,15 @@ Please install it.
1188
1240
  RunLoop.log_debug("#{response.body}")
1189
1241
 
1190
1242
  expect_300_response(response)
1243
+
1244
+ # Dylib injection. DeviceAgent.run checks the arguments.
1245
+ dylib_injection_details = launcher_options[:dylib_injection_details]
1246
+ if dylib_injection_details
1247
+ process_name = dylib_injection_details[:process_name]
1248
+ dylib_path = dylib_injection_details[:dylib_path]
1249
+ injector = RunLoop::DylibInjector.new(process_name, dylib_path)
1250
+ injector.retriable_inject_dylib
1251
+ end
1191
1252
  rescue => e
1192
1253
  retries = retries - 1
1193
1254
  if !RunLoop::Environment.xtc?
@@ -1271,7 +1332,7 @@ Expected JSON response with no error, but found
1271
1332
  raise ArgumentError, %Q[
1272
1333
  Expected #{position} to be a Symbol or Fixnum but found #{position.class}
1273
1334
 
1274
- ]
1335
+ ]
1275
1336
  end
1276
1337
  end
1277
1338
 
@@ -1293,9 +1354,19 @@ Expected #{position} to be a Symbol or Fixnum but found #{position.class}
1293
1354
  Could not coerce '#{position}' into a valid orientation.
1294
1355
 
1295
1356
  Valid values are: :down, :up, :right, :left, :bottom, :top
1357
+
1296
1358
  ]
1297
1359
  end
1298
1360
  end
1361
+
1362
+ # @!visibility private
1363
+ # Private method. Do not call.
1364
+ def _dismiss_springboard_alerts
1365
+ request = request("dismiss-springboard-alerts")
1366
+ client = http_client(http_options)
1367
+ response = client.post(request)
1368
+ expect_300_response(response)
1369
+ end
1299
1370
  end
1300
1371
  end
1301
1372
  end
@@ -26,6 +26,30 @@ module RunLoop
26
26
  :timeout => RunLoop::Environment.ci? ? 40 : 20
27
27
  }
28
28
 
29
+ # Extracts the value of :inject_dylib from options Hash.
30
+ # @param options [Hash] arguments passed to {RunLoop.run}
31
+ # @return [String, nil] If the options contains :inject_dylibs and it is a
32
+ # path to a dylib that exists, return the path. Otherwise return nil or
33
+ # raise an error.
34
+ # @raise [RuntimeError] If :inject_dylib points to a path that does not exist.
35
+ # @raise [ArgumentError] If :inject_dylib is not a String.
36
+ def self.dylib_path_from_options(options)
37
+ inject_dylib = options.fetch(:inject_dylib, nil)
38
+ return nil if inject_dylib.nil?
39
+ if !inject_dylib.is_a? String
40
+ raise ArgumentError, %Q[
41
+
42
+ Expected :inject_dylib to be a path to a dylib, but found '#{inject_dylib}'
43
+
44
+ ]
45
+ end
46
+ dylib_path = File.expand_path(inject_dylib)
47
+ unless File.exist?(dylib_path)
48
+ raise "Cannot load dylib. The file '#{dylib_path}' does not exist."
49
+ end
50
+ dylib_path
51
+ end
52
+
29
53
  # @!attribute [r] process_name
30
54
  # The name of the process to inject the dylib into. This should be obtained
31
55
  # by inspecting the Info.plist in the app bundle.
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = "2.1.10"
2
+ VERSION = "2.1.11"
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.10
4
+ version: 2.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-09 00:00:00.000000000 Z
12
+ date: 2016-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json