/
AudioUnitTest.cs
96 lines (85 loc) · 2.54 KB
/
AudioUnitTest.cs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// Unit tests for AudioUnit
//
#if !__WATCHOS__
using System.Runtime.InteropServices;
using NUnit.Framework;
using Foundation;
using AudioUnit;
using AudioToolbox;
using ObjCRuntime;
namespace MonoTouchFixtures.AudioUnit {
[TestFixture]
[Preserve (AllMembers = true)]
public class AudioUnitTest {
[Test]
public void DisposeMethodTest ()
{
// Test case from bxc #5410
// Create instance of AudioUnit object
AudioComponentDescription cd = new AudioComponentDescription () {
ComponentType = AudioComponentType.Output,
#if MONOMAC
#if NET
ComponentSubType = AudioUnitSubType.VoiceProcessingIO,
#else
ComponentSubType = (int)AudioUnitSubType.VoiceProcessingIO,
#endif
#else
#if NET
ComponentSubType = (AudioUnitSubType) AudioTypeOutput.Remote,
#else
ComponentSubType = 0x72696f63, // Remote_IO
#endif
#endif
ComponentManufacturer = AudioComponentManufacturerType.Apple
};
AudioComponent component = AudioComponent.FindComponent (ref cd);
var audioUnit = component.CreateAudioUnit ();
audioUnit.Dispose ();
}
[Test]
public void GetElementCount ()
{
var graph = new AUGraph ();
var mixerNode = graph.AddNode (AudioComponentDescription.CreateMixer (AudioTypeMixer.MultiChannel));
graph.Open ();
var mixer = graph.GetNodeInfo (mixerNode);
Assert.AreEqual (1, mixer.GetElementCount (AudioUnitScopeType.Global));
}
[Test]
public void CopyIconTest ()
{
TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
AudioComponentDescription cd = new AudioComponentDescription () {
ComponentType = AudioComponentType.Output,
#if MONOMAC
#if NET
ComponentSubType = AudioUnitSubType.VoiceProcessingIO,
#else
ComponentSubType = (int)AudioUnitSubType.VoiceProcessingIO,
#endif
#else
#if NET
ComponentSubType = (AudioUnitSubType) AudioTypeOutput.Remote,
#else
ComponentSubType = 0x72696f63, // Remote_IO
#endif
#endif
ComponentManufacturer = AudioComponentManufacturerType.Apple
};
AudioComponent component = AudioComponent.FindComponent (ref cd);
Assert.DoesNotThrow (() => {
var icon = component.CopyIcon (); // ensuring that the manual binding does not throw, we do not care about the result
});
}
[Test]
public unsafe void TestSizeOf ()
{
Assert.AreEqual (sizeof (AudioFormat), Marshal.SizeOf (typeof (AudioFormat)));
Assert.AreEqual (sizeof (AudioValueRange), Marshal.SizeOf (typeof (AudioValueRange)));
Assert.AreEqual (sizeof (AudioClassDescription), Marshal.SizeOf (typeof (AudioClassDescription)));
}
}
}
#endif // !__WATCHOS__