Permalink
Browse files

Unroll Element#call_app private calls

  • Loading branch information...
1 parent 00368cd commit 774efb88996265ed325458a1932c3b8a5be308c2 @ferrous26 ferrous26 committed Feb 28, 2012
Showing with 17 additions and 18 deletions.
  1. +16 −18 lib/ax/application.rb
  2. +1 −0 test/unit/ax/test_application.rb
View
@@ -60,6 +60,13 @@ def hidden?
end
##
+ # Ask the app whether or not it is still running.
+ def terminated?
+ spin_run_loop
+ @app.terminated?
+ end
+
+ ##
# Overridden to handle the {Accessibility::Language#set_focus} case.
#
# (see AX::Element#set:to:)
@@ -85,9 +92,15 @@ def set attr, to: value
# @return [Boolean]
def perform name
case name
- when :terminate then call_app(:terminated?, name)
- when :hide then call_app(:hidden?, name)
- when :unhide then call_app(:active?, :activateWithOptions, NSApplicationActivateIgnoringOtherApps)
+ when :terminate
+ @app.terminate
+ sleep 0.2 and terminated?
+ when :hide
+ @app.hide
+ sleep 0.2 and hidden?
+ when :unhide
+ @app.activateWithOptions NSApplicationActivateIgnoringOtherApps
+ sleep 0.2 and active?
else
super
end
@@ -149,19 +162,4 @@ def bundle_identifier
@app.bundleIdentifier
end
-
- private
-
- ##
- # Call to the underlying `NSRunningApplication` object and wait an
- # arbitrary amount of time for the action to complete.
- #
- # @param [#to_s]
- def call_app test, *send_args
- @app.send *send_args
- sleep 0.2
- spin_run_loop
- @app.send test
- end
-
end
@@ -62,6 +62,7 @@ def test_inspect_includes_focused
def test_terminate_kills_app
skip 'Not sure how to reset state after this test...'
assert AX::DOCK.terminate
+ assert AX::DOCK.terminated?
end
def test_overrides_call_super

0 comments on commit 774efb8

Please sign in to comment.