2017-08-23 23:58:26 +03:00
|
|
|
|
//
|
|
|
|
|
// 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;
|
2017-09-13 18:08:39 +03:00
|
|
|
|
|
|
|
|
|
using MatrixFloat2x2 = global::OpenTK.NMatrix2;
|
|
|
|
|
using MatrixFloat3x3 = global::OpenTK.NMatrix3;
|
|
|
|
|
using MatrixFloat4x4 = global::OpenTK.NMatrix4;
|
|
|
|
|
using VectorFloat3 = global::OpenTK.NVector3;
|
2017-08-23 23:58:26 +03:00
|
|
|
|
|
|
|
|
|
namespace MonoTouchFixtures.ARKit {
|
|
|
|
|
|
|
|
|
|
class ARPointCloudPoker : ARPointCloud {
|
|
|
|
|
|
|
|
|
|
GCHandle vectorArrayHandle;
|
|
|
|
|
GCHandle identifiersHandle;
|
2017-09-08 16:00:46 +03:00
|
|
|
|
VectorFloat3 [] vectorArray;
|
2017-08-23 23:58:26 +03:00
|
|
|
|
ulong [] identifiers;
|
|
|
|
|
|
|
|
|
|
public ARPointCloudPoker () : base (IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override nuint Count {
|
|
|
|
|
get {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected unsafe override IntPtr GetRawPoints ()
|
|
|
|
|
{
|
2017-09-08 16:00:46 +03:00
|
|
|
|
vectorArray = new VectorFloat3 [] { new VectorFloat3 (1, 2, 3), new VectorFloat3 (4, 5, 6) };
|
2017-08-23 23:58:26 +03:00
|
|
|
|
if (!vectorArrayHandle.IsAllocated)
|
|
|
|
|
vectorArrayHandle = GCHandle.Alloc (vectorArray, GCHandleType.Pinned);
|
2017-09-08 16:00:46 +03:00
|
|
|
|
return vectorArrayHandle.AddrOfPinnedObject ();
|
2017-08-23 23:58:26 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2017-09-08 16:00:46 +03:00
|
|
|
|
Assert.AreEqual (new VectorFloat3 (1, 2, 3), cloud.Points [0]);
|
|
|
|
|
Assert.AreEqual (new VectorFloat3 (4, 5, 6), cloud.Points [1]);
|
2017-08-23 23:58:26 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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__
|