Repository navigation
Expand file tree
/
Copy pathaudio_test.go
More file actions
65 lines (59 loc) · 1.81 KB
/
Copy pathaudio_test.go
File metadata and controls
65 lines (59 loc) · 1.81 KB
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
55
56
57
58
59
60
61
62
63
64
65
//go:build darwin
package vz_test
import (
"errors"
"testing"
"github.com/Code-Hex/vz/v4"
"github.com/Code-Hex/vz/v4/internal/objc"
"github.com/Code-Hex/vz/v4/internal/vzbridge"
)
func TestVirtioSoundDeviceInputStreamWithoutSource(t *testing.T) {
stream, err := vz.NewVirtioSoundDeviceInputStreamConfiguration()
if errors.Is(err, vz.ErrUnsupportedOSVersion) {
t.Skipf("not supported on this macOS version: %v", err)
}
if err != nil {
t.Fatal(err)
}
defer objc.Release(stream)
if objc.Ptr(stream) == nil {
t.Fatal("input stream has no native object")
}
if source := vzbridge.VZVirtioSoundDeviceInputStreamConfiguration_Source(stream); source != nil {
objc.Release(source)
t.Fatal("input stream has a host audio source")
}
device, err := vz.NewVirtioSoundDeviceConfiguration()
if err != nil {
t.Fatal(err)
}
defer objc.Release(device)
device.SetStreams(stream)
streams := vzbridge.VZVirtioSoundDeviceConfiguration_Streams(device)
defer objc.Release(streams)
if count := vzbridge.NSArray_Count(streams); count != 1 {
t.Fatalf("audio stream count = %d, want 1", count)
}
input := vzbridge.NSArray_ObjectAtIndex(streams, 0)
defer objc.Release(input)
if objc.Ptr(input) != objc.Ptr(stream) {
t.Fatal("audio device does not contain the input stream")
}
}
func TestVirtioSoundDeviceOutputStreamWithoutSink(t *testing.T) {
stream, err := vz.NewVirtioSoundDeviceOutputStreamConfiguration()
if errors.Is(err, vz.ErrUnsupportedOSVersion) {
t.Skipf("not supported on this macOS version: %v", err)
}
if err != nil {
t.Fatal(err)
}
defer objc.Release(stream)
if objc.Ptr(stream) == nil {
t.Fatal("output stream has no native object")
}
if sink := vzbridge.VZVirtioSoundDeviceOutputStreamConfiguration_Sink(stream); sink != nil {
objc.Release(sink)
t.Fatal("output stream has a host audio sink")
}
}