AXElements 1.0.0.alpha5 → 1.0.0.alpha6
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.
- data/lib/accessibility/core.rb +3 -1
 - data/lib/accessibility/dsl.rb +1 -1
 - data/lib/accessibility/version.rb +1 -1
 - data/lib/ax/application.rb +39 -0
 - data/lib/ax/element.rb +1 -1
 - data/lib/mouse.rb +6 -0
 - data/test/integration/accessibility/test_dsl.rb +1 -5
 - data/test/integration/ax/test_application.rb +7 -0
 - data/test/sanity/ax/test_application.rb +11 -0
 - metadata +1 -1
 
    
        data/lib/accessibility/core.rb
    CHANGED
    
    | 
         @@ -159,7 +159,9 @@ module Accessibility::Element 
     | 
|
| 
       159 
159 
     | 
    
         
             
              # @return [Array<AXUIElementRef>]
         
     | 
| 
       160 
160 
     | 
    
         
             
              def children
         
     | 
| 
       161 
161 
     | 
    
         
             
                STATS.increment :Children
         
     | 
| 
       162 
     | 
    
         
            -
                 
     | 
| 
      
 162 
     | 
    
         
            +
                ptr  = Pointer.new :id
         
     | 
| 
      
 163 
     | 
    
         
            +
                code = AXUIElementCopyAttributeValue(self, KAXChildrenAttribute, ptr)
         
     | 
| 
      
 164 
     | 
    
         
            +
                code.zero? ? ptr.value.to_ruby : []
         
     | 
| 
       163 
165 
     | 
    
         
             
              end
         
     | 
| 
       164 
166 
     | 
    
         | 
| 
       165 
167 
     | 
    
         
             
              ##
         
     | 
    
        data/lib/accessibility/dsl.rb
    CHANGED
    
    | 
         @@ -738,7 +738,7 @@ module Accessibility::DSL 
     | 
|
| 
       738 
738 
     | 
    
         
             
              # @param id [String]
         
     | 
| 
       739 
739 
     | 
    
         
             
              # @return [AX::Application,nil]
         
     | 
| 
       740 
740 
     | 
    
         
             
              def app_with_bundle_identifier id
         
     | 
| 
       741 
     | 
    
         
            -
                 
     | 
| 
      
 741 
     | 
    
         
            +
                AX::Application.new id
         
     | 
| 
       742 
742 
     | 
    
         
             
              end
         
     | 
| 
       743 
743 
     | 
    
         
             
              alias_method :app_with_bundle_id, :app_with_bundle_identifier
         
     | 
| 
       744 
744 
     | 
    
         
             
              alias_method :launch,             :app_with_bundle_identifier
         
     | 
    
        data/lib/ax/application.rb
    CHANGED
    
    | 
         @@ -198,6 +198,45 @@ class AX::Application < AX::Element 
     | 
|
| 
       198 
198 
     | 
    
         | 
| 
       199 
199 
     | 
    
         
             
              # @group Actions
         
     | 
| 
       200 
200 
     | 
    
         | 
| 
      
 201 
     | 
    
         
            +
              ##
         
     | 
| 
      
 202 
     | 
    
         
            +
              # @note This is often async and may return before the action is completed
         
     | 
| 
      
 203 
     | 
    
         
            +
              #
         
     | 
| 
      
 204 
     | 
    
         
            +
              # Ask the app to quit
         
     | 
| 
      
 205 
     | 
    
         
            +
              #
         
     | 
| 
      
 206 
     | 
    
         
            +
              # @return [Boolean]
         
     | 
| 
      
 207 
     | 
    
         
            +
              def terminate
         
     | 
| 
      
 208 
     | 
    
         
            +
                perform :terminate
         
     | 
| 
      
 209 
     | 
    
         
            +
              end
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
              ##
         
     | 
| 
      
 212 
     | 
    
         
            +
              # @note This is often async and may return before the action is completed
         
     | 
| 
      
 213 
     | 
    
         
            +
              #
         
     | 
| 
      
 214 
     | 
    
         
            +
              # Force the app to quit
         
     | 
| 
      
 215 
     | 
    
         
            +
              #
         
     | 
| 
      
 216 
     | 
    
         
            +
              # @return [Boolean]
         
     | 
| 
      
 217 
     | 
    
         
            +
              def terminate!
         
     | 
| 
      
 218 
     | 
    
         
            +
                perform :force_terminate
         
     | 
| 
      
 219 
     | 
    
         
            +
              end
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
              ##
         
     | 
| 
      
 222 
     | 
    
         
            +
              # @note This is often async and may return before the action is completed
         
     | 
| 
      
 223 
     | 
    
         
            +
              #
         
     | 
| 
      
 224 
     | 
    
         
            +
              # Ask the app to hide itself
         
     | 
| 
      
 225 
     | 
    
         
            +
              #
         
     | 
| 
      
 226 
     | 
    
         
            +
              # @return [Boolean]
         
     | 
| 
      
 227 
     | 
    
         
            +
              def hide
         
     | 
| 
      
 228 
     | 
    
         
            +
                perform :hide
         
     | 
| 
      
 229 
     | 
    
         
            +
              end
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
              ##
         
     | 
| 
      
 232 
     | 
    
         
            +
              # @note This is often async and may return before the action is completed
         
     | 
| 
      
 233 
     | 
    
         
            +
              #
         
     | 
| 
      
 234 
     | 
    
         
            +
              # As the app to unhide itself and bring to front
         
     | 
| 
      
 235 
     | 
    
         
            +
              #
         
     | 
| 
      
 236 
     | 
    
         
            +
              # @return [Boolean]
         
     | 
| 
      
 237 
     | 
    
         
            +
              def unhide
         
     | 
| 
      
 238 
     | 
    
         
            +
                perform :unhide
         
     | 
| 
      
 239 
     | 
    
         
            +
              end
         
     | 
| 
       201 
240 
     | 
    
         | 
| 
       202 
241 
     | 
    
         
             
              # (see AX::Element#perform)
         
     | 
| 
       203 
242 
     | 
    
         
             
              def perform name
         
     | 
    
        data/lib/ax/element.rb
    CHANGED
    
    
    
        data/lib/mouse.rb
    CHANGED
    
    | 
         @@ -172,6 +172,9 @@ module Mouse 
     | 
|
| 
       172 
172 
     | 
    
         
             
              #
         
     | 
| 
       173 
173 
     | 
    
         
             
              # @param point [CGPoint]
         
     | 
| 
       174 
174 
     | 
    
         
             
              def double_click point = current_position
         
     | 
| 
      
 175 
     | 
    
         
            +
                # some apps still expect to receive the single click event first
         
     | 
| 
      
 176 
     | 
    
         
            +
                # and then the double click event
         
     | 
| 
      
 177 
     | 
    
         
            +
                multi_click 1, point
         
     | 
| 
       175 
178 
     | 
    
         
             
                multi_click 2, point
         
     | 
| 
       176 
179 
     | 
    
         
             
              end
         
     | 
| 
       177 
180 
     | 
    
         | 
| 
         @@ -182,6 +185,9 @@ module Mouse 
     | 
|
| 
       182 
185 
     | 
    
         
             
              #
         
     | 
| 
       183 
186 
     | 
    
         
             
              # @param point [CGPoint]
         
     | 
| 
       184 
187 
     | 
    
         
             
              def triple_click point = current_position
         
     | 
| 
      
 188 
     | 
    
         
            +
                # some apps still expect to receive the single click event first
         
     | 
| 
      
 189 
     | 
    
         
            +
                # and then the double and triple click events
         
     | 
| 
      
 190 
     | 
    
         
            +
                double_click
         
     | 
| 
       185 
191 
     | 
    
         
             
                multi_click 3, point
         
     | 
| 
       186 
192 
     | 
    
         
             
              end
         
     | 
| 
       187 
193 
     | 
    
         | 
| 
         @@ -199,13 +199,9 @@ class TestAccessibilityDSL < MiniTest::Unit::TestCase 
     | 
|
| 
       199 
199 
     | 
    
         
             
                app.main_window.set :position, orig_window_position if orig_window_position
         
     | 
| 
       200 
200 
     | 
    
         
             
              end
         
     | 
| 
       201 
201 
     | 
    
         | 
| 
       202 
     | 
    
         
            -
              def dummy_text
         
     | 
| 
       203 
     | 
    
         
            -
                'Lorem ipsum dolor. Sit amet orci feugiat facilisis quis neque con quisque vestibulum condimentum nec velit laoreet eget. Dolor felis quis. Nulla mi urna ligula porta blandit tenetur et velit habitant rerum numquam. Erat ut eget.'
         
     | 
| 
       204 
     | 
    
         
            -
              end
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
202 
     | 
    
         
             
              def test_triple_click
         
     | 
| 
      
 203 
     | 
    
         
            +
                dummy_text = 'Lorem ipsum dolor.' * 15
         
     | 
| 
       207 
204 
     | 
    
         
             
                text_area.set :value, dummy_text
         
     | 
| 
       208 
     | 
    
         
            -
                dsl.click text_area
         
     | 
| 
       209 
205 
     | 
    
         
             
                dsl.triple_click text_area
         
     | 
| 
       210 
206 
     | 
    
         
             
                assert_equal dummy_text, text_area.selected_text
         
     | 
| 
       211 
207 
     | 
    
         
             
              ensure
         
     | 
| 
         @@ -13,6 +13,13 @@ class TestAXApplication < MiniTest::Unit::TestCase 
     | 
|
| 
       13 
13 
     | 
    
         
             
                assert_equal app, AX::Application.new(running_app)
         
     | 
| 
       14 
14 
     | 
    
         
             
              end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
      
 16 
     | 
    
         
            +
              def test_initialize_causing_app_to_launch
         
     | 
| 
      
 17 
     | 
    
         
            +
                app = AX::Application.new('com.apple.Grab')
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_kind_of AX::Application, app
         
     | 
| 
      
 19 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 20 
     | 
    
         
            +
                app.terminate if app
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       16 
23 
     | 
    
         
             
              def test_can_set_focus_and_blur_app # lol, blur
         
     | 
| 
       17 
24 
     | 
    
         
             
                assert app.set :focused, false
         
     | 
| 
       18 
25 
     | 
    
         
             
                refute app.active?
         
     | 
| 
         @@ -24,6 +24,17 @@ class TestAXApplication < MiniTest::Unit::TestCase 
     | 
|
| 
       24 
24 
     | 
    
         
             
                assert_match /\sfocused\[(?:✔|✘)\]/, app.inspect
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
      
 27 
     | 
    
         
            +
              def tset_action_methods_forward_to_perform
         
     | 
| 
      
 28 
     | 
    
         
            +
                def app.perform name
         
     | 
| 
      
 29 
     | 
    
         
            +
                  [:cracker_jacks, name]
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                assert_equal [:cracker_jacks, :terminate], app.terminate
         
     | 
| 
      
 33 
     | 
    
         
            +
                assert_equal [:cracker_jacks, :force_terminate], app.terminate!
         
     | 
| 
      
 34 
     | 
    
         
            +
                assert_equal [:cracker_jacks, :hide], app.hide
         
     | 
| 
      
 35 
     | 
    
         
            +
                assert_equal [:cracker_jacks, :unhide], app.unhide
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
       27 
38 
     | 
    
         
             
              def test_terminate
         
     | 
| 
       28 
39 
     | 
    
         
             
                got_called = false
         
     | 
| 
       29 
40 
     | 
    
         
             
                mock       = Object.new
         
     |