Show incoming fight reactions on unfocused visible players
This commit is contained in:
@@ -44,7 +44,7 @@ def test_strip_is_native_positioned_and_does_not_steal_focus(room, qtbot, kind):
|
||||
qtbot.wait(50)
|
||||
bounds = QRect(video.mapToGlobal(QPoint(0, 0)), video.size())
|
||||
assert bounds.contains(strip.geometry())
|
||||
QApplication.sendEvent(room, QEvent(QEvent.Type.WindowDeactivate))
|
||||
QApplication.sendEvent(room, QEvent(QEvent.Type.Hide))
|
||||
assert not strip.isVisible()
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ def test_arcade_ko_covers_video_then_restores_strip(room, qtbot):
|
||||
assert overlay.ko_animation.state() == overlay.ko_animation.State.Stopped
|
||||
|
||||
|
||||
def test_sound_is_enabled_by_default_and_background_effects_are_suppressed(room, qtbot, monkeypatch):
|
||||
def test_sound_is_enabled_by_default_and_hidden_effects_are_suppressed(room, qtbot, monkeypatch):
|
||||
play = Mock()
|
||||
monkeypatch.setattr(room, '_play_reaction_sound', play)
|
||||
room.activateWindow()
|
||||
@@ -109,6 +109,29 @@ def test_sound_is_enabled_by_default_and_background_effects_are_suppressed(room,
|
||||
assert not room.ringside_strip.isVisible()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('kind', ['ko', 'bell'])
|
||||
def test_receiving_client_shows_reaction_without_focus(room, qtbot, monkeypatch, kind):
|
||||
from PyQt6.QtWidgets import QLineEdit
|
||||
other_client = QLineEdit()
|
||||
qtbot.addWidget(other_client)
|
||||
other_client.show()
|
||||
other_client.activateWindow()
|
||||
other_client.setFocus()
|
||||
qtbot.wait(30)
|
||||
assert not room.isActiveWindow()
|
||||
play = Mock()
|
||||
monkeypatch.setattr(room, '_play_reaction_sound', play)
|
||||
room.handle_fight_reaction({'kind': kind, 'username': 'Other client', 'position': 0})
|
||||
assert room.ringside_strip.isVisible()
|
||||
play.assert_called_once_with(kind)
|
||||
assert QApplication.focusWidget() is other_client
|
||||
QApplication.sendEvent(room, QEvent(QEvent.Type.WindowDeactivate))
|
||||
assert room.ringside_strip.isVisible()
|
||||
room.showMinimized()
|
||||
qtbot.wait(30)
|
||||
assert not room.ringside_strip.isVisible()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('kind', REACTIONS)
|
||||
def test_original_sound_files_are_valid_and_loadable(qtbot, tmp_path, kind):
|
||||
path = write_reaction_sound(tmp_path, kind)
|
||||
|
||||
Reference in New Issue
Block a user