accessibility_core 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.markdown +6 -0
- data/README.markdown +6 -3
- data/Rakefile +0 -14
- data/ext/accessibility/bridge/bridge.c +393 -425
- data/ext/accessibility/bridge/bridge.h +126 -128
- data/ext/accessibility/bridge/extconf.rb +7 -12
- data/ext/accessibility/core/core.c +76 -109
- data/ext/accessibility/core/extconf.rb +7 -12
- data/ext/accessibility/extras/extconf.rb +7 -13
- data/ext/accessibility/extras/extras.c +18 -41
- data/ext/accessibility/highlighter/extconf.rb +7 -13
- data/ext/accessibility/highlighter/highlighter.c +11 -20
- data/lib/accessibility/bridge.rb +1 -31
- data/lib/accessibility/core.rb +1 -6
- data/lib/accessibility/core/version.rb +1 -1
- data/lib/accessibility/extras.rb +0 -2
- data/lib/accessibility/highlighter.rb +1 -6
- data/test/helper.rb +0 -10
- metadata +4 -9
- data/lib/accessibility/bridge/macruby.rb +0 -202
- data/lib/accessibility/core/macruby.rb +0 -855
- data/lib/accessibility/highlighter/macruby.rb +0 -85
- data/test/test_core.rb +0 -100
@@ -1,85 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# A screen highlighter for debugging
|
3
|
-
#
|
4
|
-
# When you initialize a highligter object it will highlight the given
|
5
|
-
# bounds on the screen.
|
6
|
-
#
|
7
|
-
# Highligter objects can have their colour configured at initialization,
|
8
|
-
# and can also have a timeout to automatically stop displaying.
|
9
|
-
#
|
10
|
-
# Options for setting up a highlighter are document in
|
11
|
-
# {Accessibility::Highlighter#initialize}.
|
12
|
-
#
|
13
|
-
# @example
|
14
|
-
#
|
15
|
-
# h = Accessibility::Highlighter.new [100,100,100,100]
|
16
|
-
# # when you are done...
|
17
|
-
# h.stop
|
18
|
-
#
|
19
|
-
class Accessibility::Highlighter < NSWindow
|
20
|
-
|
21
|
-
# @param bounds [CGRect,#to_rect]
|
22
|
-
# @param opts [Hash]
|
23
|
-
# @option opts [Number] :timeout
|
24
|
-
# @option opts [NSColor] :colour (NSColor.magentaColor)
|
25
|
-
def initialize bounds, opts = {}
|
26
|
-
color = opts[:colour] || opts[:color] || NSColor.magentaColor
|
27
|
-
|
28
|
-
bounds = bounds.to_rect
|
29
|
-
bounds.flip! # we assume the rect is in the other co-ordinate system
|
30
|
-
|
31
|
-
initWithContentRect bounds,
|
32
|
-
styleMask: NSBorderlessWindowMask,
|
33
|
-
backing: NSBackingStoreBuffered,
|
34
|
-
defer: true
|
35
|
-
setOpaque false
|
36
|
-
setAlphaValue 0.20
|
37
|
-
setLevel NSStatusWindowLevel
|
38
|
-
setBackgroundColor color
|
39
|
-
setIgnoresMouseEvents true
|
40
|
-
setFrame bounds, display: false
|
41
|
-
makeKeyAndOrderFront NSApp
|
42
|
-
|
43
|
-
if opts.has_key? :timeout
|
44
|
-
Dispatch::Queue.concurrent.after opts[:timeout] do
|
45
|
-
self.stop
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
##
|
51
|
-
# Tell the highlighter to stop displaying.
|
52
|
-
#
|
53
|
-
# @return [self]
|
54
|
-
def stop
|
55
|
-
close
|
56
|
-
end
|
57
|
-
|
58
|
-
##
|
59
|
-
# Returns the color for the highlighter
|
60
|
-
#
|
61
|
-
# @return [NSColor]
|
62
|
-
def color
|
63
|
-
backgroundColor
|
64
|
-
end
|
65
|
-
alias_method :colour, :color
|
66
|
-
|
67
|
-
##
|
68
|
-
# Return whether or not the highlighter is currently drawn on screen
|
69
|
-
def visible?
|
70
|
-
super
|
71
|
-
end
|
72
|
-
|
73
|
-
##
|
74
|
-
# Return the rectangle on screen which the highlighter is occupying
|
75
|
-
#
|
76
|
-
# @return [CGRect]
|
77
|
-
def frame
|
78
|
-
super
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
# Initialize the shared application so that windows can be created
|
85
|
-
NSApplication.sharedApplication
|
data/test/test_core.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
def assert_error args, should_raise: klass, with_fragments: msgs
|
4
|
-
e = assert_raises(klass) { (@derp || app).handle_error *args }
|
5
|
-
assert_match /test_core.rb:272/, e.backtrace.first unless RUNNING_COMPILED
|
6
|
-
msgs.each { |msg| assert_match msg, e.message }
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_handle_errors
|
10
|
-
app_inspect = Regexp.new(Regexp.escape(app.inspect))
|
11
|
-
|
12
|
-
assert_error [KAXErrorFailure],
|
13
|
-
should_raise: RuntimeError,
|
14
|
-
with_fragments: [/system failure/, app_inspect]
|
15
|
-
|
16
|
-
assert_error [KAXErrorIllegalArgument],
|
17
|
-
should_raise: ArgumentError,
|
18
|
-
with_fragments: [/is not an AXUIElementRef/, app_inspect]
|
19
|
-
|
20
|
-
assert_error [KAXErrorIllegalArgument, :cake],
|
21
|
-
should_raise: ArgumentError,
|
22
|
-
with_fragments: [/is not a legal argument/, /the element/, app_inspect, /cake/]
|
23
|
-
|
24
|
-
assert_error [KAXErrorIllegalArgument, 'cake', 'chocolate'],
|
25
|
-
should_raise: ArgumentError,
|
26
|
-
with_fragments: [/can't get\/set "cake" with\/to "chocolate"/, app_inspect]
|
27
|
-
|
28
|
-
p = CGPoint.new(1,3)
|
29
|
-
assert_error [KAXErrorIllegalArgument, p, nil, nil],
|
30
|
-
should_raise: ArgumentError,
|
31
|
-
with_fragments: [/The point #{p.inspect}/, app_inspect]
|
32
|
-
|
33
|
-
assert_error [KAXErrorInvalidUIElement],
|
34
|
-
should_raise: ArgumentError,
|
35
|
-
with_fragments: [/no longer a valid reference/, app_inspect]
|
36
|
-
|
37
|
-
assert_error [KAXErrorInvalidUIElementObserver, :pie, :cake],
|
38
|
-
should_raise: ArgumentError,
|
39
|
-
with_fragments: [/no longer support/]
|
40
|
-
|
41
|
-
assert_error [KAXErrorCannotComplete],
|
42
|
-
should_raise: RuntimeError,
|
43
|
-
with_fragments: [/An unspecified error/, app_inspect, /:\(/]
|
44
|
-
|
45
|
-
@derp = Accessibility::Element.application_for pid_for 'com.apple.finder'
|
46
|
-
def @derp.pid; false end
|
47
|
-
assert_error [KAXErrorCannotComplete],
|
48
|
-
should_raise: RuntimeError,
|
49
|
-
with_fragments: [/Application for pid/, /Maybe it crashed\?/]
|
50
|
-
@derp = nil
|
51
|
-
|
52
|
-
assert_error [KAXErrorAttributeUnsupported, :cake],
|
53
|
-
should_raise: ArgumentError,
|
54
|
-
with_fragments: [/does not have/, /:cake attribute/, app_inspect]
|
55
|
-
|
56
|
-
assert_error [KAXErrorActionUnsupported, :pie],
|
57
|
-
should_raise: ArgumentError,
|
58
|
-
with_fragments: [/does not have/, /:pie action/, app_inspect]
|
59
|
-
|
60
|
-
assert_error [KAXErrorNotificationUnsupported, :cheese],
|
61
|
-
should_raise: ArgumentError,
|
62
|
-
with_fragments: [/no longer support/]
|
63
|
-
|
64
|
-
assert_error [KAXErrorNotImplemented],
|
65
|
-
should_raise: NotImplementedError,
|
66
|
-
with_fragments: [/does not work with AXAPI/, app_inspect]
|
67
|
-
|
68
|
-
assert_error [KAXErrorNotificationAlreadyRegistered, :lamp],
|
69
|
-
should_raise: ArgumentError,
|
70
|
-
with_fragments: [/no longer support/]
|
71
|
-
|
72
|
-
assert_error [KAXErrorNotificationNotRegistered, :peas],
|
73
|
-
should_raise: RuntimeError,
|
74
|
-
with_fragments: [/no longer support/]
|
75
|
-
|
76
|
-
assert_error [KAXErrorAPIDisabled],
|
77
|
-
should_raise: RuntimeError,
|
78
|
-
with_fragments: [/AXAPI has been disabled/]
|
79
|
-
|
80
|
-
assert_error [KAXErrorNoValue],
|
81
|
-
should_raise: RuntimeError,
|
82
|
-
with_fragments: [/internal error/]
|
83
|
-
|
84
|
-
assert_error [KAXErrorParameterizedAttributeUnsupported, :oscar],
|
85
|
-
should_raise: ArgumentError,
|
86
|
-
with_fragments: [/does not have/, /:oscar parameterized attribute/, app_inspect]
|
87
|
-
|
88
|
-
assert_error [KAXErrorNotEnoughPrecision],
|
89
|
-
should_raise: RuntimeError,
|
90
|
-
with_fragments: [/not enough precision/, '¯\(°_o)/¯']
|
91
|
-
|
92
|
-
exception = assert_raises(RuntimeError) { app.send(:handle_error, 0) }
|
93
|
-
assert_match /assertion failed/, exception.message
|
94
|
-
|
95
|
-
assert_error [99],
|
96
|
-
should_raise: RuntimeError,
|
97
|
-
with_fragments: [/unknown error code/, /99/, app_inspect]
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|