AXElements 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.yardopts +4 -0
  2. data/History.markdown +41 -0
  3. data/README.markdown +59 -62
  4. data/Rakefile +1 -1
  5. data/ext/accessibility/key_coder/extconf.rb +1 -1
  6. data/ext/accessibility/key_coder/key_coder.c +8 -5
  7. data/lib/accessibility/dsl.rb +261 -87
  8. data/lib/accessibility/enumerators.rb +14 -11
  9. data/lib/accessibility/errors.rb +4 -3
  10. data/lib/accessibility/factory.rb +159 -108
  11. data/lib/accessibility/graph.rb +13 -9
  12. data/lib/accessibility/{pp_inspector.rb → pretty_printer.rb} +4 -5
  13. data/lib/accessibility/qualifier.rb +23 -13
  14. data/lib/accessibility/string.rb +4 -4
  15. data/lib/accessibility/system_info.rb +230 -0
  16. data/lib/accessibility/translator.rb +38 -28
  17. data/lib/accessibility/version.rb +24 -2
  18. data/lib/accessibility.rb +25 -8
  19. data/lib/ax/application.rb +207 -77
  20. data/lib/ax/element.rb +62 -65
  21. data/lib/ax/menu.rb +5 -1
  22. data/lib/ax/row.rb +1 -1
  23. data/lib/ax/scroll_area.rb +7 -6
  24. data/lib/ax/systemwide.rb +38 -5
  25. data/lib/ax_elements/active_support_selections.rb +10 -0
  26. data/lib/ax_elements/mri.rb +57 -0
  27. data/lib/ax_elements/nsarray_compat.rb +97 -17
  28. data/lib/ax_elements.rb +9 -1
  29. data/rakelib/gem.rake +11 -11
  30. data/rakelib/test.rake +0 -9
  31. data/test/helper.rb +10 -18
  32. data/test/integration/accessibility/test_dsl.rb +52 -42
  33. data/test/integration/accessibility/test_enumerators.rb +0 -1
  34. data/test/integration/accessibility/test_graph.rb +1 -0
  35. data/test/integration/accessibility/test_qualifier.rb +2 -2
  36. data/test/integration/ax/test_application.rb +9 -2
  37. data/test/integration/ax/test_element.rb +41 -1
  38. data/test/sanity/accessibility/test_factory.rb +23 -56
  39. data/test/sanity/accessibility/{test_pp_inspector.rb → test_pretty_printer.rb} +9 -9
  40. data/test/sanity/accessibility/test_translator.rb +2 -5
  41. data/test/sanity/accessibility/test_version.rb +15 -0
  42. data/test/sanity/ax/test_application.rb +17 -2
  43. data/test/sanity/ax/test_element.rb +2 -2
  44. data/test/sanity/ax_elements/test_nsobject_inspect.rb +4 -2
  45. data/test/sanity/test_ax_elements.rb +1 -0
  46. metadata +69 -39
  47. data/lib/accessibility/core.rb +0 -973
  48. data/lib/accessibility/highlighter.rb +0 -86
  49. data/lib/ax_elements/vendor/inflection_data.rb +0 -66
  50. data/lib/ax_elements/vendor/inflections.rb +0 -172
  51. data/lib/ax_elements/vendor/inflector.rb +0 -306
  52. data/lib/minitest/ax_elements.rb +0 -175
  53. data/lib/mouse.rb +0 -223
  54. data/lib/rspec/expectations/ax_elements.rb +0 -234
  55. data/test/integration/accessibility/test_core.rb +0 -18
  56. data/test/integration/minitest/test_ax_elements.rb +0 -89
  57. data/test/integration/rspec/expectations/test_ax_elements.rb +0 -102
  58. data/test/sanity/accessibility/test_core.rb +0 -561
  59. data/test/sanity/accessibility/test_highlighter.rb +0 -56
  60. data/test/sanity/minitest/test_ax_elements.rb +0 -17
  61. data/test/sanity/rspec/expectations/test_ax_elements.rb +0 -15
  62. data/test/sanity/test_mouse.rb +0 -19
data/.yardopts CHANGED
@@ -8,3 +8,7 @@
8
8
  --hide-void-return
9
9
  lib/**/*.rb
10
10
  ext/**/*{.m,.c}
11
+ -
12
+ History.markdown
13
+ CONTRIBUTING.markdown
14
+
data/History.markdown ADDED
@@ -0,0 +1,41 @@
1
+ # 0.9.0
2
+
3
+ * AXElements can now run on MRI as well as MacRuby
4
+
5
+ * Added `DSL#pinch` to simulate pinch gestures
6
+ * Added `DSL#rotate` to simulate rotation gestures
7
+ * Added `DSL#swipe` to simulate swipe gestures
8
+ * Added `DSL#smart_magnify` to simulate smart magnification (two finger double tap)
9
+ * Added `DSL#horizontal_scroll`
10
+ * Added `DSL#contextual_menu` hack for finding contextual menus (WIP)
11
+ * Added `NSScreen.wakeup` to the `NSScreen` class to wake up sleeping displays
12
+ * Added `Accessibility::SystemInfo` for getting information about the running system
13
+ - Added a `Battery` module for querying information about the battery status
14
+ * Added `DSL#record` to run a screen recording of the given block (actual video!)
15
+ * Added `Application.frontmost_application`
16
+ * Added `Application.menu_bar_owner`
17
+ * Added `Application.finder`
18
+ * Added `Application.dock`
19
+ * Added `SystemWide.focused_application` as override of built in attribute
20
+ * Added `SystemWide.status_items`
21
+ * Added `SystemWide.desktop`
22
+ * Added History.markdown to track notable changes
23
+ * Added CONTRIBUTING.markdown with much less stringent guidelines
24
+
25
+ * Moved MiniTest extensions to their own gem/repository [minitest-ax\_elements](https://github.com/AXElements/minitest-ax_elements)
26
+ * Moved RSpec extensions to their own gem/repository [rspec-ax\_elements](https://github.com/AXElements/rspec-ax_elements)
27
+
28
+ * Ported `mouse.rb` to C and moved code to [mouse](https://github.com/AXElements/mouse)
29
+ * Ported `core.rb` to C and moved code to [accessibility\_core](https://github.com/AXElements/accessibility_core)
30
+ * Ported `screen_recorder.rb` to C and moved code to [screen\_recorder](https://github.com/AXElements/screen_recorder)
31
+
32
+ * Changed `DSL#right_click` to accept a block; block is yielded to between click down and click up events
33
+ * Changed `AX::Element#rect` to `AX::Element#to_rect`
34
+
35
+ * Deprecate `AX::DOCK` constant, use `AX::Application.dock` instead
36
+ * Remove `Accessibility.application_with_bundle_identifier`; use `AX::Application.new` instead
37
+ * Remove `Accessibility.application_with_name; use `AX::Application.new` instead
38
+ * Remove `DSL#subtree_for`; use `Element#inspect_subtree` instead
39
+
40
+ * Fixed fetching parameterized attributes through `Element#method_missing`
41
+ * Fixed `Element#parameterized_attribute` automatically normalizing `Range` parameters
data/README.markdown CHANGED
@@ -12,75 +12,75 @@ computer.
12
12
 
13
13
  ## Demo
14
14
 
15
- Perhaps you want to do something with the finder. This example opens a
16
- new Finder window, finds Activity Monitor, and then opens the application
17
- from a quick look window:
15
+ [Demo Video](http://www.youtube.com/watch?v=G9O5wzb7oTY)
16
+
17
+ The code from the demo video is right here:
18
18
 
19
19
  ```ruby
20
20
  require 'rubygems'
21
21
  require 'ax_elements'
22
22
 
23
+ # Highlight objects that the mouse will move to
24
+ Accessibility.debug = true
25
+
26
+ # Get a reference to the Finder and bring it to the front
23
27
  finder = app_with_bundle_identifier 'com.apple.finder'
24
- set_focus_to finder # bring to the front so you can see it happening
28
+ set_focus_to finder
25
29
 
30
+ # Open a new window
26
31
  type "\\COMMAND+n"
27
- sleep 1 # this is so you can see it happen in "slow motion"
32
+ sleep 1 # pause for "slow motion"
28
33
 
34
+ # Find and click the "Applications" item in the sidebar
29
35
  window = finder.main_window
30
36
  click window.outline.row(static_text: { value: 'Applications' })
31
37
 
38
+ # Find the Utilities folder
32
39
  utilities = window.row(text_field: { filename: 'Utilities' })
33
40
  scroll_to utilities
34
41
  double_click utilities
35
42
 
36
- activity_monitor = window.text_field( filename: /Activity Monitor/ )
37
- scroll_to activity_monitor
38
- click activity_monitor
39
- type " " # type a space, which should bring up quick look
40
- sleep 1
41
-
42
- click finder.quick_look.button(id: 'QLControlOpen')
43
- ```
43
+ # Wait for the folder to open and find the Activity Monitor app
44
+ app = wait_for :text_field, ancestor: window, filename: /Activity Monitor/
45
+ scroll_to app
46
+ click app
44
47
 
45
- A simpler example would be changing the system volume by moving the
46
- slider in the menu bar (unless you've hidden it):
48
+ # Bring up QuickLook
49
+ type " "
50
+ sleep 1 # pause for "slow motion"
47
51
 
48
- ```ruby
49
- require 'rubygems'
50
- require 'ax_elements'
52
+ # Click the Quick Look button that opens the app
53
+ click finder.quick_look.button(id: 'QLControlOpen')
54
+ sleep 1 # pause for "slow motion"
51
55
 
52
- ui = app_with_bundle_id 'com.apple.systemuiserver'
53
- volume = ui.menu_extra(description: 'system sound volume')
56
+ # Get a reference to activity monitor and close the app
57
+ activity_monitor = app_with_bundle_identifier 'com.apple.ActivityMonitor'
58
+ terminate activity_monitor
54
59
 
55
- click volume
56
- 15.times { decrement volume.slider }
57
- 15.times { increment volume.slider }
60
+ # Close the Finder window
61
+ select_menu_item finder, 'File', 'Close Window'
58
62
  ```
59
63
 
60
64
 
61
65
  ## Getting Setup
62
66
 
63
- You need to have the OS X command line tools installed in order to
64
- build and install AXElements, but you will also need Xcode in order to
65
- run the test suite (sorry). Go ahead and install the tools now if you
66
- haven't done that yet, I'll wait. Once you have the developer tools,
67
- you should install [MacRuby](http://macruby.org/), version 0.12 or
68
- later is required and downloads can be found at
69
- https://github.com/MacRuby/MacRuby/downloads.
70
- If you are on Snow Leopard, you will also need to install the
71
- [Bridge Support Preview](http://www.macruby.org/blog/2010/10/08/bridgesupport-preview.html).
67
+ You will need Ruby 1.9.3 or a MacRuby nightly build for
68
+ installation. You can get help installing Ruby 1.9.3 from the
69
+ [Ruby Website](http://www.ruby-lang.org), or help installing MacRuby
70
+ from the
71
+ [Setup MacRuby](https://github.com/MacRuby/MacRuby/wiki/Setting-up-MacRuby)
72
+ guide on Github.
72
73
 
73
- Then you can install AXElements. You can install AXElements via
74
- rubygems:
74
+ You will also need to make sure you "enable access for assistive devices".
75
+ This can be done in System Preferences in the Universal Access section:
75
76
 
76
- ```bash
77
- gem install AXElements
78
- ```
77
+ ![Universal Access](http://ferrous26.com/images/enable_accessibility.png)
79
78
 
80
- And then you can try things out in IRb:
79
+ Then you can install AXElements either from RubyGems or from source. The
80
+ RubyGems install is as usual, but you may need `sudo` power:
81
81
 
82
82
  ```bash
83
- irb -rubygems -rax_elements
83
+ gem install AXElements --pre
84
84
  ```
85
85
 
86
86
  Or you can install from source:
@@ -91,19 +91,17 @@ Or you can install from source:
91
91
  cd AXElements && rake install
92
92
  ```
93
93
 
94
- And then try things out in the developer console. AXElements has no
95
- gem dependencies, so from the AXElements source directory you can just
96
- run the `console` task:
94
+ Once all the setup is finished, you can start up AXElements in IRB:
97
95
 
98
96
  ```bash
99
- rake console
97
+ irb -rubygems -rax_elements
100
98
  ```
101
99
 
102
- __NOTE__: If you are not using RVM, then you should use `macrake`
103
- instead of `rake`, and `macirb` instead of `irb`, etc.. You may also
104
- need to add `sudo` to your command when you install the gem. If you
105
- are not using RVM with MacRuby, but have RVM installed, remember to
106
- disable it like so:
100
+ __NOTE__: If you are not using RVM, but are using MacRuby, then you
101
+ should use `macrake` instead of `rake`, and `macirb` instead of `irb`,
102
+ etc.. You may also need to add `sudo` to your command when you install
103
+ the gem. If you are not using RVM with MacRuby, but have RVM
104
+ installed, remember to disable it like so:
107
105
 
108
106
  ```bash
109
107
  rvm use system
@@ -114,20 +112,22 @@ disable it like so:
114
112
 
115
113
  The [wiki](http://github.com/Marketcircle/AXElements/wiki)
116
114
  is the best place to get started, it includes tutorials to help you get
117
- started as well the API documentation (API docs are broken right now due
118
- to incompatabilities between MacRuby and YARD).
115
+ started. API documentation is also available on
116
+ [rdoc.info](http://rdoc.info/gems/AXElements/frames).
119
117
 
120
118
  Though it is not required, you may want to read Apple's
121
119
  [Accessibility Overview](http://developer.apple.com/library/mac/#documentation/Accessibility/Conceptual/AccessibilityMacOSX/OSXAXModel/OSXAXmodel.html)
122
120
  as a primer on some the rationale for the accessibility APIs as well
123
- as the technical underpinnings of AXElements.
121
+ as some of the technical the technical underpinnings of AXElements.
124
122
 
125
123
 
126
124
  ## Development
127
125
 
128
- AXElements has reached a point where the main focus is now performance,
129
- features, and documentation. It will be magical, so we're code naming
130
- the next version "Clefable".
126
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Marketcircle/AXElements)
127
+
128
+ AXElements has reached a point where the main focus is stability,
129
+ documentation, and additional conveniences. It will be out of this
130
+ world, so we're code naming the next version "Lunatone".
131
131
 
132
132
  ![The Moon](https://github.com/Marketcircle/AXElements/raw/gh-pages/images/next_version.png)
133
133
 
@@ -155,6 +155,9 @@ you simply need to run the `test` task:
155
155
  rake test
156
156
  ```
157
157
 
158
+ If there is a test that crashes MacRuby then you will need to run tests
159
+ in verbose mode.
160
+
158
161
  __NOTE__: There may be some tests are dependent on Accessibility
159
162
  features that are new in OS X Lion which will cause test failures on
160
163
  OS X Snow Leopard. If you have any issues then you should look at the
@@ -176,18 +179,12 @@ disabled by default. In order to enable them you need to set the
176
179
 
177
180
  ## Contributing to AXElements
178
181
 
179
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
180
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
181
- * Fork the project
182
- * Start a feature/bugfix branch
183
- * Commit and push until you are happy with your contribution
184
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
185
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
182
+ See {file:CONTRIBUTING.markdown}
186
183
 
187
184
 
188
185
  ## Copyright
189
186
 
190
- Copyright (c) 2010-2012, Marketcircle Inc.
187
+ Copyright (c) 2010-2013, Marketcircle Inc.
191
188
  All rights reserved.
192
189
 
193
190
  Redistribution and use in source and binary forms, with or without
data/Rakefile CHANGED
@@ -11,4 +11,4 @@ desc 'Compile C extensions'
11
11
  task :ext => 'ext:key_coder'
12
12
 
13
13
  desc 'Run all tests'
14
- task :test => ['test:sanity', 'test:integration', 'test:cruby']
14
+ task :test => ['test:sanity', 'test:integration']
@@ -10,7 +10,7 @@ else
10
10
  clang = `which clang`.chomp
11
11
  if clang.empty?
12
12
  $stdout.puts "Clang not installed. Cannot build C extension"
13
- exit 1
13
+ raise "Clang not installed. Cannot build C extension"
14
14
  else
15
15
  RbConfig::MAKEFILE_CONFIG["CC"] = clang
16
16
  RbConfig::MAKEFILE_CONFIG["CXX"] = clang
@@ -3,7 +3,7 @@
3
3
  * KeyCoder
4
4
  *
5
5
  * Created by Mark Rada on 11-07-27.
6
- * Copyright 2011 Marketcircle Incorporated. All rights reserved.
6
+ * Copyright 2011-2012 Marketcircle Incorporated. All rights reserved.
7
7
  */
8
8
 
9
9
 
@@ -26,7 +26,8 @@
26
26
  * @return [Hash{String=>Number}]
27
27
  */
28
28
 
29
- static VALUE
29
+ static
30
+ VALUE
30
31
  keycoder_dynamic_mapping()
31
32
  {
32
33
 
@@ -45,7 +46,8 @@ keycoder_dynamic_mapping()
45
46
  UniCharCount string_length = 0;
46
47
  UInt32 dead_key_state = 0;
47
48
  UCKeyTranslate(
48
- layout,key_code,
49
+ layout,
50
+ key_code,
49
51
  kUCKeyActionDown,
50
52
  0,
51
53
  LMGetKbdType(), // kb type
@@ -90,7 +92,8 @@ keycoder_dynamic_mapping()
90
92
  * @return [true]
91
93
  */
92
94
 
93
- static VALUE
95
+ static
96
+ VALUE
94
97
  keycoder_post_event(VALUE self, VALUE event)
95
98
  {
96
99
  VALUE code = rb_ary_entry(event, 0);
@@ -99,7 +102,7 @@ keycoder_post_event(VALUE self, VALUE event)
99
102
  CGEventRef event_ref = CGEventCreateKeyboardEvent(NULL, FIX2LONG(code), state);
100
103
  CGEventPost(kCGHIDEventTap, event_ref);
101
104
 
102
- usleep(9000);
105
+ usleep(9000); // 9000 is a magic number
103
106
  return Qtrue;
104
107
  }
105
108