run_loop 1.0.7 → 1.0.8

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: d73937dad7c29104b1ae37c879b16e44aff02db3
4
- data.tar.gz: dda0b44e84dd217f63e2108912fb74b79049bd1b
3
+ metadata.gz: 11be3a1fe89681a24289e331b94823e23cf6ade9
4
+ data.tar.gz: 5e51d2d106452481ba15e63315ac26fb5798a0c6
5
5
  SHA512:
6
- metadata.gz: 93c63c401d4307fe1accf494b4a6a32619d66043ded3c7c75ebc7ff9cacfdcc32f0fc23552309bd048212c4ca77c0421e8aab5be9b892a3e3ab8383442950db3
7
- data.tar.gz: 5d23eda8b969944c6030affb7ff2dcd7da5a1ef357b4b5f6ce8ff9e92d7e169b9dfa0f001182bc0a95811c73fe4eba9b40149bbe00e4a2d0fe37e27b75a30c22
6
+ metadata.gz: 396eff04828c24cadfca702fc041a238b337c8310d65e1ebba5dfd8ba1a7a77dc7a3cee05a1e59966db913f7dbb3113ff8023a6c2bac609ede575c98b48c2f7e
7
+ data.tar.gz: 6c87504310686551a5bec02248b92bc24681b4bf62ae57286ba04f64e0dba3edbae7e1b804efdbeb9325e67e3be594cc2c8943fbcff8bb8405f693b973d5cfeb
data/lib/run_loop/core.rb CHANGED
@@ -574,7 +574,13 @@ module RunLoop
574
574
 
575
575
  def self.default_tracetemplate(xctools=RunLoop::XCTools.new)
576
576
  templates = xctools.instruments :templates
577
- if xctools.xcode_version_gte_6?
577
+ if xctools.xcode_version_gte_61?
578
+ templates.delete_if do |path|
579
+ not path =~ /\/Automation.tracetemplate/
580
+ end.delete_if do |path|
581
+ not path =~ /Xcode/
582
+ end.first.tr("\"", '').strip
583
+ elsif xctools.xcode_version_gte_6?
578
584
  templates.delete_if do |name|
579
585
  not name == 'Automation'
580
586
  end.first
@@ -5,23 +5,123 @@ module RunLoop
5
5
  # @note All instruments commands are run in the context of `xcrun`.
6
6
  #
7
7
  # @todo Detect Instruments.app is running and pop an alert.
8
- # @todo Needs tests.
9
8
  class Instruments
10
9
 
10
+ # Returns an Array of instruments process ids.
11
+ #
12
+ # @note The `block` parameter is included for legacy API and will be
13
+ # deprecated. Replace your existing calls with with .each or .map. The
14
+ # block argument makes this method hard to mock.
15
+ # @return [Array<Integer>] An array of instruments process ids.
16
+ def instruments_pids(&block)
17
+ pids = pids_from_ps_output
18
+ if block_given?
19
+ pids.each do |pid|
20
+ block.call(pid)
21
+ end
22
+ else
23
+ pids
24
+ end
25
+ end
26
+
27
+ # Are there any instruments processes running?
28
+ # @return [Boolean] True if there is are any instruments processes running.
29
+ def instruments_running?
30
+ instruments_pids.count > 0
31
+ end
32
+
33
+ # Send a kill signal to any running `instruments` processes.
34
+ #
35
+ # Only one instruments process can be running at any one time.
36
+ #
37
+ # @param [RunLoop::XCTools] xcode_tools The Xcode tools to use to determine
38
+ # what version of Xcode is active.
39
+ def kill_instruments(xcode_tools = RunLoop::XCTools.new)
40
+ kill_signal = kill_signal xcode_tools
41
+ # It is difficult to test using a block.
42
+ instruments_pids.each do |pid|
43
+ begin
44
+ if ENV['DEBUG'] == '1'
45
+ puts "Sending '#{kill_signal}' to instruments process '#{pid}'"
46
+ end
47
+ Process.kill(kill_signal, pid.to_i)
48
+ rescue Exception => e
49
+ if ENV['DEBUG'] == '1'
50
+ puts "Could not kill process '#{pid.to_i}' - ignoring #{e}"
51
+ end
52
+ end
53
+
54
+ # Process.wait or `wait` here is pointless. The pid may or may not be
55
+ # a child of this Process.
56
+ begin
57
+ if ENV['DEBUG'] == '1'
58
+ puts "Waiting for instruments '#{pid}' to terminate"
59
+ end
60
+ wait_for_process_to_terminate(pid, {:timeout => 2.0})
61
+ rescue Exception => e
62
+ if ENV['DEBUG'] == '1'
63
+ puts "Ignoring #{e.message}"
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ private
70
+
11
71
  # @!visibility private
12
- # $ ps x -o pid,command | grep -v grep | grep instruments
13
- # 98081 sh -c xcrun instruments -w "43be3f89d9587e9468c24672777ff6241bd91124" < args >
14
- # 98082 /Xcode/6.0.1/Xcode.app/Contents/Developer/usr/bin/instruments -w < args >
72
+ # When run from calabash, expect this:
73
+ #
74
+ # ```
75
+ # $ ps x -o pid,command | grep -v grep | grep instruments
76
+ # 98081 sh -c xcrun instruments -w "43be3f89d9587e9468c24672777ff6241bd91124" < args >
77
+ # 98082 /Xcode/6.0.1/Xcode.app/Contents/Developer/usr/bin/instruments -w < args >
78
+ # ```
79
+ # When run from run-loop (via rspec), expect this:
80
+ #
81
+ # ```
82
+ # $ ps x -o pid,command | grep -v grep | grep instruments
83
+ # 98082 /Xcode/6.0.1/Xcode.app/Contents/Developer/usr/bin/instruments -w < args >
15
84
  FIND_PIDS_CMD = 'ps x -o pid,comm | grep -v grep | grep instruments'
16
85
 
17
- def grep_for_instruments_pids
18
- ps_output = `#{FIND_PIDS_CMD}`.strip
86
+ # @!visibility private
87
+ #
88
+ # Executes `ps_cmd` to find instruments processes and returns the result.
89
+ #
90
+ # @param [String] ps_cmd The Unix ps command to execute to find instruments
91
+ # processes.
92
+ # @return [String] A ps-style list of process details. The details returned
93
+ # are controlled by the `ps_cmd`.
94
+ def ps_for_instruments(ps_cmd=FIND_PIDS_CMD)
95
+ `#{ps_cmd}`.strip
96
+ end
97
+
98
+ # @!visibility private
99
+ # Is the process described an instruments process?
100
+ #
101
+ # @param [String] ps_details Details about a process as returned by `ps`
102
+ # @return [Boolean] True if the details describe an instruments process.
103
+ def is_instruments_process?(ps_details)
104
+ return false if ps_details.nil?
105
+ (ps_details[/\/usr\/bin\/instruments/, 0] or
106
+ ps_details[/sh -c xcrun instruments/, 0]) != nil
107
+ end
108
+
109
+ # @!visibility private
110
+ # Extracts an Array of integer process ids from the output of executing
111
+ # the Unix `ps_cmd`.
112
+ #
113
+ # @param [String] ps_cmd The Unix `ps` command used to find instruments
114
+ # processes.
115
+ # @return [Array<Integer>] An array of integer pids for instruments
116
+ # processes. Returns an empty list if no instruments process are found.
117
+ def pids_from_ps_output(ps_cmd=FIND_PIDS_CMD)
118
+ ps_output = ps_for_instruments(ps_cmd)
19
119
  lines = ps_output.lines("\n").map { |line| line.strip }
20
120
  lines.map do |line|
21
121
  tokens = line.strip.split(' ').map { |token| token.strip }
22
122
  pid = tokens.fetch(0, nil)
23
- process = tokens.fetch(1, nil)
24
- if process and process[/\/usr\/bin\/instruments/, 0]
123
+ process_description = tokens[1..-1].join(' ')
124
+ if is_instruments_process? process_description
25
125
  pid.to_i
26
126
  else
27
127
  nil
@@ -29,28 +129,60 @@ module RunLoop
29
129
  end.compact
30
130
  end
31
131
 
32
- def instruments_pids(&block)
33
- pids = grep_for_instruments_pids
34
- if block_given?
35
- pids.each do |pid|
36
- block.call(pid)
37
- end
38
- else
39
- pids
40
- end # MobileGestaltHelper[909] <Error>: libMobileGestalt MobileGestalt.c:273: server_access_check denied access to question UniqueDeviceID for pid 796

132
+ # @!visibility private
133
+ # The kill signal should be sent to instruments.
134
+ #
135
+ # When testing against iOS 8, sending -9 or 'TERM' causes the ScriptAgent
136
+ # process on the device to emit the following error until the device is
137
+ # rebooted.
138
+ #
139
+ # ```
140
+ # MobileGestaltHelper[909] <Error>: libMobileGestalt MobileGestalt.c:273: server_access_check denied access to question UniqueDeviceID for pid 796

141
+ # ScriptAgent[796] <Error>: libMobileGestalt MobileGestaltSupport.m:170: pid 796 (ScriptAgent) does not have sandbox access for re6Zb+zwFKJNlkQTUeT+/w and IS NOT appropriately entitled
142
+ # ScriptAgent[703] <Error>: libMobileGestalt MobileGestalt.c:534: no access to UniqueDeviceID (see <rdar://problem/11744455>)
143
+ # ```
144
+ #
145
+ # @see https://github.com/calabash/run_loop/issues/34
146
+ #
147
+ # @param [RunLoop::XCTools] xcode_tools The Xcode tools to use to determine
148
+ # what version of Xcode is active.
149
+ # @return [String] Either 'QUIT' or 'TERM', depending on the Xcode
150
+ # version.
151
+ def kill_signal(xcode_tools = RunLoop::XCTools.new)
152
+ xcode_tools.xcode_version_gte_6? ? 'QUIT' : 'TERM'
41
153
  end
42
154
 
43
- def instruments_running?
44
- instruments_pids.count > 0
45
- end
155
+ # @!visibility private
156
+ # Wait for Unix process with id `pid` to terminate.
157
+ #
158
+ # @param [Integer] pid The id of the process we are waiting on.
159
+ # @param [Hash] options Values to control the behavior of this method.
160
+ # @option options [Float] :timeout (2.0) How long to wait for the process to
161
+ # terminate.
162
+ # @option options [Float] :interval (0.1) The polling interval.
163
+ # @option options [Boolean] :raise_on_no_terminate (false) Should an error
164
+ # be raised if process does not terminate.
165
+ # @raise [RuntimeError] If process does not terminate and
166
+ # options[:raise_on_no_terminate] is truthy.
167
+ def wait_for_process_to_terminate(pid, options={})
168
+ default_opts = {:timeout => 2.0,
169
+ :interval => 0.1,
170
+ :raise_on_no_terminate => false}
171
+ merged_opts = default_opts.merge(options)
46
172
 
47
- def kill_instruments(xcode_tools = RunLoop::XCTools.new)
48
- kill_signal = xcode_tools.xcode_version_gte_6? ? 'QUIT' : 'TERM'
49
- instruments_pids do |pid|
50
- if ENV['DEBUG'] == '1'
51
- puts "Sending '#{kill_signal}' to instruments process '#{pid}'"
52
- end
53
- Process.kill(kill_signal, pid.to_i)
173
+ cmd = "ps #{pid} -o pid | grep #{pid}"
174
+ poll_until = Time.now + merged_opts[:timeout]
175
+ delay = merged_opts[:interval]
176
+ has_terminated = false
177
+ while Time.now < poll_until
178
+ has_terminated = `#{cmd}`.strip == ''
179
+ break if has_terminated
180
+ sleep delay
181
+ end
182
+
183
+ if merged_opts[:raise_on_no_terminate] and not has_terminated
184
+ details = `ps -p #{pid} -o pid,comm | grep #{pid}`.strip
185
+ raise RuntimeError, "Waited #{merged_opts[:timeout]} s for process '#{details}' to terminate"
54
186
  end
55
187
  end
56
188
  end
@@ -1,5 +1,5 @@
1
1
  module RunLoop
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.8'
3
3
 
4
4
  # A model of a software release version that can be used to compare two versions.
5
5
  #
@@ -15,6 +15,14 @@ module RunLoop
15
15
  # @todo Refactor instruments related code to instruments class.
16
16
  class XCTools
17
17
 
18
+ # Returns a version instance for `Xcode 6.0`; used to check for the
19
+ # availability of features and paths to various items on the filesystem.
20
+ #
21
+ # @return [RunLoop::Version] 6.0
22
+ def v61
23
+ @xc61 ||= RunLoop::Version.new('6.1')
24
+ end
25
+
18
26
  # Returns a version instance for `Xcode 6.0`; used to check for the
19
27
  # availability of features and paths to various items on the filesystem.
20
28
  #
@@ -39,6 +47,13 @@ module RunLoop
39
47
  @xc50 ||= RunLoop::Version.new('5.0')
40
48
  end
41
49
 
50
+ # Are we running Xcode 6.1 or above?
51
+ #
52
+ # @return [Boolean] `true` if the current Xcode version is >= 6.1
53
+ def xcode_version_gte_61?
54
+ @xcode_gte_61 ||= xcode_version >= v61
55
+ end
56
+
42
57
  # Are we running Xcode 6 or above?
43
58
  #
44
59
  # @return [Boolean] `true` if the current Xcode version is >= 6.0
@@ -142,7 +157,16 @@ module RunLoop
142
157
  when :templates
143
158
  @instruments_templates ||= lambda {
144
159
  cmd = "#{instruments} -s templates"
145
- if self.xcode_version >= self.v60
160
+ if self.xcode_version >= self.v61
161
+ Open3.popen3(cmd) do |_, stdout, stderr, _|
162
+ stderr_filter.call(stderr)
163
+ stdout.read.chomp.split("\n").map do |line|
164
+ line.strip.tr('"', '')
165
+ end.delete_if do |path|
166
+ not path =~ /tracetemplate/
167
+ end
168
+ end
169
+ elsif self.xcode_version >= self.v60
146
170
  Open3.popen3(cmd) do |_, stdout, stderr, _|
147
171
  stderr_filter.call(stderr)
148
172
  stdout.read.chomp.split("\n").map { |elm| elm.strip.tr('"', '') }
metadata CHANGED
@@ -1,195 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: run_loop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-26 00:00:00.000000000 Z
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.18'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: retriable
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.3.3.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.3.3.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: awesome_print
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.2.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: CFPropertyList
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: travis
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.7'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.7'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '3.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '3.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '10.3'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '10.3'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: guard-rspec
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '4.3'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '4.3'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: guard-bundler
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: '2.0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ~>
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '2.0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: growl
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ~>
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
173
  version: '1.0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ~>
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '1.0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rb-readline
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ~>
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0.5'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ~>
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.5'
195
195
  description: calabash-cucumber drives tests for native iOS apps. RunLoop provides
@@ -212,7 +212,6 @@ files:
212
212
  - lib/run_loop/sim_control.rb
213
213
  - lib/run_loop/version.rb
214
214
  - lib/run_loop/xctools.rb
215
- - scripts/calabash-uia-min.js
216
215
  - scripts/calabash.lldb.erb
217
216
  - scripts/calabash_script_uia.js
218
217
  - scripts/json2-min.js
@@ -233,12 +232,12 @@ require_paths:
233
232
  - lib
234
233
  required_ruby_version: !ruby/object:Gem::Requirement
235
234
  requirements:
236
- - - '>='
235
+ - - ">="
237
236
  - !ruby/object:Gem::Version
238
237
  version: '1.9'
239
238
  required_rubygems_version: !ruby/object:Gem::Requirement
240
239
  requirements:
241
- - - '>='
240
+ - - ">="
242
241
  - !ruby/object:Gem::Version
243
242
  version: '0'
244
243
  requirements: []
@@ -248,4 +247,3 @@ signing_key:
248
247
  specification_version: 4
249
248
  summary: Tools related to running Calabash iOS tests
250
249
  test_files: []
251
- has_rdoc:
@@ -1,7 +0,0 @@
1
- (function(){function m(){return h.frontMostApp()}function r(){return m().mainWindow()}function s(){return m().windows().toArray()}function n(){return m().keyboard()}function l(a,c){this.reason=a;this.a=c||"";this.message=this.toString()}function k(a){return!a||a instanceof UIAElementNil}function t(a,c){var b=c||[],e,d;if(k(a))return b;e=a.elements();for(var f=0,g=e.length;f<g;f+=1)d=e[f],b.push(d),t(d,b);return b}function q(a,c){for(var b=0,e=c.length;b<e;b+=1)a.push(c[b])}function u(a,c){var b=[];
2
- if(k(c))return b;c instanceof this[a]&&b.push(c);for(var e=c.elements(),d=0,f=e.length;d<f;d+=1)q(b,u(a,e[d]));return b}function x(a,c){var b=null;if(a instanceof Array){if(3===a.length){var e=a[0],b=a[1],d=a[2];if("string"==typeof d)if(-1==d.indexOf("'"))d="'"+d+"'";else if(-1==d.indexOf('"'))d='"'+d+'"';else throw new l("Escaping for filters not supported yet.");b=c.withPredicate(e+" "+b+" "+d);return!k(b)}return!1}for(e in a)if(a.hasOwnProperty(e))if(b=a[e],"marked"==e){if(c.name()!=b&&c.label()!=
3
- b&&(!c.value||c.value!=b))return!1}else if(b=c.withValueForKey(b,e),k(b))return!1;return!0}function v(a,c){if(c(a))return a;var b,e;if(k(a))return null;b=a.elements();for(var d=0,f=b.length;d<f;d+=1)if(e=b[d],v(e,c))return e;return null}function w(a){h.delay(a);return h}var g={},h=UIATarget.localTarget();h.setTimeout(0);l.prototype=error();l.prototype.toString=function(){var a="UIAutomationError[reason="+this.reason;0<this.a.length&&(a+=", details="+this.a);return a+"]"};g.sleep=w;g.query=function(a,
4
- c){if(!c)return g.query(a,s());c instanceof UIAElement&&(c=[c]);var b=c,e=null,d=null,f=[],p,h,k,l;p=0;for(k=a.length;p<k;p+=1){e=a[p];h=0;for(l=b.length;h<l;h+=1)d=b[h],"string"===typeof e?"*"===e||"view"==e||"UIAElement"===e?q(f,t(d,[d])):q(f,u(e,d)):x(e,d)&&f.push(d);b=f;f=[]}return b};g.keyboard_visible=function(){return!k(n())};g.keyboard_enter_text=function(a,c){if(!g.keyboard_visible())throw new l("Keyboard not visible");c=c||{};if(c.unsafe)return n().typeString(a),!0;var b=v(r(),function(a){return 1==
5
- a.hasKeyboardFocus()});if(k(b))return n().typeString(a),!0;var e=c.initial_text||"",d=new Date,f=c.timeout||60,h=n();do try{return h.typeString(a),!0}catch(m){UIALogger.logMessage("keyboard_enter_text failed: "+m),UIALogger.logMessage("keyboard_enter_text retrying with restore to: "+e),b.setValue(e)}while(!(new Date-d>=1E3*f));throw new l("Unable to enter text","text: "+a+" failed after retrying for "+f);};g.deactivate=function(a){h.deactivateAppForDuration(a)};g.tap_offset=function(a,c,b){b=b||{};
6
- return b.unsafe?function(){return c.apply(this,arguments)}:function(){var e=new Date,d=b.timeout||60,f=b.frequency||.1;do try{return c.apply(this,arguments)}catch(g){UIALogger.logMessage(a+"Error: "+g+". Arguments: "+arguments[0]+", "+arguments[1]),w(f)}while(!(new Date-e>=1E3*d));throw new l(a,"Arguments: "+arguments[0]+", "+arguments[1]);}}("tap_offset failed",function(a,c){h.tapWithOptions(a,c||{})},{timeout:60,frequency:.5});this.target=h;this.uia=g;g.app=m;g.window=r;g.windows=s;g.keyboard=n;
7
- g.alert=function(){return m().alert()}})();