|
16 | 16 |
|
17 | 17 | from appium.webdriver.applicationstate import ApplicationState |
18 | 18 | 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 |
20 | 20 |
|
21 | 21 |
|
22 | | -class TestWebDriverApp(object): |
| 22 | +class TestWebDriverAppAndroid(object): |
23 | 23 | @httpretty.activate |
24 | 24 | def test_install_app(self): |
25 | 25 | driver = android_w3c_driver() |
@@ -150,3 +150,136 @@ def test_app_strings_with_lang_and_file(self): |
150 | 150 | 'script': 'mobile: getAppStrings', |
151 | 151 | } == get_httpretty_request_body(httpretty.last_request()) |
152 | 152 | 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 |
0 commit comments