Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions lib/appium_lib_core/android/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Device

# rubocop:disable Layout/LineLength

# @deprecated Use 'mobile: openNotifications' extension instead.
# @!method open_notifications
# Open Android notifications
#
Expand All @@ -35,6 +36,7 @@ module Device
# @driver.open_notifications
#

# @deprecated Use 'mobile: getCurrentActivity' extension instead.
# @!method current_activity
# Get current activity name
# @return [String] An activity name
Expand All @@ -44,6 +46,7 @@ module Device
# @driver.current_activity # '.ApiDemos'
#

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

# @deprecated Use 'mobile: getSystemBars' extension instead.
# @!method get_system_bars
# Get system bar's information
# @return [String]
Expand All @@ -63,6 +67,7 @@ module Device
# @driver.system_bars
#

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

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

# @deprecated Use 'mobile: getConnectivity' extension instead.
# @!method toggle_wifi
# Switch the state of the wifi service only for Android
#
Expand All @@ -96,6 +103,7 @@ module Device
# @driver.toggle_wifi
#

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

# @deprecated Use 'mobile: getConnectivity' extension instead.
# @!method location
# Get the location of the device.
#
Expand Down Expand Up @@ -143,6 +152,7 @@ module Device
# driver.set_location 10, 10, 0
#

# @deprecated Use 'mobile: toggleGps' extension instead.
# @!method toggle_location_services
# Switch the state of the location service
#
Expand All @@ -153,6 +163,7 @@ module Device
# @driver.toggle_location_services
#

# @deprecated Use 'mobile: getConnectivity' extension instead.
# @!method toggle_airplane_mode
# Toggle flight mode on or off
#
Expand All @@ -161,6 +172,7 @@ module Device
# @driver.toggle_airplane_mode
#

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

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

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

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

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

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

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

::Appium::Core::Device.add_endpoint_method(:open_notifications) do
def open_notifications
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: openNotifications' extension instead"

execute :open_notifications
end
end

::Appium::Core::Device.add_endpoint_method(:current_activity) do
def current_activity
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentActivity' extension instead"

execute :current_activity
end
end

::Appium::Core::Device.add_endpoint_method(:current_package) do
def current_package
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getCurrentPackage' extension instead"

execute :current_package
end
end

::Appium::Core::Device.add_endpoint_method(:get_system_bars) do
def get_system_bars
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead"

execute :get_system_bars
end
end
# as alias to get_system_bars
::Appium::Core::Device.add_endpoint_method(:system_bars) do
def system_bars
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getSystemBars' extension instead"

execute :get_system_bars
end
end

::Appium::Core::Device.add_endpoint_method(:toggle_location_services) do
def toggle_location_services
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: toggleGps' extension instead"

execute :toggle_location_services
end
end

::Appium::Core::Device.add_endpoint_method(:start_activity) do
def start_activity(opts)
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: startActivity' extension instead"

raise 'opts must be a hash' unless opts.is_a? Hash

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

option = {}

option[:key] = close_key if close_key
Expand All @@ -441,13 +475,16 @@ def hide_keyboard(close_key = nil, strategy = nil)
# Android, Override included method in bridge
::Appium::Core::Device.add_endpoint_method(:background_app) do
def background_app(duration = 0)
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: backgroundApp' extension instead"

execute :background_app, {}, seconds: duration
end
end

# TODO: TEST ME
::Appium::Core::Device.add_endpoint_method(:end_coverage) do
def end_coverage(path, intent)
::Appium::Logger.warn '[DEPRECATION] The method no longer exists. This method will be removed.'
execute :end_coverage, {}, path: path, intent: intent
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/appium_lib_core/android/device/auth_finger_print.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Authentication
def self.add_methods
::Appium::Core::Device.add_endpoint_method(:finger_print) do
def finger_print(finger_id)
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: fingerprint' extension instead"

unless (1..10).cover? finger_id.to_i
raise ::Appium::Core::Error::ArgumentError,
"finger_id should be integer between 1 to 10. Not #{finger_id}"
Expand Down
10 changes: 10 additions & 0 deletions lib/appium_lib_core/android/device/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,32 @@ module Network
def self.add_methods
::Appium::Core::Device.add_endpoint_method(:get_network_connection) do
def get_network_connection
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getConnectivity' extension instead"

execute :get_network_connection
end
end

::Appium::Core::Device.add_endpoint_method(:toggle_wifi) do
def toggle_wifi
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

execute :toggle_wifi
end
end

::Appium::Core::Device.add_endpoint_method(:toggle_data) do
def toggle_data
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

execute :toggle_data
end
end

::Appium::Core::Device.add_endpoint_method(:set_network_connection) do
def set_network_connection(mode)
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

# same as ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
# But this method accept number
connection_type = { airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0 }
Expand All @@ -49,6 +57,8 @@ def set_network_connection(mode)

::Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do
def toggle_airplane_mode
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

execute :toggle_airplane_mode
end
alias_method :toggle_flight_mode, :toggle_airplane_mode
Expand Down
3 changes: 3 additions & 0 deletions lib/appium_lib_core/android/device/performance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ module Performance
def self.add_methods
::Appium::Core::Device.add_endpoint_method(:get_performance_data_types) do
def get_performance_data_types
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceDataTypes' extension instead"
execute :get_performance_data_types
end
end

::Appium::Core::Device.add_endpoint_method(:get_performance_data) do
def get_performance_data(package_name:, data_type:, data_read_timeout: 1000)
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getPerformanceData' extension instead"

execute(:get_performance_data, {},
packageName: package_name, dataType: data_type, dataReadTimeout: data_read_timeout)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/appium_lib_core/android/device/screen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Screen
def self.add_methods
::Appium::Core::Device.add_endpoint_method(:get_display_density) do
def get_display_density
::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getDisplayDensity' extension instead"

execute :get_display_density
end
end
Expand Down
Loading