accessibility_core 0.1.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +2 -0
- data/History.markdown +33 -0
- data/README.markdown +11 -0
- data/Rakefile +18 -49
- data/ext/accessibility/bridge/{ext/accessibility/bridge/bridge.c → bridge.c} +136 -56
- data/ext/accessibility/bridge/bridge.h +132 -0
- data/ext/accessibility/bridge/{ext/accessibility/bridge/extconf.rb → extconf.rb} +1 -1
- data/ext/accessibility/core/core.c +21 -3
- data/ext/accessibility/core/extconf.rb +7 -1
- data/ext/accessibility/extras/extconf.rb +28 -0
- data/ext/accessibility/extras/extras.c +842 -0
- data/ext/accessibility/extras/extras.h +1 -0
- data/ext/accessibility/highlighter/extconf.rb +9 -2
- data/ext/accessibility/highlighter/highlighter.c +291 -1
- data/{ext/accessibility/bridge/lib → lib}/accessibility/bridge.rb +3 -3
- data/{ext/accessibility/bridge/lib → lib}/accessibility/bridge/common.rb +0 -0
- data/{ext/accessibility/bridge/lib → lib}/accessibility/bridge/macruby.rb +17 -0
- data/{ext/accessibility/bridge/lib → lib}/accessibility/bridge/mri.rb +10 -7
- data/lib/accessibility/core.rb +1 -1
- data/lib/accessibility/core/macruby.rb +1 -1
- data/lib/accessibility/core/version.rb +1 -1
- data/lib/accessibility/extras.rb +5 -0
- data/lib/accessibility/extras/common.rb +19 -0
- data/lib/accessibility/highlighter.rb +8 -0
- data/lib/accessibility/highlighter/macruby.rb +85 -0
- data/test/helper.rb +18 -28
- metadata +33 -56
- data/ext/accessibility/bridge/lib/accessibility/bridge/version.rb +0 -6
- data/ext/accessibility/bridge/test/array_test.rb +0 -31
- data/ext/accessibility/bridge/test/boxed_test.rb +0 -23
- data/ext/accessibility/bridge/test/cfrange_test.rb +0 -21
- data/ext/accessibility/bridge/test/cgpoint_test.rb +0 -54
- data/ext/accessibility/bridge/test/cgrect_test.rb +0 -60
- data/ext/accessibility/bridge/test/cgsize_test.rb +0 -54
- data/ext/accessibility/bridge/test/helper.rb +0 -19
- data/ext/accessibility/bridge/test/nsstring_test.rb +0 -22
- data/ext/accessibility/bridge/test/nsurl_test.rb +0 -17
- data/ext/accessibility/bridge/test/object_test.rb +0 -19
- data/ext/accessibility/bridge/test/range_test.rb +0 -16
- data/ext/accessibility/bridge/test/string_test.rb +0 -35
- data/ext/accessibility/bridge/test/uri_test.rb +0 -15
- data/ext/accessibility/core/bridge.h +0 -1
@@ -0,0 +1,19 @@
|
|
1
|
+
class CGRect
|
2
|
+
##
|
3
|
+
# Treats the rect as belonging to one co-ordinate system and then
|
4
|
+
# converts it to the other system
|
5
|
+
#
|
6
|
+
# This is useful because accessibility API's expect to work with
|
7
|
+
# the flipped co-ordinate system (origin in top left), but AppKit
|
8
|
+
# prefers to use the cartesian co-ordinate system (origin in bottom
|
9
|
+
# left).
|
10
|
+
#
|
11
|
+
# @return [CGRect]
|
12
|
+
def flip!
|
13
|
+
frame = ::NSScreen.screens.first.frame
|
14
|
+
screen_height = frame.origin.y + frame.size.height
|
15
|
+
self_max_y = self.origin.y + self.size.height
|
16
|
+
origin.y = screen_height - self_max_y
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,85 @@
|
|
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]
|
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/helper.rb
CHANGED
@@ -1,37 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# point it will start to respond, so we just sleep
|
4
|
-
#
|
5
|
-
# We also want to make it registers it's at_exit hook before
|
6
|
-
# minitest does!
|
7
|
-
APP_BUNDLE_PATH = File.expand_path './test/fixture/Release/AXElementsTester.app'
|
8
|
-
APP_BUNDLE_IDENTIFIER = 'com.marketcircle.AXElementsTester'
|
9
|
-
|
10
|
-
`open #{APP_BUNDLE_PATH}`
|
11
|
-
sleep 3
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/pride'
|
12
3
|
|
13
|
-
|
14
|
-
|
4
|
+
if defined? MACRUBY_REVISION
|
5
|
+
def on_macruby?
|
6
|
+
true
|
7
|
+
end
|
8
|
+
else
|
9
|
+
def on_macruby?
|
10
|
+
false
|
11
|
+
end
|
15
12
|
end
|
16
13
|
|
17
14
|
|
18
|
-
require 'minitest/autorun'
|
19
|
-
require 'minitest/pride'
|
20
|
-
require 'accessibility/core'
|
21
|
-
|
22
15
|
class MiniTest::Unit::TestCase
|
23
16
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# if this basic API doesn't work we might as well as give up right away
|
34
|
-
APP = Accessibility::Element.application_for PID
|
17
|
+
if respond_to? :parallelize_me!
|
18
|
+
class << self
|
19
|
+
alias_method :try_to_parallelize!, :parallelize_me!
|
20
|
+
end
|
21
|
+
else
|
22
|
+
def self.try_to_parallelize!
|
23
|
+
end
|
24
|
+
end
|
35
25
|
|
36
26
|
def rand_nums count, range = 1_000
|
37
27
|
Array.new count do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: accessibility_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: accessibility_bridge
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 0.1.1
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.1.1
|
30
14
|
- !ruby/object:Gem::Dependency
|
31
15
|
name: yard
|
32
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,25 +43,16 @@ dependencies:
|
|
59
43
|
- - ~>
|
60
44
|
- !ruby/object:Gem::Version
|
61
45
|
version: 0.14.1
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rake-compiler
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: 0.8.1
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 0.8.1
|
78
46
|
description: ! 'accessibility_core is a wrapper around the OS X Accessibility framework.
|
79
47
|
|
80
48
|
|
49
|
+
Some other extras that are intended to help build higher level abstractions
|
50
|
+
|
51
|
+
have also been included. They are primarily wrappers around misc bits
|
52
|
+
|
53
|
+
of Cocoa, but include some speciality modules.
|
54
|
+
|
55
|
+
|
81
56
|
Originally extracted from the AXElements project.
|
82
57
|
|
83
58
|
'
|
@@ -85,42 +60,38 @@ email: markrada26@gmail.com
|
|
85
60
|
executables: []
|
86
61
|
extensions:
|
87
62
|
- ext/accessibility/core/extconf.rb
|
63
|
+
- ext/accessibility/bridge/extconf.rb
|
64
|
+
- ext/accessibility/extras/extconf.rb
|
65
|
+
- ext/accessibility/highlighter/extconf.rb
|
88
66
|
extra_rdoc_files: []
|
89
67
|
files:
|
68
|
+
- lib/accessibility/bridge/common.rb
|
69
|
+
- lib/accessibility/bridge/macruby.rb
|
70
|
+
- lib/accessibility/bridge/mri.rb
|
71
|
+
- lib/accessibility/bridge.rb
|
90
72
|
- lib/accessibility/core/macruby.rb
|
91
73
|
- lib/accessibility/core/version.rb
|
92
74
|
- lib/accessibility/core.rb
|
93
|
-
-
|
75
|
+
- lib/accessibility/extras/common.rb
|
76
|
+
- lib/accessibility/extras.rb
|
77
|
+
- lib/accessibility/highlighter/macruby.rb
|
78
|
+
- lib/accessibility/highlighter.rb
|
79
|
+
- ext/accessibility/bridge/bridge.c
|
94
80
|
- ext/accessibility/core/core.c
|
81
|
+
- ext/accessibility/extras/extras.c
|
95
82
|
- ext/accessibility/highlighter/highlighter.c
|
96
|
-
- ext/accessibility/
|
97
|
-
- ext/accessibility/
|
98
|
-
- ext/accessibility/bridge/
|
99
|
-
- ext/accessibility/bridge/lib/accessibility/bridge/macruby.rb
|
100
|
-
- ext/accessibility/bridge/lib/accessibility/bridge/mri.rb
|
101
|
-
- ext/accessibility/bridge/lib/accessibility/bridge/version.rb
|
102
|
-
- ext/accessibility/bridge/lib/accessibility/bridge.rb
|
103
|
-
- ext/accessibility/bridge/test/array_test.rb
|
104
|
-
- ext/accessibility/bridge/test/boxed_test.rb
|
105
|
-
- ext/accessibility/bridge/test/cfrange_test.rb
|
106
|
-
- ext/accessibility/bridge/test/cgpoint_test.rb
|
107
|
-
- ext/accessibility/bridge/test/cgrect_test.rb
|
108
|
-
- ext/accessibility/bridge/test/cgsize_test.rb
|
109
|
-
- ext/accessibility/bridge/test/helper.rb
|
110
|
-
- ext/accessibility/bridge/test/nsstring_test.rb
|
111
|
-
- ext/accessibility/bridge/test/nsurl_test.rb
|
112
|
-
- ext/accessibility/bridge/test/object_test.rb
|
113
|
-
- ext/accessibility/bridge/test/range_test.rb
|
114
|
-
- ext/accessibility/bridge/test/string_test.rb
|
115
|
-
- ext/accessibility/bridge/test/uri_test.rb
|
83
|
+
- ext/accessibility/bridge/bridge.h
|
84
|
+
- ext/accessibility/extras/extras.h
|
85
|
+
- ext/accessibility/bridge/extconf.rb
|
116
86
|
- ext/accessibility/core/extconf.rb
|
87
|
+
- ext/accessibility/extras/extconf.rb
|
117
88
|
- ext/accessibility/highlighter/extconf.rb
|
118
89
|
- Rakefile
|
119
90
|
- README.markdown
|
120
91
|
- History.markdown
|
121
92
|
- .yardopts
|
122
93
|
- test/helper.rb
|
123
|
-
homepage: http://github.com/
|
94
|
+
homepage: http://github.com/AXElements/accessibility_core
|
124
95
|
licenses:
|
125
96
|
- BSD 3-clause
|
126
97
|
post_install_message:
|
@@ -133,12 +104,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
104
|
- - ! '>='
|
134
105
|
- !ruby/object:Gem::Version
|
135
106
|
version: '0'
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
hash: -1612632312201987392
|
136
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
111
|
none: false
|
138
112
|
requirements:
|
139
113
|
- - ! '>='
|
140
114
|
- !ruby/object:Gem::Version
|
141
115
|
version: '0'
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
hash: -1612632312201987392
|
142
119
|
requirements: []
|
143
120
|
rubyforge_project:
|
144
121
|
rubygems_version: 1.8.24
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'test/helper'
|
2
|
-
|
3
|
-
class ArrayTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
def test_to_point
|
6
|
-
x, y = rand_nums 2
|
7
|
-
p = [x, y].to_point
|
8
|
-
assert_kind_of CGPoint, p
|
9
|
-
assert_equal x, p.x
|
10
|
-
assert_equal y, p.y
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_to_size
|
14
|
-
w, h = rand_nums 2
|
15
|
-
s = [w, h].to_size
|
16
|
-
assert_kind_of CGSize, s
|
17
|
-
assert_equal w, s.width
|
18
|
-
assert_equal h, s.height
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_to_rect
|
22
|
-
x, y, w, h = rand_nums 4
|
23
|
-
r = [x, y, w, h].to_rect
|
24
|
-
assert_kind_of CGRect, r
|
25
|
-
assert_equal x, r.origin.x
|
26
|
-
assert_equal y, r.origin.y
|
27
|
-
assert_equal w, r.size.width
|
28
|
-
assert_equal h, r.size.height
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test/helper'
|
2
|
-
|
3
|
-
if on_macruby?
|
4
|
-
|
5
|
-
##
|
6
|
-
# Boxed is the common ancestor of all structs defined by bridge support
|
7
|
-
# in MacRuby.
|
8
|
-
class BoxedTest < MiniTest::Unit::TestCase
|
9
|
-
|
10
|
-
def test_to_ax_raises_for_arbitrary_boxes
|
11
|
-
assert_raises(NotImplementedError) { NSEdgeInsets.new.to_ax }
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_to_ruby # bet you would never dare to abuse the parser like this!
|
15
|
-
assert_equal CGPointZero, CGPointZero .to_ax.to_ruby
|
16
|
-
assert_equal CGSize.new(10,10), CGSize.new(10, 10) .to_ax.to_ruby
|
17
|
-
assert_equal CGRectMake(1,2,3,4), CGRectMake(1,2,3,4).to_ax.to_ruby
|
18
|
-
assert_equal 1..10, CFRange.new(1, 10) .to_ax.to_ruby
|
19
|
-
assert_equal Range.new(1,10), CFRange.new(1,10) .to_ax.to_ruby
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'test/helper'
|
2
|
-
|
3
|
-
if on_macruby?
|
4
|
-
class CFRangeTest < MiniTest::Unit::TestCase
|
5
|
-
|
6
|
-
def test_to_ax
|
7
|
-
range = CFRange.new(5, 4)
|
8
|
-
value = range.to_ax
|
9
|
-
ptr = Pointer.new CFRange.type
|
10
|
-
AXValueGetValue(value, 4, ptr)
|
11
|
-
assert_equal range, ptr.value, 'range makes a value'
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_cf_range_to_ruby_range_compatability
|
15
|
-
assert_equal CFRangeMake(1,10).to_ax, (1..10 ).to_ax
|
16
|
-
assert_equal CFRangeMake(1, 9).to_ax, (1...10 ).to_ax
|
17
|
-
assert_equal CFRangeMake(0, 3).to_ax, (0..2 ).to_ax
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'test/helper'
|
2
|
-
|
3
|
-
class CGPointTest < MiniTest::Unit::TestCase
|
4
|
-
|
5
|
-
def test_attributes
|
6
|
-
p = CGPoint.new
|
7
|
-
assert_respond_to p, :x
|
8
|
-
assert_respond_to p, :y
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_to_a
|
12
|
-
p = CGPoint.new 1, 2
|
13
|
-
assert_equal [1, 2], p.to_a
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_to_point
|
17
|
-
p = CGPoint.new
|
18
|
-
assert_same p, p.to_point
|
19
|
-
|
20
|
-
p = CGPoint.new 4, 2
|
21
|
-
assert_same p, p.to_point
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_initialize
|
25
|
-
p = CGPoint.new
|
26
|
-
assert_equal 0, p.x
|
27
|
-
assert_equal 0, p.y
|
28
|
-
|
29
|
-
x, y = rand_nums 2
|
30
|
-
p = CGPoint.new x, y
|
31
|
-
assert_equal x, p.x
|
32
|
-
assert_equal y, p.y
|
33
|
-
|
34
|
-
x, y = rand_floats 2
|
35
|
-
p = CGPoint.new x, y
|
36
|
-
assert_equal x, p.x
|
37
|
-
assert_equal y, p.y
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_inspect
|
41
|
-
assert_match /Point x=1.0 y=2.0>/, CGPoint.new(1, 2).inspect
|
42
|
-
assert_match /Point x=3.0 y=5.0>/, CGPoint.new(3, 5).inspect
|
43
|
-
end
|
44
|
-
|
45
|
-
if on_macruby?
|
46
|
-
def test_to_ax
|
47
|
-
value = CGPointZero.to_ax
|
48
|
-
ptr = Pointer.new CGPoint.type
|
49
|
-
AXValueGetValue(value, 1, ptr)
|
50
|
-
assert_equal CGPointZero, ptr.value, 'point makes a value'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|