Skip to content

Commit

Permalink
[LG Sound Sync] Test SPDIF status register parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
qerub committed Jan 25, 2020
1 parent 4717a91 commit a1cf81d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hifiberrydsp/lg/soundsync.py
Expand Up @@ -30,7 +30,12 @@
from hifiberrydsp.hardware.adau145x import Adau145x
from hifiberrydsp.filtering.volume import percent2amplification
from hifiberrydsp import datatools
from hifiberrydsp.hardware.spi import SpiHandler

try:
from hifiberrydsp.hardware.spi import SpiHandler
# depends on spidev and is not required to run tests
except:
pass

logger = logging.getLogger("LG Sound Sync")

Expand Down
19 changes: 19 additions & 0 deletions hifiberrydsp/lg/test_soundsync.py
@@ -0,0 +1,19 @@
from unittest import TestCase

from hifiberrydsp.lg.soundsync import SoundSync

class TestSoundSync(TestCase):
def test_parse_volume_with_missing_sound_sync_signature(self):
assert SoundSync.parse_volume_from_status(b'\xff\xff\xff\xff\xff\xff') is None

def test_parse_out_of_range_volume(self):
assert SoundSync.parse_volume_from_status(b'\x00\x1f\xff\x04\x8a\x62') is None

def test_parse_volume_of_0(self):
assert SoundSync.parse_volume_from_status(b'\x00\x10\x0f\x04\x8a\x62') == 0

def test_parse_volume_of_50(self):
assert SoundSync.parse_volume_from_status(b'\x00\x13\x2f\x04\x8a\x62') == 50

def test_parse_volume_of_100(self):
assert SoundSync.parse_volume_from_status(b'\x00\x16\x4f\x04\x8a\x62') == 100

0 comments on commit a1cf81d

Please sign in to comment.