Skip to content

Commit b4908db

Browse files
committed
tests: experimenting
2 parents 2048db7 + 99c4f27 commit b4908db

File tree

3 files changed

+93
-2
lines changed

3 files changed

+93
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
return {
2+
groupName = "bass.CreateMixerChannel",
3+
4+
cases = {
5+
{
6+
name = "Function exists when module enabled",
7+
when = HolyLib_IsModuleEnabled( "bass" ) and file.Exists("bin/libbass.so", "GAME"),
8+
func = function()
9+
expect( bass.CreatePushChannel ).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 = "Returns a valid IGModAudioChannel and nil error for valid call",
21+
when = HolyLib_IsModuleEnabled("bass"),
22+
func = function()
23+
local mixerChannel, err = bass.CreateMixerChannel(44100, 2, 0)
24+
25+
expect( mixerChannel ).to.exist()
26+
expect( mixerChannel ).to.beA( "IGModAudioChannel []")
27+
expect( err ).to.beNil()
28+
end
29+
}
30+
}
31+
}

gluatests/lua/tests/modules/bass/CreatePushChannel.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
return {
2-
groupName = "bass.CreateDummyChannel",
2+
groupName = "bass.CreatePushChannel",
33

44
cases = {
55
{
@@ -53,7 +53,7 @@ return {
5353
name = "Invalid arg types throw lua error",
5454
when = HolyLib_IsModuleEnabled( "bass" ),
5555
func = function()
56-
expect( bass.CreatePushChannel, "44000", 1, 0 ).to.err()
56+
expect( bass.CreatePushChannel, "We are definitely not horses", 1, 0 ).to.err()
5757
end
5858
},
5959
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
return {
2+
groupName = "IGModAudioChannel:SetPlaybackRate",
3+
4+
cases = {
5+
{
6+
name = "Function exists when module enabled",
7+
when = HolyLib_IsModuleEnabled( "bass" ),
8+
func = function()
9+
expect( FindMetaTable( "IGModAudioChannel" ).SetPlaybackRate ).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 = "Valid call sets the playback rate correctly",
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+
channel:SetPlaybackRate( 2 )
34+
expect( channel:GetPlaybackRate() ).to.equal( 2 )
35+
36+
done()
37+
end )
38+
end
39+
},
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+
}
59+
}
60+
}

0 commit comments

Comments
 (0)