aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/test/solo_tool_volume_integrationtest.py
blob: cc1aeef9ba45f939af0bda50fc712f3117e15c4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pytest

from fixtures import soloTool as uut, mockPlayer, testSongs

def test_perSongVolumeFlow(uut, mockPlayer, testSongs):
    # Before a song is added, the volume starts at 100%
    assert uut.song is None
    assert mockPlayer.currentSong == None
    assert uut.volume == 1.0
    assert mockPlayer.volume == 1.0

    # When songs are added, their volume starts at 100%
    uut.addSong(testSongs[0])
    assert uut.song == 0
    assert uut.volume == 1.0
    assert mockPlayer.volume == 1.0

    # It's possible to change the volume
    uut.volume = 0.5
    assert uut.volume == 0.5
    assert mockPlayer.volume == 0.5

    # New song song is added, volume stays because the new song is not selected
    uut.addSong(testSongs[1])
    assert uut.song == 0
    assert uut.volume == 0.5
    assert mockPlayer.volume == 0.5

    # Select new song, volume is 100%
    uut.song = 1
    assert uut.volume == 1.0
    assert mockPlayer.volume == 1.0

    uut.volume = 0.75

    # Previous song retains its volume
    uut.song = 0
    assert uut.volume == 0.5
    assert mockPlayer.volume == 0.5

    # New song also
    uut.song = 1
    assert uut.volume == 0.75
    assert mockPlayer.volume == 0.75

def test_perSongVolumeEdgeCases(uut, mockPlayer, testSongs):
    # If the player volume is not 100% when the first song is added, it is set to 100%
    uut.volume = 0.5
    assert mockPlayer.volume == 0.5

    uut.addSong(testSongs[0])
    assert uut.volume == 1.0
    assert mockPlayer.volume == 1.0