@@ -4,19 +4,49 @@ module Appium
4
4
module Device
5
5
extend Forwardable
6
6
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
+ }
12
20
}
13
21
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
+
14
44
class << self
15
45
def extended ( mod )
16
46
extend_webdriver_with_forwardable
17
47
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 }
20
50
end
21
51
22
52
add_endpoint_method ( :lock , 'session/:session_id/appium/device/lock' ) do
@@ -37,9 +67,17 @@ def remove(id)
37
67
end
38
68
end
39
69
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
41
75
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
43
81
44
82
add_endpoint_method ( :current_context= , 'session/:session_id/context' ) do
45
83
def current_context = ( context = null )
0 commit comments