Skip to content

Commit

Permalink
chore: add deprecated in app management (#353)
Browse files Browse the repository at this point in the history
* chore: add deprecated in app management

* update changelog
  • Loading branch information
KazuCocoa authored Nov 1, 2021
1 parent 5ad23bc commit 8c42356
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 30 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Read `release_notes.md` for commit level details.
- No longer set default `timeouts` as `0`
- ruby_lib_core calls `/timeouts` endpoint only when `appium_lib: { wait: 5 }` is provided explicitly
- Raises `::Appium::Core::Error::ArgumentError` instead of `ArgumentError` for this library specific argument errors
- Removed Selendroid related methods

### Deprecations
- `Appium::Core::TouchAction` and `Appium::Core::MultiTouch` are deprecated
Expand All @@ -43,7 +44,10 @@ Read `release_notes.md` for commit level details.
- https://www.youtube.com/watch?v=oAJ7jwMNFVU
- https://appiumpro.com/editions/30-ios-specific-touch-action-methods
- https://appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api
- Removed Selendroid related methods
- `launch_app`, `close_app` and `reset`. Please read [issues#15807](https://github.com/appium/appium/issues/15807) for more details.
- `activate_app` or a new session request can be alternatives of `launch_app`
- `terminate_app` or close the session request can be alternatives of `close_app`
- Close current session and creating a new session, or `terminate_app` and `launch_app` can be alternatives of `reset`

## [4.7.1] - 2021-09-26

Expand Down
53 changes: 25 additions & 28 deletions lib/appium_lib_core/common/base/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def initialize(bridge: nil, listener: nil, **opts)
@wait_timeout = opts.delete(:wait_timeout)
@wait_interval = opts.delete(:wait_interval)

# For logging.
# TODO: Remove when appium core no longer uses this in this bridge.
@automation_name = opts.delete(:automation_name)

super
end

Expand Down Expand Up @@ -414,17 +418,9 @@ def context=(context = null)
alias set_context context=

# Place a file in a specific location on the device.
# On iOS, the server should have ifuse libraries installed and configured properly for this feature to work on
# real devices.
# On Android, the application under test should be built with debuggable flag enabled in order to get access to
# its container on the internal file system.
#
# {https://github.com/libimobiledevice/ifuse iFuse GitHub page6}
#
# {https://github.com/osxfuse/osxfuse/wiki/FAQ osxFuse FAQ}
#
# {https://developer.android.com/studio/debug 'Debug Your App' developer article}
#
# @param [String] path Either an absolute path OR, for iOS devices, a path relative to the app, as described.
# If the path starts with application id prefix, then the file will be pushed to the root of
# the corresponding application container.
Expand All @@ -441,18 +437,10 @@ def push_file(path, filedata)
@bridge.push_file(path, filedata)
end

# Pull a file from the simulator/device.
# On iOS the server should have ifuse
# libraries installed and configured properly for this feature to work on real devices.
# Pull a file from the remote device.
# On Android the application under test should be built with debuggable flag enabled in order to get access
# to its container on the internal file system.
#
# {https://github.com/libimobiledevice/ifuse iFuse GitHub page6}
#
# {https://github.com/osxfuse/osxfuse/wiki/FAQ osxFuse FAQ}
#
# {https://developer.android.com/studio/debug 'Debug Your App' developer article}
#
# @param [String] path Either an absolute path OR, for iOS devices, a path relative to the app, as described.
# If the path starts with application id prefix, then the file will be pulled from the root
# of the corresponding application container.
Expand All @@ -461,7 +449,6 @@ def push_file(path, filedata)
# Only pulling files from application containers is supported for iOS Simulator.
# Provide the remote path in format
# <code>@bundle.identifier:container_type/relative_path_in_container</code>
# (Make sure this in ifuse doc)
#
# @return [Base64-decoded] Base64 decoded data
#
Expand All @@ -478,18 +465,10 @@ def pull_file(path)
@bridge.pull_file(path)
end

# Pull a folder content from the simulator/device.
# On iOS the server should have ifuse libraries installed and configured properly for this feature to work
# on real devices.
# Pull a folder content from the remote device.
# On Android the application under test should be built with debuggable flag enabled in order to get access to
# its container on the internal file system.
#
# {https://github.com/libimobiledevice/ifuse iFuse GitHub page6}
#
# {https://github.com/osxfuse/osxfuse/wiki/FAQ osxFuse FAQ}
#
# {https://developer.android.com/studio/debug 'Debug Your App' developer article}
#
# @param [String] path Absolute path to the folder.
# If the path starts with <em>@applicationId/</em> prefix, then the folder will be pulled
# from the root of the corresponding application container.
Expand All @@ -498,7 +477,6 @@ def pull_file(path)
# Only pulling files from application containers is supported for iOS Simulator.
# Provide the remote path in format
# <code>@bundle.identifier:container_type/relative_path_in_container</code>
# (Make sure this in ifuse doc)
#
# @return [Base64-decoded] Base64 decoded data which is zip archived
#
Expand Down Expand Up @@ -556,33 +534,52 @@ def long_press_keycode(key, metastate: [], flags: [])
@bridge.long_press_keycode(key, metastate: metastate, flags: flags)
end

# @deprecated Except for Windows
# Start the simulator and application configured with desired capabilities
#
# @example
#
# @driver.launch_app
#
def launch_app
# TODO: Define only in Windows module when ruby_lib_core removes this method
if @automation_name != :windows
::Appium::Logger.warn(
'[DEPRECATION] launch_app is deprecated. Please use activate_app instead.'
)
end
@bridge.launch_app
end

# @deprecated Except for Windows
# Close an app on device
#
# @example
#
# @driver.close_app
#
def close_app
# TODO: Define only in Windows module when ruby_lib_core removes this method
if @automation_name != :windows
::Appium::Logger.warn(
'[DEPRECATION] close_app is deprecated. Please use terminate_app instead.'
)
end
@bridge.close_app
end

# @deprecated
# Reset the device, relaunching the application.
#
# @example
#
# @driver.reset
#
def reset
::Appium::Logger.warn(
'[DEPRECATION] reset is deprecated. Please use terminate_app and activate_app, ' \
'or quit and create a new session instead.'
)
@bridge.reset
end

Expand Down
3 changes: 2 additions & 1 deletion lib/appium_lib_core/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ def start_driver(server_url: nil,
capabilities: @caps, # ::Selenium::WebDriver::Remote::Capabilities
url: @custom_url,
wait_timeout: @wait_timeout,
wait_interval: @wait_interval)
wait_interval: @wait_interval,
automation_name: @automation_name)

if @direct_connect
d_c = DirectConnections.new(@driver.capabilities)
Expand Down
18 changes: 18 additions & 0 deletions test/unit/windows/device/w3c/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@ def test_stop_recording_screen_custom

assert_requested(:post, "#{SESSION}/appium/stop_recording_screen", times: 1)
end

def test_launch_app
stub_request(:post, "#{SESSION}/appium/app/launch")
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)

@driver.launch_app

assert_requested(:post, "#{SESSION}/appium/app/launch", times: 1)
end

def test_close_app
stub_request(:post, "#{SESSION}/appium/app/close")
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)

@driver.close_app

assert_requested(:post, "#{SESSION}/appium/app/close", times: 1)
end
end # class CommandsTest
end # module W3C
end # module Device
Expand Down

0 comments on commit 8c42356

Please sign in to comment.