From 4a9a6f664a371963dc25dbd3256290ec431baaad Mon Sep 17 00:00:00 2001 From: Maciej Kisielewski Date: Fri, 17 May 2019 12:15:57 +0200 Subject: hotkey_tests: add mute scenario Signed-off-by: Maciej Kisielewski --- bin/hotkey_tests.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/hotkey_tests.py b/bin/hotkey_tests.py index 556f0e58..5efdd47b 100755 --- a/bin/hotkey_tests.py +++ b/bin/hotkey_tests.py @@ -315,6 +315,8 @@ class VolumeChange: def __init__(self): self.before = 0 self.after = 0 + self.mute_before = None + self.mute_after = None class FauxKeyboard(): @@ -396,6 +398,18 @@ class HotKeyTesting: KeyCodes.KEY_VOLUMEDOWN, repetitions=3, delay=0.2) return vc.before > vc.after + def check_mute(self): + """ + Check if the mute key has an effect on ALSA + """ + # first, let's raise volume (if it was already muted, then it will + # unmute it) + self.kb.press_key(KeyCodes.KEY_VOLUMEUP) + vc = VolumeChange() + with self._monitored_volume_change(vc): + self.kb.press_key(KeyCodes.KEY_MUTE) + return vc.mute_after + @contextlib.contextmanager def _monitored_volume_change(self, vc): before = subprocess.check_output('amixer').decode( @@ -416,7 +430,7 @@ class HotKeyTesting: # we expect that the lines that changed are status information about # the output devices. Percentage volume is in square brackets so let's # search for those and see if they got higher - regex = re.compile(r'\[(\d*)%\]') + regex = re.compile(r'\[(\d*)%\].*\[(on|off)\]') if len(before) != len(after): # more of an assertion - the lines diff should match return @@ -426,6 +440,8 @@ class HotKeyTesting: if vol_a and vol_b: vc.before = int(vol_b[0]) vc.after = int(vol_a[0]) + vc.mute_before = vol_b[1] == 'off' + vc.mute_after = vol_a[1] == 'off' return def check_terminal_hotkey(self): -- cgit v1.2.3