2016-05-26 16:06:52 +03:00
|
|
|
|
//
|
2017-02-06 23:20:51 +03:00
|
|
|
|
// MDLObject Unit Tests
|
2016-05-26 16:06:52 +03:00
|
|
|
|
//
|
|
|
|
|
// Authors:
|
|
|
|
|
// Rolf Bjarne Kvinge <rolf@xamarin.com>
|
|
|
|
|
//
|
|
|
|
|
// Copyright 2015 Xamarin Inc.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#if !__WATCHOS__
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using CoreGraphics;
|
|
|
|
|
using Foundation;
|
|
|
|
|
using ModelIO;
|
|
|
|
|
using ObjCRuntime;
|
|
|
|
|
using SceneKit;
|
2017-01-12 21:13:56 +03:00
|
|
|
|
#if !MONOMAC
|
|
|
|
|
using UIKit;
|
|
|
|
|
#endif
|
2016-05-26 16:06:52 +03:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
namespace MonoTouchFixtures.ModelIO {
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// we want the test to be available if we use the linker
|
|
|
|
|
[Preserve (AllMembers = true)]
|
|
|
|
|
public class MDLObjectTest {
|
2020-07-15 19:14:22 +03:00
|
|
|
|
[OneTimeSetUp]
|
2016-05-26 16:06:52 +03:00
|
|
|
|
public void Setup ()
|
|
|
|
|
{
|
2017-01-12 21:13:56 +03:00
|
|
|
|
if (!TestRuntime.CheckXcodeVersion (7, 0))
|
|
|
|
|
Assert.Ignore ("Requires iOS 9.0+ or macOS 10.11+");
|
2016-05-26 16:06:52 +03:00
|
|
|
|
|
2017-01-12 21:13:56 +03:00
|
|
|
|
if (
|
|
|
|
|
#if !MONOMAC
|
|
|
|
|
Runtime.Arch == Arch.SIMULATOR &&
|
|
|
|
|
#endif
|
|
|
|
|
IntPtr.Size == 4) {
|
2016-05-26 16:06:52 +03:00
|
|
|
|
// There's a bug in the i386 version of objc_msgSend where it doesn't preserve SIMD arguments
|
|
|
|
|
// when resizing the cache of method selectors for a type. So here we call all selectors we can
|
|
|
|
|
// find, so that the subsequent tests don't end up producing any cache resize (radar #21630410).
|
|
|
|
|
using (var obj = new MDLObject ()) {
|
|
|
|
|
object dummy;
|
|
|
|
|
obj.SetComponent (new MDLTransform (), new Protocol ("MDLComponent"));
|
|
|
|
|
obj.IsComponentConforming (new Protocol ("MDLComponent"));
|
|
|
|
|
dummy = obj.Parent;
|
|
|
|
|
dummy = obj.Transform;
|
|
|
|
|
obj.AddChild (new MDLObject ());
|
|
|
|
|
obj.GetBoundingBox (0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetBoundingBox ()
|
|
|
|
|
{
|
|
|
|
|
using (var obj = MDLObject.FromNode (SCNNode.FromGeometry (SCNBox.Create (1, 1, 1, 0)))) {
|
|
|
|
|
var bb = obj.GetBoundingBox (0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-06 23:20:51 +03:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ProtocolTest ()
|
|
|
|
|
{
|
|
|
|
|
using (var obj = new MDLObject ()) {
|
|
|
|
|
var p = new Protocol (typeof (IMDLComponent));
|
|
|
|
|
obj.SetComponent (new MDLTransform (), p);
|
|
|
|
|
Assert.NotNull (obj.IsComponentConforming (p));
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-26 16:06:52 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // !__WATCHOS__
|