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
6 changes: 2 additions & 4 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,11 @@ jobs:
name: func_test_android3
- target: test/functional/android/finger_print_tests.py test/functional/android/screen_record_tests.py test/functional/android/settings_tests.py test/functional/android/chrome_tests.py
name: func_test_android4
- target: test/functional/android/context_switching_tests.py test/functional/android/remote_fs_tests.py
- target: test/functional/android/remote_fs_tests.py
name: func_test_android5
- target: test/functional/android/common_tests.py test/functional/android/webelement_tests.py
name: func_test_android6
- target: test/functional/android/applications_tests.py
name: func_test_android7
- target: test/functional/android/network_connection_tests.py test/functional/android/log_event_tests.py test/functional/android/activities_tests.py test/functional/android/hw_actions_tests.py
- target: test/functional/android/network_connection_tests.py test/functional/android/log_event_tests.py test/functional/android/hw_actions_tests.py
name: func_test_android8

runs-on: ubuntu-latest
Expand Down
60 changes: 0 additions & 60 deletions test/functional/android/activities_tests.py

This file was deleted.

61 changes: 0 additions & 61 deletions test/functional/android/applications_tests.py

This file was deleted.

77 changes: 0 additions & 77 deletions test/functional/android/context_switching_tests.py

This file was deleted.

102 changes: 74 additions & 28 deletions test/unit/webdriver/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,84 +23,130 @@ class TestWebDriverApp(object):
@httpretty.activate
def test_install_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/appium/device/install_app'), body='{"value": ""}'
)
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.install_app('path/to/app')

assert {'app': 'path/to/app'}, get_httpretty_request_body(httpretty.last_request())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this test's assertion was wrong. I'm fixing this kind of error as well as part of https://github.com/appium/python-client/issues

assert {
'args': [{'app': 'path/to/app', 'appPath': 'path/to/app'}],
'script': 'mobile: installApp',
} == get_httpretty_request_body(httpretty.last_request())
assert isinstance(result, WebDriver)

@httpretty.activate
def test_remove_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/appium/device/remove_app'), body='{"value": ""}'
)
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.remove_app('com.app.id')

assert {'app': 'com.app.id'}, get_httpretty_request_body(httpretty.last_request())
assert {
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
'script': 'mobile: removeApp',
} == get_httpretty_request_body(httpretty.last_request())
assert isinstance(result, WebDriver)

@httpretty.activate
def test_app_installed(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/appium/device/app_installed'), body='{"value": true}'
)
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
)
result = driver.is_app_installed("com.app.id")
assert {'app': "com.app.id"}, get_httpretty_request_body(httpretty.last_request())

assert {
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
'script': 'mobile: isAppInstalled',
} == get_httpretty_request_body(httpretty.last_request())
assert result is True

@httpretty.activate
def test_terminate_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/appium/device/terminate_app'), body='{"value": true}'
)
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
)
result = driver.terminate_app("com.app.id")
assert {'app': "com.app.id"}, get_httpretty_request_body(httpretty.last_request())

assert {
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
'script': 'mobile: terminateApp',
} == get_httpretty_request_body(httpretty.last_request())
assert result is True

@httpretty.activate
def test_activate_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/appium/device/activate_app'), body='{"value": ""}'
)
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.activate_app("com.app.id")

assert {'app': 'com.app.id'}, get_httpretty_request_body(httpretty.last_request())
assert {
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
'script': 'mobile: activateApp',
} == get_httpretty_request_body(httpretty.last_request())
assert isinstance(result, WebDriver)

@httpretty.activate
def test_background_app(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/appium/app/background'), body='{"value": ""}'
)
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.background_app(0)
assert {'app': 0}, get_httpretty_request_body(httpretty.last_request())

assert {'args': [{'seconds': 0}], 'script': 'mobile: backgroundApp'} == get_httpretty_request_body(
httpretty.last_request()
)
assert isinstance(result, WebDriver)

@httpretty.activate
def test_query_app_state(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/appium/device/app_state'), body='{"value": 3 }'
)
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": 3}')
result = driver.query_app_state('com.app.id')

assert {'app': 3}, get_httpretty_request_body(httpretty.last_request())
assert {
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
'script': 'mobile: queryAppState',
} == get_httpretty_request_body(httpretty.last_request())
assert result is ApplicationState.RUNNING_IN_BACKGROUND

@httpretty.activate
def test_app_strings(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/execute/sync'),
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
)
result = driver.app_strings()

assert {'args': [{}], 'script': 'mobile: getAppStrings'} == get_httpretty_request_body(httpretty.last_request())
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result

@httpretty.activate
def test_app_strings_with_lang(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/execute/sync'),
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
)
result = driver.app_strings('en')

assert {'args': [{'language': 'en'}], 'script': 'mobile: getAppStrings'} == get_httpretty_request_body(
httpretty.last_request()
)
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result

@httpretty.activate
def test_app_strings_with_lang_and_file(self):
driver = android_w3c_driver()
httpretty.register_uri(
httpretty.POST,
appium_command('/session/1234567890/execute/sync'),
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
)
result = driver.app_strings('en', 'some_file')

assert {
'args': [{'language': 'en', 'stringFile': 'some_file'}],
'script': 'mobile: getAppStrings',
} == get_httpretty_request_body(httpretty.last_request())
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result
Loading
Loading