Skip to content

Commit 8773351

Browse files
authored
test: cleanup ios (#1034)
1 parent 9a3a633 commit 8773351

File tree

7 files changed

+249
-167
lines changed

7 files changed

+249
-167
lines changed

.github/workflows/functional-test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ jobs:
2020
test_targets:
2121
- 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
2222
name: func_test_ios1
23-
- target: test/functional/ios/applications_tests.py test/functional/ios/hw_actions_tests.py test/functional/ios/keyboard_tests.py
24-
name: func_test_ios2
2523
- target: test/functional/ios/screen_record_tests.py test/functional/ios/webdriver_tests.py
26-
name: func_test_ios3
24+
name: func_test_ios2
2725

2826
runs-on: macos-14
2927

test/functional/ios/applications_tests.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

test/functional/ios/hw_actions_tests.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

test/functional/ios/keyboard_tests.py

Lines changed: 0 additions & 87 deletions
This file was deleted.

test/unit/webdriver/app_test.py

Lines changed: 135 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
from appium.webdriver.applicationstate import ApplicationState
1818
from appium.webdriver.webdriver import WebDriver
19-
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body
19+
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body, ios_w3c_driver
2020

2121

22-
class TestWebDriverApp(object):
22+
class TestWebDriverAppAndroid(object):
2323
@httpretty.activate
2424
def test_install_app(self):
2525
driver = android_w3c_driver()
@@ -150,3 +150,136 @@ def test_app_strings_with_lang_and_file(self):
150150
'script': 'mobile: getAppStrings',
151151
} == get_httpretty_request_body(httpretty.last_request())
152152
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result
153+
154+
155+
class TestWebDriverAppIOS(object):
156+
@httpretty.activate
157+
def test_install_app(self):
158+
driver = ios_w3c_driver()
159+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
160+
result = driver.install_app('path/to/app')
161+
162+
assert {
163+
'args': [{'app': 'path/to/app', 'appPath': 'path/to/app'}],
164+
'script': 'mobile: installApp',
165+
} == get_httpretty_request_body(httpretty.last_request())
166+
assert isinstance(result, WebDriver)
167+
168+
@httpretty.activate
169+
def test_remove_app(self):
170+
driver = ios_w3c_driver()
171+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
172+
result = driver.remove_app('com.app.id')
173+
174+
assert {
175+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
176+
'script': 'mobile: removeApp',
177+
} == get_httpretty_request_body(httpretty.last_request())
178+
assert isinstance(result, WebDriver)
179+
180+
@httpretty.activate
181+
def test_app_installed(self):
182+
driver = ios_w3c_driver()
183+
httpretty.register_uri(
184+
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
185+
)
186+
result = driver.is_app_installed("com.app.id")
187+
188+
assert {
189+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
190+
'script': 'mobile: isAppInstalled',
191+
} == get_httpretty_request_body(httpretty.last_request())
192+
assert result is True
193+
194+
@httpretty.activate
195+
def test_terminate_app(self):
196+
driver = ios_w3c_driver()
197+
httpretty.register_uri(
198+
httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": true}'
199+
)
200+
result = driver.terminate_app("com.app.id")
201+
202+
assert {
203+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
204+
'script': 'mobile: terminateApp',
205+
} == get_httpretty_request_body(httpretty.last_request())
206+
assert result is True
207+
208+
@httpretty.activate
209+
def test_activate_app(self):
210+
driver = ios_w3c_driver()
211+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
212+
result = driver.activate_app("com.app.id")
213+
214+
assert {
215+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
216+
'script': 'mobile: activateApp',
217+
} == get_httpretty_request_body(httpretty.last_request())
218+
assert isinstance(result, WebDriver)
219+
220+
@httpretty.activate
221+
def test_background_app(self):
222+
driver = ios_w3c_driver()
223+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": ""}')
224+
result = driver.background_app(0)
225+
226+
assert {'args': [{'seconds': 0}], 'script': 'mobile: backgroundApp'} == get_httpretty_request_body(
227+
httpretty.last_request()
228+
)
229+
assert isinstance(result, WebDriver)
230+
231+
@httpretty.activate
232+
def test_query_app_state(self):
233+
driver = ios_w3c_driver()
234+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'), body='{"value": 3}')
235+
result = driver.query_app_state('com.app.id')
236+
237+
assert {
238+
'args': [{'appId': 'com.app.id', 'bundleId': 'com.app.id'}],
239+
'script': 'mobile: queryAppState',
240+
} == get_httpretty_request_body(httpretty.last_request())
241+
assert result is ApplicationState.RUNNING_IN_BACKGROUND
242+
243+
@httpretty.activate
244+
def test_app_strings(self):
245+
driver = ios_w3c_driver()
246+
httpretty.register_uri(
247+
httpretty.POST,
248+
appium_command('/session/1234567890/execute/sync'),
249+
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
250+
)
251+
result = driver.app_strings()
252+
253+
assert {'args': [{}], 'script': 'mobile: getAppStrings'} == get_httpretty_request_body(httpretty.last_request())
254+
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result
255+
256+
@httpretty.activate
257+
def test_app_strings_with_lang(self):
258+
driver = ios_w3c_driver()
259+
httpretty.register_uri(
260+
httpretty.POST,
261+
appium_command('/session/1234567890/execute/sync'),
262+
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
263+
)
264+
result = driver.app_strings('en')
265+
266+
assert {'args': [{'language': 'en'}], 'script': 'mobile: getAppStrings'} == get_httpretty_request_body(
267+
httpretty.last_request()
268+
)
269+
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result
270+
271+
@httpretty.activate
272+
def test_app_strings_with_lang_and_file(self):
273+
driver = ios_w3c_driver()
274+
httpretty.register_uri(
275+
httpretty.POST,
276+
appium_command('/session/1234567890/execute/sync'),
277+
body='{"value": {"monkey_wipe_data": "You can\'t wipe my data, you are a monkey!"} }',
278+
)
279+
result = driver.app_strings('en', 'some_file')
280+
281+
assert {
282+
'args': [{'language': 'en', 'stringFile': 'some_file'}],
283+
'script': 'mobile: getAppStrings',
284+
} == get_httpretty_request_body(httpretty.last_request())
285+
assert 'You can\'t wipe my data, you are a monkey!' == result['monkey_wipe_data'], result

test/unit/webdriver/device/keyboard_test.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
import httpretty
1616

1717
from appium.webdriver.webdriver import WebDriver
18-
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body
18+
from test.unit.helper.test_helper import android_w3c_driver, appium_command, get_httpretty_request_body, ios_w3c_driver
1919

2020

21-
class TestWebDriverKeyboard(object):
21+
class TestWebDriverKeyboardAndroid(object):
2222
@httpretty.activate
2323
def test_hide_keyboard(self):
2424
driver = android_w3c_driver()
@@ -96,3 +96,38 @@ def test_long_press_keycode_with_flags(self):
9696
driver.long_press_keycode(86, metastate=0x00000001 | 0x00200000, flags=0x20 | 0x00000004 | 0x00000008),
9797
WebDriver,
9898
)
99+
100+
101+
class TestWebDriverKeyboardIOS(object):
102+
@httpretty.activate
103+
def test_hide_keyboard(self):
104+
driver = ios_w3c_driver()
105+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
106+
assert isinstance(driver.hide_keyboard(), WebDriver)
107+
assert {'args': [{}], 'script': 'mobile: hideKeyboard'} == get_httpretty_request_body(httpretty.last_request())
108+
109+
@httpretty.activate
110+
def test_hide_keyboard_with_key(self):
111+
driver = ios_w3c_driver()
112+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
113+
assert isinstance(driver.hide_keyboard(key_name='Done'), WebDriver)
114+
assert {'args': [{'keys': ['Done']}], 'script': 'mobile: hideKeyboard'} == get_httpretty_request_body(
115+
httpretty.last_request()
116+
)
117+
118+
@httpretty.activate
119+
def test_hide_keyboard_with_key_and_strategy(self):
120+
driver = ios_w3c_driver()
121+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
122+
assert isinstance(driver.hide_keyboard(strategy='pressKey', key='Done'), WebDriver)
123+
# only 'keys' works
124+
assert {'args': [{'keys': ['Done']}], 'script': 'mobile: hideKeyboard'} == get_httpretty_request_body(
125+
httpretty.last_request()
126+
)
127+
128+
@httpretty.activate
129+
def test_is_keyboard_shown(self):
130+
driver = ios_w3c_driver()
131+
httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/execute/sync'))
132+
driver.is_keyboard_shown(), WebDriver
133+
assert {'script': 'mobile: isKeyboardShown', 'args': []} == get_httpretty_request_body(httpretty.last_request())

0 commit comments

Comments
 (0)