@@ -389,15 +389,31 @@ def test_threshold_cross_signal_emitted(self, qtbot, monkeypatch):
389
389
) # TODO
390
390
class TestRestrictedWebView :
391
391
@pytest .fixture
392
- def browser_widget (self , qtbot ):
393
- widget = widgets .RestrictedWebView (
392
+ def browser_widget_factory (self , qtbot ):
393
+ created_widgets = []
394
+
395
+ def _browser_widget (* args , ** kwargs ):
396
+ widget = widgets .RestrictedWebView (* args , ** kwargs )
397
+ created_widgets .append (widget )
398
+ qtbot .addWidget (widget )
399
+ return widget
400
+
401
+ yield _browser_widget
402
+
403
+ for widget in created_widgets :
404
+ try :
405
+ page = widget .webEngineView .page ()
406
+ except RuntimeError :
407
+ continue
408
+ with qtbot .waitSignal (page .destroyed ):
409
+ widget .close ()
410
+
411
+ @pytest .fixture
412
+ def browser_widget (self , qtbot , browser_widget_factory ):
413
+ yield browser_widget_factory (
394
414
url = QUrl ('http://localhost/trusted/start' ),
395
415
trusted_url_prefix = 'http://localhost/trusted/' ,
396
416
)
397
- qtbot .addWidget (widget )
398
- yield widget
399
- with qtbot .waitSignal (widget .webEngineView .page ().destroyed , timeout = 100 ):
400
- widget .close ()
401
417
402
418
def test_default_prefix (self , qtbot ):
403
419
widget = widgets .RestrictedWebView (url = 'http://localhost/' )
@@ -416,6 +432,7 @@ def test_get_set_url(self, qtbot, browser_widget):
416
432
assert not browser_widget .setUrl ('http://localhost/external/page' )
417
433
assert browser_widget .url () == QUrl ('http://localhost/trusted/other' )
418
434
435
+ @pytest .mark .xfail (sys .platform == 'win32' , reason = 'Tends to fail on Windows' )
419
436
def test_home_button_loads_home (self , qtbot , browser_widget ):
420
437
browser_widget .setUrl ('http://localhost/trusted/other' )
421
438
with qtbot .waitSignal (browser_widget .webEngineView .urlChanged ):
@@ -457,3 +474,18 @@ def test_change_prefix(self, mock_open, qtbot, browser_widget):
457
474
)
458
475
assert result is True
459
476
mock_open .assert_not_called ()
477
+
478
+ def test_tool_and_status_tips (self , qtbot , browser_widget_factory ):
479
+ widget = browser_widget_factory ('http://localhost/' )
480
+ assert len (widget .uiPushHome .toolTip ()) > 0
481
+ assert len (widget .uiPushHome .statusTip ()) == 0
482
+ widget = browser_widget_factory (
483
+ 'http://localhost/' , use_tool_tips = False , use_status_tips = True
484
+ )
485
+ assert len (widget .uiPushHome .toolTip ()) == 0
486
+ assert len (widget .uiPushHome .statusTip ()) > 0
487
+ widget = browser_widget_factory (
488
+ 'http://localhost/' , use_tool_tips = True , use_status_tips = False
489
+ )
490
+ assert len (widget .uiPushHome .toolTip ()) > 0
491
+ assert len (widget .uiPushHome .statusTip ()) == 0
0 commit comments