Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: cleanup ios func tests a bit #1034

Merged
merged 1 commit into from
Sep 27, 2024
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
4 changes: 1 addition & 3 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ jobs:
test_targets:
- target: test/functional/ios/search_context/find_by_*.py test/functional/ios/remote_fs_tests.py test/functional/ios/safari_tests.py test/functional/ios/execute_driver_tests.py
name: func_test_ios1
- target: test/functional/ios/applications_tests.py test/functional/ios/hw_actions_tests.py test/functional/ios/keyboard_tests.py
name: func_test_ios2
- target: test/functional/ios/screen_record_tests.py test/functional/ios/webdriver_tests.py
name: func_test_ios3
name: func_test_ios2

runs-on: macos-14

Expand Down
33 changes: 0 additions & 33 deletions test/functional/ios/applications_tests.py

This file was deleted.

38 changes: 0 additions & 38 deletions test/functional/ios/hw_actions_tests.py

This file was deleted.

87 changes: 0 additions & 87 deletions test/functional/ios/keyboard_tests.py

This file was deleted.

137 changes: 135 additions & 2 deletions test/unit/webdriver/app_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

from appium.webdriver.applicationstate import ApplicationState
from appium.webdriver.webdriver import WebDriver
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body, ios_w3c_driver


class TestWebDriverApp(object):
class TestWebDriverAppAndroid(object):
@httpretty.activate
def test_install_app(self):
driver = android_w3c_driver()
Expand Down Expand Up @@ -150,3 +150,136 @@ def test_app_strings_with_lang_and_file(self):
'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


class TestWebDriverAppIOS(object):
@httpretty.activate
def test_install_app(self):
driver = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.install_app('path/to/app')

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 = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.remove_app('com.app.id')

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 = ios_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
)
result = driver.is_app_installed("com.app.id")

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 = ios_w3c_driver()
httpretty.register_uri(
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
)
result = driver.terminate_app("com.app.id")

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 = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.activate_app("com.app.id")

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 = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
result = driver.background_app(0)

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 = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": 3}')
result = driver.query_app_state('com.app.id')

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 = ios_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 = ios_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 = ios_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
39 changes: 37 additions & 2 deletions test/unit/webdriver/device/keyboard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import httpretty

from appium.webdriver.webdriver import WebDriver
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body, ios_w3c_driver


class TestWebDriverKeyboard(object):
class TestWebDriverKeyboardAndroid(object):
@httpretty.activate
def test_hide_keyboard(self):
driver = android_w3c_driver()
Expand Down Expand Up @@ -96,3 +96,38 @@ def test_long_press_keycode_with_flags(self):
driver.long_press_keycode(86, metastate=0x00000001 | 0x00200000, flags=0x20 | 0x00000004 | 0x00000008),
WebDriver,
)


class TestWebDriverKeyboardIOS(object):
@httpretty.activate
def test_hide_keyboard(self):
driver = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
assert isinstance(driver.hide_keyboard(), WebDriver)
assert {'args': [{}], 'script': 'mobile: hideKeyboard'} == get_httpretty_request_body(httpretty.last_request())

@httpretty.activate
def test_hide_keyboard_with_key(self):
driver = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
assert isinstance(driver.hide_keyboard(key_name='Done'), WebDriver)
assert {'args': [{'keys': ['Done']}], 'script': 'mobile: hideKeyboard'} == get_httpretty_request_body(
httpretty.last_request()
)

@httpretty.activate
def test_hide_keyboard_with_key_and_strategy(self):
driver = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
assert isinstance(driver.hide_keyboard(strategy='pressKey', key='Done'), WebDriver)
# only 'keys' works
assert {'args': [{'keys': ['Done']}], 'script': 'mobile: hideKeyboard'} == get_httpretty_request_body(
httpretty.last_request()
)

@httpretty.activate
def test_is_keyboard_shown(self):
driver = ios_w3c_driver()
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
driver.is_keyboard_shown(), WebDriver
assert {'script': 'mobile: isKeyboardShown', 'args': []} == get_httpretty_request_body(httpretty.last_request())
Loading
Loading