[monotouch-test] Make it work with Mac Catalyst. (#10439)

* Fix system version checks to work properly on Mac Catalyst (which uses the macOS
  version as its system version).

* Add the framework-specific defines to the build for monotouch-test.csproj (using
  the generated response files), this way we can use them in the tests.

* Sprinkle conditionals in numerous places - I tried using either framework-specific
  or XAMCORE_3_0 whenever that made since (instead of using Mac Catalyst as a condition).

* Updated a few tests to use non-deprecated API (because the deprecated API often
  doesn't exist in Mac Catalyst).

* Also a few minor API fixes to make any corresponding tests compile.
This commit is contained in:
Rolf Bjarne Kvinge 2021-02-01 08:14:38 +01:00 коммит произвёл GitHub
Родитель b3ca00a14a abd54028b8
Коммит 0372e07829
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
112 изменённых файлов: 444 добавлений и 220 удалений

Просмотреть файл

@ -1806,6 +1806,22 @@ namespace ObjCRuntime {
{ {
return GCHandle.ToIntPtr (GCHandle.Alloc (value)); return GCHandle.ToIntPtr (GCHandle.Alloc (value));
} }
#if __MACCATALYST__
static string _iOSSupportVersion;
internal static string iOSSupportVersion {
get {
if (_iOSSupportVersion == null) {
// This is how Apple does it: https://github.com/llvm/llvm-project/blob/62ec4ac90738a5f2d209ed28c822223e58aaaeb7/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm#L100-L105
using var dict = NSMutableDictionary.FromFile ("/System/Library/CoreServices/SystemVersion.plist");
using var str = (NSString) "iOSSupportVersion";
using var obj = dict.ObjectForKey (str);
_iOSSupportVersion = obj.ToString ();
}
return _iOSSupportVersion;
}
}
#endif
} }
internal class IntPtrEqualityComparer : IEqualityComparer<IntPtr> internal class IntPtrEqualityComparer : IEqualityComparer<IntPtr>

Просмотреть файл

@ -17,7 +17,7 @@ namespace SafariServices {
// NSInteger -> SSReadingList.h // NSInteger -> SSReadingList.h
[NoMac][iOS (7,0)] [NoMac][iOS (7,0)]
[Unavailable (PlatformName.MacCatalyst)][Advice ("This API is not available when using UIKit on macOS.")] [MacCatalyst (14,0)]
[Native] [Native]
[ErrorDomain ("SSReadingListErrorDomain")] [ErrorDomain ("SSReadingListErrorDomain")]
public enum SSReadingListError : long { public enum SSReadingListError : long {
@ -27,7 +27,8 @@ namespace SafariServices {
[NoMac] [NoMac]
[iOS (9,0)] [iOS (9,0)]
[Deprecated (PlatformName.iOS, 10,0, message: "Use 'SFErrorCode' enum.")] [Deprecated (PlatformName.iOS, 10,0, message: "Use 'SFErrorCode' enum.")]
[Unavailable (PlatformName.MacCatalyst)][Advice ("This API is not available when using UIKit on macOS.")] [MacCatalyst (13,4)]
[Deprecated (PlatformName.MacCatalyst, 13,4, message: "Use 'SFErrorCode' enum.")]
[Native] [Native]
[ErrorDomain ("SFContentBlockerErrorDomain")] [ErrorDomain ("SFContentBlockerErrorDomain")]
public enum SFContentBlockerErrorCode : long { public enum SFContentBlockerErrorCode : long {

Просмотреть файл

@ -228,6 +228,7 @@ namespace Security {
} }
} }
#if !__MACCATALYST__ // Neither the macOS nor the non-MacOS one works on Mac Catalyst
#if MONOMAC #if MONOMAC
/* Only available on OS X v10.7 or later */ /* Only available on OS X v10.7 or later */
[DllImport (Constants.SecurityLibrary)] [DllImport (Constants.SecurityLibrary)]
@ -279,6 +280,8 @@ namespace Security {
return (data == IntPtr.Zero) ? null : new SecKey (data, true); return (data == IntPtr.Zero) ? null : new SecKey (data, true);
} }
#endif #endif
#endif // !__MACCATALYST__
[TV (12,0)][Mac (10,14)][iOS (12,0)][Watch (5,0)] [TV (12,0)][Mac (10,14)][iOS (12,0)][Watch (5,0)]
[DllImport (Constants.SecurityLibrary)] [DllImport (Constants.SecurityLibrary)]
static extern IntPtr /* SecKeyRef* */ SecCertificateCopyKey (IntPtr /* SecKeyRef* */ key); static extern IntPtr /* SecKeyRef* */ SecCertificateCopyKey (IntPtr /* SecKeyRef* */ key);

Просмотреть файл

@ -13,6 +13,7 @@ namespace Security {
public static partial class SecSharedCredential { public static partial class SecSharedCredential {
[DllImport (Constants.SecurityLibrary)] [DllImport (Constants.SecurityLibrary)]
[Introduced (PlatformName.MacCatalyst, 14, 0)]
extern static void SecAddSharedWebCredential (IntPtr /* CFStringRef */ fqdn, IntPtr /* CFStringRef */ account, IntPtr /* CFStringRef */ password, extern static void SecAddSharedWebCredential (IntPtr /* CFStringRef */ fqdn, IntPtr /* CFStringRef */ account, IntPtr /* CFStringRef */ password,
IntPtr /* void (^completionHandler)( CFErrorRef error) ) */ completionHandler); IntPtr /* void (^completionHandler)( CFErrorRef error) ) */ completionHandler);
@ -33,6 +34,7 @@ namespace Security {
} }
} }
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[BindingImpl (BindingImplOptions.Optimizable)] [BindingImpl (BindingImplOptions.Optimizable)]
public static void AddSharedWebCredential (string domainName, string account, string password, Action<NSError> handler) public static void AddSharedWebCredential (string domainName, string account, string password, Action<NSError> handler)
{ {
@ -135,9 +137,11 @@ namespace Security {
} }
} }
[Introduced (PlatformName.MacCatalyst, 14, 0)]
[DllImport (Constants.SecurityLibrary)] [DllImport (Constants.SecurityLibrary)]
extern static IntPtr /* CFStringRef */ SecCreateSharedWebCredentialPassword (); extern static IntPtr /* CFStringRef */ SecCreateSharedWebCredentialPassword ();
[Introduced (PlatformName.MacCatalyst, 14, 0)]
public static string CreateSharedWebCredentialPassword () public static string CreateSharedWebCredentialPassword ()
{ {
var handle = SecCreateSharedWebCredentialPassword (); var handle = SecCreateSharedWebCredentialPassword ();

Просмотреть файл

@ -16,6 +16,8 @@ namespace UIKit {
{ {
#if WATCH #if WATCH
return Runtime.CheckSystemVersion (major, minor, WatchKit.WKInterfaceDevice.CurrentDevice.SystemVersion); return Runtime.CheckSystemVersion (major, minor, WatchKit.WKInterfaceDevice.CurrentDevice.SystemVersion);
#elif __MACCATALYST__
return Runtime.CheckSystemVersion (major, minor, Runtime.iOSSupportVersion);
#else #else
return Runtime.CheckSystemVersion (major, minor, SystemVersion); return Runtime.CheckSystemVersion (major, minor, SystemVersion);
#endif #endif

Просмотреть файл

@ -251,6 +251,7 @@ namespace EventKit {
bool Immutable { [Bind ("isImmutable")] get; } bool Immutable { [Bind ("isImmutable")] get; }
#if !MONOMAC #if !MONOMAC
[NoMacCatalyst] // It's in the documentation and headers, but throws a "+[EKCalendar calendarWithEventStore:]: unrecognized selector" exception at runtime
[Availability (Deprecated = Platform.iOS_6_0, Message = "Use 'Create (EKEntityType, EKEventStore)' instead.")] [Availability (Deprecated = Platform.iOS_6_0, Message = "Use 'Create (EKEntityType, EKEventStore)' instead.")]
[Static, Export ("calendarWithEventStore:")] [Static, Export ("calendarWithEventStore:")]
EKCalendar FromEventStore (EKEventStore eventStore); EKCalendar FromEventStore (EKEventStore eventStore);

Просмотреть файл

@ -170,8 +170,7 @@ namespace IntentsUI {
[DisableDefaultCtor] [DisableDefaultCtor]
interface INUIAddVoiceShortcutButton { interface INUIAddVoiceShortcutButton {
[Unavailable (PlatformName.MacCatalyst)] [MacCatalyst (13, 4)]
[Advice ("This API is not available when using UIKit on macOS.")]
[Export ("initWithStyle:")] [Export ("initWithStyle:")]
[DesignatedInitializer] [DesignatedInitializer]
IntPtr Constructor (INUIAddVoiceShortcutButtonStyle style); IntPtr Constructor (INUIAddVoiceShortcutButtonStyle style);

Просмотреть файл

@ -15,9 +15,11 @@ using Foundation;
#if !__TVOS__ #if !__TVOS__
using Contacts; using Contacts;
#endif #endif
#if MONOMAC || __MACCATALYST__
using EventKit;
#endif
#if MONOMAC #if MONOMAC
using AppKit; using AppKit;
using EventKit;
#else #else
#if !__TVOS__ && !__WATCHOS__ #if !__TVOS__ && !__WATCHOS__
using AddressBook; using AddressBook;
@ -46,7 +48,7 @@ partial class TestRuntime
// Xcode 12.0 removed macOS 11.0 SDK and moved it up to Xcode 12.2 // Xcode 12.0 removed macOS 11.0 SDK and moved it up to Xcode 12.2
// we use this constant to make up for that difference when using // we use this constant to make up for that difference when using
// AssertXcodeVersion and CheckXcodeVersion // AssertXcodeVersion and CheckXcodeVersion
#if __MACOS__ #if __MACOS__ || __MACCATALYST__
public const int MinorXcode12APIMismatch = 2; public const int MinorXcode12APIMismatch = 2;
#else #else
public const int MinorXcode12APIMismatch = 0; public const int MinorXcode12APIMismatch = 0;
@ -86,6 +88,12 @@ partial class TestRuntime
return version; return version;
} }
} }
#elif __MACCATALYST__
public static Version OSXVersion {
get {
return Version.Parse (UIDevice.CurrentDevice.SystemVersion);
}
}
#endif #endif
public static Version GetSDKVersion () public static Version GetSDKVersion ()
@ -216,7 +224,7 @@ partial class TestRuntime
if (v.Xcode.Beta != beta) if (v.Xcode.Beta != beta)
continue; continue;
#if __IOS__ #if __IOS__ && !__MACCATALYST__
if (!CheckExactiOSSystemVersion (v.iOS.Major, v.iOS.Minor)) if (!CheckExactiOSSystemVersion (v.iOS.Major, v.iOS.Minor))
return false; return false;
if (v.iOS.Build == "?") if (v.iOS.Build == "?")
@ -232,7 +240,7 @@ partial class TestRuntime
var actual = GetiOSBuildVersion (); var actual = GetiOSBuildVersion ();
Console.WriteLine (actual); Console.WriteLine (actual);
return actual.StartsWith (v.tvOS.Build, StringComparison.Ordinal); return actual.StartsWith (v.tvOS.Build, StringComparison.Ordinal);
#elif __MACOS__ #elif __MACOS__ || __MACCATALYST__
if (!CheckExactmacOSSystemVersion (v.macOS.Major, v.macOS.Minor)) if (!CheckExactmacOSSystemVersion (v.macOS.Major, v.macOS.Minor))
return false; return false;
if (v.macOS.Build == "?") if (v.macOS.Build == "?")
@ -342,10 +350,10 @@ partial class TestRuntime
return CheckWatchOSSystemVersion (6, 1); return CheckWatchOSSystemVersion (6, 1);
#elif __TVOS__ #elif __TVOS__
return ChecktvOSSystemVersion (13, 2); return ChecktvOSSystemVersion (13, 2);
#elif __IOS__
return CheckiOSSystemVersion (13, 2);
#elif MONOMAC #elif MONOMAC
return CheckMacSystemVersion (10, 15, 1); return CheckMacSystemVersion (10, 15, 1);
#elif __IOS__
return CheckiOSSystemVersion (13, 2);
#else #else
throw new NotImplementedException (); throw new NotImplementedException ();
#endif #endif
@ -708,6 +716,9 @@ partial class TestRuntime
case PlatformName.WatchOS: case PlatformName.WatchOS:
AssertWatchOSSystemVersion (major, minor, throwIfOtherPlatform); AssertWatchOSSystemVersion (major, minor, throwIfOtherPlatform);
break; break;
case PlatformName.MacCatalyst:
AssertMacCatalystSystemVersion (major, minor, build, throwIfOtherPlatform);
break;
default: default:
throw new Exception ($"Unknown platform: {platform}"); throw new Exception ($"Unknown platform: {platform}");
} }
@ -839,12 +850,29 @@ partial class TestRuntime
#endif #endif
} }
static bool CheckMacCatalystSystemVersion (int major, int minor, bool throwIfOtherPlatform = true)
{
#if __MACCATALYST__
return UIDevice.CurrentDevice.CheckSystemVersion (major, minor);
#else
if (throwIfOtherPlatform)
throw new Exception ("Can't get Mac Catalyst System version on other platforms.");
return true;
#endif
}
static void AssertMacSystemVersion (int major, int minor, int build = 0, bool throwIfOtherPlatform = true) static void AssertMacSystemVersion (int major, int minor, int build = 0, bool throwIfOtherPlatform = true)
{ {
if (!CheckMacSystemVersion (major, minor, build, throwIfOtherPlatform)) if (!CheckMacSystemVersion (major, minor, build, throwIfOtherPlatform))
NUnit.Framework.Assert.Ignore ($"This test requires macOS {major}.{minor}.{build}"); NUnit.Framework.Assert.Ignore ($"This test requires macOS {major}.{minor}.{build}");
} }
static void AssertMacCatalystSystemVersion (int major, int minor, int build = 0, bool throwIfOtherPlatform = true)
{
if (!CheckMacCatalystSystemVersion (major, minor, throwIfOtherPlatform))
NUnit.Framework.Assert.Ignore ($"This test requires macOS {major}.{minor}.{build}");
}
public static bool CheckSDKVersion (int major, int minor) public static bool CheckSDKVersion (int major, int minor)
{ {
#if __WATCHOS__ #if __WATCHOS__
@ -881,6 +909,13 @@ partial class TestRuntime
} }
} }
public static void IgnoreOnMacCatalyst (string message = "")
{
#if __MACCATALYST__
NUnit.Framework.Assert.Ignore ($"This test is disabled on Mac Catalyst. {message}");
#endif
}
public static bool IgnoreTestThatRequiresSystemPermissions () public static bool IgnoreTestThatRequiresSystemPermissions ()
{ {
return !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DISABLE_SYSTEM_PERMISSION_TESTS")); return !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DISABLE_SYSTEM_PERMISSION_TESTS"));
@ -1045,7 +1080,7 @@ partial class TestRuntime
} }
#endif // !MONOMAC && !__TVOS__ #endif // !MONOMAC && !__TVOS__
#if __MACOS__ #if __MACOS__ || __MACCATALYST__
public static void RequestEventStorePermission (EKEntityType entityType, bool assert_granted = false) public static void RequestEventStorePermission (EKEntityType entityType, bool assert_granted = false)
{ {
TestRuntime.AssertMacSystemVersion (10, 9, throwIfOtherPlatform: false); TestRuntime.AssertMacSystemVersion (10, 9, throwIfOtherPlatform: false);
@ -1060,8 +1095,12 @@ partial class TestRuntime
// There's an instance method on EKEventStore to request permission, // There's an instance method on EKEventStore to request permission,
// but creating the instance can end up blocking the app showing a permission dialog... // but creating the instance can end up blocking the app showing a permission dialog...
// (on Mavericks at least) // (on Mavericks at least)
#if __MACCATALYST__
return; // Crossing fingers that this won't hang.
#else
if (TestRuntime.CheckMacSystemVersion (10, 10)) if (TestRuntime.CheckMacSystemVersion (10, 10))
return; // Crossing fingers that this won't hang. return; // Crossing fingers that this won't hang.
#endif
NUnit.Framework.Assert.Ignore ("This test requires permission to access events, but there's no API to request access without potentially showing dialogs."); NUnit.Framework.Assert.Ignore ("This test requires permission to access events, but there's no API to request access without potentially showing dialogs.");
break; break;
case EKAuthorizationStatus.Denied: case EKAuthorizationStatus.Denied:

Просмотреть файл

@ -23,10 +23,17 @@ namespace MonoTouchFixtures.ARKit {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class ARAnchorTest { public class ARAnchorTest {
[SetUp]
public void Setup ()
{
TestRuntime.AssertXcodeVersion (10, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void MarshallingTest () public void MarshallingTest ()
{ {
TestRuntime.AssertXcodeVersion (10, 0);
var faceAnchor = new ARAnchor ("My Anchor", MatrixFloat4x4.Identity); var faceAnchor = new ARAnchor ("My Anchor", MatrixFloat4x4.Identity);
Assert.AreEqual (MatrixFloat4x4.Identity, faceAnchor.Transform, "Transform"); Assert.AreEqual (MatrixFloat4x4.Identity, faceAnchor.Transform, "Transform");
} }

Просмотреть файл

@ -4,6 +4,7 @@ using System;
using System.Reflection; using System.Reflection;
using ARKit; using ARKit;
using Foundation; using Foundation;
using ObjCRuntime;
using NUnit.Framework; using NUnit.Framework;
namespace MonoTouchFixtures.ARKit { namespace MonoTouchFixtures.ARKit {
@ -12,10 +13,17 @@ namespace MonoTouchFixtures.ARKit {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class ARCondigurationTest { public class ARCondigurationTest {
[SetUp]
public void Setup ()
{
TestRuntime.AssertXcodeVersion (9, 3);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void SupportedVideoFormats () public void SupportedVideoFormats ()
{ {
TestRuntime.AssertXcodeVersion (9, 3);
var svf = ARConfiguration.SupportedVideoFormats; var svf = ARConfiguration.SupportedVideoFormats;
Assert.That (svf, Is.Empty, "empty"); Assert.That (svf, Is.Empty, "empty");
} }
@ -23,7 +31,6 @@ namespace MonoTouchFixtures.ARKit {
[Test] [Test]
public void GetSupportedVideoFormats_9_3 () public void GetSupportedVideoFormats_9_3 ()
{ {
TestRuntime.AssertXcodeVersion (9, 3);
Assert.NotNull (ARWorldTrackingConfiguration.GetSupportedVideoFormats (), "ARWorldTrackingConfiguration"); Assert.NotNull (ARWorldTrackingConfiguration.GetSupportedVideoFormats (), "ARWorldTrackingConfiguration");
Assert.NotNull (AROrientationTrackingConfiguration.GetSupportedVideoFormats (), "AROrientationTrackingConfiguration"); Assert.NotNull (AROrientationTrackingConfiguration.GetSupportedVideoFormats (), "AROrientationTrackingConfiguration");
Assert.NotNull (ARFaceTrackingConfiguration.GetSupportedVideoFormats (), "ARFaceTrackingConfiguration"); Assert.NotNull (ARFaceTrackingConfiguration.GetSupportedVideoFormats (), "ARFaceTrackingConfiguration");

Просмотреть файл

@ -28,6 +28,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (10, 0); TestRuntime.AssertXcodeVersion (10, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -88,6 +88,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (9, 0); TestRuntime.AssertXcodeVersion (9, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -102,6 +102,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (9, 0); TestRuntime.AssertXcodeVersion (9, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -77,6 +77,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (9, 0); TestRuntime.AssertXcodeVersion (9, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -28,6 +28,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (10, 0); TestRuntime.AssertXcodeVersion (10, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -62,6 +62,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (11, 0); TestRuntime.AssertXcodeVersion (11, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -76,6 +76,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (11, 0); TestRuntime.AssertXcodeVersion (11, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -17,6 +17,8 @@ namespace monotouchtest.ARKit {
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (12, 0); TestRuntime.AssertXcodeVersion (12, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -87,11 +87,7 @@ namespace MonoTouchFixtures.AVFoundation {
} }
string does_not_exists_asset_path = Path.Combine (NSBundle.MainBundle.BundlePath, "xamarin.mov"); string does_not_exists_asset_path = Path.Combine (NSBundle.MainBundle.BundlePath, "xamarin.mov");
#if MONOMAC string video_asset_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "xamvideotest.mp4");
string video_asset_path = Path.Combine (NSBundle.MainBundle.BundlePath, "Contents/Resources/xamvideotest.mp4");
#else
string video_asset_path = Path.Combine (NSBundle.MainBundle.BundlePath, "xamvideotest.mp4");
#endif
bool handled; bool handled;
ManualResetEvent mre; ManualResetEvent mre;

Просмотреть файл

@ -14,12 +14,11 @@ namespace monotouchtest {
public void TestConstructor () public void TestConstructor ()
{ {
TestRuntime.AssertXcodeVersion (8, 0); TestRuntime.AssertXcodeVersion (8, 0);
AVCaptureAutoExposureBracketedStillImageSettings [] array = new AVCaptureAutoExposureBracketedStillImageSettings [3];
array [0] = AVCaptureAutoExposureBracketedStillImageSettings.Create (-2f);
array [1] = AVCaptureAutoExposureBracketedStillImageSettings.Create (0f);
array [2] = AVCaptureAutoExposureBracketedStillImageSettings.Create (2f);
var output = new AVCapturePhotoOutput (); var output = new AVCapturePhotoOutput ();
if (output.AvailablePhotoPixelFormatTypes.Length > 0) { if (output.AvailablePhotoPixelFormatTypes.Length > 0 && output.MaxBracketedCapturePhotoCount > 0) {
var array = new AVCaptureAutoExposureBracketedStillImageSettings [Math.Min (3, (int) output.MaxBracketedCapturePhotoCount)];
for (var i = 0; i < array.Length; i++)
array [i] = AVCaptureAutoExposureBracketedStillImageSettings.Create (-2f + 2f * i);
using (var settings = AVCapturePhotoBracketSettings.FromRawPixelFormatType ((uint) output.AvailablePhotoPixelFormatTypes [0], null, array)) using (var settings = AVCapturePhotoBracketSettings.FromRawPixelFormatType ((uint) output.AvailablePhotoPixelFormatTypes [0], null, array))
Assert.That (settings.Handle, Is.Not.EqualTo (IntPtr.Zero)); Assert.That (settings.Handle, Is.Not.EqualTo (IntPtr.Zero));
} }

Просмотреть файл

@ -34,7 +34,13 @@ namespace MonoTouchFixtures.AVFoundation {
Compare (AVMediaType.MetadataObject, AVMediaTypes.MetadataObject); Compare (AVMediaType.MetadataObject, AVMediaTypes.MetadataObject);
// obsoleted in iOS 6, removed in iOS12 // obsoleted in iOS 6, removed in iOS12
if (TestRuntime.CheckSystemVersion (PlatformName.iOS, 12,0)) #if __MACCATALYST__
var removed = true;
#else
var removed = TestRuntime.CheckSystemVersion (PlatformName.iOS, 12, 0);
#endif
if (removed)
Assert.Null (AVMediaType.TimedMetadata, "AVMediaTypeTimedMetadata"); Assert.Null (AVMediaType.TimedMetadata, "AVMediaTypeTimedMetadata");
else else
Compare (AVMediaType.TimedMetadata, AVMediaTypes.TimedMetadata); Compare (AVMediaType.TimedMetadata, AVMediaTypes.TimedMetadata);

Просмотреть файл

@ -41,11 +41,13 @@ namespace MonoTouchFixtures.AVFoundation {
if (TestRuntime.CheckSystemVersion (PlatformName.iOS, 7, 0, throwIfOtherPlatform: false)) if (TestRuntime.CheckSystemVersion (PlatformName.iOS, 7, 0, throwIfOtherPlatform: false))
Assert.AreEqual (new CGRect (0, 0, 1, 1), obj.RectOfInterest, "RectOfInterest"); Assert.AreEqual (new CGRect (0, 0, 1, 1), obj.RectOfInterest, "RectOfInterest");
#if !__MACCATALYST__ // https://github.com/xamarin/maccore/issues/2345
obj.WeakMetadataObjectTypes = null; obj.WeakMetadataObjectTypes = null;
Assert.AreEqual (AVMetadataObjectType.None, obj.MetadataObjectTypes, "MetadataObjectTypes"); Assert.AreEqual (AVMetadataObjectType.None, obj.MetadataObjectTypes, "MetadataObjectTypes");
obj.MetadataObjectTypes = AVMetadataObjectType.None; obj.MetadataObjectTypes = AVMetadataObjectType.None;
Assert.AreEqual (AVMetadataObjectType.None, obj.MetadataObjectTypes, "MetadataObjectTypes"); Assert.AreEqual (AVMetadataObjectType.None, obj.MetadataObjectTypes, "MetadataObjectTypes");
obj.SetDelegate (null, null); obj.SetDelegate (null, null);
#endif // !__MACCATALYST__
} }
} }

Просмотреть файл

@ -24,6 +24,13 @@ namespace MonoTouchFixtures.AddressBook {
// very general ABSource related tests (works on both simulator and devices) // very general ABSource related tests (works on both simulator and devices)
[SetUp]
public void Setup ()
{
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void GetAllSources () public void GetAllSources ()
{ {

Просмотреть файл

@ -22,6 +22,13 @@ namespace MonoTouchFixtures.AddressBook {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class PersonTest { public class PersonTest {
[SetUp]
public void Setup ()
{
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void UpdateAddressLine () public void UpdateAddressLine ()
{ {

Просмотреть файл

@ -22,6 +22,13 @@ namespace MonoTouchFixtures.AddressBook {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class SourceTest { public class SourceTest {
[SetUp]
public void Setup ()
{
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void Default () public void Default ()
{ {

Просмотреть файл

@ -23,6 +23,13 @@ namespace MonoTouchFixtures.AddressBookUI {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class ABAddressFormattingTest { public class ABAddressFormattingTest {
[SetUp]
public void Setup ()
{
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void ChateauFrontenac () public void ChateauFrontenac ()
{ {

Просмотреть файл

@ -19,11 +19,7 @@ namespace MonoTouchFixtures.AudioToolbox {
[Test] [Test]
public void ReadTest () public void ReadTest ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#endif
var af = AudioFile.Open (CFUrl.FromFile (path), AudioFilePermission.Read, AudioFileType.CAF); var af = AudioFile.Open (CFUrl.FromFile (path), AudioFilePermission.Read, AudioFileType.CAF);
int len; int len;

Просмотреть файл

@ -22,7 +22,7 @@ namespace MonoTouchFixtures.AudioToolbox {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class AudioQueueTest public class AudioQueueTest
{ {
#if !MONOMAC // HardwareCodecPolicy and SetChannelAssignments are iOS only #if !MONOMAC && !__MACCATALYST__ // HardwareCodecPolicy and SetChannelAssignments are iOS only
[Test] [Test]
public void Properties () public void Properties ()
{ {

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2011 Xamarin Inc. All rights reserved // Copyright 2011 Xamarin Inc. All rights reserved
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC #if !__TVOS__ && !__WATCHOS__ && !MONOMAC && !XAMCORE_3_0
using System; using System;
using System.Drawing; using System.Drawing;
@ -45,4 +45,4 @@ namespace MonoTouchFixtures.AudioToolbox {
} }
} }
} }
#endif // !__TVOS__ && !__WATCHOS__ #endif // !__TVOS__ && !__WATCHOS__ && !MONOMAC && !XAMCORE_3_0

Просмотреть файл

@ -28,11 +28,8 @@ namespace MonoTouchFixtures.AudioToolbox {
[Test] [Test]
public void FromFile () public void FromFile ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else #if !MONOMAC
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
if (Runtime.Arch == Arch.SIMULATOR) if (Runtime.Arch == Arch.SIMULATOR)
Assert.Ignore ("PlaySystemSound doesn't work in the simulator"); Assert.Ignore ("PlaySystemSound doesn't work in the simulator");
#endif #endif
@ -54,11 +51,7 @@ namespace MonoTouchFixtures.AudioToolbox {
[Test] [Test]
public void Properties () public void Properties ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#endif
using (var ss = SystemSound.FromFile (NSUrl.FromFilename (path))) { using (var ss = SystemSound.FromFile (NSUrl.FromFilename (path))) {
Assert.That (ss.IsUISound, Is.True, "#1"); Assert.That (ss.IsUISound, Is.True, "#1");
@ -109,11 +102,7 @@ namespace MonoTouchFixtures.AudioToolbox {
[Test] [Test]
public void DisposeTest () public void DisposeTest ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#endif
var ss = SystemSound.FromFile (NSUrl.FromFilename (path)); var ss = SystemSound.FromFile (NSUrl.FromFilename (path));
Assert.That (ss.Handle, Is.Not.EqualTo (IntPtr.Zero), "DisposeTest"); Assert.That (ss.Handle, Is.Not.EqualTo (IntPtr.Zero), "DisposeTest");

Просмотреть файл

@ -24,11 +24,7 @@ namespace MonoTouchFixtures.AudioUnit {
[Test] [Test]
public void WrapAudioFileID () public void WrapAudioFileID ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#endif
using (var file = ExtAudioFile.OpenUrl (CFUrl.FromFile (path))) { using (var file = ExtAudioFile.OpenUrl (CFUrl.FromFile (path))) {
Assert.IsNotNull (file.AudioFile, "#1"); Assert.IsNotNull (file.AudioFile, "#1");
@ -40,11 +36,7 @@ namespace MonoTouchFixtures.AudioUnit {
[Test] [Test]
public void ClientDataFormat () public void ClientDataFormat ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#endif
using (var file = ExtAudioFile.OpenUrl (CFUrl.FromFile (path))) { using (var file = ExtAudioFile.OpenUrl (CFUrl.FromFile (path))) {
var fmt = file.ClientDataFormat; var fmt = file.ClientDataFormat;
} }
@ -53,11 +45,7 @@ namespace MonoTouchFixtures.AudioUnit {
[Test] [Test]
public void OpenNSUrlTest () public void OpenNSUrlTest ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#endif
ExtAudioFileError err; ExtAudioFileError err;
using (var file = ExtAudioFile.OpenUrl (NSUrl.FromFilename (path), out err)) { using (var file = ExtAudioFile.OpenUrl (NSUrl.FromFilename (path), out err)) {
Assert.IsTrue (err == ExtAudioFileError.OK, "OpenNSUrlTest"); Assert.IsTrue (err == ExtAudioFileError.OK, "OpenNSUrlTest");
@ -68,11 +56,7 @@ namespace MonoTouchFixtures.AudioUnit {
[Test] [Test]
public void OpenCFUrlTest () public void OpenCFUrlTest ()
{ {
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox"); var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#endif
ExtAudioFileError err; ExtAudioFileError err;
using (var file = ExtAudioFile.OpenUrl (CFUrl.FromFile (path), out err)) { using (var file = ExtAudioFile.OpenUrl (CFUrl.FromFile (path), out err)) {
Assert.IsTrue (err == ExtAudioFileError.OK, "OpenCFUrlTest"); Assert.IsTrue (err == ExtAudioFileError.OK, "OpenCFUrlTest");

Просмотреть файл

@ -13,6 +13,7 @@ using NUnit.Framework;
using CarPlay; using CarPlay;
using Foundation; using Foundation;
using ObjCRuntime;
namespace MonoTouchFixtures.CarPlay { namespace MonoTouchFixtures.CarPlay {
@ -21,7 +22,12 @@ namespace MonoTouchFixtures.CarPlay {
public class CPMessageListItemTest { public class CPMessageListItemTest {
[SetUp] [SetUp]
public void Setup () => TestRuntime.AssertXcodeVersion (12, 0); public void Setup ()
{
TestRuntime.AssertXcodeVersion (12, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void InitUsingConversationIdentifier () public void InitUsingConversationIdentifier ()

Просмотреть файл

@ -23,11 +23,7 @@ namespace MonoTouchFixtures.Compression {
public class ThoroughCompressionStreamTest public class ThoroughCompressionStreamTest
{ {
#if MONOMAC string uncompressedFilePath = Path.Combine (NSBundle.MainBundle.ResourcePath, "uncompressed.txt");
string uncompressedFilePath = Path.Combine (NSBundle.MainBundle.BundlePath, "Contents/Resources/uncompressed.txt");
#else
string uncompressedFilePath = Path.Combine (NSBundle.MainBundle.BundlePath, "uncompressed.txt");
#endif
string firstTempPath; string firstTempPath;
string secondTempPath; string secondTempPath;
@ -88,11 +84,7 @@ namespace MonoTouchFixtures.Compression {
{ {
if (!TestRuntime.CheckXcodeVersion (7, 0)) if (!TestRuntime.CheckXcodeVersion (7, 0))
Assert.Ignore ("Requires iOS 9.0+ or macOS 10.11+"); Assert.Ignore ("Requires iOS 9.0+ or macOS 10.11+");
#if MONOMAC string compressedFilePath = Path.Combine (NSBundle.MainBundle.ResourcePath, compressedFile);
string compressedFilePath = Path.Combine (NSBundle.MainBundle.BundlePath, $"Contents/Resources/{compressedFile}");
#else
string compressedFilePath = Path.Combine (NSBundle.MainBundle.BundlePath, compressedFile);
#endif
DecodeRealFile (algorithm, compressedFilePath, uncompressedFilePath); DecodeRealFile (algorithm, compressedFilePath, uncompressedFilePath);
} }
} }

Просмотреть файл

@ -43,7 +43,7 @@ namespace MonoTouchFixtures.Contacts {
var contacts = store.GetUnifiedContacts (predicate, fetchKeys, out error); var contacts = store.GetUnifiedContacts (predicate, fetchKeys, out error);
// we can't be sure what's on devices, so check there's no error is the only thing we do // we can't be sure what's on devices, so check there's no error is the only thing we do
// but it's in the default simulator build (but not the watchOS simulator) // but it's in the default simulator build (but not the watchOS simulator)
#if !MONOMAC && !__WATCHOS__ #if !MONOMAC && !__WATCHOS__ && !__MACCATALYST__
if ((error == null) && (Runtime.Arch == Arch.SIMULATOR)) { if ((error == null) && (Runtime.Arch == Arch.SIMULATOR)) {
Assert.That (contacts.Length, Is.EqualTo (1), "Length"); Assert.That (contacts.Length, Is.EqualTo (1), "Length");
identifier = contacts [0].Identifier; identifier = contacts [0].Identifier;

Просмотреть файл

@ -107,6 +107,9 @@ namespace MonoTouchFixtures.CoreAnimation {
static int TextLayersDisposed; static int TextLayersDisposed;
static int Generation; static int Generation;
[Test] [Test]
#if __MACCATALYST__
[Ignore ("https://github.com/dotnet/runtime/issues/47407")] // The GC doesn't collect objects with finalizers
#endif
public void TestBug26532() public void TestBug26532()
{ {
TextLayersDisposed = 0; TextLayersDisposed = 0;

Просмотреть файл

@ -3,6 +3,7 @@
// //
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using Foundation; using Foundation;
using CoreFoundation; using CoreFoundation;
using NUnit.Framework; using NUnit.Framework;
@ -104,10 +105,13 @@ namespace MonoTouchFixtures.CoreFoundation {
{ {
var main = CFBundle.GetMain (); var main = CFBundle.GetMain ();
#if MONOMAC #if MONOMAC
Assert.That (main.ExecutableUrl.ToString (), Contains.Substring (ExpectedAppName + "/Contents/MacOS/xammac_tests")); var executableRelativePath = Path.Combine (ExpectedAppName, "Contents", "MacOS", "xammac_tests");
#elif __MACCATALYST__
var executableRelativePath = Path.Combine (ExpectedAppName, "Contents", "MacOS", "monotouchtest");
#else #else
Assert.That(main.ExecutableUrl.ToString (), Contains.Substring (ExpectedAppName + "/monotouchtest")); var executableRelativePath = Path.Combine (ExpectedAppName, "monotouchtest");
#endif #endif
Assert.That (main.ExecutableUrl.ToString (), Contains.Substring (executableRelativePath));
} }
[Test] [Test]

Просмотреть файл

@ -76,7 +76,7 @@ namespace MonoTouchFixtures.CoreFoundation {
do { do {
var context = listener.GetContext (); var context = listener.GetContext ();
var request = context.Request; var request = context.Request;
var pacPath = Path.Combine (NSBundle.MainBundle.BundlePath, request.RawUrl.Substring (1)); var pacPath = Path.Combine (NSBundle.MainBundle.ResourcePath, request.RawUrl.Substring (1));
Console.WriteLine ($" Serving {pacPath}"); Console.WriteLine ($" Serving {pacPath}");
var buf = File.ReadAllBytes (pacPath); var buf = File.ReadAllBytes (pacPath);
context.Response.ContentLength64 = buf.Length; context.Response.ContentLength64 = buf.Length;
@ -115,7 +115,7 @@ namespace MonoTouchFixtures.CoreFoundation {
{ {
// get the path for the pac file, try to parse it and ensure that // get the path for the pac file, try to parse it and ensure that
// our cb was called // our cb was called
string pacPath = Path.Combine (NSBundle.MainBundle.BundlePath, "example.pac"); string pacPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "example.pac");
NSError error = null; NSError error = null;
var script = File.ReadAllText (pacPath); var script = File.ReadAllText (pacPath);
var targetUri = NetworkResources.XamarinUri; var targetUri = NetworkResources.XamarinUri;
@ -129,7 +129,7 @@ namespace MonoTouchFixtures.CoreFoundation {
[Test] [Test]
public void TestPACParsingScriptNoProxy () public void TestPACParsingScriptNoProxy ()
{ {
string pacPath = Path.Combine (NSBundle.MainBundle.BundlePath, "example.pac"); string pacPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "example.pac");
NSError error = null; NSError error = null;
var script = File.ReadAllText (pacPath); var script = File.ReadAllText (pacPath);
var targetUri = NetworkResources.MicrosoftUri; var targetUri = NetworkResources.MicrosoftUri;
@ -158,7 +158,7 @@ namespace MonoTouchFixtures.CoreFoundation {
NSError error = null; NSError error = null;
NSObject cbClient = null; NSObject cbClient = null;
bool done = false; bool done = false;
string pacPath = Path.Combine (NSBundle.MainBundle.BundlePath, "example.pac"); string pacPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "example.pac");
var script = File.ReadAllText (pacPath); var script = File.ReadAllText (pacPath);
var targetUri = NetworkResources.XamarinUri; var targetUri = NetworkResources.XamarinUri;
@ -196,7 +196,7 @@ namespace MonoTouchFixtures.CoreFoundation {
NSError error = null; NSError error = null;
NSObject cbClient = null; NSObject cbClient = null;
bool done = false; bool done = false;
string pacPath = Path.Combine (NSBundle.MainBundle.BundlePath, "example.pac"); string pacPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "example.pac");
var script = File.ReadAllText (pacPath); var script = File.ReadAllText (pacPath);
var targetUri = NetworkResources.MicrosoftUri; var targetUri = NetworkResources.MicrosoftUri;

Просмотреть файл

@ -22,8 +22,10 @@ using AppKit;
using OpenGL; using OpenGL;
#else #else
using UIKit; using UIKit;
#if HAS_OPENGLES
using OpenGLES; using OpenGLES;
#endif #endif
#endif
using NUnit.Framework; using NUnit.Framework;
@ -65,7 +67,7 @@ namespace MonoTouchFixtures.CoreImage {
} }
} }
#if !MONOMAC // No EAGLContext for Mac #if HAS_OPENGLES
[Test] [Test]
public void FromContext_13983 () public void FromContext_13983 ()
{ {
@ -88,7 +90,7 @@ namespace MonoTouchFixtures.CoreImage {
ci.Render (img, cv, CGRect.Empty, null); ci.Render (img, cv, CGRect.Empty, null);
} }
} }
#endif #endif // HAS_OPENGLES
} }
} }

Просмотреть файл

@ -63,6 +63,8 @@ namespace MonoTouchFixtures.CoreMedia {
using (var captureSession = new AVCaptureSession ()) { using (var captureSession = new AVCaptureSession ()) {
using (var videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video)) { using (var videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video)) {
if (videoDevice == null)
Assert.Inconclusive ("Failed to create a video device for testing");
NSError error; NSError error;
using (var videoInput = new AVCaptureDeviceInput (videoDevice, out error)) { using (var videoInput = new AVCaptureDeviceInput (videoDevice, out error)) {
// this seems to initialize something. // this seems to initialize something.
@ -94,6 +96,8 @@ namespace MonoTouchFixtures.CoreMedia {
using (var captureSession = new AVCaptureSession ()) { using (var captureSession = new AVCaptureSession ()) {
using (var videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video)) { using (var videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video)) {
if (videoDevice == null)
Assert.Inconclusive ("Failed to create a video device for testing");
foreach (var format in videoDevice.Formats) { foreach (var format in videoDevice.Formats) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
using (var f = format.FormatDescription) { using (var f = format.FormatDescription) {

Просмотреть файл

@ -60,7 +60,7 @@ namespace MonoTouchFixtures.CoreText {
// xcode 11 beta 4 stopped reporting errors // xcode 11 beta 4 stopped reporting errors
// Assert.IsNotNull (err, "err 3"); // Assert.IsNotNull (err, "err 3");
err = CTFontManager.UnregisterFontsForUrl (url, CTFontManagerScope.Process); err = CTFontManager.UnregisterFontsForUrl (url, CTFontManagerScope.Process);
#if MONOMAC #if MONOMAC || __MACCATALYST__
if (TestRuntime.CheckXcodeVersion (12,2)) if (TestRuntime.CheckXcodeVersion (12,2))
Assert.IsNotNull (err, "err 4"); Assert.IsNotNull (err, "err 4");
else else
@ -157,7 +157,7 @@ namespace MonoTouchFixtures.CoreText {
// Assert.AreEqual (1, err.Length, "err 3 l"); // Assert.AreEqual (1, err.Length, "err 3 l");
// Assert.IsNotNull (err [0], "err 3[0]"); // Assert.IsNotNull (err [0], "err 3[0]");
err = CTFontManager.UnregisterFontsForUrl (new [] { url }, CTFontManagerScope.Process); err = CTFontManager.UnregisterFontsForUrl (new [] { url }, CTFontManagerScope.Process);
#if MONOMAC #if MONOMAC || __MACCATALYST__
if (TestRuntime.CheckXcodeVersion (12, 2)) { if (TestRuntime.CheckXcodeVersion (12, 2)) {
Assert.IsNotNull (err, "err 4"); Assert.IsNotNull (err, "err 4");
Assert.AreEqual (1, err.Length, "err 4 l"); Assert.AreEqual (1, err.Length, "err 4 l");
@ -293,7 +293,8 @@ namespace MonoTouchFixtures.CoreText {
} }
} }
#if __IOS__ #if __IOS__ && !__MACCATALYST__
// Running this on Mac Catalyst prints "CTFontManagerRequestFonts not implemented for plaform or scope" to the terminal
[Test] [Test]
public void RequestFonts () public void RequestFonts ()
{ {

Просмотреть файл

@ -30,7 +30,7 @@ namespace MonoTouchFixtures.EventKit {
void RequestPermission () void RequestPermission ()
{ {
#if __MACOS__ #if __MACOS__ || __MACCATALYST__
TestRuntime.RequestEventStorePermission (EKEntityType.Event, true); TestRuntime.RequestEventStorePermission (EKEntityType.Event, true);
TestRuntime.RequestEventStorePermission (EKEntityType.Reminder, true); TestRuntime.RequestEventStorePermission (EKEntityType.Reminder, true);
#endif #endif
@ -43,7 +43,7 @@ namespace MonoTouchFixtures.EventKit {
RequestPermission (); RequestPermission ();
EKEventStore store = new EKEventStore (); EKEventStore store = new EKEventStore ();
#if MONOMAC #if MONOMAC || __MACCATALYST__
var c = EKCalendar.Create (EKEntityType.Event, store); var c = EKCalendar.Create (EKEntityType.Event, store);
#else #else
var c = EKCalendar.FromEventStore (store); var c = EKCalendar.FromEventStore (store);
@ -76,7 +76,7 @@ namespace MonoTouchFixtures.EventKit {
Assert.Null (c.Source, "Source"); Assert.Null (c.Source, "Source");
Assert.False (c.Subscribed, "Subscribed"); Assert.False (c.Subscribed, "Subscribed");
#if MONOMAC #if MONOMAC || __MACCATALYST__
Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities");
Assert.That (c.Title, Is.EqualTo (string.Empty), "Title"); Assert.That (c.Title, Is.EqualTo (string.Empty), "Title");
#else #else
@ -115,7 +115,7 @@ namespace MonoTouchFixtures.EventKit {
#endif #endif
Assert.Null (c.Source, "Source"); Assert.Null (c.Source, "Source");
Assert.False (c.Subscribed, "Subscribed"); Assert.False (c.Subscribed, "Subscribed");
#if MONOMAC #if MONOMAC || __MACCATALYST__
Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities");
Assert.That (c.Title, Is.EqualTo (string.Empty), "Title"); Assert.That (c.Title, Is.EqualTo (string.Empty), "Title");
#else #else
@ -133,7 +133,7 @@ namespace MonoTouchFixtures.EventKit {
RequestPermission (); RequestPermission ();
EKEventStore store = new EKEventStore (); EKEventStore store = new EKEventStore ();
#if MONOMAC #if MONOMAC || __MACCATALYST__
var c = EKCalendar.Create (EKEntityType.Event, store); var c = EKCalendar.Create (EKEntityType.Event, store);
#else #else
var c = EKCalendar.FromEventStore (store); var c = EKCalendar.FromEventStore (store);
@ -145,7 +145,7 @@ namespace MonoTouchFixtures.EventKit {
[Test] [Test]
public void FromEventStore_Null () public void FromEventStore_Null ()
{ {
#if MONOMAC #if MONOMAC || __MACCATALYST__
Assert.Throws<ArgumentNullException> (() => EKCalendar.Create (EKEntityType.Event, null)); Assert.Throws<ArgumentNullException> (() => EKCalendar.Create (EKEntityType.Event, null));
#else #else
Assert.Throws<ArgumentNullException> (() => EKCalendar.FromEventStore (null)); Assert.Throws<ArgumentNullException> (() => EKCalendar.FromEventStore (null));

Просмотреть файл

@ -12,6 +12,7 @@
using System; using System;
using Foundation; using Foundation;
using ExternalAccessory; using ExternalAccessory;
using ObjCRuntime;
using NUnit.Framework; using NUnit.Framework;
namespace MonoTouchFixtures.ExternalAccessory { namespace MonoTouchFixtures.ExternalAccessory {
@ -41,6 +42,8 @@ namespace MonoTouchFixtures.ExternalAccessory {
[Test] [Test]
public void ShowBluetoothAccessoryPicker () public void ShowBluetoothAccessoryPicker ()
{ {
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
EAAccessoryManager.SharedAccessoryManager.ShowBluetoothAccessoryPicker (null, null); EAAccessoryManager.SharedAccessoryManager.ShowBluetoothAccessoryPicker (null, null);
} }
#endif #endif

Просмотреть файл

@ -71,12 +71,13 @@ namespace MonoTouchFixtures.Foundation {
public void FromFile () public void FromFile ()
{ {
Assert.Null (NSData.FromFile ("does not exists"), "unexisting"); Assert.Null (NSData.FromFile ("does not exists"), "unexisting");
#if MONOMAC // Info.Plist isn't there to load from the same location on mac #if MONOMAC || __MACCATALYST__
if (!TestRuntime.IsLinkAll) // Info.Plist isn't there to load from the same location on mac
Assert.NotNull (NSData.FromFile (NSBundle.MainBundle.PathForResource ("runtime-options", "plist")), "runtime-options.plist"); var plistPath = Path.Combine (NSBundle.MainBundle.BundlePath, "Contents", "Info.plist");
#else #else
Assert.NotNull (NSData.FromFile ("Info.plist"), "Info.plist"); var plistPath = Path.Combine (NSBundle.MainBundle.BundlePath, "Info.plist");
#endif #endif
Assert.NotNull (NSData.FromFile (plistPath), "Info.plist");
} }
[Test] [Test]

Просмотреть файл

@ -27,17 +27,21 @@ namespace MonoTouchFixtures.Foundation {
} }
} }
#if !MONOMAC //NSData.FromFile ("Info.plist") returns null. Trying the same in xcode also returns nil
[Test] [Test]
public void Data () public void Data ()
{ {
using (var d = NSData.FromFile ("Info.plist")) #if MONOMAC || __MACCATALYST__
// Info.Plist isn't there to load from the same location on mac
var plistPath = global::System.IO.Path.Combine (NSBundle.MainBundle.BundlePath, "Contents", "Info.plist");
#else
var plistPath = global::System.IO.Path.Combine (NSBundle.MainBundle.BundlePath, "Info.plist");
#endif
using (var d = NSData.FromFile (plistPath))
using (var s = new NSInputStream (d)) { using (var s = new NSInputStream (d)) {
// initWithData: does not respond (see dontlink.app) but it works // initWithData: does not respond (see dontlink.app) but it works
Assert.That (s.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle"); Assert.That (s.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle");
} }
} }
#endif
[Test] [Test]
public void Url () public void Url ()

Просмотреть файл

@ -8,6 +8,7 @@
// //
using System; using System;
using System.IO;
using CoreGraphics; using CoreGraphics;
#if !__WATCHOS__ #if !__WATCHOS__
using System.Drawing; using System.Drawing;
@ -103,7 +104,7 @@ namespace MonoTouchFixtures.Foundation {
} }
//No Mac version of DrawString with those parameters //No Mac version of DrawString with those parameters
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC #if !__TVOS__ && !__WATCHOS__ && !MONOMAC && !__MACCATALYST__
[Test] [Test]
[Culture ("en")] // fails for some cultures, e.g. ar-AE [Culture ("en")] // fails for some cultures, e.g. ar-AE
public void DrawString_7 () public void DrawString_7 ()
@ -226,7 +227,7 @@ namespace MonoTouchFixtures.Foundation {
[Test] [Test]
public void FromData () public void FromData ()
{ {
UIImage img = UIImage.FromFile ("basn3p08.png"); UIImage img = UIImage.FromFile (Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png"));
using (NSData imageData = img.AsPNG ()) { using (NSData imageData = img.AsPNG ()) {
using (var str = NSString.FromData (imageData, NSStringEncoding.UTF8)) { using (var str = NSString.FromData (imageData, NSStringEncoding.UTF8)) {
Assert.IsNull (str, "NSDataFromImage"); Assert.IsNull (str, "NSDataFromImage");

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2012 Xamarin Inc. All rights reserved // Copyright 2012 Xamarin Inc. All rights reserved
#if !__WATCHOS__ #if HAS_GLKIT
using System; using System;
using System.Drawing; using System.Drawing;
@ -32,4 +32,4 @@ namespace MonoTouchFixtures.GLKit {
} }
} }
} }
#endif // !__WATCHOS__ #endif // HAS_GLKIT

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2012 Xamarin Inc. All rights reserved // Copyright 2012 Xamarin Inc. All rights reserved
#if !__WATCHOS__ #if HAS_GLKIT
using System; using System;
using System.Drawing; using System.Drawing;
@ -30,4 +30,4 @@ namespace MonoTouchFixtures.GLKit {
} }
} }
#endif // !__WATCHOS__ #endif // HAS_GLKIT

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2012 Xamarin Inc. All rights reserved // Copyright 2012 Xamarin Inc. All rights reserved
#if !__WATCHOS__ #if HAS_GLKIT
using System; using System;
using System.Drawing; using System.Drawing;
@ -36,4 +36,4 @@ namespace MonoTouchFixtures.GLKit {
} }
} }
#endif // !__WATCHOS__ #endif // HAS_GLKIT

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2012 Xamarin Inc. All rights reserved // Copyright 2012 Xamarin Inc. All rights reserved
#if !__WATCHOS__ #if HAS_GLKIT
using System; using System;
using System.Drawing; using System.Drawing;
@ -37,4 +37,4 @@ namespace MonoTouchFixtures.GLKit {
} }
} }
#endif // !__WATCHOS__ #endif // HAS_GLKIT

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2012 Xamarin Inc. All rights reserved // Copyright 2012 Xamarin Inc. All rights reserved
#if !__WATCHOS__ #if HAS_GLKIT
using System; using System;
using System.Drawing; using System.Drawing;
@ -34,4 +34,4 @@ namespace MonoTouchFixtures.GLKit {
} }
} }
#endif // !__WATCHOS__ #endif // HAS_GLKIT

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2011 Xamarin Inc. All rights reserved // Copyright 2011 Xamarin Inc. All rights reserved
#if !__WATCHOS__ && !MONOMAC #if HAS_GLKIT && !MONOMAC
using System; using System;
using System.Drawing; using System.Drawing;
@ -26,4 +26,4 @@ namespace MonoTouchFixtures.GLKit {
} }
} }
#endif // !__WATCHOS__ #endif // HAS_GLKIT && !MONOMAC

Просмотреть файл

@ -23,6 +23,7 @@ namespace MonoTouchFixtures.GameKit {
[Test] [Test]
public void Show_NSAction_Null () public void Show_NSAction_Null ()
{ {
TestRuntime.IgnoreOnMacCatalyst ("https://github.com/xamarin/maccore/issues/2346");
// Once upon a time (circa 2012) using null for the action would have crashed the application // Once upon a time (circa 2012) using null for the action would have crashed the application
// but it's not the case anymore (in 2015 / iOS9) and the header files says it's nullable // but it's not the case anymore (in 2015 / iOS9) and the header files says it's nullable
GKNotificationBanner.Show ("title", "message", null); GKNotificationBanner.Show ("title", "message", null);

Просмотреть файл

@ -91,7 +91,7 @@ namespace MonoTouchFixtures.HealthKit {
case HKCategoryTypeIdentifier.VaginalDryness: case HKCategoryTypeIdentifier.VaginalDryness:
case HKCategoryTypeIdentifier.EnvironmentalAudioExposureEvent: case HKCategoryTypeIdentifier.EnvironmentalAudioExposureEvent:
case HKCategoryTypeIdentifier.HandwashingEvent: case HKCategoryTypeIdentifier.HandwashingEvent:
if (!TestRuntime.CheckXcodeVersion (12, 0)) if (!TestRuntime.CheckXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch))
continue; continue;
break; break;
case HKCategoryTypeIdentifier.HeadphoneAudioExposureEvent: case HKCategoryTypeIdentifier.HeadphoneAudioExposureEvent:

Просмотреть файл

@ -35,7 +35,13 @@ namespace MonoTouchFixtures.HealthKit {
Assert.That (details.ValidationError.Length, Is.EqualTo ((nint) 0), "Length"); Assert.That (details.ValidationError.Length, Is.EqualTo ((nint) 0), "Length");
} }
}; };
if (TestRuntime.CheckXcodeVersion (11, 0)) { #if __MACCATALYST__
var throwsException = false;
#else
var throwsException = TestRuntime.CheckXcodeVersion (11, 0);
#endif
if (throwsException) {
var ex = Assert.Throws<MonoTouchException> (action, "Exception"); var ex = Assert.Throws<MonoTouchException> (action, "Exception");
Assert.That (ex.Message, Does.Match ("startDate.*and endDate.*exceed the maximum allowed duration for this sample type"), "Exception Message"); Assert.That (ex.Message, Does.Match ("startDate.*and endDate.*exceed the maximum allowed duration for this sample type"), "Exception Message");
} else { } else {

Просмотреть файл

@ -74,7 +74,7 @@ namespace MonoTouchFixtures.HealthKit {
case HKQuantityTypeIdentifier.WalkingDoubleSupportPercentage: case HKQuantityTypeIdentifier.WalkingDoubleSupportPercentage:
case HKQuantityTypeIdentifier.WalkingSpeed: case HKQuantityTypeIdentifier.WalkingSpeed:
case HKQuantityTypeIdentifier.WalkingStepLength: case HKQuantityTypeIdentifier.WalkingStepLength:
if (!TestRuntime.CheckXcodeVersion (12, 0)) if (!TestRuntime.CheckXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch))
continue; continue;
break; break;

Просмотреть файл

@ -15,6 +15,7 @@ using NUnit.Framework;
using Foundation; using Foundation;
using HomeKit; using HomeKit;
using ObjCRuntime;
namespace MonoTouchFixtures.HomeKit namespace MonoTouchFixtures.HomeKit
{ {
@ -26,6 +27,8 @@ namespace MonoTouchFixtures.HomeKit
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (9, 0); TestRuntime.AssertXcodeVersion (9, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -15,6 +15,7 @@ using NUnit.Framework;
using Foundation; using Foundation;
using HomeKit; using HomeKit;
using ObjCRuntime;
namespace MonoTouchFixtures.HomeKit namespace MonoTouchFixtures.HomeKit
{ {
@ -26,6 +27,8 @@ namespace MonoTouchFixtures.HomeKit
public void Setup () public void Setup ()
{ {
TestRuntime.AssertXcodeVersion (9, 0); TestRuntime.AssertXcodeVersion (9, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -13,33 +13,20 @@ namespace MonoTouchFixtures.ImageIO {
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class CGImageSourceTest { public class CGImageSourceTest {
const string filename = "xamarin2.png";
NSUrl fileUrl = NSBundle.MainBundle.GetUrlForResource ("xamarin2", "png"); NSUrl fileUrl = NSBundle.MainBundle.GetUrlForResource ("xamarin2", "png");
[Test] [Test]
public void FromUrlTest () public void FromUrlTest ()
{ {
#if MONOMAC
using (var img = CGImageSource.FromUrl (fileUrl)) { using (var img = CGImageSource.FromUrl (fileUrl)) {
#else
using (var img = CGImageSource.FromUrl (NSUrl.FromFilename (filename))) {
#endif
Assert.NotNull (img, "#a1"); Assert.NotNull (img, "#a1");
} }
#if MONOMAC
using (var img = CGImageSource.FromUrl (fileUrl, new CGImageOptions ())) { using (var img = CGImageSource.FromUrl (fileUrl, new CGImageOptions ())) {
#else
using (var img = CGImageSource.FromUrl (NSUrl.FromFilename (filename), new CGImageOptions ())) {
#endif
Assert.NotNull (img, "#b1"); Assert.NotNull (img, "#b1");
} }
#if MONOMAC
using (var img = CGImageSource.FromUrl (fileUrl, null)) { using (var img = CGImageSource.FromUrl (fileUrl, null)) {
#else
using (var img = CGImageSource.FromUrl (NSUrl.FromFilename (filename), null)) {
#endif
Assert.NotNull (img, "#c1"); Assert.NotNull (img, "#c1");
} }
} }
@ -48,31 +35,19 @@ namespace MonoTouchFixtures.ImageIO {
public void FromDataProviderTest () public void FromDataProviderTest ()
{ {
var file = NSBundle.MainBundle.PathForResource ("xamarin2", "png"); var file = NSBundle.MainBundle.PathForResource ("xamarin2", "png");
#if MONOMAC
using (var dp = new CGDataProvider (file)) { using (var dp = new CGDataProvider (file)) {
#else
using (var dp = new CGDataProvider (filename)) {
#endif
using (var img = CGImageSource.FromDataProvider (dp)) { using (var img = CGImageSource.FromDataProvider (dp)) {
Assert.NotNull (img, "#a1"); Assert.NotNull (img, "#a1");
} }
} }
#if MONOMAC
using (var dp = new CGDataProvider (file)) { using (var dp = new CGDataProvider (file)) {
#else
using (var dp = new CGDataProvider (filename)) {
#endif
using (var img = CGImageSource.FromDataProvider (dp, new CGImageOptions ())) { using (var img = CGImageSource.FromDataProvider (dp, new CGImageOptions ())) {
Assert.NotNull (img, "#b1"); Assert.NotNull (img, "#b1");
} }
} }
#if MONOMAC
using (var dp = new CGDataProvider (file)) { using (var dp = new CGDataProvider (file)) {
#else
using (var dp = new CGDataProvider (filename)) {
#endif
using (var img = CGImageSource.FromDataProvider (dp, null)) { using (var img = CGImageSource.FromDataProvider (dp, null)) {
Assert.NotNull (img, "#c1"); Assert.NotNull (img, "#c1");
} }
@ -82,11 +57,7 @@ namespace MonoTouchFixtures.ImageIO {
[Test] [Test]
public void FromDataTest () public void FromDataTest ()
{ {
#if MONOMAC
NSData data = NSData.FromFile (NSBundle.MainBundle.PathForResource ("xamarin2", "png")); NSData data = NSData.FromFile (NSBundle.MainBundle.PathForResource ("xamarin2", "png"));
#else
NSData data = NSData.FromFile (filename);
#endif
using (var img = CGImageSource.FromData (data)) { using (var img = CGImageSource.FromData (data)) {
Assert.NotNull (img, "#a1"); Assert.NotNull (img, "#a1");
@ -104,11 +75,7 @@ namespace MonoTouchFixtures.ImageIO {
[Test] [Test]
public void CreateImageTest () public void CreateImageTest ()
{ {
#if MONOMAC
using (var imgsrc = CGImageSource.FromUrl (fileUrl)) { using (var imgsrc = CGImageSource.FromUrl (fileUrl)) {
#else
using (var imgsrc = CGImageSource.FromUrl (NSUrl.FromFilename (filename))) {
#endif
using (var img = imgsrc.CreateImage (0, null)) { using (var img = imgsrc.CreateImage (0, null)) {
Assert.NotNull (img, "#a1"); Assert.NotNull (img, "#a1");
} }
@ -121,11 +88,7 @@ namespace MonoTouchFixtures.ImageIO {
[Test] [Test]
public void CreateThumbnailTest () public void CreateThumbnailTest ()
{ {
#if MONOMAC
using (var imgsrc = CGImageSource.FromUrl (fileUrl)) { using (var imgsrc = CGImageSource.FromUrl (fileUrl)) {
#else
using (var imgsrc = CGImageSource.FromUrl (NSUrl.FromFilename (filename))) {
#endif
using (var img = imgsrc.CreateThumbnail (0, null)) { using (var img = imgsrc.CreateThumbnail (0, null)) {
Assert.NotNull (img, "#a1"); Assert.NotNull (img, "#a1");
} }
@ -157,11 +120,7 @@ namespace MonoTouchFixtures.ImageIO {
NSString kCGImagePropertyPixelWidth = Dlfcn.GetStringConstant (lib, "kCGImagePropertyPixelWidth"); NSString kCGImagePropertyPixelWidth = Dlfcn.GetStringConstant (lib, "kCGImagePropertyPixelWidth");
NSString kCGImagePropertyPixelHeight = Dlfcn.GetStringConstant (lib, "kCGImagePropertyPixelHeight"); NSString kCGImagePropertyPixelHeight = Dlfcn.GetStringConstant (lib, "kCGImagePropertyPixelHeight");
#if MONOMAC
using (var imageSource = CGImageSource.FromUrl (fileUrl)) { using (var imageSource = CGImageSource.FromUrl (fileUrl)) {
#else
using (var imageSource = CGImageSource.FromUrl (NSUrl.FromFilename (filename))) {
#endif
using (var dict = new NSMutableDictionary ()) { using (var dict = new NSMutableDictionary ()) {
dict [kCGImageSourceShouldCache] = NSNumber.FromBoolean (false); dict [kCGImageSourceShouldCache] = NSNumber.FromBoolean (false);
using (var props = imageSource.CopyProperties (dict)) { using (var props = imageSource.CopyProperties (dict)) {
@ -182,11 +141,7 @@ namespace MonoTouchFixtures.ImageIO {
[Test] [Test]
public void GetProperties () public void GetProperties ()
{ {
#if MONOMAC
using (var imageSource = CGImageSource.FromUrl (fileUrl)) { using (var imageSource = CGImageSource.FromUrl (fileUrl)) {
#else
using (var imageSource = CGImageSource.FromUrl (NSUrl.FromFilename (filename))) {
#endif
CGImageOptions options = new CGImageOptions () { ShouldCache = false }; CGImageOptions options = new CGImageOptions () { ShouldCache = false };
var props = imageSource.GetProperties (options); var props = imageSource.GetProperties (options);
@ -209,7 +164,7 @@ namespace MonoTouchFixtures.ImageIO {
{ {
TestRuntime.AssertXcodeVersion (5, 0); TestRuntime.AssertXcodeVersion (5, 0);
using (var imageSource = CGImageSource.FromUrl (NSUrl.FromFilename (filename))) { using (var imageSource = CGImageSource.FromUrl (fileUrl)) {
CGImageOptions options = new CGImageOptions () { ShouldCacheImmediately = true }; CGImageOptions options = new CGImageOptions () { ShouldCacheImmediately = true };
using (CGImageMetadata metadata = imageSource.CopyMetadata (0, options)) { using (CGImageMetadata metadata = imageSource.CopyMetadata (0, options)) {
Console.WriteLine (); Console.WriteLine ();
@ -222,7 +177,7 @@ namespace MonoTouchFixtures.ImageIO {
{ {
TestRuntime.AssertXcodeVersion (5, 0); TestRuntime.AssertXcodeVersion (5, 0);
using (var imageSource = CGImageSource.FromUrl (NSUrl.FromFilename (filename))) { using (var imageSource = CGImageSource.FromUrl (fileUrl)) {
imageSource.RemoveCache (0); imageSource.RemoveCache (0);
} }
} }

Просмотреть файл

@ -88,7 +88,7 @@ namespace MonoTouchFixtures.ImageIO {
string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png"); string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png");
using (NSMutableData destData = new NSMutableData ()) using (NSMutableData destData = new NSMutableData ())
#if MONOMAC #if MONOMAC
using (var uiimg = new NSImage (NSBundle.MainBundle.PathForResource ("basn3p08", "png"))) using (var uiimg = new NSImage (file))
#else #else
using (var uiimg = UIImage.FromFile (file)) using (var uiimg = UIImage.FromFile (file))
#endif #endif
@ -106,7 +106,7 @@ namespace MonoTouchFixtures.ImageIO {
string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png"); string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png");
using (NSMutableData destData = new NSMutableData ()) using (NSMutableData destData = new NSMutableData ())
#if MONOMAC #if MONOMAC
using (var uiimg = new NSImage (NSBundle.MainBundle.PathForResource ("basn3p08", "png"))) using (var uiimg = new NSImage (file))
#else #else
using (var uiimg = UIImage.FromFile (file)) using (var uiimg = UIImage.FromFile (file))
#endif #endif
@ -122,11 +122,7 @@ namespace MonoTouchFixtures.ImageIO {
{ {
TestRuntime.AssertXcodeVersion (5, 0); TestRuntime.AssertXcodeVersion (5, 0);
#if MONOMAC
using (NSData data = NSData.FromFile (NSBundle.MainBundle.PathForResource ("xamarin2", "png"))) using (NSData data = NSData.FromFile (NSBundle.MainBundle.PathForResource ("xamarin2", "png")))
#else
using (NSData data = NSData.FromFile ("xamarin2.png"))
#endif
using (var source = CGImageSource.FromData (data)) using (var source = CGImageSource.FromData (data))
using (NSMutableData destData = new NSMutableData ()) using (NSMutableData destData = new NSMutableData ())
using (var id = CGImageDestination.Create (destData, GoodUti, 1)) { using (var id = CGImageDestination.Create (destData, GoodUti, 1)) {

Просмотреть файл

@ -21,6 +21,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.MapKit { namespace MonoTouchFixtures.MapKit {
#if !XAMCORE_3_0
class AnnotationViewPoker : MKAnnotationView { class AnnotationViewPoker : MKAnnotationView {
static FieldInfo bkAnnotation; static FieldInfo bkAnnotation;
@ -46,6 +47,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
} }
#endif
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
@ -78,6 +80,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
#if !XAMCORE_3_0
[Test] [Test]
public void Annotation_BackingFields () public void Annotation_BackingFields ()
{ {
@ -90,6 +93,7 @@ namespace MonoTouchFixtures.MapKit {
Assert.AreSame (a, av.Annotation, "2a"); Assert.AreSame (a, av.Annotation, "2a");
} }
} }
#endif // !XAMCORE_3_0
[Test] [Test]
public void Default () public void Default ()

Просмотреть файл

@ -12,6 +12,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.MapKit { namespace MonoTouchFixtures.MapKit {
#if !XAMCORE_3_0
class CircleViewPoker : MKCircleView { class CircleViewPoker : MKCircleView {
static FieldInfo bkCircle; static FieldInfo bkCircle;
@ -42,6 +43,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
#endif // !XAMCORE_3_0
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class CircleViewTest { public class CircleViewTest {
@ -55,6 +57,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
#if !XAMCORE_3_0
[Test] [Test]
public void Defaults_BackingFields () public void Defaults_BackingFields ()
{ {
@ -79,6 +82,7 @@ namespace MonoTouchFixtures.MapKit {
Assert.AreSame (c, cv.Circle, "2a"); Assert.AreSame (c, cv.Circle, "2a");
} }
} }
#endif // !XAMCORE_3_0
} }
} }

Просмотреть файл

@ -17,6 +17,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.MapKit { namespace MonoTouchFixtures.MapKit {
#if !XAMCORE_3_0
class MapViewPoker : MKMapView { class MapViewPoker : MKMapView {
static FieldInfo bkAnnotations; static FieldInfo bkAnnotations;
@ -63,6 +64,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
} }
#endif // !XAMCORE_3_0
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
@ -82,6 +84,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
#if !XAMCORE_3_0
[Test] [Test]
public void Annotations_BackingFields () public void Annotations_BackingFields ()
{ {
@ -213,6 +216,7 @@ namespace MonoTouchFixtures.MapKit {
Assert.That (mv.Overlays.Length, Is.EqualTo (2), "9b"); Assert.That (mv.Overlays.Length, Is.EqualTo (2), "9b");
} }
} }
#endif // !XAMCORE_3_0
[Test] [Test]
public void Overlays () public void Overlays ()

Просмотреть файл

@ -14,6 +14,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.MapKit { namespace MonoTouchFixtures.MapKit {
#if !XAMCORE_3_0
class OverlayViewPoker : MKOverlayView { class OverlayViewPoker : MKOverlayView {
static FieldInfo bkOverlay; static FieldInfo bkOverlay;
@ -39,6 +40,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
} }
#endif // !XAMCORE_3_0
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
@ -54,6 +56,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
#if !XAMCORE_3_0
[Test] [Test]
public void Overlay_BackingFields () public void Overlay_BackingFields ()
{ {
@ -66,6 +69,7 @@ namespace MonoTouchFixtures.MapKit {
Assert.AreSame (c, ov.Overlay, "2a"); Assert.AreSame (c, ov.Overlay, "2a");
} }
} }
#endif // !XAMCORE_3_0
} }
} }

Просмотреть файл

@ -12,6 +12,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.MapKit { namespace MonoTouchFixtures.MapKit {
#if !XAMCORE_3_0
class PolygonViewPoker : MKPolygonView { class PolygonViewPoker : MKPolygonView {
static FieldInfo bkPolygon; static FieldInfo bkPolygon;
@ -41,6 +42,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
} }
#endif // !XAMCORE_3_0
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
@ -55,6 +57,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
#if !XAMCORE_3_0
[Test] [Test]
public void Defaults_BackingFields () public void Defaults_BackingFields ()
{ {
@ -79,6 +82,7 @@ namespace MonoTouchFixtures.MapKit {
Assert.AreSame (p, pv.Polygon, "2a"); Assert.AreSame (p, pv.Polygon, "2a");
} }
} }
#endif // !XAMCORE_3_0
} }
} }

Просмотреть файл

@ -12,6 +12,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.MapKit { namespace MonoTouchFixtures.MapKit {
#if !XAMCORE_3_0
class PolylineViewPoker : MKPolylineView { class PolylineViewPoker : MKPolylineView {
static FieldInfo bkPolyline; static FieldInfo bkPolyline;
@ -41,6 +42,7 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
} }
#endif // !XAMCORE_3_0
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
@ -54,6 +56,8 @@ namespace MonoTouchFixtures.MapKit {
Assert.That (pl.Frame, Is.EqualTo (frame), "Frame"); Assert.That (pl.Frame, Is.EqualTo (frame), "Frame");
} }
} }
#if !XAMCORE_3_0
[Test] [Test]
public void Defaults_BackingFields () public void Defaults_BackingFields ()
{ {
@ -78,6 +82,7 @@ namespace MonoTouchFixtures.MapKit {
Assert.AreSame (p, pv.Polyline, "2a"); Assert.AreSame (p, pv.Polyline, "2a");
} }
} }
#endif // !XAMCORE_3_0
} }
} }

Просмотреть файл

@ -7,7 +7,7 @@
// Copyright 2012 Xamarin Inc. All rights reserved. // Copyright 2012 Xamarin Inc. All rights reserved.
// //
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC #if !XAMCORE_3_0 && !MONOMAC
using System; using System;
using System.Drawing; using System.Drawing;
@ -83,4 +83,4 @@ namespace MonoTouchFixtures.MapKit {
} }
} }
#endif // !__TVOS__ && !__WATCHOS__ #endif // !XAMCORE_3_0 && !MONOMAC

Просмотреть файл

@ -29,8 +29,12 @@ namespace MonoTouchFixtures.MessageUI {
if (!MFMailComposeViewController.CanSendMail) if (!MFMailComposeViewController.CanSendMail)
Assert.Inconclusive ("Not configured to send emails"); Assert.Inconclusive ("Not configured to send emails");
#if XAMCORE_3_0
var cancelAttributes = new UIStringAttributes ();
#else
var cancelAttributes = new UITextAttributes (); var cancelAttributes = new UITextAttributes ();
cancelAttributes.TextShadowOffset = new UIOffset (0, -1); cancelAttributes.TextShadowOffset = new UIOffset (0, -1);
#endif
UIBarButtonItem.AppearanceWhenContainedIn (typeof(UISearchBar)).SetTitleTextAttributes (cancelAttributes, UIControlState.Disabled); UIBarButtonItem.AppearanceWhenContainedIn (typeof(UISearchBar)).SetTitleTextAttributes (cancelAttributes, UIControlState.Disabled);
using (var mail = new MFMailComposeViewController ()) { using (var mail = new MFMailComposeViewController ()) {
// we're happy the .ctor did not crash (only on iOS6) because the dictionary had a null key (typo) // we're happy the .ctor did not crash (only on iOS6) because the dictionary had a null key (typo)

Просмотреть файл

@ -12,6 +12,7 @@
using System; using System;
using Foundation; using Foundation;
using Messages; using Messages;
using ObjCRuntime;
using NUnit.Framework; using NUnit.Framework;
namespace MonoTouchFixtures.Messages namespace MonoTouchFixtures.Messages
@ -25,6 +26,8 @@ namespace MonoTouchFixtures.Messages
public void MinimumSdkCheck () public void MinimumSdkCheck ()
{ {
TestRuntime.AssertXcodeVersion (8, 0); TestRuntime.AssertXcodeVersion (8, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
} }
[Test] [Test]

Просмотреть файл

@ -89,15 +89,11 @@ namespace MonoTouchFixtures.Metal {
} }
#if __MACOS__
string metal_code = File.ReadAllText (Path.Combine (NSBundle.MainBundle.ResourcePath, "metal-sample.metal")); string metal_code = File.ReadAllText (Path.Combine (NSBundle.MainBundle.ResourcePath, "metal-sample.metal"));
string metallib_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "default.metallib"); string metallib_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "default.metallib");
string fragmentshader_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "fragmentShader.metallib"); string fragmentshader_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "fragmentShader.metallib");
#else
string metal_code = File.ReadAllText (Path.Combine (NSBundle.MainBundle.BundlePath, "metal-sample.metal"));
string metallib_path = Path.Combine (NSBundle.MainBundle.BundlePath, "default.metallib");
string fragmentshader_path = Path.Combine (NSBundle.MainBundle.BundlePath, "fragmentShader.metallib");
#if !__MACOS__
if (Runtime.Arch == Arch.SIMULATOR) if (Runtime.Arch == Arch.SIMULATOR)
Assert.Ignore ("Metal isn't available in the simulator"); Assert.Ignore ("Metal isn't available in the simulator");
#endif #endif

Просмотреть файл

@ -3,6 +3,7 @@
using System; using System;
using Metal; using Metal;
using ObjCRuntime;
using NUnit.Framework; using NUnit.Framework;
@ -16,6 +17,8 @@ namespace MonoTouchFixtures.Metal {
public void SetUp () public void SetUp ()
{ {
TestRuntime.AssertXcodeVersion (9, 0); TestRuntime.AssertXcodeVersion (9, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
descriptor = new MTLTileRenderPipelineColorAttachmentDescriptor (); descriptor = new MTLTileRenderPipelineColorAttachmentDescriptor ();
} }

Просмотреть файл

@ -3,6 +3,7 @@
using System; using System;
using Metal; using Metal;
using ObjCRuntime;
using NUnit.Framework; using NUnit.Framework;
@ -16,6 +17,8 @@ namespace MonoTouchFixtures.Metal {
public void SetUp () public void SetUp ()
{ {
TestRuntime.AssertXcodeVersion (9, 0); TestRuntime.AssertXcodeVersion (9, 0);
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
descriptor = new MTLTileRenderPipelineDescriptor (); descriptor = new MTLTileRenderPipelineDescriptor ();
} }

Просмотреть файл

@ -29,8 +29,8 @@ namespace MonoTouchFixtures.MultipeerConnectivity {
TestRuntime.AssertSystemVersion (PlatformName.TvOS, 10, 0, throwIfOtherPlatform: false); TestRuntime.AssertSystemVersion (PlatformName.TvOS, 10, 0, throwIfOtherPlatform: false);
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false); TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);
using (var peer = new MCPeerID ()) { using (var peer = new MCPeerID ("MyDisplayName")) {
Assert.Null (peer.DisplayName, "DisplayName"); Assert.AreEqual ("MyDisplayName", peer.DisplayName, "DisplayName");
} }
} }

Просмотреть файл

@ -14,6 +14,12 @@ namespace MonoTouchFixtures.NearbyInteraction {
[TestFixture] [TestFixture]
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class NINearbyObjectTest { public class NINearbyObjectTest {
[SetUp]
public void Setup ()
{
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
}
[Test] [Test]
public void DirectionNotAvailable () public void DirectionNotAvailable ()

Просмотреть файл

@ -110,7 +110,7 @@ namespace MonoTouchFixtures.Network {
[Test] [Test]
public void HasIPV4PropertyTest () public void HasIPV4PropertyTest ()
{ {
#if !MONOMAC #if !MONOMAC && !__MACCATALYST__
if (Runtime.Arch != Arch.DEVICE) if (Runtime.Arch != Arch.DEVICE)
Assert.False (path.HasIPV4, "By default the interface does not support IPV4 on the simulator"); Assert.False (path.HasIPV4, "By default the interface does not support IPV4 on the simulator");
else else
@ -128,7 +128,7 @@ namespace MonoTouchFixtures.Network {
[Test] [Test]
public void HasDnsPropertyTest () public void HasDnsPropertyTest ()
{ {
#if !MONOMAC #if !MONOMAC && !__MACCATALYST__
if (Runtime.Arch != Arch.DEVICE) if (Runtime.Arch != Arch.DEVICE)
Assert.False (path.HasDns, "By default the interface does not support DNS on the simulator"); Assert.False (path.HasDns, "By default the interface does not support DNS on the simulator");
else else

Просмотреть файл

@ -34,7 +34,7 @@ namespace MonoTouchFixtures.NetworkExtension {
Assert.Inconclusive ("Requires enabling Personal PVN (entitlements)"); Assert.Inconclusive ("Requires enabling Personal PVN (entitlements)");
Assert.That (shared.Connection.Status, Is.EqualTo (NEVpnStatus.Invalid), "Connection"); Assert.That (shared.Connection.Status, Is.EqualTo (NEVpnStatus.Invalid), "Connection");
#if MONOMAC #if MONOMAC || __MACCATALYST__
Assert.True (shared.Enabled, "Enabled"); Assert.True (shared.Enabled, "Enabled");
#else #else
Assert.False (shared.Enabled, "Enabled"); Assert.False (shared.Enabled, "Enabled");

Просмотреть файл

@ -99,6 +99,7 @@ namespace MonoTouchFixtures {
public void NavigationControllerOverride () public void NavigationControllerOverride ()
{ {
TestRuntime.IgnoreOnTVOS (); // shouldAutorotate is not available on TVOS. TestRuntime.IgnoreOnTVOS (); // shouldAutorotate is not available on TVOS.
TestRuntime.IgnoreOnMacCatalyst (); // rotation is not available on Mac Catalyst
try { try {
bool category_invoked = false; bool category_invoked = false;

Просмотреть файл

@ -29,7 +29,7 @@ namespace MonoTouchFixtures.ObjCRuntime {
MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException; MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException;
MarshalManagedExceptionMode defaultManagedExceptionMode = MarshalManagedExceptionMode.Default; MarshalManagedExceptionMode defaultManagedExceptionMode = MarshalManagedExceptionMode.Default;
#else #else
#if __MACOS__ && DEBUG #if (__MACOS__ || __MACCATALYST__) && DEBUG
MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException; MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException;
#else #else
MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.UnwindManagedCode; MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.UnwindManagedCode;

Просмотреть файл

@ -2007,6 +2007,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
} }
} }
#if __MACCATALYST__
[Ignore ("https://github.com/dotnet/runtime/issues/47407")] // The GC doesn't collect objects with finalizers
#endif
[Test] [Test]
public void BlockCollection () public void BlockCollection ()
{ {
@ -2203,6 +2206,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
[Test] [Test]
public void VoidPtrToINativeObjectArgument () public void VoidPtrToINativeObjectArgument ()
{ {
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
using (var obj = new ABPeoplePickerNavigationControllerDelegateImpl ()) { using (var obj = new ABPeoplePickerNavigationControllerDelegateImpl ()) {
using (var person = new ABPerson ()) { using (var person = new ABPerson ()) {
Messaging.void_objc_msgSend_IntPtr_IntPtr (obj.Handle, Selector.GetHandle ("peoplePickerNavigationController:didSelectPerson:"), IntPtr.Zero, person.Handle); Messaging.void_objc_msgSend_IntPtr_IntPtr (obj.Handle, Selector.GetHandle ("peoplePickerNavigationController:didSelectPerson:"), IntPtr.Zero, person.Handle);

Просмотреть файл

@ -8,7 +8,7 @@
// //
#if !NET // OpenTK-1.0.dll not yet supported for .NET #if !NET // OpenTK-1.0.dll not yet supported for .NET
#if !__WATCHOS__ && !MONOMAC #if HAS_OPENGLES
using System; using System;
using Foundation; using Foundation;
@ -40,5 +40,5 @@ namespace MonoTouchFixtures.OpenGLES
} }
} }
#endif // !__WATCHOS__ #endif // HAS_OPENGLES
#endif // !NET #endif // !NET

Просмотреть файл

@ -10,6 +10,7 @@
#if !__TVOS__ && !MONOMAC #if !__TVOS__ && !MONOMAC
using System; using System;
using System.IO;
using Foundation; using Foundation;
using UIKit; using UIKit;
using PassKit; using PassKit;
@ -39,9 +40,12 @@ namespace MonoTouchFixtures.PassKit {
// not null (but empty by default) and there's no API to add them // not null (but empty by default) and there's no API to add them
Assert.NotNull (library.GetPasses (), "GetPasses"); Assert.NotNull (library.GetPasses (), "GetPasses");
using (var url = PassTest.GetBoardingPassUrl ()) {
#if __MACCATALYST__
// we can just open the url
Assert.True (UIApplication.SharedApplication.OpenUrl (url), "OpenUrl");
#elif !__WATCHOS__
// and we can't trick the OS to do it for us // and we can't trick the OS to do it for us
using (NSUrl url = new NSUrl (NSBundle.MainBundle.BundleUrl + "/BoardingPass.pkpass")) {
#if !__WATCHOS__
Assert.False (UIApplication.SharedApplication.OpenUrl (url), "OpenUrl"); Assert.False (UIApplication.SharedApplication.OpenUrl (url), "OpenUrl");
#endif #endif
} }

Просмотреть файл

@ -10,6 +10,7 @@
#if !__TVOS__ && !MONOMAC #if !__TVOS__ && !MONOMAC
using System; using System;
using System.IO;
using Foundation; using Foundation;
using UIKit; using UIKit;
using PassKit; using PassKit;
@ -21,6 +22,11 @@ namespace MonoTouchFixtures.PassKit {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class PassTest { public class PassTest {
public static NSUrl GetBoardingPassUrl ()
{
return new NSUrl ("file://" + Path.Combine (NSBundle.MainBundle.ResourcePath, "BoardingPass.pkpass"));
}
[Test] [Test]
public void Defaults () public void Defaults ()
{ {
@ -29,7 +35,9 @@ namespace MonoTouchFixtures.PassKit {
using (PKPass pass = new PKPass ()) { using (PKPass pass = new PKPass ()) {
Assert.Null (pass.AuthenticationToken, "AuthenticationToken"); Assert.Null (pass.AuthenticationToken, "AuthenticationToken");
#if !__WATCHOS__ #if !__WATCHOS__
#if !__MACCATALYST__ // PKPass.Icon doesn't work: https://github.com/xamarin/maccore/issues/2347
Assert.NotNull (pass.Icon, "Icon"); Assert.NotNull (pass.Icon, "Icon");
#endif
#endif #endif
Assert.Null (pass.LocalizedDescription, "LocalizedDescription"); Assert.Null (pass.LocalizedDescription, "LocalizedDescription");
Assert.That (string.IsNullOrEmpty (pass.LocalizedName), Is.False, "LocalizedName"); Assert.That (string.IsNullOrEmpty (pass.LocalizedName), Is.False, "LocalizedName");
@ -44,7 +52,7 @@ namespace MonoTouchFixtures.PassKit {
static public PKPass GetBoardingPass () static public PKPass GetBoardingPass ()
{ {
using (NSUrl url = new NSUrl (NSBundle.MainBundle.BundleUrl + "/BoardingPass.pkpass")) using (var url = GetBoardingPassUrl ())
using (NSData data = NSData.FromUrl (url)) { using (NSData data = NSData.FromUrl (url)) {
NSError error; NSError error;
PKPass pass = new PKPass (data, out error); PKPass pass = new PKPass (data, out error);
@ -61,7 +69,9 @@ namespace MonoTouchFixtures.PassKit {
using (var pass = GetBoardingPass ()) { using (var pass = GetBoardingPass ()) {
Assert.That (pass.AuthenticationToken, Is.EqualTo ("vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc"), "AuthenticationToken"); Assert.That (pass.AuthenticationToken, Is.EqualTo ("vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc"), "AuthenticationToken");
#if !__WATCHOS__ #if !__WATCHOS__
#if !__MACCATALYST__ // PKPass.Icon doesn't work: https://github.com/xamarin/maccore/issues/2347
Assert.NotNull (pass.Icon, "Icon"); Assert.NotNull (pass.Icon, "Icon");
#endif
#endif #endif
Assert.That (pass.LocalizedDescription, Is.Not.Null, "LocalizedDescription is not null"); Assert.That (pass.LocalizedDescription, Is.Not.Null, "LocalizedDescription is not null");

Просмотреть файл

@ -30,10 +30,12 @@ namespace MonoTouchFixtures.QuickLook {
using (QLPreviewController pc = new QLPreviewController ()) { using (QLPreviewController pc = new QLPreviewController ()) {
Assert.Null (pc.CurrentPreviewItem, "CurrentPreviewItem"); Assert.Null (pc.CurrentPreviewItem, "CurrentPreviewItem");
nint index = 0; nint index = 0;
#if !__MACCATALYST__
if (TestRuntime.CheckSystemVersion (PlatformName.iOS, 10, 0)) if (TestRuntime.CheckSystemVersion (PlatformName.iOS, 10, 0))
index = nint.MaxValue; index = nint.MaxValue;
else if (TestRuntime.CheckSystemVersion (PlatformName.iOS, 7, 1)) else if (TestRuntime.CheckSystemVersion (PlatformName.iOS, 7, 1))
index = -1; index = -1;
#endif
Assert.That (pc.CurrentPreviewItemIndex, Is.EqualTo (index), "CurrentPreviewItemIndex"); Assert.That (pc.CurrentPreviewItemIndex, Is.EqualTo (index), "CurrentPreviewItemIndex");
Assert.Null (pc.Delegate, "Delegate"); Assert.Null (pc.Delegate, "Delegate");

Просмотреть файл

@ -22,7 +22,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.Security { namespace MonoTouchFixtures.Security {
[TestFixture] [TestFixture]
// we want the test to be availble if we use the linker // we want the test to be available if we use the linker
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class CertificateTest { public class CertificateTest {
@ -510,7 +510,9 @@ namespace MonoTouchFixtures.Security {
Assert.NotNull (cert.GetNormalizedIssuerSequence (), "GetNormalizedIssuerSequence"); Assert.NotNull (cert.GetNormalizedIssuerSequence (), "GetNormalizedIssuerSequence");
Assert.NotNull (cert.GetNormalizedSubjectSequence (), "GetNormalizedSubjectSequence"); Assert.NotNull (cert.GetNormalizedSubjectSequence (), "GetNormalizedSubjectSequence");
#if !__MACCATALYST__
Assert.NotNull (cert.GetPublicKey (), "GetPublicKey"); Assert.NotNull (cert.GetPublicKey (), "GetPublicKey");
#endif
} }
if (TestRuntime.CheckXcodeVersion (9,0)) { if (TestRuntime.CheckXcodeVersion (9,0)) {
NSError err; NSError err;

Просмотреть файл

@ -22,6 +22,9 @@ namespace MonoTouchFixtures.Security {
extern static int CFGetRetainCount (IntPtr handle); extern static int CFGetRetainCount (IntPtr handle);
[Test] [Test]
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif
public void Add_Certificate () public void Add_Certificate ()
{ {
#if MONOMAC #if MONOMAC
@ -51,6 +54,9 @@ namespace MonoTouchFixtures.Security {
#if !MONOMAC // No QueryAsConcreteType on Mac #if !MONOMAC // No QueryAsConcreteType on Mac
[Test] [Test]
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif
public void AddQueryRemove_Identity () public void AddQueryRemove_Identity ()
{ {
using (SecRecord rec = new SecRecord (SecKind.Identity)) using (SecRecord rec = new SecRecord (SecKind.Identity))
@ -87,6 +93,9 @@ namespace MonoTouchFixtures.Security {
[Test] [Test]
// same as Add_Identity but directly p/invoking - shows that the type MUST NOT be included for Identity // same as Add_Identity but directly p/invoking - shows that the type MUST NOT be included for Identity
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif
public void SecItemAdd_Identity () public void SecItemAdd_Identity ()
{ {
using (NSString valueref = new NSString ("v_Ref")) using (NSString valueref = new NSString ("v_Ref"))
@ -204,6 +213,9 @@ namespace MonoTouchFixtures.Security {
} }
[Test] [Test]
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif
public void CheckId () public void CheckId ()
{ {
TestRuntime.AssertXcodeVersion (5, 1); // macOS 10.9 TestRuntime.AssertXcodeVersion (5, 1); // macOS 10.9

Просмотреть файл

@ -90,6 +90,9 @@ namespace MonoTouchFixtures.Security {
[Test] [Test]
#if MONOMAC #if MONOMAC
[Ignore ("Returns SecAccessible.Invalid")] [Ignore ("Returns SecAccessible.Invalid")]
#endif
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif #endif
public void Accessible_17579 () public void Accessible_17579 ()
{ {
@ -125,6 +128,9 @@ namespace MonoTouchFixtures.Security {
} }
[Test] [Test]
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif
public void Protocol_17579 () public void Protocol_17579 ()
{ {
Protocol (SecProtocol.Afp); Protocol (SecProtocol.Afp);
@ -189,6 +195,9 @@ namespace MonoTouchFixtures.Security {
Assert.That (match.AuthenticationType, Is.EqualTo (type), "AuthenticationType"); Assert.That (match.AuthenticationType, Is.EqualTo (type), "AuthenticationType");
} }
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif
[Test] [Test]
public void AuthenticationType_17579 () public void AuthenticationType_17579 ()
{ {
@ -205,6 +214,9 @@ namespace MonoTouchFixtures.Security {
// Test Case provided by user // Test Case provided by user
// This test case scenario used to fail under iOS 6 or lower // This test case scenario used to fail under iOS 6 or lower
[Test] [Test]
#if __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif
public void DeskCase_83099_InmutableDictionary () public void DeskCase_83099_InmutableDictionary ()
{ {
var testUsername = "testusername"; var testUsername = "testusername";
@ -294,6 +306,8 @@ namespace MonoTouchFixtures.Security {
[Test] [Test]
#if MONOMAC #if MONOMAC
[Ignore ("SecStatusCode code = SecKeyChain.Add (rec); returns SecStatusCode.Param")] [Ignore ("SecStatusCode code = SecKeyChain.Add (rec); returns SecStatusCode.Param")]
#elif __MACCATALYST__
[Ignore ("This test requires an app signed with the keychain-access-groups entitlement, and for Mac Catalyst that requires a custom provisioning profile.")]
#endif #endif
public void IdentityRecordTest () public void IdentityRecordTest ()
{ {

Просмотреть файл

@ -22,6 +22,9 @@ namespace MonoTouchFixtures.Security {
[SetUp] [SetUp]
public void SetUp () public void SetUp ()
{ {
// The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
TestRuntime.AssertSystemVersion (PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
domainName = "com.xamarin.monotouch-test"; domainName = "com.xamarin.monotouch-test";
account = "twitter"; account = "twitter";
password = "12345678"; password = "12345678";

Просмотреть файл

@ -160,7 +160,7 @@ namespace MonoTouchFixtures.SystemConfiguration {
{ {
TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false); TestRuntime.AssertSystemVersion (PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);
#if MONOMAC #if MONOMAC || __MACCATALYST__
bool supported = true; bool supported = true;
#else #else
// that API is deprecated in iOS9 - and it might be why it returns false (or not) // that API is deprecated in iOS9 - and it might be why it returns false (or not)

Просмотреть файл

@ -36,14 +36,14 @@ namespace MonoTouchFixtures.UIKit {
[Test] [Test]
public void ButtonShapesEnabled () public void ButtonShapesEnabled ()
{ {
TestRuntime.AssertXcodeVersion (12, 0); TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
Assert.False (UIAccessibility.ButtonShapesEnabled); Assert.False (UIAccessibility.ButtonShapesEnabled);
} }
[Test] [Test]
public void PrefersCrossFadeTransitions () public void PrefersCrossFadeTransitions ()
{ {
TestRuntime.AssertXcodeVersion (12, 0); TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
Assert.False (UIAccessibility.PrefersCrossFadeTransitions); Assert.False (UIAccessibility.PrefersCrossFadeTransitions);
} }
} }

Просмотреть файл

@ -128,7 +128,11 @@ namespace MonoTouchFixtures.UIKit {
{ {
using (MyView v = new MyView ("note")) using (MyView v = new MyView ("note"))
using (var b = new UIBarButtonItem (v)) { using (var b = new UIBarButtonItem (v)) {
b.SetTitleTextAttributes (null, UIControlState.Disabled); #if XAMCORE_3_0
b.SetTitleTextAttributes ((UIStringAttributes) null, UIControlState.Disabled);
#else
b.SetTitleTextAttributes ((UITextAttributes) null, UIControlState.Disabled);
#endif
} }
} }
#endif #endif

Просмотреть файл

@ -15,7 +15,7 @@ namespace MonoTouchFixtures.UIKit {
[Test] [Test]
public void GetPositionBeforeAccessory () public void GetPositionBeforeAccessory ()
{ {
TestRuntime.AssertXcodeVersion (12, 0); TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
var cap = UICellAccessory.GetPositionBeforeAccessory (new Class ("UIButton")); var cap = UICellAccessory.GetPositionBeforeAccessory (new Class ("UIButton"));
Assert.NotNull (cap, "Class/cap"); Assert.NotNull (cap, "Class/cap");
Assert.That (cap (new UICellAccessory [0]), Is.EqualTo ((nuint) 0), "Class/Invoke"); Assert.That (cap (new UICellAccessory [0]), Is.EqualTo ((nuint) 0), "Class/Invoke");
@ -28,7 +28,7 @@ namespace MonoTouchFixtures.UIKit {
[Test] [Test]
public void GetPositionAfterAccessory () public void GetPositionAfterAccessory ()
{ {
TestRuntime.AssertXcodeVersion (12, 0); TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
var cap = UICellAccessory.GetPositionAfterAccessory (new Class ("UIButton")); var cap = UICellAccessory.GetPositionAfterAccessory (new Class ("UIButton"));
Assert.NotNull (cap, "Class/cap"); Assert.NotNull (cap, "Class/cap");
Assert.That (cap (new UICellAccessory [0]), Is.EqualTo ((nuint) 0), "Class/Invoke"); Assert.That (cap (new UICellAccessory [0]), Is.EqualTo ((nuint) 0), "Class/Invoke");

Просмотреть файл

@ -2,6 +2,7 @@
#if !MONOMAC #if !MONOMAC
using System; using System;
using System.IO;
#if !__WATCHOS__ #if !__WATCHOS__
using System.Drawing; using System.Drawing;
#endif #endif
@ -244,7 +245,7 @@ namespace MonoTouchFixtures.UIKit {
[Test] [Test]
public void Pattern_7362 () public void Pattern_7362 ()
{ {
using (var img = UIImage.FromFile ("basn3p08.png")) using (var img = UIImage.FromFile (Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png")))
using (var color = UIColor.FromPatternImage (img)) { using (var color = UIColor.FromPatternImage (img)) {
Assert.That (color.ToString (), Is.EqualTo (color.Description), "not an RGBA color"); Assert.That (color.ToString (), Is.EqualTo (color.Description), "not an RGBA color");
} }
@ -297,7 +298,7 @@ namespace MonoTouchFixtures.UIKit {
[Test] [Test]
public void UIConfigurationColorTransformerTest () public void UIConfigurationColorTransformerTest ()
{ {
TestRuntime.AssertXcodeVersion (12, 0); TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
var redColor = UIColor.Red; var redColor = UIColor.Red;
var transformer = UIConfigurationColorTransformer.Grayscale; var transformer = UIConfigurationColorTransformer.Grayscale;
var grayColor = transformer (redColor); var grayColor = transformer (redColor);

Просмотреть файл

@ -14,6 +14,9 @@ namespace MonoTouchFixtures.UIKit {
public class FontTest { public class FontTest {
[Test] [Test]
#if __MACCATALYST__
[Ignore ("https://github.com/xamarin/maccore/issues/2382")]
#endif
public void WithSize () public void WithSize ()
{ {
var f1 = UIFont.SystemFontOfSize (10).WithSize (20); var f1 = UIFont.SystemFontOfSize (10).WithSize (20);
@ -82,10 +85,12 @@ namespace MonoTouchFixtures.UIKit {
f2 = UIFont.SystemFontOfSize (12); f2 = UIFont.SystemFontOfSize (12);
SemiFactory_25511 (f1, f2, "SystemFontOfSize"); SemiFactory_25511 (f1, f2, "SystemFontOfSize");
#if !__MACCATALYST__ // https://github.com/xamarin/maccore/issues/2382
// instance // instance
f1 = f2.WithSize (12); f1 = f2.WithSize (12);
f2 = f2.WithSize (12); f2 = f2.WithSize (12);
SemiFactory_25511 (f1, f2, "WithSize"); SemiFactory_25511 (f1, f2, "WithSize");
#endif
if (!TestRuntime.CheckXcodeVersion (5, 0)) if (!TestRuntime.CheckXcodeVersion (5, 0))
return; return;
@ -156,7 +161,11 @@ namespace MonoTouchFixtures.UIKit {
Assert.IsNotNull (UIFont.ItalicSystemFontOfSize (-5), "ItalicSystemFontOfSize"); Assert.IsNotNull (UIFont.ItalicSystemFontOfSize (-5), "ItalicSystemFontOfSize");
using (var font = UIFont.SystemFontOfSize (12)) { using (var font = UIFont.SystemFontOfSize (12)) {
#if __MACCATALYST__
Assert.IsNull (font.WithSize (-6), "WithSize");
#else
Assert.IsNotNull (font.WithSize (-6), "WithSize"); Assert.IsNotNull (font.WithSize (-6), "WithSize");
#endif
} }
} }
} }

Просмотреть файл

@ -34,7 +34,9 @@ namespace MonoTouchFixtures.UIKit {
Assert.That (lm.FirstUnlaidCharacterIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidCharacterIndex"); Assert.That (lm.FirstUnlaidCharacterIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidCharacterIndex");
Assert.That (lm.FirstUnlaidGlyphIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidGlyphIndex"); Assert.That (lm.FirstUnlaidGlyphIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidGlyphIndex");
Assert.False (lm.HasNonContiguousLayout, "HasNonContiguousLayout"); Assert.False (lm.HasNonContiguousLayout, "HasNonContiguousLayout");
#if !__MACCATALYST__
Assert.That (lm.HyphenationFactor, Is.EqualTo ((nfloat) 0), "HyphenationFactor"); Assert.That (lm.HyphenationFactor, Is.EqualTo ((nfloat) 0), "HyphenationFactor");
#endif
Assert.That (lm.NumberOfGlyphs, Is.EqualTo ((nuint) 0), "NumberOfGlyphs"); Assert.That (lm.NumberOfGlyphs, Is.EqualTo ((nuint) 0), "NumberOfGlyphs");
Assert.False (lm.ShowsControlCharacters, "ShowsControlCharacters"); Assert.False (lm.ShowsControlCharacters, "ShowsControlCharacters");
Assert.False (lm.ShowsInvisibleCharacters, "ShowsInvisibleCharacters"); Assert.False (lm.ShowsInvisibleCharacters, "ShowsInvisibleCharacters");

Просмотреть файл

@ -51,8 +51,12 @@ namespace MonoTouchFixtures.UIKit {
using (var vc = new UIViewController ()) using (var vc = new UIViewController ())
using (var bbi = new UIBarButtonItem (UIBarButtonSystemItem.Action)) using (var bbi = new UIBarButtonItem (UIBarButtonSystemItem.Action))
using (var pc = new UIPopoverController (vc)) { using (var pc = new UIPopoverController (vc)) {
#if __MACCATALYST__
pc.PresentFromBarButtonItem (bbi, UIPopoverArrowDirection.Down, true);
#else
// UIBarButtonItem is itself 'ok' but it's not assigned to a view // UIBarButtonItem is itself 'ok' but it's not assigned to a view
Assert.Throws<MonoTouchException> (() => pc.PresentFromBarButtonItem (bbi, UIPopoverArrowDirection.Down, true)); Assert.Throws<MonoTouchException> (() => pc.PresentFromBarButtonItem (bbi, UIPopoverArrowDirection.Down, true));
#endif
// fails with: // fails with:
// Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIPopoverController presentPopoverFromBarButtonItem:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window. // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIPopoverController presentPopoverFromBarButtonItem:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.
} }

Просмотреть файл

@ -15,6 +15,10 @@ namespace MonoTouchFixtures.UIKit {
public class ReferenceLibraryViewControllerTest { public class ReferenceLibraryViewControllerTest {
[Test] [Test]
#if __MACCATALYST__
[Ignore ("https://github.com/xamarin/maccore/issues/2348")] // The native class doesn't exist
#endif
public void InitWithTerm () public void InitWithTerm ()
{ {
if (Runtime.Arch == Arch.DEVICE && TestRuntime.CheckSystemVersion (PlatformName.iOS, 9, 0)) if (Runtime.Arch == Arch.DEVICE && TestRuntime.CheckSystemVersion (PlatformName.iOS, 9, 0))

Просмотреть файл

@ -7,7 +7,7 @@
// Copyright 2012 Xamarin Inc. All rights reserved. // Copyright 2012 Xamarin Inc. All rights reserved.
// //
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC #if !XAMCORE_3_0 && !MONOMAC
using System; using System;
using System.Drawing; using System.Drawing;
@ -116,5 +116,5 @@ namespace MonoTouchFixtures.UIKit {
} }
} }
#endif // !__TVOS__ && !__WATCHOS__ #endif // !XAMCORE_3_0 && !MONOMAC

Просмотреть файл

@ -4,6 +4,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO;
using CoreGraphics; using CoreGraphics;
using Foundation; using Foundation;
using UIKit; using UIKit;
@ -49,7 +50,7 @@ namespace MonoTouchFixtures.UIKit {
Assert.Throws<ArgumentException> (() => new UISegmentedControl ((object []) new [] { NSZone.Default }), "invalid type"); Assert.Throws<ArgumentException> (() => new UISegmentedControl ((object []) new [] { NSZone.Default }), "invalid type");
using (var ns = new NSString ("NSString")) using (var ns = new NSString ("NSString"))
using (var img = UIImage.FromFile ("basn3p08.png")) using (var img = UIImage.FromFile (Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png")))
using (UISegmentedControl sc = new UISegmentedControl ("string", ns, img)) { using (UISegmentedControl sc = new UISegmentedControl ("string", ns, img)) {
Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 3), "NumberOfSegments"); Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 3), "NumberOfSegments");
} }
@ -65,7 +66,7 @@ namespace MonoTouchFixtures.UIKit {
} }
using (var ns = new NSString ("NSString")) using (var ns = new NSString ("NSString"))
using (var img = UIImage.FromFile ("basn3p08.png")) using (var img = UIImage.FromFile (Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png")))
using (var a = NSArray.FromObjects ("string", ns, img)) using (var a = NSArray.FromObjects ("string", ns, img))
using (UISegmentedControl sc = new UISegmentedControl (a)) { using (UISegmentedControl sc = new UISegmentedControl (a)) {
Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 3), "NumberOfSegments"); Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 3), "NumberOfSegments");
@ -101,7 +102,7 @@ namespace MonoTouchFixtures.UIKit {
Assert.Throws<ArgumentNullException> (() => new UISegmentedControl ((UIImage) null), "null"); Assert.Throws<ArgumentNullException> (() => new UISegmentedControl ((UIImage) null), "null");
Assert.Throws<ArgumentNullException> (() => new UISegmentedControl ((UIImage[]) null), "null array"); Assert.Throws<ArgumentNullException> (() => new UISegmentedControl ((UIImage[]) null), "null array");
using (var img = UIImage.FromFile ("basn3p08.png")) using (var img = UIImage.FromFile (Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png")))
using (UISegmentedControl sc = new UISegmentedControl (img)) { using (UISegmentedControl sc = new UISegmentedControl (img)) {
Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 1), "NumberOfSegments"); Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 1), "NumberOfSegments");
} }

Просмотреть файл

@ -23,6 +23,7 @@ namespace MonoTouchFixtures.UIKit {
[Preserve (AllMembers = true)] [Preserve (AllMembers = true)]
public class SimpleTextPrintFormatterTest { public class SimpleTextPrintFormatterTest {
#if !XAMCORE_3_0 // The default ctor is not available in XAMCORE_3_0+
[Test] [Test]
public void DefaultCtor () public void DefaultCtor ()
{ {
@ -44,6 +45,7 @@ namespace MonoTouchFixtures.UIKit {
Assert.That (stpf.Text, Is.Empty, "Text"); Assert.That (stpf.Text, Is.Empty, "Text");
} }
} }
#endif // !XAMCORE_3_0
[Test] [Test]
public void StringCtor () public void StringCtor ()

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright 2011-2012 Xamarin Inc. All rights reserved // Copyright 2011-2012 Xamarin Inc. All rights reserved
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC #if !XAMCORE_3_0 && !MONOMAC
using System; using System;
using System.Drawing; using System.Drawing;
@ -161,4 +161,4 @@ namespace MonoTouchFixtures.UIKit {
} }
} }
#endif // !__TVOS__ && !__WATCHOS__ #endif // !XAMCORE_3_0 && !MONOMAC

Просмотреть файл

@ -68,7 +68,9 @@ namespace MonoTouchFixtures.UIKit {
Assert.That (lm.FirstUnlaidCharacterIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidCharacterIndex"); Assert.That (lm.FirstUnlaidCharacterIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidCharacterIndex");
Assert.That (lm.FirstUnlaidGlyphIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidGlyphIndex"); Assert.That (lm.FirstUnlaidGlyphIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidGlyphIndex");
Assert.False (lm.HasNonContiguousLayout, "HasNonContiguousLayout"); Assert.False (lm.HasNonContiguousLayout, "HasNonContiguousLayout");
#if !__MACCATALYST__
Assert.That (lm.HyphenationFactor, Is.EqualTo ((nfloat) 0), "HyphenationFactor"); Assert.That (lm.HyphenationFactor, Is.EqualTo ((nfloat) 0), "HyphenationFactor");
#endif
Assert.That (lm.NumberOfGlyphs, Is.EqualTo ((nuint) 0), "NumberOfGlyphs"); Assert.That (lm.NumberOfGlyphs, Is.EqualTo ((nuint) 0), "NumberOfGlyphs");
Assert.False (lm.ShowsControlCharacters, "ShowsControlCharacters"); Assert.False (lm.ShowsControlCharacters, "ShowsControlCharacters");
Assert.False (lm.ShowsInvisibleCharacters, "ShowsInvisibleCharacters"); Assert.False (lm.ShowsInvisibleCharacters, "ShowsInvisibleCharacters");

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше