AXElements 1.0.0.alpha11 → 1.0.0.beta

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.
Files changed (48) hide show
  1. data/History.markdown +11 -1
  2. data/README.markdown +10 -8
  3. data/Rakefile +1 -1
  4. data/lib/accessibility/dsl.rb +5 -2
  5. data/lib/accessibility/factory.rb +134 -78
  6. data/lib/accessibility/qualifier.rb +2 -0
  7. data/lib/accessibility/system_info.rb +82 -17
  8. data/lib/accessibility/translator.rb +17 -17
  9. data/lib/accessibility/version.rb +1 -1
  10. data/lib/ax/application.rb +11 -16
  11. data/lib/ax/element.rb +21 -34
  12. data/lib/ax/systemwide.rb +2 -2
  13. data/lib/ax_elements.rb +7 -1
  14. data/lib/ax_elements/active_support_selections.rb +10 -0
  15. data/lib/ax_elements/mri.rb +57 -0
  16. data/lib/ax_elements/nsarray_compat.rb +97 -17
  17. data/rakelib/gem.rake +12 -3
  18. data/rakelib/test.rake +0 -6
  19. data/test/helper.rb +10 -20
  20. data/test/integration/accessibility/test_dsl.rb +6 -14
  21. data/test/integration/accessibility/test_enumerators.rb +0 -1
  22. data/test/integration/accessibility/test_graph.rb +1 -0
  23. data/test/integration/accessibility/test_qualifier.rb +2 -2
  24. data/test/integration/ax/test_application.rb +2 -2
  25. data/test/sanity/accessibility/test_factory.rb +2 -2
  26. data/test/sanity/accessibility/test_pretty_printer.rb +2 -2
  27. data/test/sanity/ax/test_application.rb +1 -1
  28. data/test/sanity/ax/test_element.rb +2 -2
  29. data/test/sanity/ax_elements/test_nsobject_inspect.rb +4 -2
  30. metadata +28 -36
  31. data/ext/accessibility/core/core.c +0 -26
  32. data/lib/accessibility/core.rb +0 -943
  33. data/lib/accessibility/highlighter.rb +0 -86
  34. data/lib/accessibility/statistics.rb +0 -57
  35. data/lib/ax_elements/core_graphics_workaround.rb +0 -7
  36. data/lib/ax_elements/vendor/inflection_data.rb +0 -66
  37. data/lib/ax_elements/vendor/inflections.rb +0 -176
  38. data/lib/ax_elements/vendor/inflector.rb +0 -306
  39. data/lib/minitest/ax_elements.rb +0 -180
  40. data/lib/rspec/expectations/ax_elements.rb +0 -234
  41. data/test/integration/accessibility/test_core.rb +0 -18
  42. data/test/integration/minitest/test_ax_elements.rb +0 -89
  43. data/test/integration/rspec/expectations/test_ax_elements.rb +0 -102
  44. data/test/sanity/accessibility/test_highlighter.rb +0 -56
  45. data/test/sanity/accessibility/test_statistics.rb +0 -57
  46. data/test/sanity/minitest/test_ax_elements.rb +0 -17
  47. data/test/sanity/rspec/expectations/test_ax_elements.rb +0 -15
  48. data/test/test_core.rb +0 -454
data/rakelib/gem.rake CHANGED
@@ -4,15 +4,24 @@ ax_elements = Gem::Specification.load('AXElements.gemspec')
4
4
  Gem::PackageTask.new(ax_elements) { }
5
5
 
6
6
  desc 'Build and install gem (not including deps)'
7
- task :install => :gem do
7
+ task :install => [:gem, :setup] do
8
8
  require 'rubygems/installer'
9
9
  Gem::Installer.new("pkg/#{ax_elements.file_name}").install
10
10
  end
11
11
 
12
+ desc 'Install dependencies for running AXElements'
13
+ task :setup do
14
+ require 'rubygems/dependency_installer'
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
19
+ end
20
+
12
21
  desc 'Install dependencies for development'
13
- task :setup_dev do
22
+ task :setup_dev => :setup do
14
23
  require 'rubygems/dependency_installer'
15
- ax_elements.development_dependencies.each do |dep|
24
+ (ax_elements.runtime_dependencies + ax_elements.development_dependencies).each do |dep|
16
25
  puts "Installing #{dep.name} (#{dep.requirement})"
17
26
  Gem::DependencyInstaller.new.install(dep.name, dep.requirement)
18
27
  end
data/rakelib/test.rake CHANGED
@@ -23,12 +23,6 @@ task :clobber => :clobber_fixture
23
23
 
24
24
  require 'rake/testtask'
25
25
  namespace :test do
26
- Rake::TestTask.new(:core) do |t|
27
- t.libs << '.'
28
- t.pattern = 'test/test_core.rb'
29
- end
30
- task :core => [:ext, :fixture]
31
-
32
26
  Rake::TestTask.new(:sanity) do |t|
33
27
  t.libs << '.'
34
28
  t.pattern = "test/sanity/**/test_*.rb"
data/test/helper.rb CHANGED
@@ -1,28 +1,18 @@
1
- framework 'Cocoa'
1
+ require 'rubygems'
2
+ require 'accessibility/core'
3
+ framework 'Cocoa' if on_macruby?
2
4
 
3
5
  # We want to launch the test app and make sure it responds to
4
6
  # accessibility queries, but that is difficult to know at what
5
7
  # point it will start to respond, so we just sleep
6
- APP_BUNDLE_URL = NSURL.fileURLWithPath File.expand_path './test/fixture/Release/AXElementsTester.app'
8
+ APP_BUNDLE_PATH = File.expand_path './test/fixture/Release/AXElementsTester.app'
7
9
  APP_BUNDLE_IDENTIFIER = 'com.marketcircle.AXElementsTester'
8
10
 
9
- error = Pointer.new :id
10
- TEST_APP = NSWorkspace.sharedWorkspace.launchApplicationAtURL APP_BUNDLE_URL,
11
- options: NSWorkspaceLaunchAsync,
12
- configuration: {},
13
- error: error
14
- if TEST_APP.nil?
15
- $stderr.puts 'You need to build AND run the fixture app once before running tests'
16
- $stderr.puts 'Run `rake run_fixture` to initalize the fixture'
17
- exit 3
18
- else
19
- sleep 2 # Instead of using high level features of AXElements that we are
20
- # testing, I think it is just safer to sleep
21
- # Make sure the test app is closed when testing finishes
22
- at_exit do
23
- TEST_APP.terminate
24
- puts STATS.to_s
25
- end
11
+ `open #{APP_BUNDLE_PATH}`
12
+ sleep 3
13
+
14
+ at_exit do
15
+ `killall AXElementsTester`
26
16
  end
27
17
 
28
18
 
@@ -32,5 +22,5 @@ require 'test/runner'
32
22
  class MiniTest::Unit::TestCase
33
23
  # needs to be defined in the class, there is a TOPLEVEL::PID
34
24
  PID = pid_for APP_BUNDLE_IDENTIFIER
35
- REF = AXUIElementCreateApplication(PID)
25
+ REF = Accessibility::Element.application_for PID
36
26
  end
@@ -166,7 +166,8 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase
166
166
 
167
167
  def test_wait_for_invalidation_of_element
168
168
  app.main_window.button(title: 'Yes').perform(:press)
169
- Dispatch::Queue.new("herp").after(1) do
169
+ Thread.new do
170
+ sleep 1
170
171
  app.main_window.button(title: 'No').perform(:press)
171
172
  end
172
173
 
@@ -175,7 +176,8 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase
175
176
 
176
177
  def test_wait_for_invalidation_of_wait_for
177
178
  app.main_window.button(title: 'Yes').perform(:press)
178
- Dispatch::Queue.new("herp").after(1) do
179
+ Thread.new do
180
+ sleep 1
179
181
  app.main_window.button(title: 'No').perform(:press)
180
182
  end
181
183
 
@@ -211,19 +213,9 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase
211
213
  def test_highlight
212
214
  highlighter = dsl.highlight app.main_window, colour: NSColor.blueColor
213
215
  assert_kind_of Accessibility::Highlighter, highlighter
214
- assert_equal NSColor.blueColor, highlighter.backgroundColor
216
+ assert_equal NSColor.blueColor, highlighter.color
215
217
  highlighter.stop
216
-
217
- def highlight_test
218
- @got_called = true
219
- end
220
- highlighter = dsl.highlight app.main_window, color: NSColor.greenColor, timeout: 0.1
221
- NSNotificationCenter.defaultCenter.addObserver self,
222
- selector: 'highlight_test',
223
- name: NSWindowWillCloseNotification,
224
- object: highlighter
225
- sleep 0.1
226
- assert @got_called
218
+ refute highlighter.visible?
227
219
  end
228
220
 
229
221
  def test_screenshot
@@ -49,7 +49,6 @@ end
49
49
 
50
50
 
51
51
  class TestAccessibilityEnumeratorsDepthFirst < MiniTest::Unit::TestCase
52
- include Accessibility::Element
53
52
 
54
53
  def app
55
54
  @@app ||= AX::Application.new REF
@@ -4,6 +4,7 @@ require 'accessibility/graph'
4
4
  class TestAccessibilityGraph < MiniTest::Unit::TestCase
5
5
 
6
6
  def test_generate
7
+ skip 'graphs are broken right now'
7
8
  p = Accessibility::Graph.new(app.main_window).generate_png!
8
9
  assert File.exists? p
9
10
  assert_match /^PNG image/, `file --brief #{p}`
@@ -72,14 +72,14 @@ class TestAccessibilityQualifier < MiniTest::Unit::TestCase
72
72
 
73
73
  def test_qualifies_based_on_param_attribute_value
74
74
  e = app.attribute(:main_window).attribute(:title_ui_element)
75
- q = qualifier(:StaticText, [:string_for_range, CFRange.new(0,2)] => 'AX' )
75
+ q = qualifier(:StaticText, [:string_for_range, 0..1] => 'AX' )
76
76
  assert q.qualifies? e
77
77
  refute q.qualifies? list
78
78
  end
79
79
 
80
80
  def test_qualifies_based_on_param_attribute_regexp_match
81
81
  e = app.attribute(:main_window).attribute(:title_ui_element)
82
- q = qualifier(:StaticText, [:string_for_range, CFRange.new(0,2)] => /AX/ )
82
+ q = qualifier(:StaticText, [:string_for_range, 0..1] => /AX/ )
83
83
  assert q.qualifies? e
84
84
  refute q.qualifies? items.sample
85
85
  end
@@ -32,7 +32,7 @@ class TestAXApplication < MiniTest::Unit::TestCase
32
32
  assert app.attribute :focused?
33
33
 
34
34
  ensure
35
- running_app.activateWithOptions NSApplicationActivateIgnoringOtherApps
35
+ running_app.activateWithOptions NSRunningApplication::NSApplicationActivateIgnoringOtherApps
36
36
  end
37
37
 
38
38
  def test_can_hide_and_unhide_app
@@ -49,7 +49,7 @@ class TestAXApplication < MiniTest::Unit::TestCase
49
49
  refute app.hidden?
50
50
 
51
51
  ensure
52
- running_app.activateWithOptions NSApplicationActivateIgnoringOtherApps
52
+ running_app.activateWithOptions NSRunningApplication::NSApplicationActivateIgnoringOtherApps
53
53
  end
54
54
 
55
55
  def test_set_calls_super
@@ -5,13 +5,13 @@ require 'ax/application'
5
5
  class TestAccessibilityElementFactory < MiniTest::Unit::TestCase
6
6
 
7
7
  def window
8
- @@window ||= REF.children.find { |x| x.role == KAXWindowRole }
8
+ @@window ||= REF.to_ruby.children.find { |x| x.role == KAXWindowRole }
9
9
  end
10
10
 
11
11
  def scroll_area
12
12
  @@scroll_area ||= window.children.find { |x|
13
13
  x.attributes.include?(:description) &&
14
- x.attribute(:description) == 'Test Web Area'
14
+ x.description == 'Test Web Area'
15
15
  }
16
16
  end
17
17
 
@@ -43,7 +43,7 @@ class TestAccessibilityPrettyPrinter < MiniTest::Unit::TestCase
43
43
  @attribute = 'roflcopter'
44
44
  assert_match /roflcopter/, pp_identifier
45
45
 
46
- @attribute = NSString.string
46
+ @attribute = ''
47
47
  assert_equal EMPTY_STRING, pp_identifier.to_s
48
48
 
49
49
  @attribute = 26
@@ -66,7 +66,7 @@ class TestAccessibilityPrettyPrinter < MiniTest::Unit::TestCase
66
66
  end
67
67
 
68
68
  def test_position
69
- @attribute = CGPointZero
69
+ @attribute = CGPoint.new
70
70
  assert_match /\(0\.0, 0\.0\)/, pp_position
71
71
 
72
72
  @attribute = CGPoint.new(3.14, -5)
@@ -100,7 +100,7 @@ class TestAXApplication < MiniTest::Unit::TestCase
100
100
  end
101
101
 
102
102
  def test_info_plist
103
- assert_equal 'hmmmmm.icns', app.info_plist['CFBundleIconFile']
103
+ assert_equal 'transmute', app.info_plist['CFBundleIconFile']
104
104
  end
105
105
 
106
106
  def test_version
@@ -51,7 +51,7 @@ class TestAXElement < MiniTest::Unit::TestCase
51
51
  end
52
52
 
53
53
  # the nil case
54
- center_test CGPointZero, CGSizeZero, CGPointZero
54
+ center_test CGPoint.new, CGSize.new, CGPoint.new
55
55
  # simple square with origin at zero
56
56
  center_test [0,0], [2,2], [1,1]
57
57
  # simple square in positive positive quadrant
@@ -71,7 +71,7 @@ class TestSearchResultBlankness < MiniTest::Unit::TestCase
71
71
 
72
72
  def test_array_blank
73
73
  [
74
- NSArray.array,
74
+ Array.new,
75
75
  [true]
76
76
  ].each do |ary|
77
77
  assert_equal ary.empty?, ary.blank?
@@ -1,11 +1,13 @@
1
1
  require 'test/runner'
2
2
 
3
+ if on_macruby?
3
4
  class TestNSObjectExtensions < MiniTest::Unit::TestCase
4
5
  # keeping this test just to make sure the version of MacRuby
5
6
  # being used is new enough
6
7
  def test_inspecting
7
- url = NSURL.URLWithString('http://marketcircle.com/')
8
- assert_equal url.description, url.inspect
8
+ url = NSURL.URLWithString('http://marketcircle.com/')
9
+ assert_equal url.description, url.inspect
9
10
  end
10
11
  end
12
+ end
11
13
 
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: AXElements
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.0.0.alpha11
5
+ version: 1.0.0.beta
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-12-12 00:00:00 Z
12
+ date: 2012-12-27 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mouse
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.3
22
+ version: 1.0.6
23
23
  type: :runtime
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.0.3
29
+ version: 1.0.6
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: screen_recorder
32
32
  prerelease: false
@@ -35,30 +35,46 @@ dependencies:
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: 0.1.4
38
+ version: 0.1.5
39
39
  type: :runtime
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.4
45
+ version: 0.1.5
46
46
  - !ruby/object:Gem::Dependency
47
- name: minitest
47
+ name: accessibility_core
48
48
  prerelease: false
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: "4.3"
55
- type: :development
54
+ version: 0.3.5
55
+ type: :runtime
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.5
62
+ - !ruby/object:Gem::Dependency
63
+ name: activesupport
64
+ prerelease: false
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 3.2.9
71
+ type: :runtime
56
72
  version_requirements: !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
75
  - - ~>
60
76
  - !ruby/object:Gem::Version
61
- version: "4.3"
77
+ version: 3.2.9
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: yard
64
80
  prerelease: false
@@ -104,16 +120,13 @@ extensions:
104
120
  - ext/accessibility/key_coder/extconf.rb
105
121
  extra_rdoc_files: []
106
122
  files:
107
- - lib/accessibility/core.rb
108
123
  - lib/accessibility/dsl.rb
109
124
  - lib/accessibility/enumerators.rb
110
125
  - lib/accessibility/errors.rb
111
126
  - lib/accessibility/factory.rb
112
127
  - lib/accessibility/graph.rb
113
- - lib/accessibility/highlighter.rb
114
128
  - lib/accessibility/pretty_printer.rb
115
129
  - lib/accessibility/qualifier.rb
116
- - lib/accessibility/statistics.rb
117
130
  - lib/accessibility/string.rb
118
131
  - lib/accessibility/system_info.rb
119
132
  - lib/accessibility/translator.rb
@@ -129,19 +142,14 @@ files:
129
142
  - lib/ax/scroll_area.rb
130
143
  - lib/ax/static_text.rb
131
144
  - lib/ax/systemwide.rb
145
+ - lib/ax_elements/active_support_selections.rb
132
146
  - lib/ax_elements/awesome_print.rb
133
- - lib/ax_elements/core_graphics_workaround.rb
134
147
  - lib/ax_elements/exception_workaround.rb
148
+ - lib/ax_elements/mri.rb
135
149
  - lib/ax_elements/nsarray_compat.rb
136
- - lib/ax_elements/vendor/inflection_data.rb
137
- - lib/ax_elements/vendor/inflections.rb
138
- - lib/ax_elements/vendor/inflector.rb
139
150
  - lib/ax_elements.rb
140
151
  - lib/AXElements.rb
141
- - lib/minitest/ax_elements.rb
142
- - lib/rspec/expectations/ax_elements.rb
143
152
  - ext/accessibility/key_coder/extconf.rb
144
- - ext/accessibility/core/core.c
145
153
  - ext/accessibility/key_coder/key_coder.c
146
154
  - rakelib/doc.rake
147
155
  - rakelib/ext.rake
@@ -151,7 +159,6 @@ files:
151
159
  - README.markdown
152
160
  - History.markdown
153
161
  - .yardopts
154
- - test/integration/accessibility/test_core.rb
155
162
  - test/integration/accessibility/test_dsl.rb
156
163
  - test/integration/accessibility/test_enumerators.rb
157
164
  - test/integration/accessibility/test_errors.rb
@@ -162,15 +169,11 @@ files:
162
169
  - test/integration/ax/test_menu.rb
163
170
  - test/integration/ax/test_row.rb
164
171
  - test/integration/ax_elements/test_nsarray_compat.rb
165
- - test/integration/minitest/test_ax_elements.rb
166
- - test/integration/rspec/expectations/test_ax_elements.rb
167
172
  - test/sanity/accessibility/test_dsl.rb
168
173
  - test/sanity/accessibility/test_errors.rb
169
174
  - test/sanity/accessibility/test_factory.rb
170
- - test/sanity/accessibility/test_highlighter.rb
171
175
  - test/sanity/accessibility/test_pretty_printer.rb
172
176
  - test/sanity/accessibility/test_qualifier.rb
173
- - test/sanity/accessibility/test_statistics.rb
174
177
  - test/sanity/accessibility/test_string.rb
175
178
  - test/sanity/accessibility/test_translator.rb
176
179
  - test/sanity/ax/test_application.rb
@@ -178,11 +181,8 @@ files:
178
181
  - test/sanity/ax/test_systemwide.rb
179
182
  - test/sanity/ax_elements/test_nsarray_compat.rb
180
183
  - test/sanity/ax_elements/test_nsobject_inspect.rb
181
- - test/sanity/minitest/test_ax_elements.rb
182
- - test/sanity/rspec/expectations/test_ax_elements.rb
183
184
  - test/sanity/test_accessibility.rb
184
185
  - test/sanity/test_ax_elements.rb
185
- - test/test_core.rb
186
186
  - test/helper.rb
187
187
  homepage: http://github.com/Marketcircle/AXElements
188
188
  licenses:
@@ -210,7 +210,6 @@ signing_key:
210
210
  specification_version: 3
211
211
  summary: A DSL for automating GUI manipulation
212
212
  test_files:
213
- - test/integration/accessibility/test_core.rb
214
213
  - test/integration/accessibility/test_dsl.rb
215
214
  - test/integration/accessibility/test_enumerators.rb
216
215
  - test/integration/accessibility/test_errors.rb
@@ -221,15 +220,11 @@ test_files:
221
220
  - test/integration/ax/test_menu.rb
222
221
  - test/integration/ax/test_row.rb
223
222
  - test/integration/ax_elements/test_nsarray_compat.rb
224
- - test/integration/minitest/test_ax_elements.rb
225
- - test/integration/rspec/expectations/test_ax_elements.rb
226
223
  - test/sanity/accessibility/test_dsl.rb
227
224
  - test/sanity/accessibility/test_errors.rb
228
225
  - test/sanity/accessibility/test_factory.rb
229
- - test/sanity/accessibility/test_highlighter.rb
230
226
  - test/sanity/accessibility/test_pretty_printer.rb
231
227
  - test/sanity/accessibility/test_qualifier.rb
232
- - test/sanity/accessibility/test_statistics.rb
233
228
  - test/sanity/accessibility/test_string.rb
234
229
  - test/sanity/accessibility/test_translator.rb
235
230
  - test/sanity/ax/test_application.rb
@@ -237,9 +232,6 @@ test_files:
237
232
  - test/sanity/ax/test_systemwide.rb
238
233
  - test/sanity/ax_elements/test_nsarray_compat.rb
239
234
  - test/sanity/ax_elements/test_nsobject_inspect.rb
240
- - test/sanity/minitest/test_ax_elements.rb
241
- - test/sanity/rspec/expectations/test_ax_elements.rb
242
235
  - test/sanity/test_accessibility.rb
243
236
  - test/sanity/test_ax_elements.rb
244
- - test/test_core.rb
245
237
  - test/helper.rb