@@ -4,19 +4,49 @@ module Appium
44 module Device
55 extend Forwardable
66
7- # @private
8- NoArgPostMethods = {
9- shake : 'session/:session_id/appium/device/shake' ,
10- launch : 'session/:session_id/appium/app/launch' ,
11- closeApp : 'session/:session_id/appium/app/close' ,
7+ NoArgMethods = {
8+ post : {
9+ shake : 'session/:session_id/appium/device/shake' ,
10+ launch : 'session/:session_id/appium/app/launch' ,
11+ closeApp : 'session/:session_id/appium/app/close' ,
12+ reset : 'session/:session_id/appium/app/reset'
13+ } ,
14+ get : {
15+ current_activity : 'session/:session_id/appium/device/current_activity' ,
16+ current_context : 'session/:session_id/context' ,
17+ app_strings : 'session/:session_id/appium/app/strings' ,
18+ available_contexts : 'session/:session_id/contexts' ,
19+ }
1220 }
1321
22+ # @!method app_strings
23+ # Return the hash of all localization strings.
24+ # ```ruby
25+ # app_strings #=> "TransitionsTitle"=>"Transitions", "WebTitle"=>"Web"
26+ # ```
27+
28+ # @!method background_app
29+ # Backgrounds the app for a set number of seconds.
30+ # This is a blocking application
31+ # @param seconds (int) How many seconds to background the app for.
32+
33+ # @!method current_activity
34+
35+ # @!method launch
36+ # Start the simulator and applicaton configured with desired capabilities
37+
38+ # @!method reset
39+ # Reset the device, relaunching the application.
40+
41+ # @!method shake
42+ # Cause the device to shake
43+
1444 class << self
1545 def extended ( mod )
1646 extend_webdriver_with_forwardable
1747
18- NoArgPostMethods . each_pair do |m , p |
19- add_endpoint_method m , p
48+ NoArgMethods . each_pair do |verb , pair |
49+ pair . each_pair { | command , path | add_endpoint_method command , path , verb }
2050 end
2151
2252 add_endpoint_method ( :lock , 'session/:session_id/appium/device/lock' ) do
@@ -37,9 +67,17 @@ def remove(id)
3767 end
3868 end
3969
40- add_endpoint_method ( :available_contexts , 'session/:session_id/contexts' , :get )
70+ add_endpoint_method ( :is_installed? , 'session/:session_id?/appium/device/app_installed' ) do
71+ def is_installed? ( app_id )
72+ execute :is_installed? , { } , :bundleId => app_id
73+ end
74+ end
4175
42- add_endpoint_method ( :current_context , 'session/:session_id/context' , :get )
76+ add_endpoint_method ( :background_app , 'session/:session_id/appium/app/background' ) do
77+ def background_app ( duration )
78+ execute :background_app , { } , :seconds => duration
79+ end
80+ end
4381
4482 add_endpoint_method ( :current_context= , 'session/:session_id/context' ) do
4583 def current_context = ( context = null )
0 commit comments