test(media_player): spied sleep proves a non-default digit delay (0.3 s) reaches the channel sequence — option consumed per digit (t26 F3)
This commit is contained in:
1 parent
67174b8536
commit
2e63135745
1 file changed
+31
@@ -724,6 +724,37 @@ class TestAdbCommandService:
|
|||||||
assert not player.hass.services.has_service("nvidia_shield", "adb_command")
|
assert not player.hass.services.has_service("nvidia_shield", "adb_command")
|
||||||
|
|
||||||
|
|
||||||
|
class TestChannelDigitDelayConsumed:
|
||||||
|
"""t26 F3: a non-default digit delay reaches the sequence's sleep."""
|
||||||
|
|
||||||
|
async def test_non_default_delay_reaches_the_sequence_sleep(self, modules):
|
||||||
|
import asyncio
|
||||||
|
|
||||||
|
player, _s = _ladder_player(modules)
|
||||||
|
player._entry.options["channel_digit_delay"] = 0.3 # non-default
|
||||||
|
|
||||||
|
sleeps: list[float] = []
|
||||||
|
real_sleep = asyncio.sleep
|
||||||
|
|
||||||
|
mp_module = sys.modules["nsh.media_player"]
|
||||||
|
real_module_sleep = mp_module.asyncio.sleep
|
||||||
|
|
||||||
|
async def spying_sleep(delay, *args):
|
||||||
|
sleeps.append(delay)
|
||||||
|
await real_sleep(0)
|
||||||
|
|
||||||
|
mp_module.asyncio.sleep = spying_sleep
|
||||||
|
try:
|
||||||
|
await player.async_play_media("channel", "123")
|
||||||
|
if player._channel_task is not None:
|
||||||
|
await player._channel_task # the sequence runs to completion
|
||||||
|
finally:
|
||||||
|
mp_module.asyncio.sleep = real_module_sleep
|
||||||
|
|
||||||
|
# three digits → three sleeps, each with the option's 0.3 s
|
||||||
|
assert sleeps == [0.3, 0.3, 0.3]
|
||||||
|
|
||||||
|
|
||||||
class TestTextEntry:
|
class TestTextEntry:
|
||||||
"""P5-2: text entry — protocol IME first, ADB input-text fallback."""
|
"""P5-2: text entry — protocol IME first, ADB input-text fallback."""
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user