AXElements 1.0.0.beta4 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/History.markdown +7 -0
- data/README.markdown +41 -29
- data/Rakefile +1 -6
- data/lib/accessibility/dsl.rb +17 -15
- data/lib/accessibility/pretty_printer.rb +40 -12
- data/lib/accessibility/system_info.rb +2 -0
- data/lib/accessibility/text_highlighter.rb +73 -0
- data/lib/accessibility/translator.rb +1 -0
- data/lib/accessibility/version.rb +1 -1
- data/lib/accessibility.rb +13 -114
- data/lib/ax/application.rb +54 -42
- data/lib/ax/element.rb +27 -7
- data/lib/ax/scroll_area.rb +1 -0
- data/lib/ax/systemwide.rb +5 -4
- data/lib/ax/text_area.rb +16 -0
- data/lib/ax/text_field.rb +10 -0
- data/lib/ax_elements/mri.rb +36 -1
- data/rakelib/ci.rake +9 -0
- data/rakelib/doc.rake +4 -13
- data/rakelib/ext.rake +1 -57
- data/rakelib/gem.rake +7 -23
- data/rakelib/test.rake +10 -17
- data/test/helper.rb +15 -18
- data/test/integration/accessibility/test_dsl.rb +9 -3
- data/test/integration/ax/test_application.rb +1 -1
- data/test/integration/ax/test_text_area.rb +62 -0
- data/test/integration/ax/test_text_field.rb +49 -0
- data/test/sanity/accessibility/test_dsl.rb +1 -0
- data/test/sanity/accessibility/test_errors.rb +1 -1
- data/test/sanity/accessibility/test_pretty_printer.rb +6 -1
- data/test/sanity/accessibility/test_qualifier.rb +1 -1
- data/test/sanity/accessibility/test_system_info.rb +109 -0
- data/test/sanity/accessibility/test_translator.rb +1 -1
- data/test/sanity/accessibility/test_version.rb +2 -2
- data/test/sanity/ax_elements/test_nsarray_compat.rb +1 -1
- data/test/sanity/ax_elements/test_nsobject_inspect.rb +1 -1
- data/test/sanity/test_ax_elements.rb +1 -1
- metadata +34 -59
- data/ext/accessibility/key_coder/extconf.rb +0 -22
- data/ext/accessibility/key_coder/key_coder.c +0 -123
- data/lib/accessibility/string.rb +0 -502
- data/test/sanity/accessibility/test_string.rb +0 -238
data/lib/ax/application.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'ax/element'
|
2
|
-
require 'accessibility/
|
2
|
+
require 'accessibility/keyboard'
|
3
3
|
|
4
4
|
##
|
5
5
|
# The accessibility object representing the running application. This
|
@@ -9,7 +9,7 @@ require 'accessibility/string'
|
|
9
9
|
# As this class has evolved, it has gathered some functionality from
|
10
10
|
# the `NSRunningApplication` and `NSBundle` classes.
|
11
11
|
class AX::Application < AX::Element
|
12
|
-
include Accessibility::
|
12
|
+
include Accessibility::Keyboard
|
13
13
|
|
14
14
|
class << self
|
15
15
|
##
|
@@ -75,12 +75,16 @@ class AX::Application < AX::Element
|
|
75
75
|
end
|
76
76
|
|
77
77
|
##
|
78
|
+
# @note Initialization with bundle identifiers is case-sensitive
|
79
|
+
# (e.g. 'com.apple.iCal' is correct, 'com.apple.ical' is wrong)
|
80
|
+
#
|
78
81
|
# Standard way of creating a new application object
|
79
82
|
#
|
80
83
|
# You can initialize an application object with either the process
|
81
|
-
# identifier (pid) of the application, the name of the application,
|
82
|
-
#
|
83
|
-
#
|
84
|
+
# identifier (pid) of the application, the name of the application, the
|
85
|
+
# bundle identifier string (e.g. 'com.company.appName'), an
|
86
|
+
# `NSRunningApplication` instance for the application, or an accessibility
|
87
|
+
# (`AXUIElementRef`) token.
|
84
88
|
#
|
85
89
|
# Given a PID, we try to lookup the application and wrap it.
|
86
90
|
#
|
@@ -105,46 +109,27 @@ class AX::Application < AX::Element
|
|
105
109
|
#
|
106
110
|
# AX::Application.new 'com.apple.mail'
|
107
111
|
# AX::Application.new 'Mail'
|
112
|
+
# AX::Application.new 578
|
113
|
+
# AX::Application.new 'com.apple.iCal'
|
114
|
+
# AX::Application.new 'Calendar'
|
115
|
+
# AX::Application.new 3782
|
116
|
+
# AX::Application.new 'com.apple.AddressBook'
|
117
|
+
# AX::Application.new 'Contacts'
|
108
118
|
# AX::Application.new 43567
|
109
119
|
#
|
110
120
|
# @param arg [Number,String,NSRunningApplication]
|
111
121
|
def initialize arg
|
112
|
-
case arg
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
app.first
|
122
|
-
|
123
|
-
) || (
|
124
|
-
spin
|
125
|
-
NSWorkspace.sharedWorkspace.runningApplications.find { |app|
|
126
|
-
app.localizedName == arg
|
127
|
-
}
|
128
|
-
|
129
|
-
) || (
|
130
|
-
count ||= 0
|
131
|
-
if AX::Application.launch arg
|
132
|
-
spin 1
|
133
|
-
count += 1
|
134
|
-
raise "#{arg} failed to launch in time" if count == 10
|
135
|
-
else
|
136
|
-
raise "#{arg} is not a registered bundle identifier for the system"
|
122
|
+
@app = case arg
|
123
|
+
when String
|
124
|
+
init_with_bundle_id(arg) || init_with_name(arg) || try_launch(arg)
|
125
|
+
when Fixnum
|
126
|
+
NSRunningApplication.runningApplicationWithProcessIdentifier arg
|
127
|
+
when NSRunningApplication
|
128
|
+
arg
|
129
|
+
else # assume it is an AXUIElementRef (Accessibility::Element)
|
130
|
+
NSRunningApplication.runningApplicationWithProcessIdentifier arg.pid
|
137
131
|
end
|
138
|
-
|
139
|
-
end
|
140
|
-
super Accessibility::Element.application_for @app.processIdentifier
|
141
|
-
when NSRunningApplication
|
142
|
-
super Accessibility::Element.application_for arg.processIdentifier
|
143
|
-
@app = arg
|
144
|
-
else
|
145
|
-
super arg # assume it is an AXUIElementRef
|
146
|
-
@app = NSRunningApplication.runningApplicationWithProcessIdentifier pid
|
147
|
-
end
|
132
|
+
super Accessibility::Element.application_for @app.processIdentifier
|
148
133
|
end
|
149
134
|
|
150
135
|
|
@@ -318,8 +303,10 @@ class AX::Application < AX::Element
|
|
318
303
|
# @param string [String]
|
319
304
|
# @return [Boolean]
|
320
305
|
def type string
|
321
|
-
|
322
|
-
|
306
|
+
perform(:unhide) unless focused?
|
307
|
+
keyboard_events_for(string).each do |event|
|
308
|
+
KeyCoder.post_event event
|
309
|
+
end
|
323
310
|
end
|
324
311
|
alias_method :type_string, :type
|
325
312
|
|
@@ -437,4 +424,29 @@ class AX::Application < AX::Element
|
|
437
424
|
@bundle ||= NSBundle.bundleWithURL @app.bundleURL
|
438
425
|
end
|
439
426
|
|
427
|
+
def init_with_bundle_id id
|
428
|
+
app = NSRunningApplication.runningApplicationsWithBundleIdentifier id
|
429
|
+
app.first
|
430
|
+
end
|
431
|
+
|
432
|
+
def init_with_name name
|
433
|
+
spin
|
434
|
+
NSWorkspace.sharedWorkspace.runningApplications.find { |app|
|
435
|
+
app.localizedName == name
|
436
|
+
}
|
437
|
+
end
|
438
|
+
|
439
|
+
def try_launch id
|
440
|
+
10.times do
|
441
|
+
app = init_with_bundle_id id
|
442
|
+
return app if app
|
443
|
+
if AX::Application.launch id
|
444
|
+
spin 1
|
445
|
+
else
|
446
|
+
raise "#{arg} is not a registered bundle identifier for the system"
|
447
|
+
end
|
448
|
+
end
|
449
|
+
raise "#{arg} failed to launch in time"
|
450
|
+
end
|
451
|
+
|
440
452
|
end
|
data/lib/ax/element.rb
CHANGED
@@ -227,6 +227,22 @@ class AX::Element
|
|
227
227
|
@ref.perform TRANSLATOR.cocoaify action
|
228
228
|
end
|
229
229
|
|
230
|
+
##
|
231
|
+
# @note As of OS X 10.9 (Sea Lion), it is no longer possible to send
|
232
|
+
# keyboard events directly to an element. What we have here is
|
233
|
+
# only an approximation.
|
234
|
+
#
|
235
|
+
# Send keyboard events to the receiver.
|
236
|
+
#
|
237
|
+
# @param string [String]
|
238
|
+
# @return [Boolean]
|
239
|
+
def type string
|
240
|
+
set_focus_to self unless focused?
|
241
|
+
keyboard_events_for(string).each do |event|
|
242
|
+
KeyCoder.post_event event
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
230
246
|
|
231
247
|
# @group Search
|
232
248
|
|
@@ -280,7 +296,7 @@ class AX::Element
|
|
280
296
|
element = self
|
281
297
|
until qualifier.qualifies? element
|
282
298
|
element = element.attribute :parent
|
283
|
-
|
299
|
+
break unless element
|
284
300
|
end
|
285
301
|
element
|
286
302
|
end
|
@@ -365,12 +381,9 @@ class AX::Element
|
|
365
381
|
#
|
366
382
|
# @return [String]
|
367
383
|
def inspect
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
msg << pp_checkbox(:enabled) if attributes.include? :enabled
|
372
|
-
msg << pp_checkbox(:focused) if attributes.include? :focused
|
373
|
-
msg << '>'
|
384
|
+
"#<#{self.class}" << pp_identifier.to_s <<
|
385
|
+
pp_position << pp_children <<
|
386
|
+
pp_enabled << pp_focused << '>'
|
374
387
|
end
|
375
388
|
|
376
389
|
##
|
@@ -384,6 +397,13 @@ class AX::Element
|
|
384
397
|
inspect
|
385
398
|
end
|
386
399
|
|
400
|
+
##
|
401
|
+
#
|
402
|
+
# @return [Hash{Symbol=>Object}]
|
403
|
+
def to_h
|
404
|
+
Hash[attributes.zip attributes.map { |attr| attribute(attr) }]
|
405
|
+
end
|
406
|
+
|
387
407
|
##
|
388
408
|
# Get the relevant details about the receiver and also the children
|
389
409
|
# and further descendents of the receiver. Each generation down the
|
data/lib/ax/scroll_area.rb
CHANGED
data/lib/ax/systemwide.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'ax/element'
|
2
|
-
require 'accessibility/
|
2
|
+
require 'accessibility/keyboard'
|
3
3
|
|
4
4
|
##
|
5
5
|
# Represents the special `SystemWide` accessibility object.
|
@@ -9,7 +9,7 @@ require 'accessibility/string'
|
|
9
9
|
# of the system wide object when you need to use it (even though they
|
10
10
|
# are all the same thing).
|
11
11
|
class AX::SystemWide < AX::Element
|
12
|
-
include Accessibility::
|
12
|
+
include Accessibility::Keyboard
|
13
13
|
|
14
14
|
class << self
|
15
15
|
##
|
@@ -57,8 +57,9 @@ class AX::SystemWide < AX::Element
|
|
57
57
|
# @param string [String]
|
58
58
|
# @return [Boolean]
|
59
59
|
def type string
|
60
|
-
|
61
|
-
|
60
|
+
keyboard_events_for(string).each do |event|
|
61
|
+
KeyCoder.post_event event
|
62
|
+
end
|
62
63
|
end
|
63
64
|
alias_method :type_string, :type
|
64
65
|
|
data/lib/ax/text_area.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'ax/element'
|
2
|
+
require 'accessibility/text_highlighter'
|
3
|
+
|
4
|
+
##
|
5
|
+
# Represents a generic text field on screen that users can
|
6
|
+
# manipulate. Usually seen in form with placeholder text.
|
7
|
+
class AX::TextArea < AX::Element
|
8
|
+
include Accessibility::TextHighlighter
|
9
|
+
|
10
|
+
# (see Accessibility::TextHighlighter#highlight_text)
|
11
|
+
def highlight_text range
|
12
|
+
# @todo make sure the text is visible first
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'ax/element'
|
2
|
+
require 'accessibility/text_highlighter'
|
3
|
+
|
4
|
+
|
5
|
+
##
|
6
|
+
# Represents a generic text field on screen that users can
|
7
|
+
# manipulate. Usually seen in form with placeholder text.
|
8
|
+
class AX::TextField < AX::Element
|
9
|
+
include Accessibility::TextHighlighter
|
10
|
+
end
|
data/lib/ax_elements/mri.rb
CHANGED
@@ -1,42 +1,78 @@
|
|
1
1
|
unless on_macruby?
|
2
2
|
|
3
|
+
# @return [String]
|
3
4
|
KAXChildrenAttribute = 'AXChildren'
|
5
|
+
# @return [String]
|
4
6
|
KAXRoleAttribute = 'AXRole'
|
7
|
+
# @return [String]
|
5
8
|
KAXSubroleAttribute = 'AXSubrole'
|
9
|
+
# @return [String]
|
6
10
|
KAXIdentifierAttribute = 'AXIdentifier'
|
11
|
+
# @return [String]
|
7
12
|
KAXWindowCreatedNotification = 'AXWindowCreated'
|
13
|
+
# @return [String]
|
8
14
|
KAXMainWindowAttribute = 'AXMainWindow'
|
15
|
+
# @return [String]
|
9
16
|
KAXFocusedAttribute = 'AXFocused'
|
17
|
+
# @return [String]
|
10
18
|
KAXValueChangedNotification = 'AXValueChanged'
|
19
|
+
# @return [String]
|
11
20
|
KAXTitleAttribute = 'AXTitle'
|
21
|
+
# @return [String]
|
12
22
|
KAXURLAttribute = 'AXURL'
|
23
|
+
# @return [String]
|
13
24
|
KAXTitleUIElementAttribute = 'AXTitleUIElement'
|
25
|
+
# @return [String]
|
14
26
|
KAXPlaceholderValueAttribute = 'AXPlaceholderValue'
|
27
|
+
# @return [String]
|
15
28
|
KAXWindowRole = 'AXWindow'
|
29
|
+
# @return [String]
|
16
30
|
KAXCloseButtonSubrole = 'AXCloseButton'
|
31
|
+
# @return [String]
|
17
32
|
KAXTrashDockItemSubrole = 'AXTrashDockItem'
|
33
|
+
# @return [String]
|
34
|
+
KAXPosition = 'AXPosition'
|
35
|
+
# @return [String]
|
36
|
+
KAXSize = 'AXSize'
|
37
|
+
# @return [String]
|
18
38
|
KAXRTFForRangeParameterizedAttribute = 'AXRTFForRange'
|
39
|
+
# @return [String]
|
19
40
|
KAXIsApplicationRunningAttribute = 'AXIsApplicationRunning'
|
41
|
+
# @return [String]
|
20
42
|
KAXStringForRangeParameterizedAttribute = 'AXStringForRange'
|
21
43
|
|
22
44
|
unless defined? NSString
|
45
|
+
# Alias for the `String` class, compatible with MacRuby
|
46
|
+
# @return [Class]
|
23
47
|
NSString = String
|
24
48
|
end
|
25
49
|
|
26
50
|
unless defined? NSDictionary
|
51
|
+
# Alias for the `Hash` class, compatible with MacRuby
|
52
|
+
# @return [Class]
|
27
53
|
NSDictionary = Hash
|
28
54
|
end
|
29
55
|
|
30
56
|
unless defined? NSArray
|
57
|
+
# Alias for the `Array` class, compatible with MacRuby
|
58
|
+
# @return [Class]
|
31
59
|
NSArray = Array
|
32
60
|
end
|
33
61
|
|
34
62
|
unless defined? NSDate
|
63
|
+
# Alias for the `Time` class, compatible with MacRuby
|
64
|
+
# @return [Class]
|
35
65
|
NSDate = Time
|
36
66
|
end
|
37
67
|
|
68
|
+
##
|
69
|
+
# AXElements extensions to the Symbol class
|
38
70
|
class Symbol
|
39
71
|
|
72
|
+
##
|
73
|
+
# Equivalent to `String#chomp`, coerces receiver to string first
|
74
|
+
#
|
75
|
+
# @return [String]
|
40
76
|
def chomp suffix
|
41
77
|
to_s.chomp suffix
|
42
78
|
end
|
@@ -54,4 +90,3 @@ unless defined? KAXIdentifierAttribute
|
|
54
90
|
# @return [String]
|
55
91
|
KAXIdentifierAttribute = 'AXIdentifier'
|
56
92
|
end
|
57
|
-
|
data/rakelib/ci.rake
ADDED
data/rakelib/doc.rake
CHANGED
@@ -1,16 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# $stderr.puts 'It seems as though you do not have yard installed.'
|
6
|
-
# command = ENV['RUBY_VERSION'] ? 'rake' : 'sudo macrake'
|
7
|
-
# $stderr.puts "You can install it by running `#{command} setup_dev`"
|
8
|
-
# end
|
9
|
-
|
10
|
-
# desc 'Generate Graphviz object graph'
|
11
|
-
# task :garden => :yard do
|
12
|
-
# sh 'yard graph --full --dependencies --dot="-Tpng:quartz" -f docs/images/AX.dot'
|
13
|
-
# end
|
1
|
+
desc 'Generate Graphviz object graph'
|
2
|
+
task :garden => :yard do
|
3
|
+
sh 'yard graph --full --dependencies --dot="-Tpng:quartz" -f docs/images/AX.dot'
|
4
|
+
end
|
14
5
|
|
15
6
|
desc 'Remove files generated by YARD'
|
16
7
|
task :clobber_yard do
|
data/rakelib/ext.rake
CHANGED
@@ -1,61 +1,5 @@
|
|
1
|
-
module ExtHelpers
|
2
|
-
def macruby?
|
3
|
-
defined? MACRUBY_REVISION
|
4
|
-
end
|
5
|
-
|
6
|
-
def cruby?
|
7
|
-
RUBY_ENGINE == 'ruby'
|
8
|
-
end
|
9
|
-
|
10
|
-
def needs_regeneration? source, bundle
|
11
|
-
return true unless File.exists? bundle
|
12
|
-
return true unless File.mtime(bundle) > File.mtime(source)
|
13
|
-
return true if macruby? && ext_platform(bundle) == :cruby
|
14
|
-
return true if cruby? && ext_platform(bundle) == :macruby
|
15
|
-
end
|
16
|
-
|
17
|
-
def ext_platform bundle
|
18
|
-
return :macruby if `otool -L #{bundle}`.match /MacRuby/
|
19
|
-
return :cruby
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
namespace :ext do
|
25
|
-
extend ExtHelpers
|
26
|
-
|
27
|
-
desc 'Compile the key_coder C extension'
|
28
|
-
task :key_coder do
|
29
|
-
dir = 'ext/accessibility/key_coder'
|
30
|
-
ext = "#{dir}/key_coder"
|
31
|
-
if needs_regeneration? "#{ext}.c", "#{ext}.bundle"
|
32
|
-
Rake::Task['clobber_key_coder'].execute
|
33
|
-
Dir.chdir(dir) do
|
34
|
-
ruby 'extconf.rb'
|
35
|
-
sh 'make'
|
36
|
-
end
|
37
|
-
cp "#{ext}.bundle", 'lib/accessibility'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
desc 'Remove files generated by compiling key_coder'
|
44
|
-
task :clobber_key_coder do
|
45
|
-
Dir.glob('{lib,ext}/**/*{.bundle,.o}').each do |file|
|
46
|
-
$stdout.puts "rm #{file}"
|
47
|
-
rm_f file
|
48
|
-
end
|
49
|
-
file = 'ext/accessibility/key_coder/Makefile'
|
50
|
-
$stdout.puts "rm #{file}"
|
51
|
-
rm_f file
|
52
|
-
end
|
53
|
-
|
54
|
-
desc 'Remove files generated by compiling extensions'
|
55
|
-
task :clobber_ext => [:clobber_key_coder]
|
56
|
-
|
57
|
-
|
58
1
|
if RUBY_ENGINE == 'macruby'
|
59
2
|
require 'rake/compiletask'
|
60
3
|
Rake::CompileTask.new
|
61
4
|
end
|
5
|
+
|
data/rakelib/gem.rake
CHANGED
@@ -1,28 +1,12 @@
|
|
1
|
-
require '
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
|
-
|
4
|
-
Gem::PackageTask.new(ax_elements) { }
|
3
|
+
task :install => :setup
|
5
4
|
|
6
|
-
desc '
|
7
|
-
task :install => [:gem, :setup] do
|
8
|
-
require 'rubygems/installer'
|
9
|
-
Gem::Installer.new("pkg/#{ax_elements.file_name}").install
|
10
|
-
end
|
11
|
-
|
12
|
-
desc 'Install dependencies for running AXElements'
|
5
|
+
desc 'Install AXElements dependencies'
|
13
6
|
task :setup do
|
14
|
-
|
15
|
-
ax_elements.runtime_dependencies.each do |dep|
|
16
|
-
puts "Installing #{dep.name} (#{dep.requirement})"
|
17
|
-
Gem::DependencyInstaller.new.install(dep.name, dep.requirement)
|
18
|
-
end
|
7
|
+
sh 'bundle install'
|
19
8
|
end
|
20
9
|
|
21
|
-
desc 'Install
|
22
|
-
task :setup_dev => :setup
|
23
|
-
|
24
|
-
(ax_elements.runtime_dependencies + ax_elements.development_dependencies).each do |dep|
|
25
|
-
puts "Installing #{dep.name} (#{dep.requirement})"
|
26
|
-
Gem::DependencyInstaller.new.install(dep.name, dep.requirement)
|
27
|
-
end
|
28
|
-
end
|
10
|
+
desc 'Install AXElements development dependencies'
|
11
|
+
task :setup_dev => :setup
|
12
|
+
|
data/rakelib/test.rake
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
desc 'Start up irb with AXElements loaded'
|
2
|
-
task :console
|
2
|
+
task :console do
|
3
3
|
irb = ENV['RUBY_VERSION'] ? 'irb' : 'macirb'
|
4
|
+
ENV['AXDEBUG'] = '1'
|
4
5
|
sh "#{irb} -Ilib -rubygems -rax_elements"
|
5
6
|
end
|
6
7
|
|
@@ -21,24 +22,16 @@ task :clobber_fixture do
|
|
21
22
|
end
|
22
23
|
task :clobber => :clobber_fixture
|
23
24
|
|
24
|
-
require 'rake/testtask'
|
25
25
|
namespace :test do
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
desc 'Run sanity tests (basic, fast stuff)'
|
27
|
+
task :sanity => :fixture do
|
28
|
+
files = FileList['test/sanity/**/test_*.rb']
|
29
|
+
sh "./test/runner #{files}"
|
29
30
|
end
|
30
|
-
task :sanity => [:ext, :fixture]
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
desc 'Run integration tests (complex, slow stuff)'
|
33
|
+
task :integration => :fixture do
|
34
|
+
files = FileList['test/integration/**/test_*.rb']
|
35
|
+
sh "./test/runner #{files}"
|
35
36
|
end
|
36
|
-
task :integration => [:ext, :fixture]
|
37
|
-
|
38
|
-
desc 'Run tests for the string parser'
|
39
|
-
Rake::TestTask.new(:string) do |t|
|
40
|
-
t.libs << '.'
|
41
|
-
t.pattern = "test/sanity/accessibility/test_string.rb"
|
42
|
-
end
|
43
|
-
task :string => :ext
|
44
37
|
end
|
data/test/helper.rb
CHANGED
@@ -1,26 +1,23 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
3
|
-
framework 'Cocoa' if on_macruby?
|
2
|
+
require 'simplecov' unless RUBY_ENGINE == 'macruby'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
# point it will start to respond, so we just sleep
|
8
|
-
APP_BUNDLE_PATH = File.expand_path './test/fixture/Release/AXElementsTester.app'
|
9
|
-
APP_BUNDLE_IDENTIFIER = 'com.marketcircle.AXElementsTester'
|
4
|
+
require 'test/fixture_app' # must be loaded before minitest
|
5
|
+
require 'minitest/autorun'
|
10
6
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
# preprocessor powers, assemble!
|
8
|
+
if ENV['BENCH']
|
9
|
+
require 'minitest/benchmark'
|
10
|
+
else
|
11
|
+
require'minitest/pride'
|
16
12
|
end
|
17
13
|
|
14
|
+
class MiniTest::Unit::TestCase
|
18
15
|
|
19
|
-
|
20
|
-
|
16
|
+
def self.bench_range
|
17
|
+
bench_exp 100, 100_000
|
18
|
+
end
|
21
19
|
|
22
|
-
class MiniTest::Unit::TestCase
|
23
|
-
# needs to be defined in the class, there is a TOPLEVEL::PID
|
24
|
-
PID = pid_for APP_BUNDLE_IDENTIFIER
|
25
|
-
REF = Accessibility::Element.application_for PID
|
26
20
|
end
|
21
|
+
|
22
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
23
|
+
|
@@ -12,8 +12,14 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase
|
|
12
12
|
@dsl ||= DSL.new
|
13
13
|
end
|
14
14
|
|
15
|
-
def text_area
|
16
|
-
|
15
|
+
def text_area
|
16
|
+
@@text_area ||= app.main_window.text_area
|
17
|
+
end
|
18
|
+
|
19
|
+
def pop_up
|
20
|
+
@@pop_up ||= app.main_window.pop_up
|
21
|
+
end
|
22
|
+
|
17
23
|
def pref_window
|
18
24
|
app.children.find { |x|
|
19
25
|
if x.respond_to? :title
|
@@ -54,7 +60,7 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase
|
|
54
60
|
end
|
55
61
|
|
56
62
|
def test_application_with_pid
|
57
|
-
assert_equal app, dsl.app_with_pid(
|
63
|
+
assert_equal app, dsl.app_with_pid(APP_PID)
|
58
64
|
end
|
59
65
|
|
60
66
|
def test_set_focus_to
|
@@ -7,7 +7,7 @@ class TestAXApplication < MiniTest::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_initialize_args
|
10
|
-
assert_equal app, AX::Application.new(
|
10
|
+
assert_equal app, AX::Application.new(APP_PID)
|
11
11
|
assert_equal app, AX::Application.new(APP_BUNDLE_IDENTIFIER)
|
12
12
|
assert_equal app, AX::Application.new(running_app.localizedName)
|
13
13
|
assert_equal app, AX::Application.new(running_app)
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test/integration/helper'
|
2
|
+
|
3
|
+
class TestAXTextArea < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def text_area
|
6
|
+
@area ||= app.main_window.text_area
|
7
|
+
end
|
8
|
+
|
9
|
+
def text
|
10
|
+
<<-EOS
|
11
|
+
Lorem ipsum dolor sit amet, dignissim at eget. Porttitor ut, montes eget, sed ante nec faucibus erat id, fermentum sed eu inceptos turpis, rutrum vitae lectus est augue. Leo leo pede eu sem. Ornare ridiculus bibendum elit amet integer elit, leo porttitor vestibulum vestibulum, ut dignissim faucibus laoreet sodales nullam tellus, lacus pellentesque laoreet consectetur viverra ut. Turpis risus vestibulum purus. Integer convallis, in eros conubia, augue metus ut, hac litora elit lorem. Enim feugiat sem vel, ut integer, fermentum in wisi, pharetra pharetra posuere. Torquent vehicula hendrerit donec, scelerisque tincidunt adipiscing orci non fames luctus, per pellentesque lectus felis sed massa elit, praesent lectus diam est vitae congue et. Neque justo vitae suspendisse in. Et morbi, primis a.
|
12
|
+
EOS
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup
|
16
|
+
text_area.value = text
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
text_area.value = ''
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_highlight_text_regexp
|
24
|
+
[
|
25
|
+
/L/,
|
26
|
+
/Lorem/,
|
27
|
+
/orem/,
|
28
|
+
# /a.$/
|
29
|
+
].each do |expected|
|
30
|
+
text_area.highlight_text expected
|
31
|
+
actual = text_area.selected_text
|
32
|
+
expected = text_area.value.scan(expected).first
|
33
|
+
assert_equal expected, actual
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_highlight_text_string
|
38
|
+
skip
|
39
|
+
[
|
40
|
+
'Enim feugiat sem vel, ut integer, fermentum in wisi, pharetra pharetra posuere.',
|
41
|
+
'Enim',
|
42
|
+
'at'
|
43
|
+
].each do |expected|
|
44
|
+
text_area.highlight_text expected
|
45
|
+
actual = text_area.selected_text
|
46
|
+
assert_equal expected, actual, expected
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_highlight_text_range
|
51
|
+
[
|
52
|
+
6..10,
|
53
|
+
6...10,
|
54
|
+
].each do |range|
|
55
|
+
expected = text_area.value[range]
|
56
|
+
text_area.highlight_text range
|
57
|
+
actual = text_area.selected_text
|
58
|
+
assert_equal expected, actual, range
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|