[arkit] Update for Xcode 9 beta 5 - Part 2 (#2505)
- Add last missing selector. - Add tests for manual code.
This commit is contained in:
Родитель
11c099b3f5
Коммит
302878b99b
|
@ -20,7 +20,18 @@ namespace XamCore.ARKit {
|
|||
get {
|
||||
var count = (int)Count;
|
||||
var rv = new Vector3 [count];
|
||||
var ptr = (Vector3*)_GetPoints ();
|
||||
var ptr = (Vector3*)GetRawPoints ();
|
||||
for (int i = 0; i < count; i++)
|
||||
rv [i] = *ptr++;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe ulong [] Identifiers {
|
||||
get {
|
||||
var count = (int)Count;
|
||||
var rv = new ulong [count];
|
||||
var ptr = (ulong*)GetRawIdentifiers ();
|
||||
for (int i = 0; i < count; i++)
|
||||
rv [i] = *ptr++;
|
||||
return rv;
|
||||
|
|
10
src/arkit.cs
10
src/arkit.cs
|
@ -10,6 +10,7 @@
|
|||
#if XAMCORE_2_0
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using XamCore.CoreFoundation;
|
||||
using XamCore.CoreGraphics;
|
||||
using XamCore.CoreMedia;
|
||||
|
@ -279,8 +280,13 @@ namespace XamCore.ARKit {
|
|||
[Export ("count")]
|
||||
nuint Count { get; }
|
||||
|
||||
[Internal, Export ("points")]
|
||||
IntPtr _GetPoints ();
|
||||
[EditorBrowsable (EditorBrowsableState.Advanced)]
|
||||
[Protected, Export ("points")]
|
||||
IntPtr GetRawPoints ();
|
||||
|
||||
[EditorBrowsable (EditorBrowsableState.Advanced)]
|
||||
[Protected, Export ("identifiers")]
|
||||
IntPtr GetRawIdentifiers ();
|
||||
}
|
||||
|
||||
[iOS (11,0)]
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
//
|
||||
// Unit tests for ARPointCloud
|
||||
//
|
||||
// Authors:
|
||||
// Vincent Dondain <vidondai@microsoft.com>
|
||||
//
|
||||
// Copyright 2017 Microsoft. All rights reserved.
|
||||
//
|
||||
|
||||
#if XAMCORE_2_0 && __IOS__
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using ARKit;
|
||||
using AVFoundation;
|
||||
using Foundation;
|
||||
using NUnit.Framework;
|
||||
using ObjCRuntime;
|
||||
using OpenTK;
|
||||
|
||||
namespace MonoTouchFixtures.ARKit {
|
||||
|
||||
class ARPointCloudPoker : ARPointCloud {
|
||||
|
||||
GCHandle vectorArrayHandle;
|
||||
GCHandle identifiersHandle;
|
||||
Vector3 [] vectorArray;
|
||||
ulong [] identifiers;
|
||||
|
||||
public ARPointCloudPoker () : base (IntPtr.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
public override nuint Count {
|
||||
get {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
protected unsafe override IntPtr GetRawPoints ()
|
||||
{
|
||||
vectorArray = new Vector3 [] { new Vector3 (1, 2, 3), new Vector3 (4, 5, 6) };
|
||||
if (!vectorArrayHandle.IsAllocated)
|
||||
vectorArrayHandle = GCHandle.Alloc (vectorArray, GCHandleType.Pinned);
|
||||
Vector3* addr = (Vector3*)vectorArrayHandle.AddrOfPinnedObject ();
|
||||
return (IntPtr)addr;
|
||||
}
|
||||
|
||||
protected unsafe override IntPtr GetRawIdentifiers ()
|
||||
{
|
||||
identifiers = new ulong [] { 0, 1 };
|
||||
if (!identifiersHandle.IsAllocated)
|
||||
identifiersHandle = GCHandle.Alloc (identifiers, GCHandleType.Pinned);
|
||||
ulong* addr = (ulong*)identifiersHandle.AddrOfPinnedObject ();
|
||||
return (IntPtr)addr;
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
base.Dispose (disposing);
|
||||
if (vectorArrayHandle.IsAllocated)
|
||||
vectorArrayHandle.Free ();
|
||||
if (identifiersHandle.IsAllocated)
|
||||
identifiersHandle.Free ();
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
[Preserve (AllMembers = true)]
|
||||
public class ARPointCloudTest {
|
||||
|
||||
[SetUp]
|
||||
public void Setup ()
|
||||
{
|
||||
TestRuntime.AssertXcodeVersion (9, 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PointsTest ()
|
||||
{
|
||||
var cloud = new ARPointCloudPoker ();
|
||||
|
||||
var points = cloud.Points;
|
||||
Assert.AreEqual (new Vector3 (1, 2, 3), cloud.Points [0]);
|
||||
Assert.AreEqual (new Vector3 (4, 5, 6), cloud.Points [1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IdentifiersTest ()
|
||||
{
|
||||
var cloud = new ARPointCloudPoker ();
|
||||
|
||||
var points = cloud.Identifiers;
|
||||
Assert.AreEqual (0, cloud.Identifiers [0]);
|
||||
Assert.AreEqual (1, cloud.Identifiers [1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // XAMCORE_2_0 && __IOS__
|
|
@ -659,6 +659,7 @@
|
|||
<Compile Include="PassKit\PKPaymentRequestTest.cs" />
|
||||
<Compile Include="AudioToolbox\AudioComponentTest.cs" />
|
||||
<Compile Include="UIKit\DirectionalEdgeInsetsTest.cs" />
|
||||
<Compile Include="ARKit\ARPointCloudTest.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
@ -725,6 +726,7 @@
|
|||
<Folder Include="System.Net.Http\" />
|
||||
<Folder Include="OpenGLES\" />
|
||||
<Folder Include="HomeKit\" />
|
||||
<Folder Include="ARKit\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="AudioToolbox\1.caf" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче