Skip to content

Commit

Permalink
Make changes as per reviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque committed Aug 7, 2017
1 parent bda6a10 commit 0f1de92
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
29 changes: 22 additions & 7 deletions src/AudioUnit/AudioComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,30 @@ public ResourceUsageInfo (NSDictionary dic) : base (dic) {}
public string[] IOKitUserClient {
get {
var array = GetNativeValue<NSArray> (userClientK);
return NSArray.StringArrayFromHandle (array.ClassHandle);
if (array == null )
return null;
return NSArray.StringArrayFromHandle (array.Handle);
}
set {
SetArrayValue (userClientK, value);
if (value == null)
SetArrayValue (userClientK, value);
else
RemoveValue (userClientK);
}
}

public string[] MachLookUpGlobalName {
get {
var array = GetNativeValue<NSArray> (globalNameK);
return NSArray.StringArrayFromHandle (array.ClassHandle);
if (array == null)
return null;
return NSArray.StringArrayFromHandle (array.Handle);
}
set {
SetArrayValue (globalNameK, value);
if (value == null)
SetArrayValue (globalNameK, value);
else
RemoveValue (globalNameK);
}
}

Expand Down Expand Up @@ -176,17 +186,22 @@ public ResourceUsageInfo ResourceUsage {
return GetStrongDictionary<ResourceUsageInfo> (resourceUsageK);
}
set {
SetNativeValue (resourceUsageK, value.Dictionary, true);
SetNativeValue (resourceUsageK, value?.Dictionary, true);
}
}

public string[] Tags {
get {
var array = GetNativeValue<NSArray> (tagsK);
return NSArray.StringArrayFromHandle (array.ClassHandle);
if (array == null)
return null;
return NSArray.StringArrayFromHandle (array.Handle);
}
set {
SetArrayValue (tagsK, value);
if (value == null)
RemoveValue (tagsK);
else
SetArrayValue (tagsK, value);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AudioUnit/AudioUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public struct RampStruct
[StructLayout (LayoutKind.Sequential)]
public struct ImmediateStruct
{
public uint bBufferOffset;
public uint BufferOffset;
public float Value;
}

Expand Down
37 changes: 37 additions & 0 deletions tests/monotouch-test/AudioToolbox/AudioComponentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,43 @@ public void GetSetComponentList ()
Assert.Throws <InvalidOperationException> (() => component.ComponentList = l);
}
}

// test the diff properties of the ResourceUsageInfo since it was manually done

[Test]
public void TestResourceUsageInfoIOKitUserClient ()
{
TestRuntime.AssertXcodeVersion (9, 0);
var clientId = "CustomUserClient1";
var resources = new ResourceUsageInfo ();
resources.IOKitUserClient = new string[] { clientId };
var userClientList = resources.IOKitUserClient;
Assert.AreEqual (1, userClientList.Length, "List does not have all client ids.");
Assert.AreEqual (clientId, userClientList [0], "Client ids are not the same.");

// similar test but with null values.

resources.IOKitUserClient = null;
Assert.IsNull (resources.IOKitUserClient, "Value was not set to null.");
}

[Test]
public void TestResourceUsageInfoMachLookUpGlobalName ()
{
TestRuntime.AssertXcodeVersion (9, 0);
var serviceName = "MachServiceName1";
var resources = new ResourceUsageInfo ();
resources.MachLookUpGlobalName = new string[] { serviceName };
var serviceNames = resources.MachLookUpGlobalName;

Assert.AreEqual (1, serviceNames.Length, "List does not have all service names.");
Assert.AreEqual (serviceName, serviceNames [0], "Service names are not equal.");

// similar test but with null values

resources.MachLookUpGlobalName = null;
Assert.IsNull (resources.MachLookUpGlobalName, "Value was no set to null.");
}
}
}

Expand Down

0 comments on commit 0f1de92

Please sign in to comment.