(self, meth, **kwargs)
| 258 | webbrowser.objc = self.orig_objc |
| 259 | |
| 260 | def _test(self, meth, **kwargs): |
| 261 | # The browser always gets focus, there's no concept of separate browser |
| 262 | # windows, and there's no API-level control over creating a new tab. |
| 263 | # Therefore, all calls to webbrowser are effectively the same. |
| 264 | getattr(webbrowser, meth)(URL, **kwargs) |
| 265 | |
| 266 | # The ObjC String version of the URL is created with UTF-8 encoding |
| 267 | url_string_args = [ |
| 268 | "C#NSString", |
| 269 | "S#stringWithCString:encoding:", |
| 270 | b'https://www.example.com', |
| 271 | 4, |
| 272 | ] |
| 273 | # The NSURL version of the URL is created from that string |
| 274 | url_obj_args = [ |
| 275 | "C#NSURL", |
| 276 | "S#URLWithString:", |
| 277 | self._obj_ref(*url_string_args), |
| 278 | ] |
| 279 | # The openURL call is invoked on the shared application |
| 280 | shared_app_args = ["C#UIApplication", "S#sharedApplication"] |
| 281 | |
| 282 | # Verify that the last call is the one that opens the URL. |
| 283 | webbrowser.objc.objc_msgSend.assert_called_with( |
| 284 | self._obj_ref(*shared_app_args), |
| 285 | "S#openURL:options:completionHandler:", |
| 286 | self._obj_ref(*url_obj_args), |
| 287 | None, |
| 288 | None |
| 289 | ) |
| 290 | |
| 291 | def test_open(self): |
| 292 | self._test('open') |
no test coverage detected