[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));
}
#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>

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

@ -17,7 +17,7 @@ namespace SafariServices {
// NSInteger -> SSReadingList.h
[NoMac][iOS (7,0)]
[Unavailable (PlatformName.MacCatalyst)][Advice ("This API is not available when using UIKit on macOS.")]
[MacCatalyst (14,0)]
[Native]
[ErrorDomain ("SSReadingListErrorDomain")]
public enum SSReadingListError : long {
@ -27,7 +27,8 @@ namespace SafariServices {
[NoMac]
[iOS (9,0)]
[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]
[ErrorDomain ("SFContentBlockerErrorDomain")]
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
/* Only available on OS X v10.7 or later */
[DllImport (Constants.SecurityLibrary)]
@ -279,6 +280,8 @@ namespace Security {
return (data == IntPtr.Zero) ? null : new SecKey (data, true);
}
#endif
#endif // !__MACCATALYST__
[TV (12,0)][Mac (10,14)][iOS (12,0)][Watch (5,0)]
[DllImport (Constants.SecurityLibrary)]
static extern IntPtr /* SecKeyRef* */ SecCertificateCopyKey (IntPtr /* SecKeyRef* */ key);

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

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

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

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

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

@ -251,6 +251,7 @@ namespace EventKit {
bool Immutable { [Bind ("isImmutable")] get; }
#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.")]
[Static, Export ("calendarWithEventStore:")]
EKCalendar FromEventStore (EKEventStore eventStore);

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

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

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

@ -15,9 +15,11 @@ using Foundation;
#if !__TVOS__
using Contacts;
#endif
#if MONOMAC || __MACCATALYST__
using EventKit;
#endif
#if MONOMAC
using AppKit;
using EventKit;
#else
#if !__TVOS__ && !__WATCHOS__
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
// we use this constant to make up for that difference when using
// AssertXcodeVersion and CheckXcodeVersion
#if __MACOS__
#if __MACOS__ || __MACCATALYST__
public const int MinorXcode12APIMismatch = 2;
#else
public const int MinorXcode12APIMismatch = 0;
@ -86,6 +88,12 @@ partial class TestRuntime
return version;
}
}
#elif __MACCATALYST__
public static Version OSXVersion {
get {
return Version.Parse (UIDevice.CurrentDevice.SystemVersion);
}
}
#endif
public static Version GetSDKVersion ()
@ -216,7 +224,7 @@ partial class TestRuntime
if (v.Xcode.Beta != beta)
continue;
#if __IOS__
#if __IOS__ && !__MACCATALYST__
if (!CheckExactiOSSystemVersion (v.iOS.Major, v.iOS.Minor))
return false;
if (v.iOS.Build == "?")
@ -232,7 +240,7 @@ partial class TestRuntime
var actual = GetiOSBuildVersion ();
Console.WriteLine (actual);
return actual.StartsWith (v.tvOS.Build, StringComparison.Ordinal);
#elif __MACOS__
#elif __MACOS__ || __MACCATALYST__
if (!CheckExactmacOSSystemVersion (v.macOS.Major, v.macOS.Minor))
return false;
if (v.macOS.Build == "?")
@ -342,10 +350,10 @@ partial class TestRuntime
return CheckWatchOSSystemVersion (6, 1);
#elif __TVOS__
return ChecktvOSSystemVersion (13, 2);
#elif __IOS__
return CheckiOSSystemVersion (13, 2);
#elif MONOMAC
return CheckMacSystemVersion (10, 15, 1);
#elif __IOS__
return CheckiOSSystemVersion (13, 2);
#else
throw new NotImplementedException ();
#endif
@ -708,6 +716,9 @@ partial class TestRuntime
case PlatformName.WatchOS:
AssertWatchOSSystemVersion (major, minor, throwIfOtherPlatform);
break;
case PlatformName.MacCatalyst:
AssertMacCatalystSystemVersion (major, minor, build, throwIfOtherPlatform);
break;
default:
throw new Exception ($"Unknown platform: {platform}");
}
@ -839,12 +850,29 @@ partial class TestRuntime
#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)
{
if (!CheckMacSystemVersion (major, minor, build, throwIfOtherPlatform))
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)
{
#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 ()
{
return !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DISABLE_SYSTEM_PERMISSION_TESTS"));
@ -1045,7 +1080,7 @@ partial class TestRuntime
}
#endif // !MONOMAC && !__TVOS__
#if __MACOS__
#if __MACOS__ || __MACCATALYST__
public static void RequestEventStorePermission (EKEntityType entityType, bool assert_granted = false)
{
TestRuntime.AssertMacSystemVersion (10, 9, throwIfOtherPlatform: false);
@ -1060,8 +1095,12 @@ partial class TestRuntime
// There's an instance method on EKEventStore to request permission,
// but creating the instance can end up blocking the app showing a permission dialog...
// (on Mavericks at least)
#if __MACCATALYST__
return; // Crossing fingers that this won't hang.
#else
if (TestRuntime.CheckMacSystemVersion (10, 10))
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.");
break;
case EKAuthorizationStatus.Denied:

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

@ -23,10 +23,17 @@ namespace MonoTouchFixtures.ARKit {
[Preserve (AllMembers = true)]
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]
public void MarshallingTest ()
{
TestRuntime.AssertXcodeVersion (10, 0);
var faceAnchor = new ARAnchor ("My Anchor", MatrixFloat4x4.Identity);
Assert.AreEqual (MatrixFloat4x4.Identity, faceAnchor.Transform, "Transform");
}

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

@ -4,6 +4,7 @@ using System;
using System.Reflection;
using ARKit;
using Foundation;
using ObjCRuntime;
using NUnit.Framework;
namespace MonoTouchFixtures.ARKit {
@ -12,10 +13,17 @@ namespace MonoTouchFixtures.ARKit {
[Preserve (AllMembers = true)]
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]
public void SupportedVideoFormats ()
{
TestRuntime.AssertXcodeVersion (9, 3);
var svf = ARConfiguration.SupportedVideoFormats;
Assert.That (svf, Is.Empty, "empty");
}
@ -23,7 +31,6 @@ namespace MonoTouchFixtures.ARKit {
[Test]
public void GetSupportedVideoFormats_9_3 ()
{
TestRuntime.AssertXcodeVersion (9, 3);
Assert.NotNull (ARWorldTrackingConfiguration.GetSupportedVideoFormats (), "ARWorldTrackingConfiguration");
Assert.NotNull (AROrientationTrackingConfiguration.GetSupportedVideoFormats (), "AROrientationTrackingConfiguration");
Assert.NotNull (ARFaceTrackingConfiguration.GetSupportedVideoFormats (), "ARFaceTrackingConfiguration");

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

@ -28,6 +28,8 @@ namespace MonoTouchFixtures.ARKit {
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]

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

@ -88,6 +88,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup ()
{
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]

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

@ -102,6 +102,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup ()
{
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]
@ -142,4 +144,4 @@ namespace MonoTouchFixtures.ARKit {
}
}
#endif // __IOS__
#endif // __IOS__

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

@ -77,6 +77,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup ()
{
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]

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

@ -28,6 +28,8 @@ namespace MonoTouchFixtures.ARKit {
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]
@ -45,4 +47,4 @@ namespace MonoTouchFixtures.ARKit {
}
}
#endif
#endif

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

@ -62,6 +62,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup ()
{
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]

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

@ -76,6 +76,8 @@ namespace MonoTouchFixtures.ARKit {
public void Setup ()
{
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]

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

@ -17,6 +17,8 @@ namespace monotouchtest.ARKit {
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]

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

@ -87,11 +87,7 @@ namespace MonoTouchFixtures.AVFoundation {
}
string does_not_exists_asset_path = Path.Combine (NSBundle.MainBundle.BundlePath, "xamarin.mov");
#if MONOMAC
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
string video_asset_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "xamvideotest.mp4");
bool handled;
ManualResetEvent mre;

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

@ -14,12 +14,11 @@ namespace monotouchtest {
public void TestConstructor ()
{
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 ();
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))
Assert.That (settings.Handle, Is.Not.EqualTo (IntPtr.Zero));
}

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

@ -34,7 +34,13 @@ namespace MonoTouchFixtures.AVFoundation {
Compare (AVMediaType.MetadataObject, AVMediaTypes.MetadataObject);
// 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");
else
Compare (AVMediaType.TimedMetadata, AVMediaTypes.TimedMetadata);

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

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

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

@ -24,6 +24,13 @@ namespace MonoTouchFixtures.AddressBook {
// 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]
public void GetAllSources ()
{

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

@ -22,6 +22,13 @@ namespace MonoTouchFixtures.AddressBook {
[Preserve (AllMembers = true)]
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]
public void UpdateAddressLine ()
{

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

@ -22,6 +22,13 @@ namespace MonoTouchFixtures.AddressBook {
[Preserve (AllMembers = true)]
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]
public void Default ()
{

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

@ -23,6 +23,13 @@ namespace MonoTouchFixtures.AddressBookUI {
[Preserve (AllMembers = true)]
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]
public void ChateauFrontenac ()
{

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

@ -19,11 +19,7 @@ namespace MonoTouchFixtures.AudioToolbox {
[Test]
public void ReadTest ()
{
#if MONOMAC
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);
int len;

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

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

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

@ -1,6 +1,6 @@
// Copyright 2011 Xamarin Inc. All rights reserved
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC && !XAMCORE_3_0
using System;
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]
public void FromFile ()
{
#if MONOMAC
var path = NSBundle.MainBundle.PathForResource ("1", "caf", "AudioToolbox");
#else
var path = Path.GetFullPath (Path.Combine ("AudioToolbox", "1.caf"));
#if !MONOMAC
if (Runtime.Arch == Arch.SIMULATOR)
Assert.Ignore ("PlaySystemSound doesn't work in the simulator");
#endif
@ -54,11 +51,7 @@ namespace MonoTouchFixtures.AudioToolbox {
[Test]
public void Properties ()
{
#if MONOMAC
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))) {
Assert.That (ss.IsUISound, Is.True, "#1");
@ -109,11 +102,7 @@ namespace MonoTouchFixtures.AudioToolbox {
[Test]
public void DisposeTest ()
{
#if MONOMAC
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));
Assert.That (ss.Handle, Is.Not.EqualTo (IntPtr.Zero), "DisposeTest");

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

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

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

@ -13,6 +13,7 @@ using NUnit.Framework;
using CarPlay;
using Foundation;
using ObjCRuntime;
namespace MonoTouchFixtures.CarPlay {
@ -21,7 +22,12 @@ namespace MonoTouchFixtures.CarPlay {
public class CPMessageListItemTest {
[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]
public void InitUsingConversationIdentifier ()

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

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

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

@ -43,7 +43,7 @@ namespace MonoTouchFixtures.Contacts {
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
// 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)) {
Assert.That (contacts.Length, Is.EqualTo (1), "Length");
identifier = contacts [0].Identifier;

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

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

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

@ -3,6 +3,7 @@
//
using System;
using System.Collections.Generic;
using System.IO;
using Foundation;
using CoreFoundation;
using NUnit.Framework;
@ -104,10 +105,13 @@ namespace MonoTouchFixtures.CoreFoundation {
{
var main = CFBundle.GetMain ();
#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
Assert.That(main.ExecutableUrl.ToString (), Contains.Substring (ExpectedAppName + "/monotouchtest"));
var executableRelativePath = Path.Combine (ExpectedAppName, "monotouchtest");
#endif
Assert.That (main.ExecutableUrl.ToString (), Contains.Substring (executableRelativePath));
}
[Test]

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

@ -76,7 +76,7 @@ namespace MonoTouchFixtures.CoreFoundation {
do {
var context = listener.GetContext ();
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}");
var buf = File.ReadAllBytes (pacPath);
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
// 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;
var script = File.ReadAllText (pacPath);
var targetUri = NetworkResources.XamarinUri;
@ -129,7 +129,7 @@ namespace MonoTouchFixtures.CoreFoundation {
[Test]
public void TestPACParsingScriptNoProxy ()
{
string pacPath = Path.Combine (NSBundle.MainBundle.BundlePath, "example.pac");
string pacPath = Path.Combine (NSBundle.MainBundle.ResourcePath, "example.pac");
NSError error = null;
var script = File.ReadAllText (pacPath);
var targetUri = NetworkResources.MicrosoftUri;
@ -158,7 +158,7 @@ namespace MonoTouchFixtures.CoreFoundation {
NSError error = null;
NSObject cbClient = null;
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 targetUri = NetworkResources.XamarinUri;
@ -196,7 +196,7 @@ namespace MonoTouchFixtures.CoreFoundation {
NSError error = null;
NSObject cbClient = null;
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 targetUri = NetworkResources.MicrosoftUri;

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

@ -22,8 +22,10 @@ using AppKit;
using OpenGL;
#else
using UIKit;
#if HAS_OPENGLES
using OpenGLES;
#endif
#endif
using NUnit.Framework;
@ -65,7 +67,7 @@ namespace MonoTouchFixtures.CoreImage {
}
}
#if !MONOMAC // No EAGLContext for Mac
#if HAS_OPENGLES
[Test]
public void FromContext_13983 ()
{
@ -88,7 +90,7 @@ namespace MonoTouchFixtures.CoreImage {
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 videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video)) {
if (videoDevice == null)
Assert.Inconclusive ("Failed to create a video device for testing");
NSError error;
using (var videoInput = new AVCaptureDeviceInput (videoDevice, out error)) {
// this seems to initialize something.
@ -94,6 +96,8 @@ namespace MonoTouchFixtures.CoreMedia {
using (var captureSession = new AVCaptureSession ()) {
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) {
for (int i = 0; i < 10; i++) {
using (var f = format.FormatDescription) {

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

@ -60,7 +60,7 @@ namespace MonoTouchFixtures.CoreText {
// xcode 11 beta 4 stopped reporting errors
// Assert.IsNotNull (err, "err 3");
err = CTFontManager.UnregisterFontsForUrl (url, CTFontManagerScope.Process);
#if MONOMAC
#if MONOMAC || __MACCATALYST__
if (TestRuntime.CheckXcodeVersion (12,2))
Assert.IsNotNull (err, "err 4");
else
@ -157,7 +157,7 @@ namespace MonoTouchFixtures.CoreText {
// Assert.AreEqual (1, err.Length, "err 3 l");
// Assert.IsNotNull (err [0], "err 3[0]");
err = CTFontManager.UnregisterFontsForUrl (new [] { url }, CTFontManagerScope.Process);
#if MONOMAC
#if MONOMAC || __MACCATALYST__
if (TestRuntime.CheckXcodeVersion (12, 2)) {
Assert.IsNotNull (err, "err 4");
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]
public void RequestFonts ()
{

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

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

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

@ -12,6 +12,7 @@
using System;
using Foundation;
using ExternalAccessory;
using ObjCRuntime;
using NUnit.Framework;
namespace MonoTouchFixtures.ExternalAccessory {
@ -41,6 +42,8 @@ namespace MonoTouchFixtures.ExternalAccessory {
[Test]
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);
}
#endif

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

@ -71,12 +71,13 @@ namespace MonoTouchFixtures.Foundation {
public void FromFile ()
{
Assert.Null (NSData.FromFile ("does not exists"), "unexisting");
#if MONOMAC // Info.Plist isn't there to load from the same location on mac
if (!TestRuntime.IsLinkAll)
Assert.NotNull (NSData.FromFile (NSBundle.MainBundle.PathForResource ("runtime-options", "plist")), "runtime-options.plist");
#if MONOMAC || __MACCATALYST__
// Info.Plist isn't there to load from the same location on mac
var plistPath = Path.Combine (NSBundle.MainBundle.BundlePath, "Contents", "Info.plist");
#else
Assert.NotNull (NSData.FromFile ("Info.plist"), "Info.plist");
var plistPath = Path.Combine (NSBundle.MainBundle.BundlePath, "Info.plist");
#endif
Assert.NotNull (NSData.FromFile (plistPath), "Info.plist");
}
[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]
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)) {
// initWithData: does not respond (see dontlink.app) but it works
Assert.That (s.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle");
}
}
#endif
[Test]
public void Url ()

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

@ -8,6 +8,7 @@
//
using System;
using System.IO;
using CoreGraphics;
#if !__WATCHOS__
using System.Drawing;
@ -103,7 +104,7 @@ namespace MonoTouchFixtures.Foundation {
}
//No Mac version of DrawString with those parameters
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC && !__MACCATALYST__
[Test]
[Culture ("en")] // fails for some cultures, e.g. ar-AE
public void DrawString_7 ()
@ -226,7 +227,7 @@ namespace MonoTouchFixtures.Foundation {
[Test]
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 (var str = NSString.FromData (imageData, NSStringEncoding.UTF8)) {
Assert.IsNull (str, "NSDataFromImage");

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

@ -1,6 +1,6 @@
// Copyright 2012 Xamarin Inc. All rights reserved
#if !__WATCHOS__
#if HAS_GLKIT
using System;
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
#if !__WATCHOS__
#if HAS_GLKIT
using System;
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
#if !__WATCHOS__
#if HAS_GLKIT
using System;
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
#if !__WATCHOS__
#if HAS_GLKIT
using System;
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
#if !__WATCHOS__
#if HAS_GLKIT
using System;
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
#if !__WATCHOS__ && !MONOMAC
#if HAS_GLKIT && !MONOMAC
using System;
using System.Drawing;
@ -26,4 +26,4 @@ namespace MonoTouchFixtures.GLKit {
}
}
#endif // !__WATCHOS__
#endif // HAS_GLKIT && !MONOMAC

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

@ -23,6 +23,7 @@ namespace MonoTouchFixtures.GameKit {
[Test]
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
// but it's not the case anymore (in 2015 / iOS9) and the header files says it's nullable
GKNotificationBanner.Show ("title", "message", null);

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

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

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

@ -35,7 +35,13 @@ namespace MonoTouchFixtures.HealthKit {
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");
Assert.That (ex.Message, Does.Match ("startDate.*and endDate.*exceed the maximum allowed duration for this sample type"), "Exception Message");
} else {

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

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

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

@ -15,6 +15,7 @@ using NUnit.Framework;
using Foundation;
using HomeKit;
using ObjCRuntime;
namespace MonoTouchFixtures.HomeKit
{
@ -26,6 +27,8 @@ namespace MonoTouchFixtures.HomeKit
public void Setup ()
{
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]

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

@ -15,6 +15,7 @@ using NUnit.Framework;
using Foundation;
using HomeKit;
using ObjCRuntime;
namespace MonoTouchFixtures.HomeKit
{
@ -26,6 +27,8 @@ namespace MonoTouchFixtures.HomeKit
public void Setup ()
{
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]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -7,7 +7,7 @@
// Copyright 2012 Xamarin Inc. All rights reserved.
//
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC
#if !XAMCORE_3_0 && !MONOMAC
using System;
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)
Assert.Inconclusive ("Not configured to send emails");
#if XAMCORE_3_0
var cancelAttributes = new UIStringAttributes ();
#else
var cancelAttributes = new UITextAttributes ();
cancelAttributes.TextShadowOffset = new UIOffset (0, -1);
#endif
UIBarButtonItem.AppearanceWhenContainedIn (typeof(UISearchBar)).SetTitleTextAttributes (cancelAttributes, UIControlState.Disabled);
using (var mail = new MFMailComposeViewController ()) {
// 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 Foundation;
using Messages;
using ObjCRuntime;
using NUnit.Framework;
namespace MonoTouchFixtures.Messages
@ -25,6 +26,8 @@ namespace MonoTouchFixtures.Messages
public void MinimumSdkCheck ()
{
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]

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

@ -89,15 +89,11 @@ namespace MonoTouchFixtures.Metal {
}
#if __MACOS__
string metal_code = File.ReadAllText (Path.Combine (NSBundle.MainBundle.ResourcePath, "metal-sample.metal"));
string metallib_path = Path.Combine (NSBundle.MainBundle.ResourcePath, "default.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)
Assert.Ignore ("Metal isn't available in the simulator");
#endif

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

@ -3,6 +3,7 @@
using System;
using Metal;
using ObjCRuntime;
using NUnit.Framework;
@ -16,6 +17,8 @@ namespace MonoTouchFixtures.Metal {
public void SetUp ()
{
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 ();
}

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

@ -3,6 +3,7 @@
using System;
using Metal;
using ObjCRuntime;
using NUnit.Framework;
@ -16,6 +17,8 @@ namespace MonoTouchFixtures.Metal {
public void SetUp ()
{
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 ();
}
@ -75,4 +78,4 @@ namespace MonoTouchFixtures.Metal {
}
}
#endif // !__WATCHOS__
#endif // !__WATCHOS__

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

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

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

@ -14,6 +14,12 @@ namespace MonoTouchFixtures.NearbyInteraction {
[TestFixture]
[Preserve (AllMembers = true)]
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]
public void DirectionNotAvailable ()

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

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

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

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

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

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

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

@ -29,7 +29,7 @@ namespace MonoTouchFixtures.ObjCRuntime {
MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException;
MarshalManagedExceptionMode defaultManagedExceptionMode = MarshalManagedExceptionMode.Default;
#else
#if __MACOS__ && DEBUG
#if (__MACOS__ || __MACCATALYST__) && DEBUG
MarshalObjectiveCExceptionMode defaultObjectiveCExceptionMode = MarshalObjectiveCExceptionMode.ThrowManagedException;
#else
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]
public void BlockCollection ()
{
@ -2203,6 +2206,9 @@ namespace MonoTouchFixtures.ObjCRuntime {
[Test]
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 person = new ABPerson ()) {
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 !__WATCHOS__ && !MONOMAC
#if HAS_OPENGLES
using System;
using Foundation;
@ -40,5 +40,5 @@ namespace MonoTouchFixtures.OpenGLES
}
}
#endif // !__WATCHOS__
#endif // HAS_OPENGLES
#endif // !NET

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

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

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

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

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

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

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

@ -22,7 +22,7 @@ using NUnit.Framework;
namespace MonoTouchFixtures.Security {
[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)]
public class CertificateTest {
@ -510,7 +510,9 @@ namespace MonoTouchFixtures.Security {
Assert.NotNull (cert.GetNormalizedIssuerSequence (), "GetNormalizedIssuerSequence");
Assert.NotNull (cert.GetNormalizedSubjectSequence (), "GetNormalizedSubjectSequence");
#if !__MACCATALYST__
Assert.NotNull (cert.GetPublicKey (), "GetPublicKey");
#endif
}
if (TestRuntime.CheckXcodeVersion (9,0)) {
NSError err;

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

@ -22,6 +22,9 @@ namespace MonoTouchFixtures.Security {
extern static int CFGetRetainCount (IntPtr handle);
[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 ()
{
#if MONOMAC
@ -51,6 +54,9 @@ namespace MonoTouchFixtures.Security {
#if !MONOMAC // No QueryAsConcreteType on Mac
[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 ()
{
using (SecRecord rec = new SecRecord (SecKind.Identity))
@ -87,6 +93,9 @@ namespace MonoTouchFixtures.Security {
[Test]
// 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 ()
{
using (NSString valueref = new NSString ("v_Ref"))
@ -204,6 +213,9 @@ namespace MonoTouchFixtures.Security {
}
[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 ()
{
TestRuntime.AssertXcodeVersion (5, 1); // macOS 10.9

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

@ -90,6 +90,9 @@ namespace MonoTouchFixtures.Security {
[Test]
#if MONOMAC
[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
public void Accessible_17579 ()
{
@ -125,6 +128,9 @@ namespace MonoTouchFixtures.Security {
}
[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 ()
{
Protocol (SecProtocol.Afp);
@ -189,6 +195,9 @@ namespace MonoTouchFixtures.Security {
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]
public void AuthenticationType_17579 ()
{
@ -205,6 +214,9 @@ namespace MonoTouchFixtures.Security {
// Test Case provided by user
// This test case scenario used to fail under iOS 6 or lower
[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 ()
{
var testUsername = "testusername";
@ -294,6 +306,8 @@ namespace MonoTouchFixtures.Security {
[Test]
#if MONOMAC
[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
public void IdentityRecordTest ()
{

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

@ -22,6 +22,9 @@ namespace MonoTouchFixtures.Security {
[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";
account = "twitter";
password = "12345678";

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

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

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

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

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

@ -128,7 +128,11 @@ namespace MonoTouchFixtures.UIKit {
{
using (MyView v = new MyView ("note"))
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

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

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

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

@ -2,6 +2,7 @@
#if !MONOMAC
using System;
using System.IO;
#if !__WATCHOS__
using System.Drawing;
#endif
@ -244,7 +245,7 @@ namespace MonoTouchFixtures.UIKit {
[Test]
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)) {
Assert.That (color.ToString (), Is.EqualTo (color.Description), "not an RGBA color");
}
@ -297,7 +298,7 @@ namespace MonoTouchFixtures.UIKit {
[Test]
public void UIConfigurationColorTransformerTest ()
{
TestRuntime.AssertXcodeVersion (12, 0);
TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
var redColor = UIColor.Red;
var transformer = UIConfigurationColorTransformer.Grayscale;
var grayColor = transformer (redColor);

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

@ -14,6 +14,9 @@ namespace MonoTouchFixtures.UIKit {
public class FontTest {
[Test]
#if __MACCATALYST__
[Ignore ("https://github.com/xamarin/maccore/issues/2382")]
#endif
public void WithSize ()
{
var f1 = UIFont.SystemFontOfSize (10).WithSize (20);
@ -82,10 +85,12 @@ namespace MonoTouchFixtures.UIKit {
f2 = UIFont.SystemFontOfSize (12);
SemiFactory_25511 (f1, f2, "SystemFontOfSize");
#if !__MACCATALYST__ // https://github.com/xamarin/maccore/issues/2382
// instance
f1 = f2.WithSize (12);
f2 = f2.WithSize (12);
SemiFactory_25511 (f1, f2, "WithSize");
#endif
if (!TestRuntime.CheckXcodeVersion (5, 0))
return;
@ -156,7 +161,11 @@ namespace MonoTouchFixtures.UIKit {
Assert.IsNotNull (UIFont.ItalicSystemFontOfSize (-5), "ItalicSystemFontOfSize");
using (var font = UIFont.SystemFontOfSize (12)) {
#if __MACCATALYST__
Assert.IsNull (font.WithSize (-6), "WithSize");
#else
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.FirstUnlaidGlyphIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidGlyphIndex");
Assert.False (lm.HasNonContiguousLayout, "HasNonContiguousLayout");
#if !__MACCATALYST__
Assert.That (lm.HyphenationFactor, Is.EqualTo ((nfloat) 0), "HyphenationFactor");
#endif
Assert.That (lm.NumberOfGlyphs, Is.EqualTo ((nuint) 0), "NumberOfGlyphs");
Assert.False (lm.ShowsControlCharacters, "ShowsControlCharacters");
Assert.False (lm.ShowsInvisibleCharacters, "ShowsInvisibleCharacters");

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

@ -51,8 +51,12 @@ namespace MonoTouchFixtures.UIKit {
using (var vc = new UIViewController ())
using (var bbi = new UIBarButtonItem (UIBarButtonSystemItem.Action))
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
Assert.Throws<MonoTouchException> (() => pc.PresentFromBarButtonItem (bbi, UIPopoverArrowDirection.Down, true));
#endif
// 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.
}

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

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

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

@ -7,7 +7,7 @@
// Copyright 2012 Xamarin Inc. All rights reserved.
//
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC
#if !XAMCORE_3_0 && !MONOMAC
using System;
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.Drawing;
using System.IO;
using CoreGraphics;
using Foundation;
using UIKit;
@ -49,7 +50,7 @@ namespace MonoTouchFixtures.UIKit {
Assert.Throws<ArgumentException> (() => new UISegmentedControl ((object []) new [] { NSZone.Default }), "invalid type");
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)) {
Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 3), "NumberOfSegments");
}
@ -65,7 +66,7 @@ namespace MonoTouchFixtures.UIKit {
}
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 (UISegmentedControl sc = new UISegmentedControl (a)) {
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 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)) {
Assert.That (sc.NumberOfSegments, Is.EqualTo ((nint) 1), "NumberOfSegments");
}

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

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

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

@ -1,6 +1,6 @@
// Copyright 2011-2012 Xamarin Inc. All rights reserved
#if !__TVOS__ && !__WATCHOS__ && !MONOMAC
#if !XAMCORE_3_0 && !MONOMAC
using System;
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.FirstUnlaidGlyphIndex, Is.EqualTo ((nuint) 0), "FirstUnlaidGlyphIndex");
Assert.False (lm.HasNonContiguousLayout, "HasNonContiguousLayout");
#if !__MACCATALYST__
Assert.That (lm.HyphenationFactor, Is.EqualTo ((nfloat) 0), "HyphenationFactor");
#endif
Assert.That (lm.NumberOfGlyphs, Is.EqualTo ((nuint) 0), "NumberOfGlyphs");
Assert.False (lm.ShowsControlCharacters, "ShowsControlCharacters");
Assert.False (lm.ShowsInvisibleCharacters, "ShowsInvisibleCharacters");

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