Skip to content

Commit dbd67f0

Browse files
authored
chore: add deprecation marks (#504)
* chore: add deprecation marks * fix lint
1 parent 646f749 commit dbd67f0

File tree

7 files changed

+95
-2
lines changed

7 files changed

+95
-2
lines changed

lib/appium_lib_core/android/device.rb

+37
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Device
2727

2828
# rubocop:disable Layout/LineLength
2929

30+
# @deprecated Use 'mobile: openNotifications' extension instead.
3031
# @!method open_notifications
3132
# Open Android notifications
3233
#
@@ -35,6 +36,7 @@ module Device
3536
# @driver.open_notifications
3637
#
3738

39+
# @deprecated Use 'mobile: getCurrentActivity' extension instead.
3840
# @!method current_activity
3941
# Get current activity name
4042
# @return [String] An activity name
@@ -44,6 +46,7 @@ module Device
4446
# @driver.current_activity # '.ApiDemos'
4547
#
4648

49+
# @deprecated Use 'mobile: getCurrentPackage' extension instead.
4750
# @!method current_package
4851
# Get current package name
4952
# @return [String] A package name
@@ -53,6 +56,7 @@ module Device
5356
# @driver.current_package # 'com.example.android.apis'
5457
#
5558

59+
# @deprecated Use 'mobile: getSystemBars' extension instead.
5660
# @!method get_system_bars
5761
# Get system bar's information
5862
# @return [String]
@@ -63,6 +67,7 @@ module Device
6367
# @driver.system_bars
6468
#
6569

70+
# @deprecated Use 'mobile: getDisplayDensity' extension instead.
6671
# @!method get_display_density
6772
# Get connected device's density.
6873
# @return [Integer] The size of density
@@ -72,6 +77,7 @@ module Device
7277
# @driver.get_display_density # 320
7378
#
7479

80+
# @deprecated Use 'mobile: getConnectivity' extension instead.
7581
# @!method get_network_connection
7682
# Get the device network connection current status
7783
# See set_network_connection method for return value
@@ -86,6 +92,7 @@ module Device
8692
# @driver.get_network_connection #=> 6
8793
#
8894

95+
# @deprecated Use 'mobile: getConnectivity' extension instead.
8996
# @!method toggle_wifi
9097
# Switch the state of the wifi service only for Android
9198
#
@@ -96,6 +103,7 @@ module Device
96103
# @driver.toggle_wifi
97104
#
98105

106+
# @deprecated Use 'mobile: getConnectivity' extension instead.
99107
# @!method toggle_data
100108
# Switch the state of data service only for Android, and the device should be rooted
101109
#
@@ -106,6 +114,7 @@ module Device
106114
# @driver.toggle_data
107115
#
108116

117+
# @deprecated Use 'mobile: getConnectivity' extension instead.
109118
# @!method location
110119
# Get the location of the device.
111120
#
@@ -143,6 +152,7 @@ module Device
143152
# driver.set_location 10, 10, 0
144153
#
145154

155+
# @deprecated Use 'mobile: toggleGps' extension instead.
146156
# @!method toggle_location_services
147157
# Switch the state of the location service
148158
#
@@ -153,6 +163,7 @@ module Device
153163
# @driver.toggle_location_services
154164
#
155165

166+
# @deprecated Use 'mobile: getConnectivity' extension instead.
156167
# @!method toggle_airplane_mode
157168
# Toggle flight mode on or off
158169
#
@@ -161,6 +172,7 @@ module Device
161172
# @driver.toggle_airplane_mode
162173
#
163174

175+
# @deprecated Use 'mobile: hideKeyboard' extension instead.
164176
# @!method hide_keyboard(close_key = nil, strategy = nil)
165177
# Hide the onscreen keyboard
166178
# @param [String] close_key The name of the key which closes the keyboard.
@@ -176,12 +188,14 @@ module Device
176188
# @driver.hide_keyboard(nil, :tapOutside) # Close a keyboard with tapping out side of keyboard
177189
#
178190

191+
# @deprecated The method no longer exists. This method will be removed.
179192
# @!method end_coverage(path, intent)
180193
# Android only; Ends the test coverage and writes the results to the given path on device.
181194
# @param [String] path Path on the device to write too.
182195
# @param [String] intent Intent to broadcast when ending coverage.
183196
#
184197

198+
# @deprecated Use 'mobile: startActivity' extension instead.
185199
# @!method start_activity(opts)
186200
# Android only. Start a new activity within the current app or launch a new app and start the target activity.
187201
#
@@ -206,6 +220,7 @@ module Device
206220
# app_activity: '.accessibility.AccessibilityNodeProviderActivity'
207221
#
208222

223+
# @deprecated Use 'mobile: setConnectivity' extension instead.
209224
# @!method set_network_connection(mode)
210225
# Set the device network connection mode
211226
# Same as +#network_connection_type+ in selenium-webdriver.
@@ -228,6 +243,7 @@ module Device
228243
# @driver.network_connection_type = :airplane_mode # As selenium-webdriver
229244
#
230245

246+
# @deprecated Use 'mobile: getPerformanceDataTypes' extension instead.
231247
# @!method get_performance_data_types
232248
# Get the information type of the system state which is supported to read such as
233249
# cpu, memory, network, battery via adb commands.
@@ -238,6 +254,7 @@ module Device
238254
# @driver.get_performance_data_types #=> ["cpuinfo", "batteryinfo", "networkinfo", "memoryinfo"]
239255
#
240256

257+
# @deprecated Use 'mobile: getPerformanceData' extension instead.
241258
# @!method get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
242259
# Get the resource usage information of the application.
243260
# https://github.com/appium/appium-base-driver/blob/be29aec2318316d12b5c3295e924a5ba8f09b0fb/lib/mjsonwp/routes.js#L303
@@ -317,6 +334,7 @@ module Device
317334
# @driver.set_clipboard(content: 'happy testing') #=> {"protocol"=>"W3C"}
318335
#
319336

337+
# @deprecated Use 'mobile: fingerprint' extension instead.
320338
# @!method finger_print(finger_id)
321339
# Authenticate users by using their finger print scans on supported emulators.
322340
#
@@ -356,42 +374,56 @@ def extended(_mod)
356374

357375
::Appium::Core::Device.add_endpoint_method(:open_notifications) do
358376
def open_notifications
377+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: openNotifications' extension instead"
378+
359379
execute :open_notifications
360380
end
361381
end
362382

363383
::Appium::Core::Device.add_endpoint_method(:current_activity) do
364384
def current_activity
385+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentActivity' extension instead"
386+
365387
execute :current_activity
366388
end
367389
end
368390

369391
::Appium::Core::Device.add_endpoint_method(:current_package) do
370392
def current_package
393+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentPackage' extension instead"
394+
371395
execute :current_package
372396
end
373397
end
374398

375399
::Appium::Core::Device.add_endpoint_method(:get_system_bars) do
376400
def get_system_bars
401+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead"
402+
377403
execute :get_system_bars
378404
end
379405
end
380406
# as alias to get_system_bars
381407
::Appium::Core::Device.add_endpoint_method(:system_bars) do
382408
def system_bars
409+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead"
410+
383411
execute :get_system_bars
384412
end
385413
end
386414

387415
::Appium::Core::Device.add_endpoint_method(:toggle_location_services) do
388416
def toggle_location_services
417+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: toggleGps' extension instead"
418+
389419
execute :toggle_location_services
390420
end
391421
end
392422

393423
::Appium::Core::Device.add_endpoint_method(:start_activity) do
394424
def start_activity(opts)
425+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: startActivity' extension instead"
426+
395427
raise 'opts must be a hash' unless opts.is_a? Hash
396428

397429
option = {}
@@ -429,6 +461,8 @@ def start_activity(opts)
429461
# Android, Override included method in bridge
430462
::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do
431463
def hide_keyboard(close_key = nil, strategy = nil)
464+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: hideKeyboard' extension instead"
465+
432466
option = {}
433467

434468
option[:key] = close_key if close_key
@@ -441,13 +475,16 @@ def hide_keyboard(close_key = nil, strategy = nil)
441475
# Android, Override included method in bridge
442476
::Appium::Core::Device.add_endpoint_method(:background_app) do
443477
def background_app(duration = 0)
478+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: backgroundApp' extension instead"
479+
444480
execute :background_app, {}, seconds: duration
445481
end
446482
end
447483

448484
# TODO: TEST ME
449485
::Appium::Core::Device.add_endpoint_method(:end_coverage) do
450486
def end_coverage(path, intent)
487+
::Appium::Logger.warn '[DEPRECATION] The method no longer exists. This method will be removed.'
451488
execute :end_coverage, {}, path: path, intent: intent
452489
end
453490
end

lib/appium_lib_core/android/device/auth_finger_print.rb

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module Authentication
2020
def self.add_methods
2121
::Appium::Core::Device.add_endpoint_method(:finger_print) do
2222
def finger_print(finger_id)
23+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: fingerprint' extension instead"
24+
2325
unless (1..10).cover? finger_id.to_i
2426
raise ::Appium::Core::Error::ArgumentError,
2527
"finger_id should be integer between 1 to 10. Not #{finger_id}"

lib/appium_lib_core/android/device/network.rb

+10
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,32 @@ module Network
2020
def self.add_methods
2121
::Appium::Core::Device.add_endpoint_method(:get_network_connection) do
2222
def get_network_connection
23+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getConnectivity' extension instead"
24+
2325
execute :get_network_connection
2426
end
2527
end
2628

2729
::Appium::Core::Device.add_endpoint_method(:toggle_wifi) do
2830
def toggle_wifi
31+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
32+
2933
execute :toggle_wifi
3034
end
3135
end
3236

3337
::Appium::Core::Device.add_endpoint_method(:toggle_data) do
3438
def toggle_data
39+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
40+
3541
execute :toggle_data
3642
end
3743
end
3844

3945
::Appium::Core::Device.add_endpoint_method(:set_network_connection) do
4046
def set_network_connection(mode)
47+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
48+
4149
# same as ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
4250
# But this method accept number
4351
connection_type = { airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0 }
@@ -49,6 +57,8 @@ def set_network_connection(mode)
4957

5058
::Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do
5159
def toggle_airplane_mode
60+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"
61+
5262
execute :toggle_airplane_mode
5363
end
5464
alias_method :toggle_flight_mode, :toggle_airplane_mode

lib/appium_lib_core/android/device/performance.rb

+3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ module Performance
2020
def self.add_methods
2121
::Appium::Core::Device.add_endpoint_method(:get_performance_data_types) do
2222
def get_performance_data_types
23+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceDataTypes' extension instead"
2324
execute :get_performance_data_types
2425
end
2526
end
2627

2728
::Appium::Core::Device.add_endpoint_method(:get_performance_data) do
2829
def get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
30+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceData' extension instead"
31+
2932
execute(:get_performance_data, {},
3033
packageName: package_name, dataType: data_type, dataReadTimeout: data_read_timeout)
3134
end

lib/appium_lib_core/android/device/screen.rb

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ module Screen
2020
def self.add_methods
2121
::Appium::Core::Device.add_endpoint_method(:get_display_density) do
2222
def get_display_density
23+
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getDisplayDensity' extension instead"
24+
2325
execute :get_display_density
2426
end
2527
end

0 commit comments

Comments
 (0)