lib/calabash/interactions.rb in calabash-2.0.0.pre10 vs lib/calabash/interactions.rb in calabash-2.0.0.pre11

- old
+ new

@@ -60,54 +60,22 @@ # @param args Optional var-args list describing a chain of method # names (selectors). # # @return [Calabash::QueryResult] A result of the query def query(query, *args) - Calabash::Device.default.map_route(Query.new(query), :query, *args) + Calabash::Internal.with_default_device {|device| device.map_route(Query.new(query), :query, *args)} end # Flashes any views matching `query`. Only one view is flashed at a time, # in the order they are returned. # # @param [String, Hash, Calabash::Query] query The query to match the # view(s) def flash(query) - Calabash::Device.default.map_route(Query.new(query), :flash) + Calabash::Internal.with_default_device {|device| device.map_route(Query.new(query), :flash)} end - # Evaluate javascript in a Web View. On iOS, an implicit return is - # inserted, on Android an explicit return is needed. - # - # @example - # # iOS - # evaluate_javascript_in("UIWebView", "2+2") - # # Android - # evaluate_javascript_in("WebView", "return 2+2") - # - # @example - # # iOS - # evaluate_javascript_in("WKWebView", - # "document.body.style.backgroundColor = 'red';") - # - # # Android - # evaluate_javascript_in("XWalkContent", - # "document.body.style.backgroundColor = 'red';") - # - # @note No error will be raised if the javascript given is invalid, or - # throws an exception. - # - # @param [String, Hash, Calabash::Query] query Query that matches the view - # @param [String] javascript The javascript to evaluate - # - # @raise ViewNotFoundError If no views are found matching `query` - def evaluate_javascript_in(query, javascript) - wait_for_view(query, - timeout: Calabash::Gestures::DEFAULT_GESTURE_WAIT_TIMEOUT) - - _evaluate_javascript_in(query, javascript) - end - # Invoke a method in your application. # # This is an escape hatch for calling an arbitrary hook inside # (the test build) of your app. Commonly used to "go around" the UI for # speed purposes or reset the app to a good known state. @@ -156,14 +124,9 @@ # @param [Object] arguments A comma separated list of arguments to be # passed to the backdoor selector/method. # @return [Object] the result of performing the selector/method with the # arguments (serialized) def backdoor(name, *arguments) - Device.default.backdoor(name, *arguments) - end - - # @!visibility private - def _evaluate_javascript_in(query, javascript) - abstract_method! + Calabash::Internal.with_default_device {|device| device.backdoor(name, *arguments)} end end end