Skip to content

Commit bf1cbc8

Browse files
committed
tests: some stuff
- added basic GetPlaybackRate tests - adjusted SetPlaybackRate tests
1 parent 2c54256 commit bf1cbc8

File tree

2 files changed

+63
-19
lines changed

2 files changed

+63
-19
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
return {
2+
groupName = "IGModAudioChannel:GetPlaybackRate",
3+
4+
cases = {
5+
{
6+
name = "Function exists when module enabled",
7+
when = HolyLib_IsModuleEnabled( "bass" ),
8+
func = function()
9+
expect( FindMetaTable( "IGModAudioChannel" ).GetPlaybackRate ).to.beA( "function" )
10+
end
11+
},
12+
{
13+
name = "Function is nil when module disabled",
14+
when = not HolyLib_IsModuleEnabled( "bass" ),
15+
func = function()
16+
expect( bass ).to.beA( "nil" )
17+
end
18+
},
19+
{
20+
name = "GetPlaybackRate returns a number",
21+
when = HolyLib_IsModuleEnabled( "bass" ),
22+
async = true,
23+
timeout = 2,
24+
func = function()
25+
local filePath = "sound/bass_testsound.wav"
26+
local flags = ""
27+
28+
bass.PlayFile( filePath, flags, function( channel, errorCode, errorMsg )
29+
expect( channel ).to.beValid()
30+
expect( errorCode ).to.equal( 0 )
31+
expect( errorMsg ).to.beNil()
32+
33+
local rate = channel:GetPlaybackRate()
34+
expect( rate ).to.beA( "number" )
35+
36+
done()
37+
end )
38+
end
39+
},
40+
{
41+
name = "Matches value set with SetPlaybackRate",
42+
when = HolyLib_IsModuleEnabled( "bass" ),
43+
async = true,
44+
timeout = 2,
45+
func = function()
46+
local filePath = "sound/bass_testsound.wav"
47+
local flags = ""
48+
49+
bass.PlayFile( filePath, flags, function( channel, errCode, errMsg )
50+
expect( channel ).to.beValid()
51+
52+
channel:SetPlaybackRate( 1.5 )
53+
expect( channel:GetPlaybackRate() ).to.equal( 1.5 )
54+
55+
channel:SetPlaybackRate( 0.75 )
56+
expect( channel:GetPlaybackRate() ).to.equal( 0.75 )
57+
58+
done()
59+
end)
60+
end
61+
},
62+
}
63+
}

gluatests/lua/tests/modules/bass/igmodaudiochannel/SetPlaybackrate.lua

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,5 @@ return {
3737
end )
3838
end
3939
},
40-
{
41-
name = "SetPlaybackRate works after pausing or stopping the channel",
42-
when = HolyLib_IsModuleEnabled("bass"),
43-
async = true,
44-
func = function()
45-
local filePath = "sound/bass_testsound.wav"
46-
local flags = ""
47-
48-
bass.PlayFile(filePath, flags, function( channel )
49-
channel:Pause()
50-
expect( channel:SetPlaybackRate, 1 ).toNot.err()
51-
52-
channel:Stop()
53-
expect( channel:SetPlaybackRate, 1.2 ).to.err()
54-
55-
done()
56-
end )
57-
end
58-
}
5940
}
6041
}

0 commit comments

Comments
 (0)