AXElements 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +18 -9
- data/docs/Debugging.markdown +0 -187
- data/docs/Inspecting.markdown +11 -5
- data/lib/accessibility/debug.rb +7 -11
- data/lib/accessibility/dsl.rb +1 -1
- data/lib/accessibility/enumerators.rb +12 -11
- data/lib/accessibility/factory.rb +17 -14
- data/lib/accessibility/version.rb +1 -1
- data/lib/accessibility.rb +2 -2
- data/lib/ax/application.rb +8 -3
- data/lib/ax/element.rb +9 -0
- data/lib/ax_elements/vendor/inflection_data.rb +1 -0
- data/lib/minitest/ax_elements.rb +1 -1
- data/lib/rspec/expectations/ax_elements.rb +1 -1
- data/test/integration/accessibility/test_dsl.rb +3 -2
- data/test/integration/ax/test_application.rb +1 -0
- data/test/integration/ax/test_element.rb +0 -4
- data/test/sanity/accessibility/test_translator.rb +6 -1
- data/test/sanity/ax/test_element.rb +5 -0
- metadata +2 -8
- data/docs/Setting.markdown +0 -1
- data/test/integration/accessibility/test_notifications.rb +0 -22
- data/test/integration/test_mouse.rb +0 -35
data/README.markdown
CHANGED
@@ -74,28 +74,33 @@ rubygems:
|
|
74
74
|
gem install AXElements
|
75
75
|
```
|
76
76
|
|
77
|
+
And then you can try things out in IRb:
|
78
|
+
|
79
|
+
```bash
|
80
|
+
irb -rubygems -rax_elements
|
81
|
+
```
|
82
|
+
|
77
83
|
Or you can install from source:
|
78
84
|
|
79
85
|
```bash
|
80
86
|
cd ~/Documents # or where you want to put the AXElements code
|
81
87
|
git clone git://github.com/Marketcircle/AXElements
|
82
|
-
cd AXElements
|
83
|
-
rake install
|
88
|
+
cd AXElements && rake install
|
84
89
|
```
|
85
90
|
|
86
|
-
|
87
|
-
|
91
|
+
And then try things out in the developer console. AXElements has no
|
92
|
+
gem dependencies, so from the AXElements source directory you can just
|
93
|
+
run the `console` task:
|
88
94
|
|
89
95
|
```bash
|
90
96
|
rake console
|
91
97
|
```
|
92
98
|
|
93
99
|
__NOTE__: If you are not using RVM, then you should use `macrake`
|
94
|
-
instead of `rake`, and
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
like so:
|
100
|
+
instead of `rake`, and `macirb` instead of `irb`, etc.. You may also
|
101
|
+
need to add `sudo` to your command when you install the gem. If you
|
102
|
+
are not using RVM with MacRuby, but have RVM installed, remember to
|
103
|
+
disable it like so:
|
99
104
|
|
100
105
|
```bash
|
101
106
|
rvm use system
|
@@ -154,7 +159,9 @@ tests aren't programmed to do anything destructive, but if you
|
|
154
159
|
interfere with them then something could go wrong. To run the tests
|
155
160
|
you simply need to run the `test` task:
|
156
161
|
|
162
|
+
```bash
|
157
163
|
rake test
|
164
|
+
```
|
158
165
|
|
159
166
|
__NOTE__: There may be some tests are dependent on Accessibility
|
160
167
|
features that are new in OS X Lion which will cause test failures on
|
@@ -170,7 +177,9 @@ Benchmarks are also included as part of the test suite, but they are
|
|
170
177
|
disabled by default. In order to enable them you need to set the
|
171
178
|
`BENCH` environment variable:
|
172
179
|
|
180
|
+
```bash
|
173
181
|
BENCH=1 rake test
|
182
|
+
```
|
174
183
|
|
175
184
|
|
176
185
|
## Contributing to AXElements
|
data/docs/Debugging.markdown
CHANGED
@@ -144,52 +144,6 @@ AXElements and at one time it was causing some problems when elements
|
|
144
144
|
were unexpectedly not allowing their `focused` attribute to be
|
145
145
|
written.
|
146
146
|
|
147
|
-
### Attribute Not Found
|
148
|
-
|
149
|
-
A very simple fail safe that AXElements uses is the
|
150
|
-
{AX::Element::LookupFailure `LookupFailure`} exception which will be
|
151
|
-
raised when you try to explicitly access an attribute which does not
|
152
|
-
exist, or at least does not exist for the particular element that you
|
153
|
-
are trying to access.
|
154
|
-
|
155
|
-
## Not So Custom Exceptions
|
156
|
-
|
157
|
-
Sometimes it is possible that the back trace for other exceptions can
|
158
|
-
get lost. This may be a result of
|
159
|
-
[MacRuby Ticket #1369](http://www.macruby.org/trac/ticket/1369), but
|
160
|
-
it might also be because of
|
161
|
-
[MacRuby Ticket #1320](http://www.macruby.org/trac/ticket/1320) or
|
162
|
-
some other freedom patch
|
163
|
-
that AXElements or ActiveSupport adds to the run time. I have not been
|
164
|
-
able to create a reduction of the problem yet.
|
165
|
-
|
166
|
-
The real problem is that loss of back trace happens for multiple
|
167
|
-
exception classes. The [work around](https://gist.github.com/1107314)
|
168
|
-
for this case is copied to `lib/ax_elements/macruby_extensions.rb`,
|
169
|
-
but has been commented out since it causes some regression tests to
|
170
|
-
fail. If you do not get a back trace with an error then you will need
|
171
|
-
to uncomment the freedom patches or copy them to your own script.
|
172
|
-
|
173
|
-
## Disabling Compiled Code
|
174
|
-
|
175
|
-
Back traces can be lost for reasons other than a bug. When using
|
176
|
-
compiled MacRuby code, you cannot get a Ruby level back trace in case
|
177
|
-
of an error. This feature is on the road map for MacRuby, but I am not
|
178
|
-
sure when it will be done.
|
179
|
-
|
180
|
-
In the mean time, if you suspect that the portion of a back trace that
|
181
|
-
would come from a compiled file is the problem, then you can disable
|
182
|
-
loading compiled files which will force MacRuby to load source ruby
|
183
|
-
files instead. You can disable loading compiled files by setting the
|
184
|
-
`VM_DISABLE_RBO` environment variable before running a script. You can
|
185
|
-
disable loading for a single session like so:
|
186
|
-
|
187
|
-
VM_DISABLE_RBO=1 macruby my_script.rb
|
188
|
-
|
189
|
-
Other debugging options are also available from MacRuby itself. You
|
190
|
-
should check out [Hacking.rdoc](https://github.com/MacRuby/MacRuby/blob/master/HACKING.rdoc)
|
191
|
-
in the MacRuby source repository for more details.
|
192
|
-
|
193
147
|
## Logging
|
194
148
|
|
195
149
|
The core level of AXElements has logging in every case that an error
|
@@ -209,144 +163,3 @@ can turn on logging right after you load AXElements, like so:
|
|
209
163
|
The standard log levels are available, the full set is available
|
210
164
|
[here](http://rdoc.info/stdlib/logger/1.9.2/Logger/Severity). `Logger::DEBUG`
|
211
165
|
will turn on all logs.
|
212
|
-
|
213
|
-
## MacRuby Seems Slow
|
214
|
-
|
215
|
-
There are a few things that can cause MacRuby to be slow. At boot time
|
216
|
-
there are a number of factors, which I will cover, and at run time
|
217
|
-
there is really only one culprit.
|
218
|
-
|
219
|
-
### Long Load Times
|
220
|
-
|
221
|
-
When using certain gems, or when you have many gems installed, you
|
222
|
-
will notice that the load time for your scripts is very
|
223
|
-
long---possibly more than 10 seconds. There are many reasons why this
|
224
|
-
happens, some of which we can fix ourselves and some of which you will
|
225
|
-
have to wait for the MacRuby developers to fix.
|
226
|
-
|
227
|
-
#### Huge Literal Collections
|
228
|
-
|
229
|
-
Some gems contain source code with
|
230
|
-
[unbelievably large literal collections](https://github.com/sporkmonger/addressable/blob/master/lib/addressable/idna/pure.rb#L318),
|
231
|
-
such as the `addressable` gem. This is a problem for MacRuby for two
|
232
|
-
reasons.
|
233
|
-
|
234
|
-
First, it requires several thousand allocations at once. Most of
|
235
|
-
MacRuby's performance issues come from code that allocates too much,
|
236
|
-
and large collections can allocate several thousand objects all at
|
237
|
-
once.
|
238
|
-
|
239
|
-
The second problem is that MacRuby normally will try to JIT the code,
|
240
|
-
and the LLVM chokes on things this large. Some work has been done to
|
241
|
-
break the function up into smaller pieces (it used to take over 2
|
242
|
-
minutes to load the `addressable` gem), but it can still take a while
|
243
|
-
for MacRuby and the LLVM to work through the code
|
244
|
-
|
245
|
-
As it turns out, JIT isn't that great for short lived processes that
|
246
|
-
need to start up over and over again. In fact, JIT mode for MacRuby
|
247
|
-
was meant more for debugging.
|
248
|
-
|
249
|
-
The work around to this situation will have to come from upstream gem
|
250
|
-
developers and MacRuby itself. In the mean time, compiling these gems
|
251
|
-
will usually make them load _significantly_ faster. To compile gems,
|
252
|
-
you can install the
|
253
|
-
[`rubygems-compile`](https://github.com/ferrous26/rubygems-compile)
|
254
|
-
plug-in for rubygems. Follow the instructions from the plug-ins `README`
|
255
|
-
to learn how to use it and to know which version to install.
|
256
|
-
|
257
|
-
#### Complex Metaprogramming
|
258
|
-
|
259
|
-
Another problem that can cause long load times is complex
|
260
|
-
metaprogramming. Gems such as `rspec` do a lot of weird stuff at boot
|
261
|
-
that causes the MacRuby optimizer to do a lot of work. `rspec` alone
|
262
|
-
can add nearly 10 seconds to boot time. In this case you can tell the
|
263
|
-
optimizer to not try so hard; this will result in slower run time
|
264
|
-
performance, but it is likely worth the trade off in the case of
|
265
|
-
`rspec` (unless you compile).
|
266
|
-
|
267
|
-
You can set the optimization level for MacRuby just as you would
|
268
|
-
disable loading compiled code:
|
269
|
-
|
270
|
-
# set the level to a number between 0 and 3, 3 is the highest
|
271
|
-
VM_OPT_LEVEL=1 macruby my_script.rb
|
272
|
-
|
273
|
-
#### Large Code Bases
|
274
|
-
|
275
|
-
Large code bases taking a long time to load is not really an avoidable
|
276
|
-
situation---it happens with every project. Once again, JIT and
|
277
|
-
optimizer passes take up a lot of the load time.
|
278
|
-
|
279
|
-
In this case, it is best to compile your code (and test the compiled
|
280
|
-
version) in order to speed up boot time. You can combine compiled code
|
281
|
-
and still turn off optimization passes to get even better boot times,
|
282
|
-
but I am not sure it is worth the trade off at that point.
|
283
|
-
|
284
|
-
#### Rubygems
|
285
|
-
|
286
|
-
Rubygems suffers from a lot of technical debt. The process of
|
287
|
-
activating a gem incurs so many allocations that with as few as 25
|
288
|
-
installed gems can add an extra 2 seconds to your boot time. What is
|
289
|
-
worse, the performance degrades exponentially as you install more
|
290
|
-
gems.
|
291
|
-
|
292
|
-
The only fix for this is to cleanup and fix rubygems. Fortunately this
|
293
|
-
has been underway since the rubygems 1.4; the downside is that MacRuby
|
294
|
-
has customizations to rubygems that prevent users from upgrading
|
295
|
-
themselves. We need to wait for new MacRuby releases to bundle new
|
296
|
-
rubygems versions in order to fix this issue.
|
297
|
-
|
298
|
-
### Slow Runtime Performance
|
299
|
-
|
300
|
-
In my experience, slow runtime performance in MacRuby is almost always
|
301
|
-
the result of many allocations. If your code is runinng abnormally
|
302
|
-
slow then it is likely that you are allocating a lot of memory without
|
303
|
-
realizing it, and you should compare performance to CRuby if it is
|
304
|
-
important (and if it is possible to run the code on CRuby).
|
305
|
-
|
306
|
-
Remember that things like literal strings have to be copied every time
|
307
|
-
the line of code they are on is run, whereas immutable things like
|
308
|
-
symbols do not have to be copied. At the same time, if you pass a
|
309
|
-
symbol to a method that will coerce the symbol to a string then you
|
310
|
-
haven't saved an allocation.
|
311
|
-
|
312
|
-
Try to use in-place mutations when it is safe. An example would be
|
313
|
-
when you have to perform multiple changes to an object in a single
|
314
|
-
method, you only have to create a new copy the first time and then use
|
315
|
-
the same copy for all the other changes. Example code would look like this:
|
316
|
-
|
317
|
-
def transform string
|
318
|
-
new_string = string.gsub /pie/, 'cake'
|
319
|
-
new_string.gsub! /hate/, 'love'
|
320
|
-
new_string.upcase!
|
321
|
-
new_string
|
322
|
-
end
|
323
|
-
|
324
|
-
Remember that built-in in-place methods tend to return `nil` if they
|
325
|
-
don't make any changes, which means you need to explicitly return the
|
326
|
-
new object at the end of the method. There are still many other easily
|
327
|
-
avoidable cases where you could end up allocating a lot of memory
|
328
|
-
which are not covered. If it is important you willl just have to
|
329
|
-
analyze your code.
|
330
|
-
|
331
|
-
Sometimes allocating a lot of memory is not avoidable; running RSpec
|
332
|
-
would be an example of this. In these cases you just have to bite the
|
333
|
-
bullet.
|
334
|
-
|
335
|
-
## Don't Be Afraid To Log Bugs
|
336
|
-
|
337
|
-
Or look at the AXElements source code for that matter. The source is
|
338
|
-
well documented and hopefully not too clever, so it shouldn't be too
|
339
|
-
hard to figure things out. You can log AXElements bugs on Github where
|
340
|
-
the source is being hosted.
|
341
|
-
|
342
|
-
Though, sometimes the problem will be a MacRuby problem and the best
|
343
|
-
way to get it fixed is to
|
344
|
-
[log a bug](http://www.macruby.org/trac/). You will need to create an
|
345
|
-
account with them to log bugs.
|
346
|
-
|
347
|
-
I also recommend that you subscribe to the
|
348
|
-
[MacRuby mailing list](http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel)
|
349
|
-
to keep up to date on MacRuby developments. You can send in questions
|
350
|
-
if you are unsure about a certain behaviour, even potential bugs. It
|
351
|
-
is not a high traffic mailing list so it won't blow up your mailbox
|
352
|
-
when you subscribe.
|
data/docs/Inspecting.markdown
CHANGED
@@ -10,11 +10,17 @@ begin discovering them yourself.
|
|
10
10
|
The first most important thing to understand is that accessibility
|
11
11
|
exposes the user interface as a hierarchy of user interface
|
12
12
|
tokens. Each token references a GUI element on screen, either
|
13
|
-
something literal like a button, or something
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
something literal like a button, or something structural like a group
|
14
|
+
of buttons. The organization of the hierarchy should make sense to
|
15
|
+
human beings since it is designed to be used by the disabled, so it
|
16
|
+
does not nescesarrily match the underlying organization of views and
|
17
|
+
can be completely arbitrary. That being said, most apps will use the
|
18
|
+
defaults provided by AppKit and "Just Work"™ the way you would
|
19
|
+
expect.
|
20
|
+
|
21
|
+
Throughout this documentation I will refer to tokens as if they were
|
22
|
+
the object themselves unless otherwise noted. It's much easier Each
|
23
|
+
token object knows who its parent object is, and knows about any
|
18
24
|
children objects that it may have. thus creating a tree structure. At
|
19
25
|
least this is the theory, but there are, on occasion, some hiccups
|
20
26
|
since accessibility is a protocol to which multiple parties have to
|
data/lib/accessibility/debug.rb
CHANGED
@@ -100,23 +100,19 @@ module Accessibility::Debug
|
|
100
100
|
app = NSApplication.sharedApplication
|
101
101
|
colour = opts[:colour] || opts[:color] || NSColor.magentaColor
|
102
102
|
window = highlight_window_for element.bounds, colour
|
103
|
-
|
103
|
+
|
104
|
+
if opts.has_key? :timeout
|
105
|
+
Dispatch::Queue.new('window_killer').after opts[:timeout] do
|
106
|
+
window.close
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
104
110
|
window
|
105
111
|
end
|
106
112
|
|
107
113
|
|
108
114
|
private
|
109
115
|
|
110
|
-
# @param [NSWindow]
|
111
|
-
# @param [Number]
|
112
|
-
def kill window, after: time
|
113
|
-
@kill_queue ||= Dispatch::Queue.new 'com.marketcircle.AXElements'
|
114
|
-
@kill_queue.async do
|
115
|
-
sleep time
|
116
|
-
window.close
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
116
|
##
|
121
117
|
# Create the window that acts as the highlighted portion of the screen.
|
122
118
|
#
|
data/lib/accessibility/dsl.rb
CHANGED
@@ -431,7 +431,7 @@ module Accessibility::DSL
|
|
431
431
|
start = Time.now
|
432
432
|
q = Accessibility::Qualifier.new(child, opts, &block)
|
433
433
|
until Time.now - start > timeout
|
434
|
-
result = parent.
|
434
|
+
result = parent.children.find { |x| q.qualifies? x }
|
435
435
|
return result unless result.blank?
|
436
436
|
sleep 0.2
|
437
437
|
end
|
@@ -8,7 +8,7 @@ module Accessibility::Enumerators
|
|
8
8
|
class BreadthFirst
|
9
9
|
include Enumerable
|
10
10
|
|
11
|
-
# @param [
|
11
|
+
# @param [#children]
|
12
12
|
def initialize root
|
13
13
|
@root = root
|
14
14
|
end
|
@@ -16,12 +16,13 @@ module Accessibility::Enumerators
|
|
16
16
|
##
|
17
17
|
# Semi-lazily iterate through the tree.
|
18
18
|
#
|
19
|
-
# @yieldparam [AX::Element]
|
19
|
+
# @yieldparam [AX::Element,AXUIElementRef]
|
20
20
|
def each
|
21
|
-
# @todo
|
21
|
+
# @todo mutate the array less, perhaps use an index instead
|
22
|
+
# of #shift, then the array only grows
|
22
23
|
queue = [@root]
|
23
24
|
until queue.empty?
|
24
|
-
queue.shift.
|
25
|
+
queue.shift.children.each do |x|
|
25
26
|
queue << x
|
26
27
|
yield x
|
27
28
|
end
|
@@ -48,19 +49,19 @@ module Accessibility::Enumerators
|
|
48
49
|
class DepthFirst
|
49
50
|
include Enumerable
|
50
51
|
|
51
|
-
# @param [
|
52
|
+
# @param [#children]
|
52
53
|
def initialize root
|
53
54
|
@root = root
|
54
55
|
end
|
55
56
|
|
56
|
-
# @yieldparam [AX::Element]
|
57
|
+
# @yieldparam [AX::Element,AXUIElementRef]
|
57
58
|
def each
|
58
|
-
stack = @root.
|
59
|
+
stack = @root.children
|
59
60
|
until stack.empty?
|
60
61
|
current = stack.shift
|
61
62
|
yield current
|
62
63
|
# needed to reverse it since child ordering seems to matter in practice
|
63
|
-
stack.unshift *current.
|
64
|
+
stack.unshift *current.children
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -68,11 +69,11 @@ module Accessibility::Enumerators
|
|
68
69
|
# Walk the UI element tree and yield both the element and the level
|
69
70
|
# that the element is at relative to the root.
|
70
71
|
#
|
71
|
-
# @yieldparam [AX::Element]
|
72
|
+
# @yieldparam [AX::Element,AXUIElementRef]
|
72
73
|
# @yieldparam [Number]
|
73
74
|
def each_with_level &block
|
74
75
|
# @todo A bit of a hack that I would like to fix one day...
|
75
|
-
@root.
|
76
|
+
@root.children.each do |element|
|
76
77
|
recursive_each_with_level element, 1, block
|
77
78
|
end
|
78
79
|
end
|
@@ -88,7 +89,7 @@ module Accessibility::Enumerators
|
|
88
89
|
# @param [#call]
|
89
90
|
def recursive_each_with_level element, depth, block
|
90
91
|
block.call element, depth
|
91
|
-
element.
|
92
|
+
element.children.each do |x|
|
92
93
|
recursive_each_with_level x, depth + 1, block
|
93
94
|
end
|
94
95
|
end
|
@@ -66,20 +66,23 @@ module Accessibility::Factory
|
|
66
66
|
# @param [AXUIElementRef]
|
67
67
|
# @return [AX::Element]
|
68
68
|
def process_element ref
|
69
|
-
role
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
69
|
+
if role = ref.role
|
70
|
+
role = TRANSLATOR.unprefix role
|
71
|
+
attrs = ref.attributes
|
72
|
+
if attrs.include? KAXSubroleAttribute
|
73
|
+
subrole = ref.subrole
|
74
|
+
# Some objects claim to have a subrole but return nil
|
75
|
+
if subrole
|
76
|
+
class_for(TRANSLATOR.unprefix(subrole), and: role).new ref
|
77
|
+
else
|
78
|
+
class_for(role).new ref
|
79
|
+
end
|
80
|
+
else
|
81
|
+
class_for(role).new ref
|
82
|
+
end
|
83
|
+
else # failsafe in case object dies before we even get the role
|
84
|
+
AX::Element.new ref
|
85
|
+
end
|
83
86
|
end
|
84
87
|
|
85
88
|
##
|
data/lib/accessibility.rb
CHANGED
@@ -34,8 +34,8 @@ class << self
|
|
34
34
|
# @return [AX::Application,nil]
|
35
35
|
def application_with_bundle_identifier bundle
|
36
36
|
10.times do
|
37
|
-
|
38
|
-
return AX::Application.new(
|
37
|
+
app = NSRunningApplication.runningApplicationsWithBundleIdentifier(bundle).first
|
38
|
+
return AX::Application.new(app) if app
|
39
39
|
launch_application bundle
|
40
40
|
sleep 2
|
41
41
|
end
|
data/lib/ax/application.rb
CHANGED
@@ -30,9 +30,14 @@ class AX::Application < AX::Element
|
|
30
30
|
super SYSTEMWIDE.application_for arg
|
31
31
|
@app = NSRunningApplication.runningApplicationWithProcessIdentifier arg
|
32
32
|
when String
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
@app =
|
34
|
+
NSRunningApplication.runningApplicationsWithBundleIdentifier(arg).first ||
|
35
|
+
(
|
36
|
+
SYSTEMWIDE.spin_run_loop
|
37
|
+
NSWorkspace.sharedWorkspace.runningApplications.find { |app|
|
38
|
+
app.localizedName == arg
|
39
|
+
}
|
40
|
+
)
|
36
41
|
super SYSTEMWIDE.application_for @app.processIdentifier
|
37
42
|
when NSRunningApplication
|
38
43
|
super SYSTEMWIDE.application_for arg.processIdentifier
|
data/lib/ax/element.rb
CHANGED
@@ -61,6 +61,15 @@ class AX::Element
|
|
61
61
|
attribute :description
|
62
62
|
end
|
63
63
|
|
64
|
+
##
|
65
|
+
# Fetch the children elements for the current element. If the current
|
66
|
+
# element does not have children then an empty array will be returned.
|
67
|
+
#
|
68
|
+
# @return [Array<AX::Element>]
|
69
|
+
def children
|
70
|
+
attribute :children
|
71
|
+
end
|
72
|
+
|
64
73
|
##
|
65
74
|
# Return the `#size` of an attribute. This only works for attributes
|
66
75
|
# that are a collection. This exists because it is _much_ more
|
data/lib/minitest/ax_elements.rb
CHANGED
@@ -107,7 +107,7 @@ class MiniTest::Assertions
|
|
107
107
|
|
108
108
|
def ax_check_children parent, kind, filters, block
|
109
109
|
q = Accessibility::Qualifier.new(kind, filters, &block)
|
110
|
-
parent.
|
110
|
+
parent.children.find { |x| q.qualifies? x }
|
111
111
|
end
|
112
112
|
|
113
113
|
def ax_check_descendent ancestor, kind, filters, block
|
@@ -21,10 +21,10 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase
|
|
21
21
|
expected = string unless expected
|
22
22
|
text_area.set :focused, true
|
23
23
|
assert text_area.focused?
|
24
|
-
dsl.type string
|
24
|
+
dsl.type string, app
|
25
25
|
assert_equal expected, text_area.value
|
26
26
|
ensure # reset for next test
|
27
|
-
dsl.type "\\COMMAND+a \b"
|
27
|
+
dsl.type "\\COMMAND+a \b", app
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_dsl_is_mixed_into_toplevel
|
@@ -129,6 +129,7 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase
|
|
129
129
|
assert_equal AX::DOCK.list.trash_dock_item, result
|
130
130
|
|
131
131
|
result = dsl.wait_for :button, parent: app.main_window, title: 'Yes'
|
132
|
+
refute_nil result
|
132
133
|
assert_equal 'Yes', result.title
|
133
134
|
end
|
134
135
|
|
@@ -12,6 +12,7 @@ class TestAXApplication < MiniTest::Unit::TestCase
|
|
12
12
|
|
13
13
|
def test_initialize_args
|
14
14
|
assert_equal app, AX::Application.new(PID)
|
15
|
+
assert_equal app, AX::Application.new(APP_BUNDLE_IDENTIFIER)
|
15
16
|
assert_equal app, AX::Application.new(running_app.localizedName)
|
16
17
|
assert_equal app, AX::Application.new(running_app)
|
17
18
|
end
|
@@ -21,7 +21,6 @@ class TestAccessibilityTranslator < MiniTest::Unit::TestCase
|
|
21
21
|
|
22
22
|
def test_cocoaification
|
23
23
|
assert_equal KAXChildrenAttribute, TRANSLATOR.cocoaify(:children)
|
24
|
-
assert_equal KAXTitleUIElementAttribute, TRANSLATOR.cocoaify(:title_ui_element)
|
25
24
|
assert_equal KAXFocusedAttribute, TRANSLATOR.cocoaify(:focused?)
|
26
25
|
assert_equal 'AXTotallyFake', TRANSLATOR.cocoaify(:totally_fake)
|
27
26
|
|
@@ -36,6 +35,12 @@ class TestAccessibilityTranslator < MiniTest::Unit::TestCase
|
|
36
35
|
assert_equal KAXIsApplicationRunningAttribute, TRANSLATOR.cocoaify(:application_running)
|
37
36
|
end
|
38
37
|
|
38
|
+
def test_cocoaification_of_acronyms
|
39
|
+
assert_equal KAXURLAttribute, TRANSLATOR.cocoaify(:url)
|
40
|
+
assert_equal KAXTitleUIElementAttribute, TRANSLATOR.cocoaify(:title_ui_element)
|
41
|
+
assert_equal KAXRTFForRangeParameterizedAttribute, TRANSLATOR.cocoaify(:rtf_for_range)
|
42
|
+
end
|
43
|
+
|
39
44
|
def test_rubyize
|
40
45
|
assert_equal [:role], TRANSLATOR.rubyize([KAXRoleAttribute])
|
41
46
|
assert_equal [:main_window], TRANSLATOR.rubyize([KAXMainWindowAttribute])
|
@@ -7,6 +7,11 @@ class TestAXElement < MiniTest::Unit::TestCase
|
|
7
7
|
@element ||= AX::Element.new REF
|
8
8
|
end
|
9
9
|
|
10
|
+
def test_children # not much we can do here
|
11
|
+
assert_respond_to element, :children
|
12
|
+
assert_kind_of Array, element.children
|
13
|
+
end
|
14
|
+
|
10
15
|
def test_methods_is_flat
|
11
16
|
methods = element.methods
|
12
17
|
assert_equal methods.flatten.sort!, methods.sort!
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: AXElements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.7.
|
5
|
+
version: 0.7.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Rada
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-13 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -83,7 +83,6 @@ extra_rdoc_files:
|
|
83
83
|
- docs/NewBehaviour.markdown
|
84
84
|
- docs/Notifications.markdown
|
85
85
|
- docs/Searching.markdown
|
86
|
-
- docs/Setting.markdown
|
87
86
|
- docs/TestingExtensions.markdown
|
88
87
|
- .yardopts
|
89
88
|
- README.markdown
|
@@ -131,7 +130,6 @@ files:
|
|
131
130
|
- test/integration/accessibility/test_dsl.rb
|
132
131
|
- test/integration/accessibility/test_enumerators.rb
|
133
132
|
- test/integration/accessibility/test_errors.rb
|
134
|
-
- test/integration/accessibility/test_notifications.rb
|
135
133
|
- test/integration/accessibility/test_qualifier.rb
|
136
134
|
- test/integration/ax/test_application.rb
|
137
135
|
- test/integration/ax/test_element.rb
|
@@ -139,7 +137,6 @@ files:
|
|
139
137
|
- test/integration/ax_elements/test_nsarray_compat.rb
|
140
138
|
- test/integration/minitest/test_ax_elements.rb
|
141
139
|
- test/integration/rspec/expectations/test_ax_elements.rb
|
142
|
-
- test/integration/test_mouse.rb
|
143
140
|
- test/sanity/accessibility/test_core.rb
|
144
141
|
- test/sanity/accessibility/test_debug.rb
|
145
142
|
- test/sanity/accessibility/test_dsl.rb
|
@@ -171,7 +168,6 @@ files:
|
|
171
168
|
- docs/NewBehaviour.markdown
|
172
169
|
- docs/Notifications.markdown
|
173
170
|
- docs/Searching.markdown
|
174
|
-
- docs/Setting.markdown
|
175
171
|
- docs/TestingExtensions.markdown
|
176
172
|
- .yardopts
|
177
173
|
- README.markdown
|
@@ -206,7 +202,6 @@ test_files:
|
|
206
202
|
- test/integration/accessibility/test_dsl.rb
|
207
203
|
- test/integration/accessibility/test_enumerators.rb
|
208
204
|
- test/integration/accessibility/test_errors.rb
|
209
|
-
- test/integration/accessibility/test_notifications.rb
|
210
205
|
- test/integration/accessibility/test_qualifier.rb
|
211
206
|
- test/integration/ax/test_application.rb
|
212
207
|
- test/integration/ax/test_element.rb
|
@@ -214,7 +209,6 @@ test_files:
|
|
214
209
|
- test/integration/ax_elements/test_nsarray_compat.rb
|
215
210
|
- test/integration/minitest/test_ax_elements.rb
|
216
211
|
- test/integration/rspec/expectations/test_ax_elements.rb
|
217
|
-
- test/integration/test_mouse.rb
|
218
212
|
- test/sanity/accessibility/test_core.rb
|
219
213
|
- test/sanity/accessibility/test_debug.rb
|
220
214
|
- test/sanity/accessibility/test_dsl.rb
|
data/docs/Setting.markdown
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
You can use ruby ranges, but there is one caveat, which is that negative ranges will have to be converted ahead of time by the programmer, but only if you are using Core directly. If you are using an AX::Element derived class then it will Just Work™.
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class TestAccessibilityNotifications < MiniTest::Unit::TestCase
|
2
|
-
|
3
|
-
def test_custom_notifications
|
4
|
-
end
|
5
|
-
|
6
|
-
|
7
|
-
def test_standard_notifications
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
def test_notifications_from_the_app
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
def test_notification_filtering
|
16
|
-
# I can reject based on block return value
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_notification_callbacks_get_correct_arguments
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'test/integration/helper'
|
2
|
-
|
3
|
-
class TestMouse < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
def app
|
6
|
-
@@app ||= AX::Application.new REF
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_drag_to
|
10
|
-
skip
|
11
|
-
starting_point = app.main_window.position
|
12
|
-
def element
|
13
|
-
app.main_window.title_ui_element
|
14
|
-
end
|
15
|
-
|
16
|
-
point = CGPointMake(400, 400)
|
17
|
-
Mouse.move_to element.to_point
|
18
|
-
Mouse.drag_to point, 2
|
19
|
-
highlight element, timeout: 5, color: NSColor.greenColor
|
20
|
-
assert NSPointInRect(point, element.bounds),
|
21
|
-
{
|
22
|
-
point: point.inspect,
|
23
|
-
bounds: element.bounds.inspect,
|
24
|
-
mouse: Mouse.current_position.inspect
|
25
|
-
}
|
26
|
-
|
27
|
-
point = CGPointMake(800, 200)
|
28
|
-
Mouse.move_to element.to_point
|
29
|
-
Mouse.drag_to point, 2
|
30
|
-
assert NSPointInRect(point, element.bounds)
|
31
|
-
ensure
|
32
|
-
set app.main_window, position: starting_point if starting_point
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|