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