appium_lib_core 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -2
  3. data/CHANGELOG.md +16 -0
  4. data/lib/appium_lib_core/android/device.rb +301 -406
  5. data/lib/appium_lib_core/android/device/clipboard.rb +42 -0
  6. data/lib/appium_lib_core/android/device/emulator.rb +149 -147
  7. data/lib/appium_lib_core/android/device/network.rb +47 -0
  8. data/lib/appium_lib_core/android/device/performance.rb +24 -0
  9. data/lib/appium_lib_core/android/device/screen.rb +39 -0
  10. data/lib/appium_lib_core/android/espresso/bridge.rb +1 -1
  11. data/lib/appium_lib_core/android/uiautomator1/bridge.rb +1 -1
  12. data/lib/appium_lib_core/android/uiautomator2/bridge.rb +1 -1
  13. data/lib/appium_lib_core/android/uiautomator2/device.rb +3 -14
  14. data/lib/appium_lib_core/android/uiautomator2/device/battery.rb +28 -0
  15. data/lib/appium_lib_core/common/base/http_default.rb +5 -1
  16. data/lib/appium_lib_core/device.rb +50 -370
  17. data/lib/appium_lib_core/device/app_management.rb +113 -0
  18. data/lib/appium_lib_core/device/app_state.rb +18 -1
  19. data/lib/appium_lib_core/device/context.rb +48 -0
  20. data/lib/appium_lib_core/device/device_lock.rb +28 -0
  21. data/lib/appium_lib_core/device/file_management.rb +32 -0
  22. data/lib/appium_lib_core/device/image_comparison.rb +1 -3
  23. data/lib/appium_lib_core/device/ime_actions.rb +43 -0
  24. data/lib/appium_lib_core/device/keyboard.rb +26 -0
  25. data/lib/appium_lib_core/device/keyevent.rb +44 -0
  26. data/lib/appium_lib_core/device/screen_record.rb +21 -0
  27. data/lib/appium_lib_core/device/setting.rb +21 -0
  28. data/lib/appium_lib_core/device/touch_actions.rb +22 -0
  29. data/lib/appium_lib_core/device/value.rb +23 -0
  30. data/lib/appium_lib_core/driver.rb +8 -0
  31. data/lib/appium_lib_core/ios/device.rb +70 -101
  32. data/lib/appium_lib_core/ios/device/clipboard.rb +41 -0
  33. data/lib/appium_lib_core/ios/uiautomation/bridge.rb +1 -1
  34. data/lib/appium_lib_core/ios/xcuitest/bridge.rb +2 -2
  35. data/lib/appium_lib_core/ios/xcuitest/device.rb +166 -227
  36. data/lib/appium_lib_core/ios/xcuitest/device/battery.rb +28 -0
  37. data/lib/appium_lib_core/ios/xcuitest/device/performance.rb +40 -0
  38. data/lib/appium_lib_core/ios/xcuitest/device/screen.rb +30 -0
  39. data/lib/appium_lib_core/version.rb +2 -2
  40. data/release_notes.md +12 -0
  41. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 703373935a027f386911efb13088fbcc09e655a2
4
- data.tar.gz: 0aa3d1af1e2fe7f5ef1c81d05564698b744b5c8e
3
+ metadata.gz: ae3ab4209d2a044887cda376b71c5a61a5e525d7
4
+ data.tar.gz: 16dacc763beec91077e7fdc76806c6d775002966
5
5
  SHA512:
6
- metadata.gz: eba28378ec06ae4dd9475478aedb90d8eed232fe5d5c2b4f0e5b285dc1709ae5febab7e878bd0d0fb33c40c8f282a805fddc8b8936a9f10c4732f3cf44afadd4
7
- data.tar.gz: da507de703f77f94d00a3182476ca7fca9933a1f6481dc3c1498ec93121c3e03584763e3d00f440e150c6cddfc70aeb4986a552bdfa08cd5b85aa4be041521af
6
+ metadata.gz: 74c62e4e29d2c3b6428a8f6891f209f780b73b2d5cd491e85bb74dd057de9a786f38933ff81c57a44a81bc02f6f7e76a8e127af2ef59990d793babdbef903d3b
7
+ data.tar.gz: 819194531cf4631149199061461ddf41f7be0eec4dba95cc7573f2ad75de6791c5d490c8e08226e9df3ee6e23e9663e0d8913e9012c9fe831513ef50673ff92a
@@ -11,9 +11,9 @@ Metrics/ClassLength:
11
11
  Metrics/AbcSize:
12
12
  Enabled: false
13
13
  Metrics/CyclomaticComplexity:
14
- Max: 9
14
+ Max: 10
15
15
  Metrics/PerceivedComplexity:
16
- Max: 9
16
+ Max: 10
17
17
  Style/Documentation:
18
18
  Enabled: false
19
19
  Style/CommentedKeyword:
@@ -8,6 +8,22 @@ All notable changes to this project will be documented in this file.
8
8
 
9
9
  ### Deprecations
10
10
 
11
+ ## [1.7.0] - 2018-05-28
12
+ ### Enhancements
13
+ - Has one **Breaking Change**
14
+ - Add `flags` in `press_keycode` and `long_press_keycode`
15
+ - New: `@driver.press_keycode 66, metastate: [1], flags: [0x20, 0x2000]`
16
+ - `metastate` should set as a keyword argument
17
+ - `long_press_keycode` as well
18
+ - Before: `@driver.press_keycode 66, 1` (Can set only metastate)
19
+ - How to change: add `metastate:` for the metastate argument
20
+ - [Internal] Change directory and file structure
21
+ - [Internal] Set default content-type
22
+
23
+ ### Bug fixes
24
+
25
+ ### Deprecations
26
+
11
27
  ## [1.6.0] - 2018-05-08
12
28
  ### Enhancements
13
29
  - **Breaking Change**
@@ -1,432 +1,327 @@
1
1
  require_relative 'device/emulator'
2
- require 'base64'
2
+ require_relative 'device/clipboard'
3
+ require_relative 'device/network'
4
+ require_relative 'device/performance'
5
+ require_relative 'device/screen'
3
6
 
4
7
  module Appium
5
- module Android
6
- module Device
7
- extend Forwardable
8
-
9
- # rubocop:disable Metrics/LineLength
10
-
11
- # @!method open_notifications
12
- # Open Android notifications
13
- #
14
- # @example
15
- #
16
- # @driver.open_notifications
17
- #
18
-
19
- # @!method current_activity
20
- # Get current activity name
21
- # @return [String] An activity name
22
- #
23
- # @example
24
- #
25
- # @driver.current_activity # '.ApiDemos'
26
- #
27
-
28
- # @!method current_package
29
- # Get current package name
30
- # @return [String] A package name
31
- #
32
- # @example
33
- #
34
- # @driver.current_package # 'com.example.android.apis'
35
- #
36
-
37
- # @!method get_system_bars
38
- # Get system bar's information
39
- # @return [String]
40
- #
41
- # @example
42
- #
43
- # @driver.get_system_bars
44
- #
45
-
46
- # @!method get_display_density
47
- # Get connected device's density.
48
- # @return [Integer] The size of density
49
- #
50
- # @example
51
- #
52
- # @driver.get_display_density # 320
53
- #
54
-
55
- # @!method get_network_connection
56
- # Get the device network connection current status
57
- # See set_network_connection method for return value
58
- #
59
- # @example
60
- #
61
- # @driver.network_connection_type #=> 6
62
- # @driver.get_network_connection #=> 6
63
- #
64
-
65
- # @!method toggle_wifi
66
- # Switch the state of the wifi service only for Android
67
- #
68
- # @return [String]
69
- #
70
- # @example
71
- #
72
- # @driver.toggle_wifi
73
- #
74
-
75
- # @!method toggle_data
76
- # Switch the state of data service only for Android, and the device should be rooted
77
- #
78
- # @return [String]
79
- #
80
- # @example
81
- #
82
- # @driver.toggle_data
83
- #
84
-
85
- # @!method toggle_location_services
86
- # Switch the state of the location service
87
- #
88
- # @return [String]
89
- #
90
- # @example
91
- #
92
- # @driver.toggle_location_services
93
- #
94
-
95
- # @!method toggle_airplane_mode
96
- # Toggle flight mode on or off
97
- #
98
- # @example
99
- #
100
- # @driver.toggle_airplane_mode
101
- #
102
-
103
- # @!method hide_keyboard(close_key = nil, strategy = nil)
104
- # Hide the onscreen keyboard
105
- # @param [String] close_key The name of the key which closes the keyboard.
106
- # Defaults to 'Done' for iOS(except for XCUITest).
107
- # @param [Symbol] strategy The symbol of the strategy which closes the keyboard.
108
- # XCUITest ignore this argument.
109
- # Default for iOS is `:pressKey`. Default for Android is `:tapOutside`.
110
- #
111
- # @example
112
- #
113
- # @driver.hide_keyboard # Close a keyboard with the 'Done' button
114
- # @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
115
- # @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard
116
- #
117
-
118
- # @!method end_coverage(path, intent)
119
- # Android only; Ends the test coverage and writes the results to the given path on device.
120
- # @param [String] path Path on the device to write too.
121
- # @param [String] intent Intent to broadcast when ending coverage.
122
- #
123
-
124
- # @!method start_activity(opts)
125
- # Android only. Start a new activity within the current app or launch a new app and start the target activity.
126
- #
127
- # @param opts [Hash] Options
128
- # @option opts [String] :app_package The package owning the activity [required]
129
- # @option opts [String] :app_activity The target activity [required]
130
- # @option opts [String] :app_wait_package The package to start before the target package [optional]
131
- # @option opts [String] :app_wait_activity The activity to start before the target activity [optional]
132
- #
133
- # @example
134
- #
135
- # start_activity app_package: 'io.appium.android.apis',
136
- # app_activity: '.accessibility.AccessibilityNodeProviderActivity'
137
- #
138
-
139
- # @!method set_network_connection(mode)
140
- # Set the device network connection mode
141
- # @param [String] mode Bit mask that represent the network mode
142
- #
143
- # Value (Alias) | Data | Wifi | Airplane Mode
144
- # -------------------------------------------------
145
- # 1 (Airplane Mode) | 0 | 0 | 1
146
- # 6 (All network on) | 1 | 1 | 0
147
- # 4 (Data only) | 1 | 0 | 0
148
- # 2 (Wifi only) | 0 | 1 | 0
149
- # 0 (None) | 0 | 0 | 0
150
- #
151
- # @example
152
- #
153
- # @driver.set_network_connection 1
154
- # @driver.network_connection_type = 1
155
- #
156
-
157
- # @!method get_performance_data_types
158
- # Get the information type of the system state which is supported to read such as
159
- # cpu, memory, network, battery via adb commands.
160
- # https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L300
161
- #
162
- # @example
163
- #
164
- # @driver.get_performance_data_types #=> ["cpuinfo", "batteryinfo", "networkinfo", "memoryinfo"]
165
- #
166
-
167
- # @!method get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
168
- # Get the resource usage information of the application.
169
- # https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303
170
- # @param [String] package_name: Package name
171
- # @param [String] data_type: Data type get with `get_performance_data_types`
172
- # @param [String] data_read_timeout: Command timeout. Default is 2.
173
- #
174
- # @example
175
- #
176
- # @driver.get_performance_data package_name: package_name, data_type: data_type, data_read_timeout: 2
177
- #
178
-
179
- # @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil, video_size: nil, time_limit: '180', bit_rate: '4000000')
180
- # @param [String] remote_path: The path to the remote location, where the resulting video should be uploaded.
181
- # The following protocols are supported: http/https, ftp.
182
- # Null or empty string value (the default setting) means the content of resulting
183
- # file should be encoded as Base64 and passed as the endpoint response value.
184
- # An exception will be thrown if the generated media file is too big to
185
- # fit into the available process memory.
186
- # This option only has an effect if there is screen recording process in progress
187
- # and `forceRestart` parameter is not set to `true`.
188
- # @param [String] user: The name of the user for the remote authentication.
189
- # @param [String] pass: The password for the remote authentication.
190
- # @param [String] method: The http multipart upload method name. The 'PUT' one is used by default.
191
- # @param [Boolean] force_restart: Whether to try to catch and upload/return the currently running screen recording
192
- # (`false`, the default setting on server) or ignore the result of it
193
- # and start a new recording immediately (`true`).
194
- #
195
- # @param [String] video_size: The format is widthxheight.
196
- # The default value is the device's native display resolution (if supported),
197
- # 1280x720 if not. For best results,
198
- # use a size supported by your device's Advanced Video Coding (AVC) encoder.
199
- # For example, "1280x720"
200
- # @param [String] time_limit: Recording time. 180 seconds is by default.
201
- # @param [String] bit_rate: The video bit rate for the video, in megabits per second.
202
- # 4 Mbp/s(4000000) is by default for Android API level below 27. 20 Mb/s(20000000) for API level 27 and above.
203
- # @param [Boolean] bug_report: Set it to `true` in order to display additional information on the video overlay,
204
- # such as a timestamp, that is helpful in videos captured to illustrate bugs.
205
- # This option is only supported since API level 27 (Android P).
206
- #
207
- # @example
208
- #
209
- # @driver.start_recording_screen
210
- # @driver.start_recording_screen video_size: '1280x720', time_limit: '180', bit_rate: '5000000'
211
- #
212
-
213
- # @!method get_clipboard(content_type: :plaintext)
214
- # Set the content of device's clipboard.
215
- # @param [String] content_type: one of supported content types.
216
- # @return [String]
217
- #
218
- # @example
219
- #
220
- # @driver.get_clipboard #=> "happy testing"
221
- #
222
-
223
- # @!method set_clipboard(content:, content_type: :plaintext, label: nil)
224
- # Set the content of device's clipboard.
225
- # @param [String] label: clipboard data label.
226
- # @param [String] content_type: one of supported content types.
227
- # @param [String] content: Contents to be set. (Will encode with base64-encoded inside this method)
228
- #
229
- # @example
230
- #
231
- # @driver.set_clipboard(content: 'happy testing') #=> {"protocol"=>"W3C"}
232
- #
233
-
234
- ####
235
- ## class << self
236
- ####
237
-
238
- # rubocop:enable Metrics/LineLength
239
-
240
- class << self
241
- def extended(_mod)
242
- Appium::Core::Device.extend_webdriver_with_forwardable
243
-
244
- Appium::Core::Device.add_endpoint_method(:open_notifications) do
245
- def open_notifications
246
- execute :open_notifications
247
- end
248
- end
249
-
250
- Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do
251
- def toggle_airplane_mode
252
- execute :toggle_airplane_mode
253
- end
254
- alias_method :toggle_flight_mode, :toggle_airplane_mode
255
- end
256
-
257
- Appium::Core::Device.add_endpoint_method(:current_activity) do
258
- def current_activity
259
- execute :current_activity
260
- end
261
- end
262
-
263
- Appium::Core::Device.add_endpoint_method(:current_package) do
264
- def current_package
265
- execute :current_package
266
- end
267
- end
268
-
269
- Appium::Core::Device.add_endpoint_method(:get_system_bars) do
270
- def get_system_bars
271
- execute :get_system_bars
272
- end
273
- end
274
-
275
- Appium::Core::Device.add_endpoint_method(:get_display_density) do
276
- def get_display_density
277
- execute :get_display_density
278
- end
279
- end
280
-
281
- Appium::Core::Device.add_endpoint_method(:get_network_connection) do
282
- def get_network_connection
283
- execute :get_network_connection
284
- end
285
- end
286
-
287
- Appium::Core::Device.add_endpoint_method(:get_performance_data_types) do
288
- def get_performance_data_types
289
- execute :get_performance_data_types
290
- end
291
- end
292
-
293
- Appium::Core::Device.add_endpoint_method(:toggle_wifi) do
294
- def toggle_wifi
295
- execute :toggle_wifi
296
- end
297
- end
298
-
299
- Appium::Core::Device.add_endpoint_method(:toggle_data) do
300
- def toggle_data
301
- execute :toggle_data
302
- end
303
- end
304
-
305
- Appium::Core::Device.add_endpoint_method(:toggle_location_services) do
306
- def toggle_location_services
307
- execute :toggle_location_services
8
+ module Core
9
+ module Android
10
+ module Device
11
+ extend Forwardable
12
+
13
+ # rubocop:disable Metrics/LineLength
14
+
15
+ # @!method open_notifications
16
+ # Open Android notifications
17
+ #
18
+ # @example
19
+ #
20
+ # @driver.open_notifications
21
+ #
22
+
23
+ # @!method current_activity
24
+ # Get current activity name
25
+ # @return [String] An activity name
26
+ #
27
+ # @example
28
+ #
29
+ # @driver.current_activity # '.ApiDemos'
30
+ #
31
+
32
+ # @!method current_package
33
+ # Get current package name
34
+ # @return [String] A package name
35
+ #
36
+ # @example
37
+ #
38
+ # @driver.current_package # 'com.example.android.apis'
39
+ #
40
+
41
+ # @!method get_system_bars
42
+ # Get system bar's information
43
+ # @return [String]
44
+ #
45
+ # @example
46
+ #
47
+ # @driver.get_system_bars
48
+ #
49
+
50
+ # @!method get_display_density
51
+ # Get connected device's density.
52
+ # @return [Integer] The size of density
53
+ #
54
+ # @example
55
+ #
56
+ # @driver.get_display_density # 320
57
+ #
58
+
59
+ # @!method get_network_connection
60
+ # Get the device network connection current status
61
+ # See set_network_connection method for return value
62
+ #
63
+ # @example
64
+ #
65
+ # @driver.network_connection_type #=> 6
66
+ # @driver.get_network_connection #=> 6
67
+ #
68
+
69
+ # @!method toggle_wifi
70
+ # Switch the state of the wifi service only for Android
71
+ #
72
+ # @return [String]
73
+ #
74
+ # @example
75
+ #
76
+ # @driver.toggle_wifi
77
+ #
78
+
79
+ # @!method toggle_data
80
+ # Switch the state of data service only for Android, and the device should be rooted
81
+ #
82
+ # @return [String]
83
+ #
84
+ # @example
85
+ #
86
+ # @driver.toggle_data
87
+ #
88
+
89
+ # @!method toggle_location_services
90
+ # Switch the state of the location service
91
+ #
92
+ # @return [String]
93
+ #
94
+ # @example
95
+ #
96
+ # @driver.toggle_location_services
97
+ #
98
+
99
+ # @!method toggle_airplane_mode
100
+ # Toggle flight mode on or off
101
+ #
102
+ # @example
103
+ #
104
+ # @driver.toggle_airplane_mode
105
+ #
106
+
107
+ # @!method hide_keyboard(close_key = nil, strategy = nil)
108
+ # Hide the onscreen keyboard
109
+ # @param [String] close_key The name of the key which closes the keyboard.
110
+ # Defaults to 'Done' for iOS(except for XCUITest).
111
+ # @param [Symbol] strategy The symbol of the strategy which closes the keyboard.
112
+ # XCUITest ignore this argument.
113
+ # Default for iOS is `:pressKey`. Default for Android is `:tapOutside`.
114
+ #
115
+ # @example
116
+ #
117
+ # @driver.hide_keyboard # Close a keyboard with the 'Done' button
118
+ # @driver.hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
119
+ # @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard
120
+ #
121
+
122
+ # @!method end_coverage(path, intent)
123
+ # Android only; Ends the test coverage and writes the results to the given path on device.
124
+ # @param [String] path Path on the device to write too.
125
+ # @param [String] intent Intent to broadcast when ending coverage.
126
+ #
127
+
128
+ # @!method start_activity(opts)
129
+ # Android only. Start a new activity within the current app or launch a new app and start the target activity.
130
+ #
131
+ # @param opts [Hash] Options
132
+ # @option opts [String] :app_package The package owning the activity [required]
133
+ # @option opts [String] :app_activity The target activity [required]
134
+ # @option opts [String] :app_wait_package The package to start before the target package [optional]
135
+ # @option opts [String] :app_wait_activity The activity to start before the target activity [optional]
136
+ #
137
+ # @example
138
+ #
139
+ # start_activity app_package: 'io.appium.android.apis',
140
+ # app_activity: '.accessibility.AccessibilityNodeProviderActivity'
141
+ #
142
+
143
+ # @!method set_network_connection(mode)
144
+ # Set the device network connection mode
145
+ # @param [String] mode Bit mask that represent the network mode
146
+ #
147
+ # Value (Alias) | Data | Wifi | Airplane Mode
148
+ # -------------------------------------------------
149
+ # 1 (Airplane Mode) | 0 | 0 | 1
150
+ # 6 (All network on) | 1 | 1 | 0
151
+ # 4 (Data only) | 1 | 0 | 0
152
+ # 2 (Wifi only) | 0 | 1 | 0
153
+ # 0 (None) | 0 | 0 | 0
154
+ #
155
+ # @example
156
+ #
157
+ # @driver.set_network_connection 1
158
+ # @driver.network_connection_type = 1
159
+ #
160
+
161
+ # @!method get_performance_data_types
162
+ # Get the information type of the system state which is supported to read such as
163
+ # cpu, memory, network, battery via adb commands.
164
+ # https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L300
165
+ #
166
+ # @example
167
+ #
168
+ # @driver.get_performance_data_types #=> ["cpuinfo", "batteryinfo", "networkinfo", "memoryinfo"]
169
+ #
170
+
171
+ # @!method get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
172
+ # Get the resource usage information of the application.
173
+ # https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303
174
+ # @param [String] package_name: Package name
175
+ # @param [String] data_type: Data type get with `get_performance_data_types`
176
+ # @param [String] data_read_timeout: Command timeout. Default is 2.
177
+ #
178
+ # @example
179
+ #
180
+ # @driver.get_performance_data package_name: package_name, data_type: data_type, data_read_timeout: 2
181
+ #
182
+
183
+ # @!method start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil, video_size: nil, time_limit: '180', bit_rate: '4000000')
184
+ # @param [String] remote_path: The path to the remote location, where the resulting video should be uploaded.
185
+ # The following protocols are supported: http/https, ftp.
186
+ # Null or empty string value (the default setting) means the content of resulting
187
+ # file should be encoded as Base64 and passed as the endpoint response value.
188
+ # An exception will be thrown if the generated media file is too big to
189
+ # fit into the available process memory.
190
+ # This option only has an effect if there is screen recording process in progress
191
+ # and `forceRestart` parameter is not set to `true`.
192
+ # @param [String] user: The name of the user for the remote authentication.
193
+ # @param [String] pass: The password for the remote authentication.
194
+ # @param [String] method: The http multipart upload method name. The 'PUT' one is used by default.
195
+ # @param [Boolean] force_restart: Whether to try to catch and upload/return the currently running screen recording
196
+ # (`false`, the default setting on server) or ignore the result of it
197
+ # and start a new recording immediately (`true`).
198
+ #
199
+ # @param [String] video_size: The format is widthxheight.
200
+ # The default value is the device's native display resolution (if supported),
201
+ # 1280x720 if not. For best results,
202
+ # use a size supported by your device's Advanced Video Coding (AVC) encoder.
203
+ # For example, "1280x720"
204
+ # @param [String] time_limit: Recording time. 180 seconds is by default.
205
+ # @param [String] bit_rate: The video bit rate for the video, in megabits per second.
206
+ # 4 Mbp/s(4000000) is by default for Android API level below 27. 20 Mb/s(20000000) for API level 27 and above.
207
+ # @param [Boolean] bug_report: Set it to `true` in order to display additional information on the video overlay,
208
+ # such as a timestamp, that is helpful in videos captured to illustrate bugs.
209
+ # This option is only supported since API level 27 (Android P).
210
+ #
211
+ # @example
212
+ #
213
+ # @driver.start_recording_screen
214
+ # @driver.start_recording_screen video_size: '1280x720', time_limit: '180', bit_rate: '5000000'
215
+ #
216
+
217
+ # @!method get_clipboard(content_type: :plaintext)
218
+ # Set the content of device's clipboard.
219
+ # @param [String] content_type: one of supported content types.
220
+ # @return [String]
221
+ #
222
+ # @example
223
+ #
224
+ # @driver.get_clipboard #=> "happy testing"
225
+ #
226
+
227
+ # @!method set_clipboard(content:, content_type: :plaintext, label: nil)
228
+ # Set the content of device's clipboard.
229
+ # @param [String] label: clipboard data label.
230
+ # @param [String] content_type: one of supported content types.
231
+ # @param [String] content: Contents to be set. (Will encode with base64-encoded inside this method)
232
+ #
233
+ # @example
234
+ #
235
+ # @driver.set_clipboard(content: 'happy testing') #=> {"protocol"=>"W3C"}
236
+ #
237
+
238
+ ####
239
+ ## class << self
240
+ ####
241
+
242
+ # rubocop:enable Metrics/LineLength
243
+
244
+ class << self
245
+ def extended(_mod)
246
+ ::Appium::Core::Device.extend_webdriver_with_forwardable
247
+
248
+ ::Appium::Core::Device.add_endpoint_method(:open_notifications) do
249
+ def open_notifications
250
+ execute :open_notifications
251
+ end
308
252
  end
309
- end
310
253
 
311
- Appium::Core::Device.add_endpoint_method(:start_activity) do
312
- def start_activity(opts)
313
- raise 'opts must be a hash' unless opts.is_a? Hash
314
- app_package = opts[:app_package]
315
- raise 'app_package is required' unless app_package
316
- app_activity = opts[:app_activity]
317
- raise 'app_activity is required' unless app_activity
318
- app_wait_package = opts.fetch(:app_wait_package, '')
319
- app_wait_activity = opts.fetch(:app_wait_activity, '')
320
-
321
- unknown_opts = opts.keys - %i(app_package app_activity app_wait_package app_wait_activity)
322
- raise "Unknown options #{unknown_opts}" unless unknown_opts.empty?
323
-
324
- execute :start_activity, {}, appPackage: app_package,
325
- appActivity: app_activity,
326
- appWaitPackage: app_wait_package,
327
- appWaitActivity: app_wait_activity
254
+ ::Appium::Core::Device.add_endpoint_method(:current_activity) do
255
+ def current_activity
256
+ execute :current_activity
257
+ end
328
258
  end
329
- end
330
-
331
- # Android, Override
332
- Appium::Core::Device.add_endpoint_method(:hide_keyboard) do
333
- def hide_keyboard(close_key = nil, strategy = nil)
334
- option = {}
335
-
336
- option[:key] = close_key if close_key
337
- option[:strategy] = strategy || :tapOutside # default to pressKey
338
259
 
339
- execute :hide_keyboard, {}, option
260
+ ::Appium::Core::Device.add_endpoint_method(:current_package) do
261
+ def current_package
262
+ execute :current_package
263
+ end
340
264
  end
341
- end
342
265
 
343
- # TODO: TEST ME
344
- Appium::Core::Device.add_endpoint_method(:end_coverage) do
345
- def end_coverage(path, intent)
346
- execute :end_coverage, {}, path: path, intent: intent
266
+ ::Appium::Core::Device.add_endpoint_method(:get_system_bars) do
267
+ def get_system_bars
268
+ execute :get_system_bars
269
+ end
347
270
  end
348
- end
349
271
 
350
- Appium::Core::Device.add_endpoint_method(:set_network_connection) do
351
- def set_network_connection(mode)
352
- # TODO. Update set_network_connection as well
353
- # connection_type = {airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}
354
- # raise ArgumentError, 'Invalid connection type' unless type_to_values.keys.include? mode
355
- # type = connection_type[mode]
356
- # execute :set_network_connection, {}, type: type
357
- execute :set_network_connection, {}, type: mode
272
+ ::Appium::Core::Device.add_endpoint_method(:toggle_location_services) do
273
+ def toggle_location_services
274
+ execute :toggle_location_services
275
+ end
358
276
  end
359
- end
360
277
 
361
- Appium::Core::Device.add_endpoint_method(:get_performance_data) do
362
- def get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
363
- execute(:get_performance_data, {},
364
- packageName: package_name, dataType: data_type, dataReadTimeout: data_read_timeout)
278
+ ::Appium::Core::Device.add_endpoint_method(:start_activity) do
279
+ def start_activity(opts)
280
+ raise 'opts must be a hash' unless opts.is_a? Hash
281
+ app_package = opts[:app_package]
282
+ raise 'app_package is required' unless app_package
283
+ app_activity = opts[:app_activity]
284
+ raise 'app_activity is required' unless app_activity
285
+ app_wait_package = opts.fetch(:app_wait_package, '')
286
+ app_wait_activity = opts.fetch(:app_wait_activity, '')
287
+
288
+ unknown_opts = opts.keys - %i(app_package app_activity app_wait_package app_wait_activity)
289
+ raise "Unknown options #{unknown_opts}" unless unknown_opts.empty?
290
+
291
+ execute :start_activity, {}, appPackage: app_package,
292
+ appActivity: app_activity,
293
+ appWaitPackage: app_wait_package,
294
+ appWaitActivity: app_wait_activity
295
+ end
365
296
  end
366
- end
367
-
368
- add_screen_recording
369
- add_clipboard
370
- Emulator.emulator_commands
371
- end
372
-
373
- private
374
297
 
375
- def add_screen_recording
376
- Appium::Core::Device.add_endpoint_method(:start_recording_screen) do
377
- # rubocop:disable Metrics/ParameterLists
378
- def start_recording_screen(remote_path: nil, user: nil, pass: nil, method: 'PUT', force_restart: nil,
379
- video_size: nil, time_limit: '180', bit_rate: nil, bug_report: nil)
380
- option = ::Appium::Core::Device::ScreenRecord.new(
381
- remote_path: remote_path, user: user, pass: pass, method: method, force_restart: force_restart
382
- ).upload_option
298
+ # Android, Override
299
+ ::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do
300
+ def hide_keyboard(close_key = nil, strategy = nil)
301
+ option = {}
383
302
 
384
- option[:videoSize] = video_size unless video_size.nil?
385
- option[:timeLimit] = time_limit
386
- option[:bitRate] = bit_rate unless bit_rate.nil?
303
+ option[:key] = close_key if close_key
304
+ option[:strategy] = strategy || :tapOutside # default to pressKey
387
305
 
388
- unless bug_report.nil?
389
- raise 'bug_report should be true or false' unless [true, false].member?(bug_report)
390
- option[:bugReport] = bug_report
306
+ execute :hide_keyboard, {}, option
391
307
  end
392
-
393
- execute(:start_recording_screen, {}, { options: option })
394
308
  end
395
- # rubocop:enable Metrics/ParameterLists
396
- end
397
- end
398
309
 
399
- def add_clipboard
400
- ::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
401
- def get_clipboard(content_type: :plaintext)
402
- unless ::Appium::Core::Device::Clipboard::CONTENT_TYPE.member?(content_type)
403
- raise "content_type should be #{::Appium::Core::Device::Clipboard::CONTENT_TYPE}"
310
+ # TODO: TEST ME
311
+ ::Appium::Core::Device.add_endpoint_method(:end_coverage) do
312
+ def end_coverage(path, intent)
313
+ execute :end_coverage, {}, path: path, intent: intent
404
314
  end
405
-
406
- params = { contentType: content_type }
407
-
408
- data = execute(:get_clipboard, {}, params)
409
- Base64.decode64 data
410
315
  end
411
- end
412
316
 
413
- ::Appium::Core::Device.add_endpoint_method(:set_clipboard) do
414
- def set_clipboard(content:, content_type: :plaintext, label: nil)
415
- unless ::Appium::Core::Device::Clipboard::CONTENT_TYPE.member?(content_type)
416
- raise "content_type should be #{::Appium::Core::Device::Clipboard::CONTENT_TYPE}"
417
- end
418
-
419
- params = {
420
- contentType: content_type,
421
- content: Base64.encode64(content)
422
- }
423
- params[:label] = label unless label.nil?
424
-
425
- execute(:set_clipboard, {}, params)
426
- end
317
+ Screen.add_methods
318
+ Performance.add_methods
319
+ Network.add_methods
320
+ Clipboard.add_methods
321
+ Emulator.add_methods
427
322
  end
428
323
  end
429
- end
430
- end # module Device
431
- end # module Android
324
+ end # module Device
325
+ end # module Android
326
+ end
432
327
  end # module Appium