diff --git a/src/Foundation/NSObject.mac.cs b/src/Foundation/NSObject.mac.cs index 51497b07aeef..5113e1c6bb6c 100644 --- a/src/Foundation/NSObject.mac.cs +++ b/src/Foundation/NSObject.mac.cs @@ -109,6 +109,7 @@ public partial class NSObject { static IntPtr sw = Dlfcn.dlopen (Constants.SharedWithYouLibrary, 1); static IntPtr swc = Dlfcn.dlopen (Constants.SharedWithYouCoreLibrary, 1); static IntPtr th = Dlfcn.dlopen (Constants.ThreadNetworkLibrary, 1); + static IntPtr ni = Dlfcn.dlopen (Constants.NearbyInteractionLibrary, 1); #if !NET [Obsolete ("Use PlatformAssembly for easier code sharing across platforms.")] diff --git a/src/homekit.cs b/src/homekit.cs index af06f21a4a6d..901cb5f1b9cb 100644 --- a/src/homekit.cs +++ b/src/homekit.cs @@ -175,7 +175,7 @@ partial interface HMAccessory { string FirmwareVersion { get; } [NullAllowed] - [Mac (13,0), iOS (16,1), MacCatalyst (16,1), Watch (9,1), TV (16,1)] + [Mac (13, 0), iOS (16, 1), MacCatalyst (16, 1), Watch (9, 1), TV (16, 1)] [Export ("matterNodeID", ArgumentSemantic.Copy)] NSNumber MatterNodeId { get; } diff --git a/tests/common/TestRuntime.cs b/tests/common/TestRuntime.cs index 151d726378f3..285931c2686d 100644 --- a/tests/common/TestRuntime.cs +++ b/tests/common/TestRuntime.cs @@ -113,11 +113,21 @@ public static Version GetSDKVersion () return new Version (major, minor, build); } + static bool? is_in_ci; + public static bool IsInCI { + get { + if (!is_in_ci.HasValue) { + var in_ci = !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("BUILD_REVISION")); + in_ci |= !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("BUILD_SOURCEVERSION")); // set by Azure DevOps + is_in_ci = in_ci; + } + return is_in_ci.Value; + } + } + public static void IgnoreInCI (string message) { - var in_ci = !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("BUILD_REVISION")); - in_ci |= !string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("BUILD_SOURCEVERSION")); // set by Azure DevOps - if (!in_ci) { + if (!IsInCI) { Console.WriteLine ($"Not ignoring test ('{message}'), because not running in CI. BUILD_REVISION={Environment.GetEnvironmentVariable ("BUILD_REVISION")} BUILD_SOURCEVERSION={Environment.GetEnvironmentVariable ("BUILD_SOURCEVERSION")}"); return; } @@ -169,6 +179,29 @@ public static void AssertNotDevice (string message = "This test does not run on #endif } + public static void AssertDesktop (string message = "This test only runs on Desktops (macOS or MacCatalyst).") + { +#if __MACOS__ || __MACCATALYST__ + return; +#endif + NUnit.Framework.Assert.Ignore (message); + } + + public static void AssertNotDesktop (string message = "This test does not run on Desktops (macOS or MacCatalyst).") + { +#if __MACOS__ || __MACCATALYST__ + NUnit.Framework.Assert.Ignore (message); +#endif + } + + public static void AssertNotX64Desktop (string message = "This test does not run on x64 desktops.") + { +#if __MACOS__ || __MACCATALYST__ + if (!IsARM64) + NUnit.Framework.Assert.Ignore (message); +#endif + } + public static void AssertNotARM64Desktop (string message = "This test does not run on an ARM64 desktop.") { #if __MACOS__ || __MACCATALYST__ diff --git a/tests/introspection/ApiCtorInitTest.cs b/tests/introspection/ApiCtorInitTest.cs index 4b70d3a48eed..36ba06fc8805 100644 --- a/tests/introspection/ApiCtorInitTest.cs +++ b/tests/introspection/ApiCtorInitTest.cs @@ -134,6 +134,10 @@ protected virtual bool Skip (Type type) return true; case "HMMatterRequestHandler": // got removed and the current API throws an exception at run time. return true; +#if __MACCATALYST__ + case "PKIdentityButton": + return true; +#endif } #if !NET diff --git a/tests/introspection/ApiSelectorTest.cs b/tests/introspection/ApiSelectorTest.cs index a85bd008c1f1..7409d003497f 100644 --- a/tests/introspection/ApiSelectorTest.cs +++ b/tests/introspection/ApiSelectorTest.cs @@ -380,9 +380,9 @@ protected virtual bool Skip (Type type, string selectorName) return true; } break; -#if __WATCHOS__ +#if (__WATCHOS__ || __MACOS__ || __MACCATALYST__) case "AVPlayerItem": - switch (selectorName) { + switch (selectorName) { // comes from AVPlayerItem+MPAdditions.h case "nowPlayingInfo": case "setNowPlayingInfo:": return TestRuntime.IsSimulatorOrDesktop; @@ -939,6 +939,26 @@ protected virtual bool Skip (Type type, string selectorName) return true; break; } +#endif + break; + case "SKAdImpression": +#if __MACCATALYST__ + switch (selectorName) { + case "initWithSourceAppStoreItemIdentifier:advertisedAppStoreItemIdentifier:adNetworkIdentifier:adCampaignIdentifier:adImpressionIdentifier:timestamp:signature:version:": + if (TestRuntime.CheckXcodeVersion (14, 0)) + return true; + break; + } +#endif + break; + case "EKParticipant": +#if __MACCATALYST__ + switch (selectorName) { + case "ABRecordWithAddressBook:": // Deprecated in 13.1 + if (TestRuntime.CheckXcodeVersion (14, 0)) + return true; + break; + } #endif break; case "SWRemoveParticipantAlertController": diff --git a/tests/introspection/ApiTypoTest.cs b/tests/introspection/ApiTypoTest.cs index 13733a89aca9..45c1da95776c 100644 --- a/tests/introspection/ApiTypoTest.cs +++ b/tests/introspection/ApiTypoTest.cs @@ -1072,8 +1072,12 @@ public void ConstantsCheck () Assert.True (CheckLibrary (s), fi.Name); break; #endif + case "ChipLibrary": // Chip is removed entirely beginning Xcode 14 + if (!TestRuntime.CheckXcodeVersion (14, 0)) + if (TestRuntime.IsDevice) + Assert.True (CheckLibrary (s), fi.Name); + break; #if !__MACOS__ - case "ChipLibrary": case "ThreadNetworkLibrary": case "MediaSetupLibrary": case "MLComputeLibrary": diff --git a/tests/introspection/Mac/MacApiCtorInitTest.cs b/tests/introspection/Mac/MacApiCtorInitTest.cs index b951153ed31a..8abf143872e1 100644 --- a/tests/introspection/Mac/MacApiCtorInitTest.cs +++ b/tests/introspection/Mac/MacApiCtorInitTest.cs @@ -70,6 +70,7 @@ protected override bool Skip (Type type) case "Foundation.NSUnitPressure": // -init should never be called on NSUnit! case "Foundation.NSUnitSpeed": // -init should never be called on NSUnit! case "MonoMac.EventKit.EKParticipant": + case "EventKit.EKCalendarItem": case "EventKit.EKParticipant": case "XamCore.CoreImage.CISampler": case "CoreImage.CISampler": diff --git a/tests/introspection/iOS/iOSApiProtocolTest.cs b/tests/introspection/iOS/iOSApiProtocolTest.cs index b2fcf15c4a9e..2be2eec67a4c 100644 --- a/tests/introspection/iOS/iOSApiProtocolTest.cs +++ b/tests/introspection/iOS/iOSApiProtocolTest.cs @@ -205,7 +205,6 @@ protected override bool Skip (Type type, string protocolName) #if __MACCATALYST__ case "BCChatButton": case "PKAddPassButton": - case "PKPaymentButton": case "UIButton": case "UIControl": case "UISegmentedControl": @@ -222,6 +221,32 @@ protected override bool Skip (Type type, string protocolName) if (protocolName == "UIContextMenuInteractionDelegate") return !TestRuntime.CheckXcodeVersion (12, 0); break; + + // We have to special case the following PKPayment* in MacCatalyst + // since it gets all of these via inheritance from UIView + case "PKPaymentButton": + case "PKPaymentAuthorizationViewController": + switch (protocolName) { + case "UIUserActivityRestoring": + case "UIAppearanceContainer": + case "UIFocusItem": + case "UICoordinateSpace": + case "UIPopoverPresentationControllerSourceItem": + case "UIContextMenuInteractionDelegate": + case "UIFocusItemContainer": + case "UITraitEnvironment": + case "UIActivityItemsConfigurationProviding": + case "UIResponderStandardEditActions": + case "UILargeContentViewerItem": + case "UIDynamicItem": + case "UIAppearance": + case "UIAccessibilityContentSizeCategoryImageAdjusting": + case "UIContentContainer": + if (TestRuntime.CheckXcodeVersion (14, 0)) + return true; + break; + } + break; #endif } diff --git a/tests/monotouch-test/AppKit/NSTextInputClient.cs b/tests/monotouch-test/AppKit/NSTextInputClient.cs index 6fe5052408df..75991662bce5 100644 --- a/tests/monotouch-test/AppKit/NSTextInputClient.cs +++ b/tests/monotouch-test/AppKit/NSTextInputClient.cs @@ -82,8 +82,13 @@ public void NSTextInputClient_ShouldGetFirstRect () NSRange range; var rect = textView.GetFirstRect (new NSRange (12, 18), out range); - Assert.AreEqual (rect, new CGRect (0, 0, 12, 14), "NSTextInputClient_ShouldGetFirstRect - Returned wrong rect"); - Assert.AreEqual (range, new NSRange (10, 4), "NSTextInputClient_ShouldGetFirstRect - Returned wrong Range"); + if (TestRuntime.CheckXcodeVersion (14, 0)) { + Assert.AreEqual (rect, new CGRect (0, 0, 0, 14), "NSTextInputClient_ShouldGetFirstRect - Returned wrong rect"); + Assert.AreEqual (range, new NSRange (12, 0), "NSTextInputClient_ShouldGetFirstRect - Returned wrong Range"); + } else { + Assert.AreEqual (rect, new CGRect (0, 0, 12, 14), "NSTextInputClient_ShouldGetFirstRect - Returned wrong rect"); + Assert.AreEqual (range, new NSRange (10, 4), "NSTextInputClient_ShouldGetFirstRect - Returned wrong Range"); + } } [Test] @@ -101,7 +106,10 @@ public void NSTextInputClient_ShouldGetFractionofDistanceThroughGlyph () [Test] public void NSTextInputClient_ShouldGetBaselineDelta () { - Assert.IsTrue (textView.GetBaselineDelta (4) == 11, "NSTextInputClient_ShouldGetBaselineDelta - Returned wrong baseline delta value"); + if (TestRuntime.CheckXcodeVersion (14, 0)) + Assert.IsTrue (textView.GetBaselineDelta (4) == 0, "NSTextInputClient_ShouldGetBaselineDelta - Returned wrong baseline delta value"); + else + Assert.IsTrue (textView.GetBaselineDelta (4) == 11, "NSTextInputClient_ShouldGetBaselineDelta - Returned wrong baseline delta value"); } [Test] diff --git a/tests/monotouch-test/CoreBluetooth/CentralManagerTest.cs b/tests/monotouch-test/CoreBluetooth/CentralManagerTest.cs index 968cb7954e81..71606c41a42b 100644 --- a/tests/monotouch-test/CoreBluetooth/CentralManagerTest.cs +++ b/tests/monotouch-test/CoreBluetooth/CentralManagerTest.cs @@ -76,6 +76,8 @@ public override void DisconnectedPeripheral (CBCentralManager central, CBPeriphe [SetUp] public void SetUp () { + if (TestRuntime.IsInCI && TestRuntime.CheckXcodeVersion (14, 0)) + TestRuntime.AssertNotDesktop (); // Looks like this particular test doesn't like Desktop + M1 bot machines // iOS 13 and friends require bluetooth permission if (TestRuntime.CheckXcodeVersion (11, 0)) TestRuntime.CheckBluetoothPermission (true); diff --git a/tests/monotouch-test/EventKit/CalendarTest.cs b/tests/monotouch-test/EventKit/CalendarTest.cs index 0beeb177ea20..d9e360d55866 100644 --- a/tests/monotouch-test/EventKit/CalendarTest.cs +++ b/tests/monotouch-test/EventKit/CalendarTest.cs @@ -78,7 +78,11 @@ public void FromEventStore () Assert.Null (c.Source, "Source"); Assert.False (c.Subscribed, "Subscribed"); #if MONOMAC || __MACCATALYST__ - Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); + if (TestRuntime.CheckXcodeVersion (14, 0)) + Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); + else + Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); + Assert.That (c.Title, Is.EqualTo (string.Empty), "Title"); #else Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); @@ -120,7 +124,11 @@ public void FromEventStoreWithReminder () Assert.Null (c.Source, "Source"); Assert.False (c.Subscribed, "Subscribed"); #if MONOMAC || __MACCATALYST__ - Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); + if (TestRuntime.CheckXcodeVersion (14, 0)) + Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); + else + Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.Busy | EKCalendarEventAvailability.Free), "SupportedEventAvailabilities"); + Assert.That (c.Title, Is.EqualTo (string.Empty), "Title"); #else Assert.That (c.SupportedEventAvailabilities, Is.EqualTo (EKCalendarEventAvailability.None), "SupportedEventAvailabilities"); diff --git a/tests/monotouch-test/HealthKit/HKAppleWalkingSteadinessTest.cs b/tests/monotouch-test/HealthKit/HKAppleWalkingSteadinessTest.cs index 8fb804a2f786..bc7a6b85f21a 100644 --- a/tests/monotouch-test/HealthKit/HKAppleWalkingSteadinessTest.cs +++ b/tests/monotouch-test/HealthKit/HKAppleWalkingSteadinessTest.cs @@ -20,11 +20,8 @@ public class HKAppleWalkingSteadinessTest { [SetUp] public void SetUp () { -#if MONOMAC - TestRuntime.AssertXcodeVersion (14, 0); -#else + TestRuntime.AssertNotDesktop (); // Only runs on iOS Devices or Simulators, which makes sense `Apple Walking Steadiness`. TestRuntime.AssertXcodeVersion (13, 0); -#endif } [Test] diff --git a/tests/monotouch-test/MetalPerformanceShaders/MnistTest.cs b/tests/monotouch-test/MetalPerformanceShaders/MnistTest.cs index 1bff444a3913..4d6322b51794 100644 --- a/tests/monotouch-test/MetalPerformanceShaders/MnistTest.cs +++ b/tests/monotouch-test/MetalPerformanceShaders/MnistTest.cs @@ -43,6 +43,7 @@ public void IsSupported () TestRuntime.AssertNotSimulator ("Fails with 'Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[MTLSimHeap protectionOptions]: unrecognized selector sent to instance 0x600002a09090' - note that we don't call this selector."); #endif TestRuntime.IgnoreInCI ("This test seems to make bots keel over and die."); + TestRuntime.AssertNotX64Desktop (); // Intel Mac is not fast enough. var device = MTLDevice.SystemDefault; // some older hardware won't have a default diff --git a/tests/monotouch-test/Network/NWPathMonitorTest.cs b/tests/monotouch-test/Network/NWPathMonitorTest.cs index d26b7fc6594d..38a471976cb6 100644 --- a/tests/monotouch-test/Network/NWPathMonitorTest.cs +++ b/tests/monotouch-test/Network/NWPathMonitorTest.cs @@ -126,6 +126,7 @@ public void ProhibitInterfaceTypeTest () }); } #if MONOMAC + [Ignore ("Unusable nil instance returned, verified with ObjC project. Filled rdar://FB11984039.")] [Test] public void CreateForEthernetChannelTest () { diff --git a/tests/monotouch-test/ObjCRuntime/DelegateAndDataSourceTest.cs b/tests/monotouch-test/ObjCRuntime/DelegateAndDataSourceTest.cs index d2a88e7166a5..1d928d0b6f4b 100644 --- a/tests/monotouch-test/ObjCRuntime/DelegateAndDataSourceTest.cs +++ b/tests/monotouch-test/ObjCRuntime/DelegateAndDataSourceTest.cs @@ -136,6 +136,9 @@ bool Skip (Type t) // The default constructor doesn't work (it's also obsolete) return true; #endif + case "SWCollaborationView": + // Crashes when calling setDelegate: with null. + return true; } switch (t.Namespace) { diff --git a/tests/monotouch-test/System.Net.Http/MessageHandlers.cs b/tests/monotouch-test/System.Net.Http/MessageHandlers.cs index ffe7606c12a3..11bf3a6e5431 100644 --- a/tests/monotouch-test/System.Net.Http/MessageHandlers.cs +++ b/tests/monotouch-test/System.Net.Http/MessageHandlers.cs @@ -612,6 +612,8 @@ public void RejectSslCertificatesWithCustomValidationCallbackNSUrlSessionHandler callbackWasExecuted = true; try { Assert.IsNotNull (certificate); + if (errors == SslPolicyErrors.RemoteCertificateChainErrors && TestRuntime.IsInCI) + return false; Assert.AreEqual (SslPolicyErrors.None, errors); } catch (Exception e) { ex2 = e; diff --git a/tools/devops/automation/build-pipeline.yml b/tools/devops/automation/build-pipeline.yml index 66ef48d4d9f4..689788082bc4 100644 --- a/tools/devops/automation/build-pipeline.yml +++ b/tools/devops/automation/build-pipeline.yml @@ -124,6 +124,20 @@ parameters: "Agent.HasDevices -equals False", "Agent.IsPaired -equals False" ] + }, + { + stageName: 'mac_13_0_m1', + displayName: 'M1 - Mac Ventura (13.0)', + macPool: 'VSEng-VSMac-Xamarin-Shared', + useImage: false, + statusContext: 'M1 - Mac Ventura (13.0)', + demands: [ + "Agent.OS -equals Darwin", + "macOS.Name -equals Ventura", + "macOS.Architecture -equals arm64", + "Agent.HasDevices -equals False", + "Agent.IsPaired -equals False" + ] }] resources: diff --git a/tools/devops/automation/build-pull-request.yml b/tools/devops/automation/build-pull-request.yml index e60d76ef7296..7d7bedb9b27f 100644 --- a/tools/devops/automation/build-pull-request.yml +++ b/tools/devops/automation/build-pull-request.yml @@ -109,6 +109,20 @@ parameters: "Agent.HasDevices -equals False", "Agent.IsPaired -equals False" ] + }, + { + stageName: 'mac_13_0_m1', + displayName: 'M1 - Mac Ventura (13.0)', + macPool: 'VSEng-VSMac-Xamarin-Shared', + useImage: false, + statusContext: 'M1 - Mac Ventura (13.0)', + demands: [ + "Agent.OS -equals Darwin", + "macOS.Name -equals Ventura", + "macOS.Architecture -equals arm64", + "Agent.HasDevices -equals False", + "Agent.IsPaired -equals False" + ] }] resources: