2021-08-11 11:06:46 +03:00
|
|
|
//
|
2016-05-26 16:06:52 +03:00
|
|
|
// Unit tests for CGGeometry (and related)
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Sebastien Pouliot <sebastien@xamarin.com>
|
|
|
|
//
|
|
|
|
// Copyright 2014 Xamarin Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using Foundation;
|
|
|
|
using CoreGraphics;
|
|
|
|
using ObjCRuntime;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
namespace MonoTouchFixtures.CoreGraphics {
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
[Preserve (AllMembers = true)]
|
|
|
|
public class GeometryTest {
|
|
|
|
|
|
|
|
static public readonly IntPtr Handle = Dlfcn.dlopen (Constants.CoreGraphicsLibrary, 0);
|
|
|
|
|
2020-05-28 17:35:09 +03:00
|
|
|
public static CGRect GetRect (string symbol)
|
2016-05-26 16:06:52 +03:00
|
|
|
{
|
|
|
|
var indirect = Dlfcn.dlsym (Handle, symbol);
|
|
|
|
if (indirect == IntPtr.Zero)
|
2020-05-28 17:35:09 +03:00
|
|
|
return CGRect.Empty;
|
2016-05-26 16:06:52 +03:00
|
|
|
unsafe {
|
|
|
|
nfloat *ptr = (nfloat *) indirect;
|
2020-05-28 17:35:09 +03:00
|
|
|
return new CGRect (ptr [0], ptr [1], ptr [2], ptr [3]);
|
2016-05-26 16:06:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Infinite ()
|
|
|
|
{
|
|
|
|
var r = GetRect ("CGRectInfinite");
|
|
|
|
Assert.False (r.IsEmpty, "IsEmpty");
|
|
|
|
Assert.False (r.IsNull (), "IsNull");
|
|
|
|
Assert.True (r.IsInfinite (), "IsInfinite");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Null ()
|
|
|
|
{
|
|
|
|
var r = GetRect ("CGRectNull");
|
|
|
|
Assert.True (r.IsEmpty, "IsEmpty");
|
|
|
|
Assert.True (r.IsNull (), "IsNull");
|
|
|
|
Assert.False (r.IsInfinite (), "IsInfinite");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Zero ()
|
|
|
|
{
|
|
|
|
var r = GetRect ("CGRectZero");
|
|
|
|
Assert.True (r.IsEmpty, "IsEmpty");
|
|
|
|
Assert.False (r.IsNull (), "IsNull");
|
|
|
|
Assert.False (r.IsInfinite (), "IsInfinite");
|
|
|
|
}
|
|
|
|
}
|
2021-08-11 11:06:46 +03:00
|
|
|
}
|