public void VNSupportedRevisionsUnsupportedTest() { var allSupported = new List <(string type, IEnumerable revs)> { (nameof(VNCoreMLRequest), VNCoreMLRequest.SupportedRevisions), (nameof(VNDetectBarcodesRequest), VNDetectBarcodesRequest.SupportedRevisions), (nameof(VNDetectFaceLandmarksRequest), VNDetectFaceLandmarksRequest.SupportedRevisions), (nameof(VNDetectFaceRectanglesRequest), VNDetectFaceRectanglesRequest.SupportedRevisions), (nameof(VNDetectHorizonRequest), VNDetectHorizonRequest.SupportedRevisions), (nameof(VNDetectRectanglesRequest), VNDetectRectanglesRequest.SupportedRevisions), (nameof(VNDetectTextRectanglesRequest), VNDetectTextRectanglesRequest.SupportedRevisions), (nameof(VNTranslationalImageRegistrationRequest), VNTranslationalImageRegistrationRequest.SupportedRevisions), (nameof(VNHomographicImageRegistrationRequest), VNHomographicImageRegistrationRequest.SupportedRevisions), (nameof(VNTrackObjectRequest), VNTrackObjectRequest.SupportedRevisions), (nameof(VNTrackRectangleRequest), VNTrackRectangleRequest.SupportedRevisions), }; foreach (var revisions in allSupported) { var type = revisions.type; foreach (object rev in revisions.revs) { Assert.That(Convert.ChangeType(rev, Enum.GetUnderlyingType(rev.GetType())), Is.Not.EqualTo(0), $"SupportedRevisions Unspecified found: {type}"); } } var allDefault = new List <(string type, object rev)> { (nameof(VNCoreMLRequest), VNCoreMLRequest.DefaultRevision), (nameof(VNDetectBarcodesRequest), VNDetectBarcodesRequest.DefaultRevision), (nameof(VNDetectFaceLandmarksRequest), VNDetectFaceLandmarksRequest.DefaultRevision), (nameof(VNDetectFaceRectanglesRequest), VNDetectFaceRectanglesRequest.DefaultRevision), (nameof(VNDetectHorizonRequest), VNDetectHorizonRequest.DefaultRevision), (nameof(VNDetectRectanglesRequest), VNDetectRectanglesRequest.DefaultRevision), (nameof(VNDetectTextRectanglesRequest), VNDetectTextRectanglesRequest.DefaultRevision), (nameof(VNTranslationalImageRegistrationRequest), VNTranslationalImageRegistrationRequest.DefaultRevision), (nameof(VNHomographicImageRegistrationRequest), VNHomographicImageRegistrationRequest.DefaultRevision), (nameof(VNTrackObjectRequest), VNTrackObjectRequest.DefaultRevision), (nameof(VNTrackRectangleRequest), VNTrackRectangleRequest.DefaultRevision), }; foreach (var defrev in allDefault) { Assert.That(Convert.ChangeType(defrev.rev, Enum.GetUnderlyingType(defrev.rev.GetType())), Is.Not.EqualTo(0), $"DefaultRevision Unspecified found: {defrev.type}"); } var allCurrent = new List <(string type, object rev)> { (nameof(VNCoreMLRequest), VNCoreMLRequest.CurrentRevision), (nameof(VNDetectBarcodesRequest), VNDetectBarcodesRequest.CurrentRevision), (nameof(VNDetectFaceLandmarksRequest), VNDetectFaceLandmarksRequest.CurrentRevision), (nameof(VNDetectFaceRectanglesRequest), VNDetectFaceRectanglesRequest.CurrentRevision), (nameof(VNDetectHorizonRequest), VNDetectHorizonRequest.CurrentRevision), (nameof(VNDetectRectanglesRequest), VNDetectRectanglesRequest.CurrentRevision), (nameof(VNDetectTextRectanglesRequest), VNDetectTextRectanglesRequest.CurrentRevision), (nameof(VNTranslationalImageRegistrationRequest), VNTranslationalImageRegistrationRequest.CurrentRevision), (nameof(VNHomographicImageRegistrationRequest), VNHomographicImageRegistrationRequest.CurrentRevision), (nameof(VNTrackObjectRequest), VNTrackObjectRequest.CurrentRevision), (nameof(VNTrackRectangleRequest), VNTrackRectangleRequest.CurrentRevision), }; foreach (var currev in allCurrent) { Assert.That(Convert.ChangeType(currev.rev, Enum.GetUnderlyingType(currev.rev.GetType())), Is.Not.EqualTo(0), $"CurrentRevision Unspecified found: {currev.type}"); } // Tests 'VNRequestRevision.Unspecified' given to APIs. var rect = new CGRect(0, 0, 10, 10); { var detectedObjectObservation = VNDetectedObjectObservation.FromBoundingBox(VNDetectedObjectObservationRequestRevision.Unspecified, rect); Assert.NotNull(detectedObjectObservation, "detectedObjectObservation is null"); Assert.That(detectedObjectObservation.BoundingBox, Is.EqualTo(rect)); var faceObservation = VNFaceObservation.FromBoundingBox(VNFaceObservationRequestRevision.Unspecified, rect); Assert.NotNull(faceObservation, "faceObservation is null"); Assert.That(faceObservation.BoundingBox, Is.EqualTo(rect)); var recognizedObjectObservation = VNRecognizedObjectObservation.FromBoundingBox(VNRecognizedObjectObservationRequestRevision.Unspecified, rect); if (TestRuntime.CheckXcodeVersion(11, 0)) { Assert.IsNull(recognizedObjectObservation, "recognizedObjectObservation is null"); } else { Assert.NotNull(recognizedObjectObservation, "recognizedObjectObservation is null"); Assert.That(recognizedObjectObservation.BoundingBox, Is.EqualTo(rect)); } var rectangleObservation = VNRectangleObservation.FromBoundingBox(VNRectangleObservationRequestRevision.Unspecified, rect); Assert.NotNull(rectangleObservation, "rectangleObservation is null"); Assert.That(rectangleObservation.BoundingBox, Is.EqualTo(rect)); var textObservation = VNTextObservation.FromBoundingBox(VNTextObservationRequestRevision.Unspecified, rect); Assert.NotNull(textObservation, "textObservation is null"); Assert.That(textObservation.BoundingBox, Is.EqualTo(rect)); var barcodeObservation = VNBarcodeObservation.FromBoundingBox(VNBarcodeObservationRequestRevision.Unspecified, rect); Assert.NotNull(barcodeObservation, "barcodeObservation is null"); Assert.That(barcodeObservation.BoundingBox, Is.EqualTo(rect)); } // Tests random request revision { var detectedObjectObservation = VNDetectedObjectObservation.FromBoundingBox((VNDetectedObjectObservationRequestRevision)5000, rect); Assert.NotNull(detectedObjectObservation, "randomRevision detectedObjectObservation is null"); Assert.That(detectedObjectObservation.BoundingBox, Is.EqualTo(rect)); var faceObservation = VNFaceObservation.FromBoundingBox((VNFaceObservationRequestRevision)5000, rect); Assert.NotNull(faceObservation, "randomRevision faceObservation is null"); Assert.That(faceObservation.BoundingBox, Is.EqualTo(rect)); var recognizedObjectObservation = VNRecognizedObjectObservation.FromBoundingBox((VNRecognizedObjectObservationRequestRevision)5000, rect); if (TestRuntime.CheckXcodeVersion(11, 0)) { Assert.IsNull(recognizedObjectObservation, "randomRevision recognizedObjectObservation is null"); } else { Assert.NotNull(recognizedObjectObservation, "randomRevision recognizedObjectObservation is null"); Assert.That(recognizedObjectObservation.BoundingBox, Is.EqualTo(rect)); } var rectangleObservation = VNRectangleObservation.FromBoundingBox((VNRectangleObservationRequestRevision)5000, rect); Assert.NotNull(rectangleObservation, "randomRevision rectangleObservation is null"); Assert.That(rectangleObservation.BoundingBox, Is.EqualTo(rect)); var textObservation = VNTextObservation.FromBoundingBox((VNTextObservationRequestRevision)5000, rect); Assert.NotNull(textObservation, "randomRevision textObservation is null"); Assert.That(textObservation.BoundingBox, Is.EqualTo(rect)); var barcodeObservation = VNBarcodeObservation.FromBoundingBox((VNBarcodeObservationRequestRevision)5000, rect); Assert.NotNull(barcodeObservation, "randomRevision barcodeObservation is null"); Assert.That(barcodeObservation.BoundingBox, Is.EqualTo(rect)); } }
protected override bool CheckResponse(bool value, Type actualType, MethodBase method, ref string name) { if (value) { return(true); } var declaredType = method.DeclaringType; switch (declaredType.Name) { case "AVUrlAsset": switch (name) { // fails because it is in-lined via protocol AVContentKeyRecipient case "contentKeySession:didProvideContentKey:": return(true); } break; case "NSNull": switch (name) { // conformance to CAAction started with iOS8 case "runActionForKey:object:arguments:": if (!TestRuntime.CheckXcodeVersion(8, 0)) { return(true); } break; } break; case "NSUrlSession": switch (name) { case "delegateQueue": case "sessionDescription": case "setSessionDescription:": case "delegate": // does not respond anymore but the properties works (see monotouch-test) if (TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; } break; case "NSUrlSessionTask": switch (name) { case "countOfBytesExpectedToReceive": case "countOfBytesExpectedToSend": case "countOfBytesReceived": case "countOfBytesSent": case "currentRequest": case "error": case "originalRequest": case "response": case "state": case "taskDescription": case "setTaskDescription:": case "taskIdentifier": // does not respond anymore but the properties works (see monotouch-test) if (TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; case "earliestBeginDate": case "setEarliestBeginDate:": case "countOfBytesClientExpectsToSend": case "setCountOfBytesClientExpectsToSend:": case "countOfBytesClientExpectsToReceive": case "setCountOfBytesClientExpectsToReceive:": case "progress": if (TestRuntime.CheckXcodeVersion(9, 0)) { return(true); } break; case "priority": case "setPriority:": if (TestRuntime.CheckXcodeVersion(11, 0)) { return(true); } break; } break; case "NSUrlSessionConfiguration": case "NSUrlSessionStreamTask": // does not respond anymore but the properties works (see monotouch-test for a partial list) if (TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; case "AVAssetDownloadTask": switch (name) { case "currentRequest": case "originalRequest": case "response": if (TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; case "loadedTimeRanges": case "options": case "URLAsset": if (TestRuntime.CheckXcodeVersion(11, 0)) { return(true); } break; } break; case "CMSensorRecorder": switch (name) { // breaking change from Apple in iOS 9.3 betas // https://trello.com/c/kqlEkPbG/30-24508290-cmsensorrecorder-breaking-change-re-opening-24231250 // https://trello.com/c/pKLOLjVJ/29-24231250-coremotion-api-removal-without-deprecation case "accelerometerDataFromDate:toDate:": case "recordAccelerometerForDuration:": if (!TestRuntime.CheckXcodeVersion(7, 3)) { return(true); } break; } break; case "SKNode": // iOS 10+ case "SCNNode": // iOS 11+ switch (name) { // UIFocus protocol conformance case "didUpdateFocusInContext:withAnimationCoordinator:": case "setNeedsFocusUpdate": case "shouldUpdateFocusInContext:": case "updateFocusIfNeeded": case "canBecomeFocused": #if !__TVOS__ && !__MACCATALYST__ case "preferredFocusedView": #endif int major = declaredType.Name == "SKNode" ? 8 : 9; if (!TestRuntime.CheckXcodeVersion(major, 0)) { return(true); } break; #if __TVOS__ || __MACCATALYST__ case "preferredFocusedView": return(true); #endif } break; case "CIContext": switch (name) { case "render:toIOSurface:bounds:colorSpace:": if (Runtime.Arch == Arch.SIMULATOR) { return(!TestRuntime.CheckXcodeVersion(11, 0)); } if (!TestRuntime.CheckXcodeVersion(9, 0)) { return(true); } break; } break; case "CIImage": switch (name) { case "initWithIOSurface:": case "initWithIOSurface:options:": // works on both sim/device with Xcode 11 (continue main logic) if (TestRuntime.CheckXcodeVersion(11, 0)) { break; } // did not work on simulator before iOS 13 (shortcut logic) if (Runtime.Arch == Arch.SIMULATOR) { return(true); } // was a private framework (on iOS) before Xcode 9.0 (shortcut logic) if (!TestRuntime.CheckXcodeVersion(9, 0)) { return(true); } break; } break; case "CIRenderDestination": switch (name) { case "initWithIOSurface:": if (Runtime.Arch == Arch.SIMULATOR) { return(!TestRuntime.CheckXcodeVersion(11, 0)); } if (!TestRuntime.CheckXcodeVersion(9, 0)) { return(true); } break; } break; case "EAGLContext": case "SCNGeometry": switch (name) { // symbol only exists on devices (not in simulator libraries) case "texImageIOSurface:target:internalFormat:width:height:format:type:plane:": case "setTessellator:": case "tessellator": if (Runtime.Arch == Arch.SIMULATOR) { return(!TestRuntime.CheckXcodeVersion(11, 0)); } if (!TestRuntime.CheckXcodeVersion(9, 0)) { return(true); } break; } break; case "PKSuicaPassProperties": switch (name) { // Selectors do not respond anymore in Xcode 9.3. Radar https://trello.com/c/B31EMqSg. case "isGreenCarTicketUsed": case "isInShinkansenStation": if (TestRuntime.CheckXcodeVersion(9, 3)) { return(true); } break; } break; case "UIPreviewInteraction": switch (name) { // Selectors do not respond anymore in Xcode 10.2 beta 1. case "cancelInteraction": case "locationInCoordinateSpace:": case "delegate": case "setDelegate:": case "view": if (TestRuntime.CheckXcodeVersion(10, 2)) { return(true); } break; } break; #if __TVOS__ || __MACCATALYST__ // broken with Xcode 12 beta 1 case "CKDiscoveredUserInfo": switch (name) { case "copyWithZone:": case "encodeWithCoder:": if (TestRuntime.CheckXcodeVersion(12, 0)) { return(true); } break; } break; case "CKSubscription": switch (name) { case "setZoneID:": if (TestRuntime.CheckXcodeVersion(12, 0)) { return(true); } break; } break; #endif #if __IOS__ // broken with Xcode 12 beta 1 case "ARBodyTrackingConfiguration": case "ARImageTrackingConfiguration": case "ARObjectScanningConfiguration": case "ARWorldTrackingConfiguration": switch (name) { case "isAutoFocusEnabled": case "setAutoFocusEnabled:": if ((Runtime.Arch == Arch.SIMULATOR) && TestRuntime.CheckXcodeVersion(12, 0)) { return(true); } break; } break; case "ARReferenceImage": switch (name) { case "copyWithZone:": if ((Runtime.Arch == Arch.SIMULATOR) && TestRuntime.CheckXcodeVersion(12, 0)) { return(true); } break; } break; // ARImageAnchor was added in iOS 11.3 but the conformance to ARTrackable, where `isTracked` comes from, started with iOS 12.0 case "ARImageAnchor": switch (name) { case "isTracked": if (!TestRuntime.CheckXcodeVersion(10, 0)) { return(true); } break; } break; #endif #if __WATCHOS__ case "INUserContext": switch (name) { case "encodeWithCoder:": if (!TestRuntime.CheckXcodeVersion(12, 0)) { return(true); } break; } break; #endif break; } switch (name) { // UIResponderStandardEditActions - stuffed inside UIResponder case "cut:": case "copy:": case "paste:": case "delete:": case "select:": case "selectAll:": case "pasteAndGo:": case "pasteAndMatchStyle:": case "pasteAndSearch:": case "print:": // A subclass of UIResponder typically implements this method... case "toggleBoldface:": case "toggleItalics:": case "toggleUnderline:": if (declaredType.Name == "UIResponder") { return(true); } break; case "makeTextWritingDirectionLeftToRight:": case "makeTextWritingDirectionRightToLeft:": // MonoTouch.AddressBookUI.ABNewPersonViewController // MonoTouch.AddressBookUI.ABPeoplePickerNavigationController // MonoTouch.AddressBookUI.ABPersonViewController if (declaredType.Name == "UIResponder") { return(true); } break; case "autocapitalizationType": case "setAutocapitalizationType:": case "autocorrectionType": case "setAutocorrectionType:": case "keyboardType": case "setKeyboardType:": case "spellCheckingType": case "setSpellCheckingType:": // UITextInputTraits and UITextInputProtocol if (declaredType.Name == "UITextField" || declaredType.Name == "UITextView") { return(true); } if (TestRuntime.CheckXcodeVersion(5, 1) && declaredType.Name == "UISearchBar") { return(true); } break; case "keyboardAppearance": case "setKeyboardAppearance:": case "returnKeyType": case "setReturnKeyType:": case "enablesReturnKeyAutomatically": case "setEnablesReturnKeyAutomatically:": case "isSecureTextEntry": case "setSecureTextEntry:": // UITextInputTraits and UITextInput Protocol switch (declaredType.Name) { case "UITextField": case "UITextView": case "UISearchBar": return(true); } break; case "textStylingAtPosition:inDirection:": case "positionWithinRange:atCharacterOffset:": case "characterOffsetOfPosition:withinRange:": case "shouldChangeTextInRange:replacementText:": // UITextInputTraits and UITextInputProtocol if (declaredType.Name == "UITextField" || declaredType.Name == "UITextView") { return(true); } // ignore UISearchBar before iOS8 - it did not really implement UITextInput if (declaredType.Name == "UISearchBar" && !TestRuntime.CheckXcodeVersion(6, 0)) { return(true); } break; case "dictationRecognitionFailed": case "dictationRecordingDidEnd": case "insertDictationResult:": // iOS 5.1 and not every device (or simulator) if (declaredType.Name == "UITextField" || declaredType.Name == "UITextView") { return(true); } break; // special case: see http://developer.apple.com/library/ios/#documentation/GLkit/Reference/GLKViewController_ClassRef/Reference/Reference.html case "update": if (declaredType.Name == "GLKViewController") { return(true); } break; case "thumbnailImageAtTime:timeOption:": case "requestThumbnailImagesAtTimes:timeOption:": case "cancelAllThumbnailImageRequests": case "accessLog": case "errorLog": case "timedMetadata": if (declaredType.Name == "MPMoviePlayerController") { return(true); } break; // deprecated (removed in iOS 3.2) case "backgroundColor": case "setBackgroundColor:": case "movieControlMode": case "setMovieControlMode:": if (declaredType.Name == "MPMoviePlayerController") { return(true); } break; case "skipToNextItem": case "skipToBeginning": case "skipToPreviousItem": case "setNowPlayingItem:": if (actualType.Name == "MPMusicPlayerController") { return(true); } break; // deprecated (according to docs) but actually removed (test) in iOS 6 case "useApplicationAudioSession": case "setUseApplicationAudioSession:": if (declaredType.Name == "MPMoviePlayerController") { return(TestRuntime.CheckXcodeVersion(4, 5)); } break; // iOS6 - headers says readwrite but they do not respond case "setUUID:": case "setIsPrimary:": if (declaredType.Name == "CBMutableService") { return(TestRuntime.CheckXcodeVersion(4, 5)); } if (declaredType.Name == "CBMutableCharacteristic") { return(TestRuntime.CheckXcodeVersion(7, 0)); } break; // documented since 4.0 - but does not answer on an iPad1 with 5.1.1 case "isAdjustingFocus": if (declaredType.Name == "AVCaptureDevice") { return(true); } break; // GameKit: documented since 4.1 - but does not answer case "alias": if (declaredType.Name == "GKPlayer") { return(true); } break; case "playerID": switch (declaredType.Name) { case "GKPlayer": case "GKScore": case "GKTurnBasedParticipant": // iOS 5 return(true); } break; case "category": case "setCategory:": case "date": case "formattedValue": case "rank": case "value": case "setValue:": case "context": // iOS5 case "setContext:": // iOS5 if (declaredType.Name == "GKScore") { return(true); } break; case "isUnderage": if (declaredType.Name == "GKLocalPlayer") { return(true); } break; case "identifier": if (declaredType.Name == "GKAchievement" || declaredType.Name == "GKAchievementDescription") { return(true); } break; case "setIdentifier:": case "percentComplete": case "setPercentComplete:": case "lastReportedDate": case "setLastReportedDate:": if (declaredType.Name == "GKAchievement") { return(true); } break; case "achievedDescription": case "isHidden": case "maximumPoints": case "title": case "unachievedDescription": if (declaredType.Name == "GKAchievementDescription") { return(true); } break; // 5.0 case "lastTurnDate": case "matchOutcome": case "setMatchOutcome:": if (declaredType.Name == "GKTurnBasedParticipant") { return(true); } break; case "creationDate": case "matchData": case "message": case "setMessage:": if (declaredType.Name == "GKTurnBasedMatch") { return(true); } break; // iOS6 - protocols for UICollectionView case "numberOfSectionsInCollectionView:": case "collectionView:viewForSupplementaryElementOfKind:atIndexPath:": case "collectionView:shouldHighlightItemAtIndexPath:": case "collectionView:didHighlightItemAtIndexPath:": case "collectionView:didUnhighlightItemAtIndexPath:": case "collectionView:shouldSelectItemAtIndexPath:": case "collectionView:shouldDeselectItemAtIndexPath:": case "collectionView:didSelectItemAtIndexPath:": case "collectionView:didDeselectItemAtIndexPath:": case "collectionView:didEndDisplayingCell:forItemAtIndexPath:": case "collectionView:didEndDisplayingSupplementaryView:forElementOfKind:atIndexPath:": case "collectionView:shouldShowMenuForItemAtIndexPath:": case "collectionView:canPerformAction:forItemAtIndexPath:withSender:": case "collectionView:performAction:forItemAtIndexPath:withSender:": // which also inherits from UIScrollViewDelegate case "scrollViewDidScroll:": case "scrollViewWillBeginDragging:": case "scrollViewDidEndDragging:willDecelerate:": case "scrollViewWillBeginDecelerating:": case "scrollViewDidEndDecelerating:": case "scrollViewDidEndScrollingAnimation:": case "viewForZoomingInScrollView:": case "scrollViewShouldScrollToTop:": case "scrollViewDidScrollToTop:": case "scrollViewDidEndZooming:withView:atScale:": case "scrollViewDidZoom:": case "scrollViewWillBeginZooming:withView:": case "scrollViewWillEndDragging:withVelocity:targetContentOffset:": if (declaredType.Name == "UICollectionViewController") { return(TestRuntime.CheckXcodeVersion(4, 5)); } break; // failing (check why) case "initialLayoutAttributesForInsertedItemAtIndexPath:": case "initialLayoutAttributesForInsertedSupplementaryElementOfKind:atIndexPath:": case "finalLayoutAttributesForDeletedItemAtIndexPath:": case "finalLayoutAttributesForDeletedSupplementaryElementOfKind:atIndexPath:": if (declaredType.Name == "UICollectionViewLayout") { return(TestRuntime.CheckXcodeVersion(4, 5)); } break; // This is implemented by internal concrete classes of NSFileHandle case "readInBackgroundAndNotify": case "readInBackgroundAndNotifyForModes:": case "readToEndOfFileInBackgroundAndNotifyForModes:": case "readToEndOfFileInBackgroundAndNotify": case "acceptConnectionInBackgroundAndNotifyForModes:": case "acceptConnectionInBackgroundAndNotify": case "waitForDataInBackgroundAndNotifyForModes:": case "waitForDataInBackgroundAndNotify": if (declaredType.Name == "NSFileHandle") { return(true); } break; // UITableViewController conforms to both UITableViewDelegate and UITableViewDataSource case "tableView:canEditRowAtIndexPath:": case "tableView:canMoveRowAtIndexPath:": case "sectionIndexTitlesForTableView:": case "tableView:sectionForSectionIndexTitle:atIndex:": case "tableView:commitEditingStyle:forRowAtIndexPath:": case "tableView:moveRowAtIndexPath:toIndexPath:": case "tableView:willDisplayCell:forRowAtIndexPath:": case "tableView:accessoryTypeForRowWithIndexPath:": case "tableView:accessoryButtonTappedForRowWithIndexPath:": case "tableView:willSelectRowAtIndexPath:": case "tableView:willDeselectRowAtIndexPath:": case "tableView:didSelectRowAtIndexPath:": case "tableView:didDeselectRowAtIndexPath:": case "tableView:editingStyleForRowAtIndexPath:": case "tableView:titleForDeleteConfirmationButtonForRowAtIndexPath:": case "tableView:shouldIndentWhileEditingRowAtIndexPath:": case "tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:": case "tableView:shouldShowMenuForRowAtIndexPath:": case "tableView:canPerformAction:forRowAtIndexPath:withSender:": case "tableView:performAction:forRowAtIndexPath:withSender:": case "tableView:willDisplayHeaderView:forSection:": case "tableView:willDisplayFooterView:forSection:": case "tableView:didEndDisplayingCell:forRowAtIndexPath:": case "tableView:didEndDisplayingHeaderView:forSection:": case "tableView:didEndDisplayingFooterView:forSection:": case "tableView:shouldHighlightRowAtIndexPath:": case "tableView:didHighlightRowAtIndexPath:": case "tableView:didUnhighlightRowAtIndexPath:": // iOS7 case "tableView:estimatedHeightForRowAtIndexPath:": case "tableView:estimatedHeightForHeaderInSection:": case "tableView:estimatedHeightForFooterInSection:": // iOS 8 case "tableView:editActionsForRowAtIndexPath:": if (declaredType.Name == "UITableViewController") { return(true); } break; // iOS7 beta issue ? remains in beta 5 / sim // MCSession documents the cancelConnectPeer: selector but it does not answer case "cancelConnectPeer:": // CBCharacteristic documents the selector but does not respond case "subscribedCentrals": // UIPrintFormatter header attributedText says the API is not approved yet - and it does not respond case "attributedText": case "setAttributedText:": // UISplitViewController case "splitViewControllerSupportedInterfaceOrientations:": case "splitViewControllerPreferredInterfaceOrientationForPresentation:": return(true); case "color": case "setColor:": case "font": case "setFont:": case "text": case "setText:": case "textAlignment": case "setTextAlignment:": // iOS7 GM a "no text" instance does not answer to the selector (but you can call them) if (declaredType.Name == "UISimpleTextPrintFormatter") { return(true); } break; case "copyWithZone:": switch (declaredType.Name) { // not conforming to NSCopying in 5.1 SDK case "UIFont": return(!TestRuntime.CheckXcodeVersion(4, 5)); // not conforming to NSCopying before 7.0 SDK case "CBPeripheral": return(!TestRuntime.CheckXcodeVersion(5, 0)); // not conforming to NSCopying before 8.0 SDK case "AVMetadataFaceObject": return(!TestRuntime.CheckXcodeVersion(6, 0)); // not conforming to NSCopying before 8.2 SDK case "HKUnit": return(!TestRuntime.CheckXcodeVersion(6, 2)); case "HKBiologicalSexObject": case "HKBloodTypeObject": return(!TestRuntime.CheckXcodeVersion(7, 0)); case "HKWorkoutEvent": return(!TestRuntime.CheckXcodeVersion(8, 0)); case "HMLocationEvent": return(!TestRuntime.CheckXcodeVersion(9, 0)); #if __WATCHOS__ case "INParameter": // NSCopying conformance added in Xcode 10 return(!TestRuntime.CheckXcodeVersion(10, 0)); #endif } break; // on iOS8.0 this does not work on the simulator (but works on devices) case "language": if (declaredType.Name == "AVSpeechSynthesisVoice" && TestRuntime.CheckXcodeVersion(6, 0) && Runtime.Arch == Arch.SIMULATOR) { return(true); } break; // new, optional members of UIDynamicItem protocol in iOS9 case "collisionBoundingPath": case "collisionBoundsType": switch (declaredType.Name) { case "UICollectionViewLayoutAttributes": case "UIView": case "UIDynamicItemGroup": return(true); } break; // SceneKit integration with Metal is not working on simulators (at least for iOS9 beta 5) case "currentRenderCommandEncoder": case "colorPixelFormat": case "commandQueue": case "depthPixelFormat": case "device": case "stencilPixelFormat": switch (declaredType.Name) { case "SCNRenderer": case "SCNView": return(Runtime.Arch == Arch.SIMULATOR); } break; case "preferredFocusedView": switch (declaredType.Name) { // UIFocusGuide (added in iOS 9.0 and deprecated in iOS 10) case "UIView": case "UIViewController": return(!TestRuntime.CheckXcodeVersion(7, 0)); } break; // some types adopted NS[Secure]Coding after the type was added // and for unified that's something we generate automatically (so we can't put [iOS] on them) case "encodeWithCoder:": switch (declaredType.Name) { // UITextInputMode was added in 4.2 but conformed to NSSecureCoding only from 7.0+ case "UITextInputMode": return(!TestRuntime.CheckXcodeVersion(5, 0)); // iOS9 case "HKBiologicalSexObject": case "HKBloodTypeObject": return(!TestRuntime.CheckXcodeVersion(7, 0)); case "MPSKernel": case "MPSCnnConvolutionDescriptor": return(!TestRuntime.CheckXcodeVersion(9, 0)); // Protocol conformance removed in Xcode 9.3 case "HKSeriesBuilder": if (TestRuntime.CheckXcodeVersion(9, 3)) { return(true); } break; #if __TVOS__ case "SKAttribute": case "SKAttributeValue": return(!TestRuntime.CheckXcodeVersion(7, 2)); #endif case "MLDictionaryFeatureProvider": case "MLMultiArray": case "MLFeatureValue": return(!TestRuntime.CheckXcodeVersion(10, 0)); } break; case "mutableCopyWithZone:": switch (declaredType.Name) { case "HMLocationEvent": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; } return(base.CheckResponse(value, actualType, method, ref name)); }
public void TlsDefaults() { using (var ep = NWEndpoint.Create("www.microsoft.com", "https")) using (var parameters = NWParameters.CreateSecureTcp()) using (var queue = new DispatchQueue(GetType().FullName)) { var connection = new NWConnection(ep, parameters); var ready = new ManualResetEvent(false); connection.SetStateChangeHandler((state, error) => { Console.WriteLine(state); switch (state) { case NWConnectionState.Cancelled: case NWConnectionState.Failed: // We can't dispose until the connection has been closed or it failed. connection.Dispose(); break; case NWConnectionState.Invalid: case NWConnectionState.Preparing: case NWConnectionState.Waiting: break; case NWConnectionState.Ready: ready.Set(); break; default: break; } }); connection.SetQueue(queue); connection.Start(); // Wait until the connection is ready. Assert.True(ready.WaitOne(TimeSpan.FromSeconds(10)), "Connection is ready"); using (var m = connection.GetProtocolMetadata(NWProtocolDefinition.TlsDefinition)) { var s = m.TlsSecProtocolMetadata; Assert.False(s.EarlyDataAccepted, "EarlyDataAccepted"); Assert.That(s.NegotiatedCipherSuite, Is.Not.EqualTo(SslCipherSuite.SSL_NULL_WITH_NULL_NULL), "NegotiatedCipherSuite"); Assert.Null(s.NegotiatedProtocol, "NegotiatedProtocol"); Assert.That(s.NegotiatedProtocolVersion, Is.EqualTo(SslProtocol.Tls_1_2).Or.EqualTo(SslProtocol.Tls_1_3), "NegotiatedProtocolVersion"); Assert.NotNull(s.PeerPublicKey, "PeerPublicKey"); Assert.True(SecProtocolMetadata.ChallengeParametersAreEqual(s, s), "ChallengeParametersAreEqual"); Assert.True(SecProtocolMetadata.PeersAreEqual(s, s), "PeersAreEqual"); if (TestRuntime.CheckXcodeVersion(11, 0)) { using (var d = s.CreateSecret("Xamarin", 128)) { Assert.That(d.Size, Is.EqualTo((nuint)128), "CreateSecret-1"); } using (var d = s.CreateSecret("Microsoft", new byte [1], 256)) { Assert.That(d.Size, Is.EqualTo((nuint)256), "CreateSecret-2"); } Assert.That(s.NegotiatedTlsProtocolVersion, Is.EqualTo(TlsProtocolVersion.Tls12).Or.EqualTo(TlsProtocolVersion.Tls13), "NegotiatedTlsProtocolVersion"); // we want to test the binding/API - not the exact value which can vary depending on the negotiation between the client (OS) and server... Assert.That(s.NegotiatedTlsCipherSuite, Is.Not.EqualTo(0), "NegotiatedTlsCipherSuite"); Assert.That(s.ServerName, Is.EqualTo("www.microsoft.com"), "ServerName"); // we don't have a TLS-PSK enabled server to test this Assert.False(s.AccessPreSharedKeys((psk, pskId) => { }), "AccessPreSharedKeys"); } } connection.Cancel(); } }
public void ReturnReleaseTest() { // This test tries to exercise all the Metal API that has a // ReturnRelease attribute. To test that the attribute does the // right thing: run the test app using instruments, run the test // several times by tapping on it, and do a heap mark between each // test. Then verify that there's at least one heap shot with 0 // memory increase, which means that nothing is leaking. var device = MTLDevice.SystemDefault; IntPtr buffer_mem; int buffer_length; bool freed; byte [] buffer_bytes; // some older hardware won't have a default if (device == null) { Assert.Inconclusive("Metal is not supported"); } // Apple claims that "Indirect command buffers" are available with MTLGPUFamilyCommon2, but it crashes on at least one machine. // Log what the current device supports, just to have it in the log. foreach (MTLFeatureSet fs in Enum.GetValues(typeof(MTLFeatureSet))) { Console.WriteLine($"This device supports feature set: {fs}: {device.SupportsFeatureSet (fs)}"); } if (TestRuntime.CheckXcodeVersion(11, 0)) { foreach (MTLGpuFamily gf in Enum.GetValues(typeof(MTLGpuFamily))) { Console.WriteLine($"This device supports Gpu family: {gf}: {device.SupportsFamily (gf)}"); } } 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"); #if !__MACOS__ && !__MACCATALYST__ if (Runtime.Arch == Arch.SIMULATOR) { Assert.Ignore("Metal isn't available in the simulator"); } #endif using (var hd = new MTLHeapDescriptor()) { hd.CpuCacheMode = MTLCpuCacheMode.DefaultCache; hd.StorageMode = MTLStorageMode.Private; using (var txt = MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA8Unorm, 40, 40, false)) { var sa = device.GetHeapTextureSizeAndAlign(txt); hd.Size = sa.Size; using (var heap = device.CreateHeap(hd)) { Assert.IsNotNull(heap, $"NonNullHeap"); } } } using (var queue = device.CreateCommandQueue()) { Assert.IsNotNull(queue, "Queue: NonNull 1"); } #if __MACOS__ if (TestRuntime.CheckXcodeVersion(10, 0) && device.SupportsFeatureSet(MTLFeatureSet.macOS_GPUFamily2_v1)) { using (var descriptor = MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA8Unorm, 64, 64, false)) { descriptor.StorageMode = MTLStorageMode.Private; using (var texture = device.CreateSharedTexture(descriptor)) { Assert.IsNotNull(texture, "CreateSharedTexture (MTLTextureDescriptor): NonNull"); using (var handle = texture.CreateSharedTextureHandle()) using (var shared = device.CreateSharedTexture(handle)) Assert.IsNotNull(texture, "CreateSharedTexture (MTLSharedTextureHandle): NonNull"); } } } #endif using (var queue = device.CreateCommandQueue(10)) { Assert.IsNotNull(queue, "Queue: NonNull 2"); } using (var buffer = device.CreateBuffer(1024, MTLResourceOptions.CpuCacheModeDefault)) { Assert.IsNotNull(buffer, "CreateBuffer: NonNull 1"); } buffer_mem = AllocPageAligned(1, out buffer_length); using (var buffer = device.CreateBuffer(buffer_mem, (nuint)buffer_length, MTLResourceOptions.CpuCacheModeDefault)) { Assert.IsNotNull(buffer, "CreateBuffer: NonNull 2"); } FreePageAligned(buffer_mem, buffer_length); buffer_bytes = new byte [getpagesize()]; using (var buffer = device.CreateBuffer(buffer_bytes, MTLResourceOptions.CpuCacheModeDefault)) { Assert.IsNotNull(buffer, "CreateBuffer: NonNull 3"); } buffer_mem = AllocPageAligned(1, out buffer_length); freed = false; #if __MACOS__ var resourceOptions7 = MTLResourceOptions.StorageModeManaged; #else var resourceOptions7 = MTLResourceOptions.CpuCacheModeDefault; #endif using (var buffer = device.CreateBufferNoCopy(buffer_mem, (nuint)buffer_length, resourceOptions7, (pointer, length) => { FreePageAligned(pointer, (int)length); freed = true; })) { Assert.IsNotNull(buffer, "CreateBufferNoCopy: NonNull 1"); } Assert.IsTrue(freed, "CreateBufferNoCopy: Freed 1"); using (var descriptor = new MTLDepthStencilDescriptor()) using (var dss = device.CreateDepthStencilState(descriptor)) { Assert.IsNotNull(dss, "CreateDepthStencilState: NonNull 1"); } using (var descriptor = MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA8Unorm, 64, 64, false)) { using (var texture = device.CreateTexture(descriptor)) Assert.NotNull(texture, "CreateTexture: NonNull 1"); using (var surface = new IOSurface.IOSurface(new IOSurface.IOSurfaceOptions { Width = 64, Height = 64, BytesPerElement = 4, })) { using (var texture = device.CreateTexture(descriptor, surface, 0)) Assert.NotNull(texture, "CreateTexture: NonNull 2"); } } using (var descriptor = new MTLSamplerDescriptor()) using (var sampler = device.CreateSamplerState(descriptor)) Assert.IsNotNull(sampler, "CreateSamplerState: NonNull 1"); using (var library = device.CreateDefaultLibrary()) Assert.IsNotNull(library, "CreateDefaultLibrary: NonNull 1"); using (var library = device.CreateLibrary(metallib_path, out var error)) { Assert.IsNotNull(library, "CreateLibrary: NonNull 1"); Assert.IsNull(error, "CreateLibrary: NonNull error 1"); } using (var data = DispatchData.FromByteBuffer(File.ReadAllBytes(metallib_path))) using (var library = device.CreateLibrary(data, out var error)) { Assert.IsNotNull(library, "CreateLibrary: NonNull 2"); Assert.IsNull(error, "CreateLibrary: NonNull error 2"); } using (var compile_options = new MTLCompileOptions()) using (var library = device.CreateLibrary(metal_code, compile_options, out var error)) { Assert.IsNotNull(library, "CreateLibrary: NonNull 3"); Assert.IsNull(error, "CreateLibrary: NonNull error 3"); } using (var compile_options = new MTLCompileOptions()) { device.CreateLibrary(metal_code, compile_options, (library, error) => { Assert.IsNotNull(library, "CreateLibrary: NonNull 4"); Assert.IsNull(error, "CreateLibrary: NonNull error 4"); }); } using (var library = device.CreateDefaultLibrary(NSBundle.MainBundle, out var error)) { Assert.IsNotNull(library, "CreateDefaultLibrary: NonNull 2"); Assert.IsNull(error, "CreateDefaultLibrary: NonNull error 2"); } using (var descriptor = new MTLRenderPipelineDescriptor()) using (var library = device.CreateDefaultLibrary()) using (var func = library.CreateFunction("vertexShader")) { descriptor.VertexFunction = func; descriptor.ColorAttachments [0].PixelFormat = MTLPixelFormat.BGRA8Unorm_sRGB; using (var rps = device.CreateRenderPipelineState(descriptor, out var error)) { Assert.IsNotNull(rps, "CreateRenderPipelineState: NonNull 1"); Assert.IsNull(error, "CreateRenderPipelineState: NonNull error 1"); } } using (var descriptor = new MTLRenderPipelineDescriptor()) using (var library = device.CreateDefaultLibrary()) using (var func = library.CreateFunction("vertexShader")) { descriptor.VertexFunction = func; descriptor.ColorAttachments [0].PixelFormat = MTLPixelFormat.BGRA8Unorm_sRGB; using (var rps = device.CreateRenderPipelineState(descriptor, MTLPipelineOption.BufferTypeInfo, out var reflection, out var error)) { Assert.IsNotNull(rps, "CreateRenderPipelineState: NonNull 2"); Assert.IsNull(error, "CreateRenderPipelineState: NonNull error 2"); Assert.IsNotNull(reflection, "CreateRenderPipelineState: NonNull reflection 2"); } } using (var library = device.CreateDefaultLibrary()) using (var func = library.CreateFunction("grayscaleKernel")) using (var cps = device.CreateComputePipelineState(func, MTLPipelineOption.ArgumentInfo, out var reflection, out var error)) { Assert.IsNotNull(cps, "CreateComputePipelineState: NonNull 1"); Assert.IsNull(error, "CreateComputePipelineState: NonNull error 1"); Assert.IsNotNull(reflection, "CreateComputePipelineState: NonNull reflection 1"); } using (var library = device.CreateDefaultLibrary()) using (var func = library.CreateFunction("grayscaleKernel")) using (var cps = device.CreateComputePipelineState(func, out var error)) { Assert.IsNotNull(cps, "CreateComputePipelineState: NonNull 2"); Assert.IsNull(error, "CreateComputePipelineState: NonNull error 2"); } using (var descriptor = new MTLComputePipelineDescriptor()) using (var library = device.CreateDefaultLibrary()) using (var func = library.CreateFunction("grayscaleKernel")) { descriptor.ComputeFunction = func; using (var cps = device.CreateComputePipelineState(descriptor, MTLPipelineOption.BufferTypeInfo, out var reflection, out var error)) { Assert.IsNotNull(cps, "CreateComputePipelineState: NonNull 3"); Assert.IsNull(error, "CreateComputePipelineState: NonNull error 3"); Assert.IsNotNull(reflection, "CreateComputePipelineState: NonNull reflection 3"); } } using (var fence = device.CreateFence()) { Assert.IsNotNull(fence, "CreateFence 1: NonNull"); } var url = "file://" + metallib_path; url = url.Replace(" ", "%20"); // url encode! using (var library = device.CreateLibrary(new NSUrl(url), out var error)) { #if NET // Looks like creating a library with a url always fails: https://forums.developer.apple.com/thread/110416 Assert.IsNotNull(library, "CreateLibrary (NSUrl, NSError): Null"); Assert.IsNull(error, "CreateLibrary (NSUrl, NSError): NonNull error"); #else // Looks like creating a library with a url always fails: https://forums.developer.apple.com/thread/110416 Assert.IsNull(library, "CreateLibrary (NSUrl, NSError): Null"); Assert.IsNotNull(error, "CreateLibrary (NSUrl, NSError): NonNull error"); #endif } using (var library = device.CreateArgumentEncoder(new MTLArgumentDescriptor [] { new MTLArgumentDescriptor() { DataType = MTLDataType.Int } })) { Assert.IsNotNull(library, "CreateArgumentEncoder (MTLArgumentDescriptor[]): NonNull"); } // Apple's charts say that "Indirect command buffers" are supported with MTLGpuFamilyCommon2 var supportsIndirectCommandBuffers = TestRuntime.CheckXcodeVersion(11, 0) && device.SupportsFamily(MTLGpuFamily.Common2); #if __MACOS__ // but something's not quite right somewhere, so on macOS verify that the device supports a bit more than what Apple says. supportsIndirectCommandBuffers &= device.SupportsFeatureSet(MTLFeatureSet.macOS_GPUFamily2_v1); #endif if (supportsIndirectCommandBuffers) { using (var descriptor = new MTLIndirectCommandBufferDescriptor()) { using (var library = device.CreateIndirectCommandBuffer(descriptor, 1, MTLResourceOptions.CpuCacheModeDefault)) { Assert.IsNotNull(library, "CreateIndirectCommandBuffer: NonNull"); } } using (var evt = device.CreateEvent()) { Assert.IsNotNull(evt, "CreateEvent: NonNull"); } using (var evt = device.CreateSharedEvent()) { Assert.IsNotNull(evt, "CreateSharedEvent: NonNull"); } using (var evt1 = device.CreateSharedEvent()) using (var evt_handle = evt1.CreateSharedEventHandle()) using (var evt = device.CreateSharedEvent(evt_handle)) { Assert.IsNotNull(evt, "CreateSharedEvent (MTLSharedEventHandle): NonNull"); } } using (var descriptor = new MTLRenderPipelineDescriptor()) using (var library = device.CreateDefaultLibrary()) using (var func = library.CreateFunction("vertexShader")) { descriptor.VertexFunction = func; descriptor.ColorAttachments [0].PixelFormat = MTLPixelFormat.BGRA8Unorm_sRGB; using (var rps = device.CreateRenderPipelineState(descriptor, MTLPipelineOption.ArgumentInfo, out var reflection, out var error)) { Assert.IsNotNull(rps, "CreateRenderPipelineState (MTLTileRenderPipelineDescriptor, MTLPipelineOption, MTLRenderPipelineReflection, NSError): NonNull"); Assert.IsNull(error, "CreateRenderPipelineState (MTLTileRenderPipelineDescriptor, MTLPipelineOption, MTLRenderPipelineReflection, NSError: NonNull error"); Assert.IsNotNull(reflection, "CreateRenderPipelineState (MTLTileRenderPipelineDescriptor, MTLPipelineOption, MTLRenderPipelineReflection, NSError): NonNull reflection"); } } using (var buffer = device.CreateBuffer(1024, MTLResourceOptions.CpuCacheModeDefault)) using (var descriptor = new MTLTextureDescriptor()) using (var texture = buffer.CreateTexture(descriptor, 0, 256)) { Assert.IsNotNull(buffer, "MTLBuffer.CreateTexture (MTLTextureDescriptor, nuint, nuint): NonNull"); } using (var descriptor = MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA8Unorm, 64, 64, false)) using (var texture = device.CreateTexture(descriptor)) { using (var view = texture.CreateTextureView(MTLPixelFormat.RGBA8Unorm)) { Assert.IsNotNull(view, "MTLTexture.CreateTextureView (MTLPixelFormat): nonnull"); } using (var view = texture.CreateTextureView(MTLPixelFormat.RGBA8Unorm, MTLTextureType.k2D, new NSRange(0, 1), new NSRange(0, 1))) { Assert.IsNotNull(view, "MTLTexture.CreateTextureView (MTLPixelFormat, MTLTextureType, NSRange, NSRange): nonnull"); } } using (var library = device.CreateLibrary(fragmentshader_path, out var error)) { Assert.IsNull(error, "MTLFunction.CreateArgumentEncoder: library creation failure"); using (var func = library.CreateFunction("fragmentShader2")) { using (var enc = func.CreateArgumentEncoder(0)) { Assert.IsNotNull(enc, "MTLFunction.CreateArgumentEncoder (nuint): NonNull"); } using (var enc = func.CreateArgumentEncoder(0, out var reflection)) { Assert.IsNotNull(enc, "MTLFunction.CreateArgumentEncoder (nuint, MTLArgument): NonNull"); Assert.IsNotNull(reflection, "MTLFunction.CreateArgumentEncoder (nuint, MTLArgument): NonNull reflection"); } } } using (var library = device.CreateDefaultLibrary()) { using (var func = library.CreateFunction("grayscaleKernel")) { Assert.IsNotNull(func, "CreateFunction (string): nonnull"); } if (TestRuntime.CheckXcodeVersion(9, 0)) // MTLFunctionConstantValues didn't have a default ctor until Xcode 9. { using (var constants = new MTLFunctionConstantValues()) using (var func = library.CreateFunction("grayscaleKernel", constants, out var error)) { Assert.IsNotNull(func, "CreateFunction (string, MTLFunctionConstantValues, NSError): nonnull"); Assert.IsNull(error, "CreateFunction (string, MTLFunctionConstantValues, NSError): null error"); } } } using (var hd = new MTLHeapDescriptor()) { hd.CpuCacheMode = MTLCpuCacheMode.DefaultCache; hd.StorageMode = MTLStorageMode.Private; using (var txt = MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA8Unorm, 40, 40, false)) { var sa = device.GetHeapTextureSizeAndAlign(txt); hd.Size = sa.Size; using (var heap = device.CreateHeap(hd)) using (var buffer = heap.CreateBuffer(1024, MTLResourceOptions.StorageModePrivate)) { Assert.IsNotNull(buffer, "MTLHeap.CreateBuffer (nuint, MTLResourceOptions): nonnull"); } } } using (var hd = new MTLHeapDescriptor()) { hd.CpuCacheMode = MTLCpuCacheMode.DefaultCache; #if __MACOS__ || __MACCATALYST__ hd.StorageMode = MTLStorageMode.Private; #else hd.StorageMode = MTLStorageMode.Shared; #endif using (var txt = MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA8Unorm, 40, 40, false)) { var sa = device.GetHeapTextureSizeAndAlign(txt); hd.Size = sa.Size; using (var heap = device.CreateHeap(hd)) { #if __MACOS__ || __MACCATALYST__ txt.StorageMode = MTLStorageMode.Private; #endif using (var texture = heap.CreateTexture(txt)) { Assert.IsNotNull(texture, "MTLHeap.CreateTexture (MTLTextureDescriptor): nonnull"); } } } } using (var scope = MTLCaptureManager.Shared.CreateNewCaptureScope(device)) { Assert.IsNotNull(scope, "MTLCaptureManager.CreateNewCaptureScope (MTLDevice): nonnull"); } using (var queue = device.CreateCommandQueue()) using (var scope = MTLCaptureManager.Shared.CreateNewCaptureScope(queue)) { Assert.IsNotNull(scope, "MTLCaptureManager.CreateNewCaptureScope (MTLCommandQueue): nonnull"); } TestRuntime.AssertXcodeVersion(10, 0); using (var evt = device.CreateSharedEvent()) using (var shared = evt.CreateSharedEventHandle()) { Assert.IsNotNull(shared, "MTLSharedEvent.CreateSharedEvent: NonNull"); } }
protected virtual bool Skip(Type type, string selectorName) { #if !XAMCORE_2_0 // old binding mistake if (selectorName == "subscribedCentrals") { return(true); } #else // The MapKit types/selectors are optional protocol members pulled in from MKAnnotation/MKOverlay. // These concrete (wrapper) subclasses do not implement all of those optional members, but we // still need to provide a binding for them, so that user subclasses can implement those members. switch (type.Name) { case "AVAggregateAssetDownloadTask": switch (selectorName) { case "URLAsset": // added in Xcode 9 and it is present. return(true); } break; case "AVAssetDownloadStorageManager": switch (selectorName) { case "sharedDownloadStorageManager": // added in Xcode 9 and it is present. return(true); } break; case "MKCircle": case "MKPolygon": case "MKPolyline": switch (selectorName) { case "canReplaceMapContent": return(true); } break; case "MKShape": switch (selectorName) { case "setCoordinate:": return(true); } break; case "MKPlacemark": switch (selectorName) { case "setCoordinate:": case "subtitle": return(true); } break; case "MKTileOverlay": switch (selectorName) { case "intersectsMapRect:": return(true); } break; // AVAudioChannelLayout and AVAudioFormat started conforming to NSSecureCoding in OSX 10.11 and iOS 9 case "AVAudioChannelLayout": case "AVAudioFormat": // NSSecureCoding added in iOS 10 / macOS 10.12 case "CNContactFetchRequest": case "GKEntity": case "GKPolygonObstacle": case "GKComponent": case "GKGraphNode": case "WKPreferences": case "WKUserContentController": case "WKProcessPool": case "WKWebViewConfiguration": case "WKWebsiteDataStore": switch (selectorName) { case "encodeWithCoder:": return(true); } break; // SKTransition started conforming to NSCopying in OSX 10.11 and iOS 9 case "SKTransition": // iOS 10 beta 2 case "GKBehavior": case "MDLTransform": switch (selectorName) { case "copyWithZone:": return(true); } break; case "MDLMaterialProperty": switch (selectorName) { case "copyWithZone:": // not working before iOS 10, macOS 10.12 return(!TestRuntime.CheckXcodeVersion(8, 0)); } break; // Xcode 8 beta 2 case "GKGraph": case "GKAgent": case "GKAgent2D": case "NEFlowMetaData": case "NWEndpoint": switch (selectorName) { case "copyWithZone:": case "encodeWithCoder:": return(true); } break; // now conforms to MDLName case "MTKMeshBuffer": switch (selectorName) { case "name": case "setName:": return(true); } break; // Xcode 9 case "CIQRCodeFeature": switch (selectorName) { case "copyWithZone:": case "encodeWithCoder:": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; case "CKFetchRecordZoneChangesOptions": switch (selectorName) { case "copyWithZone:": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; #if !MONOMAC case "MTLCaptureManager": if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; #endif } #endif // This ctors needs to be manually bound switch (type.Name) { case "AVCaptureVideoPreviewLayer": switch (selectorName) { case "initWithSession:": case "initWithSessionWithNoConnection:": return(true); } break; case "GKPath": switch (selectorName) { case "initWithPoints:count:radius:cyclical:": case "initWithFloat3Points:count:radius:cyclical:": return(true); } break; case "GKPolygonObstacle": switch (selectorName) { case "initWithPoints:count:": return(true); } break; case "MDLMesh": switch (selectorName) { case "initCapsuleWithExtent:cylinderSegments:hemisphereSegments:inwardNormals:geometryType:allocator:": case "initConeWithExtent:segments:inwardNormals:cap:geometryType:allocator:": case "initHemisphereWithExtent:segments:inwardNormals:cap:geometryType:allocator:": case "initMeshBySubdividingMesh:submeshIndex:subdivisionLevels:allocator:": case "initSphereWithExtent:segments:inwardNormals:geometryType:allocator:": case "initBoxWithExtent:segments:inwardNormals:geometryType:allocator:": case "initCylinderWithExtent:segments:inwardNormals:topCap:bottomCap:geometryType:allocator:": case "initIcosahedronWithExtent:inwardNormals:geometryType:allocator:": case "initPlaneWithExtent:segments:geometryType:allocator:": return(true); } break; case "MDLNoiseTexture": switch (selectorName) { case "initCellularNoiseWithFrequency:name:textureDimensions:channelEncoding:": case "initVectorNoiseWithSmoothness:name:textureDimensions:channelEncoding:": return(true); } break; case "NSImage": switch (selectorName) { case "initByReferencingFile:": return(true); } break; // Conform to SKWarpable case "SKEffectNode": case "SKSpriteNode": switch (selectorName) { case "setSubdivisionLevels:": case "setWarpGeometry:": return(true); } break; case "SKUniform": switch (selectorName) { // New selectors case "initWithName:vectorFloat2:": case "initWithName:vectorFloat3:": case "initWithName:vectorFloat4:": case "initWithName:matrixFloat2x2:": case "initWithName:matrixFloat3x3:": case "initWithName:matrixFloat4x4:": // Old selectors case "initWithName:floatVector2:": case "initWithName:floatVector3:": case "initWithName:floatVector4:": case "initWithName:floatMatrix2:": case "initWithName:floatMatrix3:": case "initWithName:floatMatrix4:": return(true); } break; case "SKVideoNode": switch (selectorName) { case "initWithFileNamed:": case "initWithURL:": case "initWithVideoFileNamed:": case "initWithVideoURL:": case "videoNodeWithFileNamed:": case "videoNodeWithURL:": return(true); } break; case "SKWarpGeometryGrid": switch (selectorName) { case "initWithColumns:rows:sourcePositions:destPositions:": return(true); } break; case "INPriceRange": switch (selectorName) { case "initWithMaximumPrice:currencyCode:": case "initWithMinimumPrice:currencyCode:": return(true); } break; case "CKUserIdentityLookupInfo": switch (selectorName) { case "initWithEmailAddress:": case "initWithPhoneNumber:": case "lookupInfosWithRecordIDs:": // FAILs on watch yet we do have a unittest for it case "lookupInfosWithEmails:": // FAILs on watch yet we do have a unittest for it case "lookupInfosWithPhoneNumbers:": // FAILs on watch yet we do have a unittest for it return(true); } break; case "AVPlayerItemVideoOutput": switch (selectorName) { case "initWithOutputSettings:": case "initWithPixelBufferAttributes:": return(true); } break; case "MTLBufferLayoutDescriptor": // We do have unit tests under monotouch-tests for this properties switch (selectorName) { case "stepFunction": case "setStepFunction:": case "stepRate": case "setStepRate:": case "stride": case "setStride:": return(true); } break; case "MTLFunctionConstant": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "name": case "type": case "index": case "required": return(true); } break; case "MTLStageInputOutputDescriptor": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "attributes": case "indexBufferIndex": case "setIndexBufferIndex:": case "indexType": case "setIndexType:": case "layouts": return(true); } break; case "MTLAttributeDescriptor": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "bufferIndex": case "setBufferIndex:": case "format": case "setFormat:": case "offset": case "setOffset:": return(true); } break; case "MTLAttribute": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "isActive": case "attributeIndex": case "attributeType": case "isPatchControlPointData": case "isPatchData": case "name": case "isDepthTexture": return(true); } break; case "MTLArgument": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "isDepthTexture": return(true); } break; case "MTLArgumentDescriptor": switch (selectorName) { case "access": case "setAccess:": case "arrayLength": case "setArrayLength:": case "constantBlockAlignment": case "setConstantBlockAlignment:": case "dataType": case "setDataType:": case "index": case "setIndex:": case "textureType": case "setTextureType:": return(true); } break; case "MTLHeapDescriptor": switch (selectorName) { case "cpuCacheMode": case "setCpuCacheMode:": case "size": case "setSize:": case "storageMode": case "setStorageMode:": return(true); } break; case "MTLPipelineBufferDescriptor": switch (selectorName) { case "mutability": case "setMutability:": return(true); } break; case "MTLPointerType": switch (selectorName) { case "access": case "alignment": case "dataSize": case "elementIsArgumentBuffer": case "elementType": return(true); } break; case "MTLTextureReferenceType": switch (selectorName) { case "access": case "isDepthTexture": case "textureDataType": case "textureType": return(true); } break; case "MTLType": switch (selectorName) { case "dataType": return(true); } break; case "MTLTileRenderPipelineColorAttachmentDescriptor": switch (selectorName) { case "pixelFormat": case "setPixelFormat:": return(true); } break; case "MTLTileRenderPipelineDescriptor": switch (selectorName) { case "colorAttachments": case "label": case "setLabel:": case "rasterSampleCount": case "setRasterSampleCount:": case "threadgroupSizeMatchesTileSize": case "setThreadgroupSizeMatchesTileSize:": case "tileBuffers": case "tileFunction": case "setTileFunction:": return(true); } break; case "AVPlayerLooper": // This API got introduced in Xcode 8.0 binding but is not currently present nor in Xcode 8.3 or Xcode 9.0 needs research switch (selectorName) { case "isLoopingEnabled": return(true); } break; case "NSQueryGenerationToken": // A test was added in monotouch tests to ensure the selector works switch (selectorName) { case "encodeWithCoder:": return(true); } break; case "INSpeakableString": switch (selectorName) { case "initWithVocabularyIdentifier:spokenPhrase:pronunciationHint:": case "initWithIdentifier:spokenPhrase:pronunciationHint:": return(true); } break; case "HMCharacteristicEvent": switch (selectorName) { case "copyWithZone:": case "mutableCopyWithZone:": // Added in Xcode9 (i.e. only 64 bits) so skip 32 bits return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; } // old binding mistake return(selectorName == "initWithCoder:"); }
protected virtual bool Skip(Type type, string selectorName) { #if !XAMCORE_2_0 // old binding mistake if (selectorName == "subscribedCentrals") { return(true); } #else // The MapKit types/selectors are optional protocol members pulled in from MKAnnotation/MKOverlay. // These concrete (wrapper) subclasses do not implement all of those optional members, but we // still need to provide a binding for them, so that user subclasses can implement those members. switch (type.Name) { case "AVAggregateAssetDownloadTask": switch (selectorName) { case "URLAsset": // added in Xcode 9 and it is present. return(true); } break; case "AVAssetDownloadStorageManager": switch (selectorName) { case "sharedDownloadStorageManager": // added in Xcode 9 and it is present. return(true); } break; case "MKCircle": case "MKPolygon": case "MKPolyline": switch (selectorName) { case "canReplaceMapContent": return(true); } break; case "MKShape": switch (selectorName) { case "setCoordinate:": return(true); } break; case "MKPlacemark": switch (selectorName) { case "setCoordinate:": case "subtitle": return(true); } break; case "MKTileOverlay": switch (selectorName) { case "intersectsMapRect:": return(true); } break; // AVAudioChannelLayout and AVAudioFormat started conforming to NSSecureCoding in OSX 10.11 and iOS 9 case "AVAudioChannelLayout": case "AVAudioFormat": // NSSecureCoding added in iOS 10 / macOS 10.12 case "CNContactFetchRequest": case "GKEntity": case "GKPolygonObstacle": case "GKComponent": case "GKGraphNode": case "WKPreferences": case "WKUserContentController": case "WKProcessPool": case "WKWebViewConfiguration": case "WKWebsiteDataStore": switch (selectorName) { case "encodeWithCoder:": return(true); } break; // SKTransition started conforming to NSCopying in OSX 10.11 and iOS 9 case "SKTransition": // iOS 10 beta 2 case "GKBehavior": case "MDLTransform": switch (selectorName) { case "copyWithZone:": return(true); } break; case "MDLMaterialProperty": switch (selectorName) { case "copyWithZone:": // not working before iOS 10, macOS 10.12 return(!TestRuntime.CheckXcodeVersion(8, 0)); } break; // Xcode 8 beta 2 case "GKGraph": case "GKAgent": case "GKAgent2D": case "NEFlowMetaData": case "NWEndpoint": switch (selectorName) { case "copyWithZone:": case "encodeWithCoder:": return(true); } break; // now conforms to MDLName case "MTKMeshBuffer": switch (selectorName) { case "name": case "setName:": return(true); } break; // Xcode 9 case "CIQRCodeFeature": switch (selectorName) { case "copyWithZone:": case "encodeWithCoder:": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; case "CKFetchRecordZoneChangesOptions": switch (selectorName) { case "copyWithZone:": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; #if !XAMCORE_4_0 case "NSUrl": case "ARQuickLookPreviewItem": switch (selectorName) { case "previewItemTitle": // 'previewItemTitle' is inlined from the QLPreviewItem protocol and should be optional (fixed in XAMCORE_4_0) return(true); } break; #endif case "MKMapItem": // Selector not available on iOS 32-bit switch (selectorName) { case "encodeWithCoder:": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; #if !MONOMAC case "MTLCaptureManager": case "NEHotspotEapSettings": // Wireless Accessory Configuration is not supported in the simulator. case "NEHotspotConfigurationManager": case "NEHotspotHS20Settings": if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; #endif } #endif // This ctors needs to be manually bound switch (type.Name) { case "AVCaptureVideoPreviewLayer": switch (selectorName) { case "initWithSession:": case "initWithSessionWithNoConnection:": return(true); } break; case "GKPath": switch (selectorName) { case "initWithPoints:count:radius:cyclical:": case "initWithFloat3Points:count:radius:cyclical:": return(true); } break; case "GKPolygonObstacle": switch (selectorName) { case "initWithPoints:count:": return(true); } break; case "MDLMesh": switch (selectorName) { case "initCapsuleWithExtent:cylinderSegments:hemisphereSegments:inwardNormals:geometryType:allocator:": case "initConeWithExtent:segments:inwardNormals:cap:geometryType:allocator:": case "initHemisphereWithExtent:segments:inwardNormals:cap:geometryType:allocator:": case "initMeshBySubdividingMesh:submeshIndex:subdivisionLevels:allocator:": case "initSphereWithExtent:segments:inwardNormals:geometryType:allocator:": case "initBoxWithExtent:segments:inwardNormals:geometryType:allocator:": case "initCylinderWithExtent:segments:inwardNormals:topCap:bottomCap:geometryType:allocator:": case "initIcosahedronWithExtent:inwardNormals:geometryType:allocator:": case "initPlaneWithExtent:segments:geometryType:allocator:": return(true); } break; case "MDLNoiseTexture": switch (selectorName) { case "initCellularNoiseWithFrequency:name:textureDimensions:channelEncoding:": case "initVectorNoiseWithSmoothness:name:textureDimensions:channelEncoding:": return(true); } break; case "NSImage": switch (selectorName) { case "initByReferencingFile:": return(true); } break; // Conform to SKWarpable case "SKEffectNode": case "SKSpriteNode": switch (selectorName) { case "setSubdivisionLevels:": case "setWarpGeometry:": return(true); } break; case "SKAttribute": case "SKAttributeValue": switch (selectorName) { case "encodeWithCoder:": if (!TestRuntime.CheckXcodeVersion(8, 0)) { return(true); } break; } break; case "SKUniform": switch (selectorName) { // New selectors case "initWithName:vectorFloat2:": case "initWithName:vectorFloat3:": case "initWithName:vectorFloat4:": case "initWithName:matrixFloat2x2:": case "initWithName:matrixFloat3x3:": case "initWithName:matrixFloat4x4:": // Old selectors case "initWithName:floatVector2:": case "initWithName:floatVector3:": case "initWithName:floatVector4:": case "initWithName:floatMatrix2:": case "initWithName:floatMatrix3:": case "initWithName:floatMatrix4:": return(true); } break; case "SKVideoNode": switch (selectorName) { case "initWithFileNamed:": case "initWithURL:": case "initWithVideoFileNamed:": case "initWithVideoURL:": case "videoNodeWithFileNamed:": case "videoNodeWithURL:": return(true); } break; case "SKWarpGeometryGrid": switch (selectorName) { case "initWithColumns:rows:sourcePositions:destPositions:": return(true); } break; case "INPriceRange": switch (selectorName) { case "initWithMaximumPrice:currencyCode:": case "initWithMinimumPrice:currencyCode:": return(true); } break; case "CKUserIdentityLookupInfo": switch (selectorName) { case "initWithEmailAddress:": case "initWithPhoneNumber:": case "lookupInfosWithRecordIDs:": // FAILs on watch yet we do have a unittest for it case "lookupInfosWithEmails:": // FAILs on watch yet we do have a unittest for it case "lookupInfosWithPhoneNumbers:": // FAILs on watch yet we do have a unittest for it return(true); } break; case "AVPlayerItemVideoOutput": switch (selectorName) { case "initWithOutputSettings:": case "initWithPixelBufferAttributes:": return(true); } break; case "MTLBufferLayoutDescriptor": // We do have unit tests under monotouch-tests for this properties switch (selectorName) { case "stepFunction": case "setStepFunction:": case "stepRate": case "setStepRate:": case "stride": case "setStride:": return(true); } break; case "MTLFunctionConstant": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "name": case "type": case "index": case "required": return(true); } break; case "MTLStageInputOutputDescriptor": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "attributes": case "indexBufferIndex": case "setIndexBufferIndex:": case "indexType": case "setIndexType:": case "layouts": return(true); } break; case "MTLAttributeDescriptor": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "bufferIndex": case "setBufferIndex:": case "format": case "setFormat:": case "offset": case "setOffset:": return(true); } break; case "MTLAttribute": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "isActive": case "attributeIndex": case "attributeType": case "isPatchControlPointData": case "isPatchData": case "name": case "isDepthTexture": return(true); } break; case "MTLArgument": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "isDepthTexture": return(true); } break; case "MTLArgumentDescriptor": switch (selectorName) { case "access": case "setAccess:": case "arrayLength": case "setArrayLength:": case "constantBlockAlignment": case "setConstantBlockAlignment:": case "dataType": case "setDataType:": case "index": case "setIndex:": case "textureType": case "setTextureType:": return(true); } break; case "MTLHeapDescriptor": switch (selectorName) { case "cpuCacheMode": case "setCpuCacheMode:": case "size": case "setSize:": case "storageMode": case "setStorageMode:": return(true); } break; case "MTLIndirectCommandBufferDescriptor": // we do have unit tests under monotouch-tests for this properties switch (selectorName) { case "commandTypes": case "setCommandTypes:": case "inheritPipelineState": case "setInheritPipelineState:": case "inheritBuffers": case "setInheritBuffers:": case "maxFragmentBufferBindCount": case "setMaxFragmentBufferBindCount:": case "maxVertexBufferBindCount": case "setMaxVertexBufferBindCount:": return(true); } break; case "MTLPipelineBufferDescriptor": switch (selectorName) { case "mutability": case "setMutability:": return(true); } break; case "MTLPointerType": switch (selectorName) { case "access": case "alignment": case "dataSize": case "elementIsArgumentBuffer": case "elementType": return(true); } break; case "MTLSharedEventListener": switch (selectorName) { case "dispatchQueue": return(true); } break; case "MTLTextureReferenceType": switch (selectorName) { case "access": case "isDepthTexture": case "textureDataType": case "textureType": return(true); } break; case "MTLType": switch (selectorName) { case "dataType": return(true); } break; case "MTLTileRenderPipelineColorAttachmentDescriptor": switch (selectorName) { case "pixelFormat": case "setPixelFormat:": return(true); } break; case "MTLTileRenderPipelineDescriptor": switch (selectorName) { case "colorAttachments": case "label": case "setLabel:": case "rasterSampleCount": case "setRasterSampleCount:": case "threadgroupSizeMatchesTileSize": case "setThreadgroupSizeMatchesTileSize:": case "tileBuffers": case "tileFunction": case "setTileFunction:": case "maxTotalThreadsPerThreadgroup": case "setMaxTotalThreadsPerThreadgroup:": return(true); } break; case "AVPlayerLooper": // This API got introduced in Xcode 8.0 binding but is not currently present nor in Xcode 8.3 or Xcode 9.0 needs research switch (selectorName) { case "isLoopingEnabled": return(true); } break; case "NSQueryGenerationToken": // A test was added in monotouch tests to ensure the selector works switch (selectorName) { case "encodeWithCoder:": return(true); } break; case "INSpeakableString": switch (selectorName) { case "initWithVocabularyIdentifier:spokenPhrase:pronunciationHint:": case "initWithIdentifier:spokenPhrase:pronunciationHint:": return(true); } break; case "HMCharacteristicEvent": switch (selectorName) { case "copyWithZone:": case "mutableCopyWithZone:": // Added in Xcode9 (i.e. only 64 bits) so skip 32 bits return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; case "MPSCnnConvolution": switch (selectorName) { case "initWithDevice:convolutionDescriptor:kernelWeights:biasTerms:flags:": return(true); } break; case "MPSCnnFullyConnected": switch (selectorName) { case "initWithDevice:convolutionDescriptor:kernelWeights:biasTerms:flags:": return(true); } break; case "MPSImageConversion": switch (selectorName) { case "initWithDevice:srcAlpha:destAlpha:backgroundColor:conversionInfo:": return(true); } break; case "MPSImageDilate": switch (selectorName) { case "initWithDevice:kernelWidth:kernelHeight:values:": return(true); } break; case "MPSImageGaussianPyramid": switch (selectorName) { case "initWithDevice:kernelWidth:kernelHeight:weights:": return(true); } break; case "MPSImagePyramid": switch (selectorName) { case "initWithDevice:kernelWidth:kernelHeight:weights:": return(true); } break; case "MPSImageSobel": switch (selectorName) { case "initWithDevice:linearGrayColorTransform:": return(true); } break; case "MPSImageThresholdBinary": switch (selectorName) { case "initWithDevice:thresholdValue:maximumValue:linearGrayColorTransform:": return(true); } break; case "MPSImageThresholdBinaryInverse": switch (selectorName) { case "initWithDevice:thresholdValue:maximumValue:linearGrayColorTransform:": return(true); } break; case "MPSImageThresholdToZero": switch (selectorName) { case "initWithDevice:thresholdValue:linearGrayColorTransform:": return(true); } break; case "MPSImageThresholdToZeroInverse": switch (selectorName) { case "initWithDevice:thresholdValue:linearGrayColorTransform:": return(true); } break; case "MPSImageThresholdTruncate": switch (selectorName) { case "initWithDevice:thresholdValue:linearGrayColorTransform:": return(true); } break; case "MPSCnnBinaryKernel": switch (selectorName) { // Xcode 9.4 removed both selectors from MPSCnnBinaryKernel, reported radar https://trello.com/c/7EAM0qk1 // but apple says this was intentional. case "kernelHeight": case "kernelWidth": return(true); } break; case "MPSImageLaplacianPyramid": case "MPSImageLaplacianPyramidSubtract": case "MPSImageLaplacianPyramidAdd": switch (selectorName) { case "initWithDevice:kernelWidth:kernelHeight:weights:": return(true); } break; case "VNFaceLandmarkRegion": case "VNFaceLandmarks": case "PHLivePhoto": switch (selectorName) { case "copyWithZone:": case "encodeWithCoder:": case "requestRevision": // Conformance added in Xcode 11 if (!TestRuntime.CheckXcodeVersion(11, 0)) { return(true); } break; } break; case "MPSNNNeuronDescriptor": case "MLDictionaryConstraint": case "MLFeatureDescription": case "MLImageConstraint": case "MLImageSize": case "MLImageSizeConstraint": case "MLModelConfiguration": case "MLModelDescription": case "MLMultiArrayConstraint": case "MLMultiArrayShapeConstraint": case "MLSequenceConstraint": switch (selectorName) { case "encodeWithCoder:": // Conformance added in Xcode 11 if (!TestRuntime.CheckXcodeVersion(11, 0)) { return(true); } break; } break; case "BGTaskScheduler": switch (selectorName) { case "sharedScheduler": return(true); } break; #if !__MACOS__ case "ARSkeletonDefinition": switch (selectorName) { case "indexForJointName:": case "defaultBody2DSkeletonDefinition": case "defaultBody3DSkeletonDefinition": // This selector does not exist in the simulator if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; } break; #endif case "INParameter": switch (selectorName) { case "copyWithZone:": if (!TestRuntime.CheckXcodeVersion(10, 0)) { return(true); } break; } break; } // old binding mistake return(selectorName == "initWithCoder:"); }
void Trust_Leaf_Only(SecTrust trust, SecPolicy policy) { Assert.That(CFGetRetainCount(trust.Handle), Is.EqualTo((nint)1), "RetainCount(trust)"); Assert.That(CFGetRetainCount(policy.Handle), Is.EqualTo((nint)2), "RetainCount(policy)"); // that certificate stopped being valid on September 30th, 2013 so we validate it with a date earlier than that trust.SetVerifyDate(new DateTime(635108745218945450, DateTimeKind.Utc)); // the system was able to construct the chain based on the single certificate var expectedTrust = SecTrustResult.RecoverableTrustFailure; #if __MACOS__ if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 9)) { expectedTrust = SecTrustResult.Unspecified; } #endif Assert.That(Evaluate(trust, true), Is.EqualTo(expectedTrust), "Evaluate"); using (var queue = new DispatchQueue("TrustAsync")) { bool assert = false; // we don't want to assert in another queue bool called = false; var err = trust.Evaluate(DispatchQueue.MainQueue, (t, result) => { assert = t.Handle == trust.Handle && result == expectedTrust; called = true; }); Assert.That(err, Is.EqualTo(SecStatusCode.Success), "async1/err"); TestRuntime.RunAsync(TimeSpan.FromSeconds(5), () => { }, () => called); Assert.True(assert, "async1"); } if (TestRuntime.CheckXcodeVersion(11, 0)) { using (var queue = new DispatchQueue("TrustErrorAsync")) { bool assert = false; // we don't want to assert in another queue bool called = false; var err = trust.Evaluate(DispatchQueue.MainQueue, (t, result, error) => { assert = t.Handle == trust.Handle && !result && error != null; called = true; }); Assert.That(err, Is.EqualTo(SecStatusCode.Success), "async2/err"); TestRuntime.RunAsync(TimeSpan.FromSeconds(5), () => { }, () => called); Assert.True(assert, "async2"); } } #if __MACOS__ var hasNetworkFetchAllowed = TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 9); #else var hasNetworkFetchAllowed = TestRuntime.CheckXcodeVersion(5, 0); #endif if (hasNetworkFetchAllowed) { Assert.True(trust.NetworkFetchAllowed, "NetworkFetchAllowed-1"); trust.NetworkFetchAllowed = false; Assert.False(trust.NetworkFetchAllowed, "NetworkFetchAllowed-2"); trust.SetPolicy(policy); var policies = trust.GetPolicies(); Assert.That(policies.Length, Is.EqualTo(1), "Policies.Length"); Assert.That(policies [0].Handle, Is.EqualTo(policy.Handle), "Handle"); } }
public void OpenClose_libSystem() { IntPtr handle = Dlfcn.dlopen("/usr/lib/libSystem.dylib", 0); Assert.That(handle, Is.Not.EqualTo(IntPtr.Zero), "dlopen"); var err = Dlfcn.dlclose(handle); var expected = 0; #if !MONOMAC if (Runtime.Arch == Arch.DEVICE && TestRuntime.CheckXcodeVersion(7, 0) && !TestRuntime.CheckXcodeVersion(10, 0)) { // Apple is doing some funky stuff with dlopen... this condition is to track if this change during betas expected = -1; } #endif Assert.That(err, Is.EqualTo(expected), "dlclose"); }
protected virtual bool Skip(Type type, string protocolName) { switch (protocolName) { case "NSCopying": switch (type.Name) { // undocumented conformance (up to 7.0) and conformity varies between iOS versions case "CAEmitterCell": case "GKAchievement": case "GKScore": case "MPMediaItem": // new in iOS8 and 10.0 case "NSExtensionContext": case "NSLayoutAnchor`1": case "NSLayoutDimension": case "NSLayoutXAxisAnchor": case "NSLayoutYAxisAnchor": // iOS 10 beta 3 case "GKCloudPlayer": // iOS 10 : test throw because of generic usage case "NSMeasurement`1": // Xcode 9 - Conformance not in headers case "MLDictionaryConstraint": case "MLImageConstraint": case "MLMultiArrayConstraint": case "VSSubscription": return(true); // skip } break; case "NSMutableCopying": switch (type.Name) { // iOS 10 : test throw because of generic usage case "NSMeasurement`1": return(true); // skip } break; case "NSCoding": switch (type.Name) { // only documented to support NSCopying - not NSCoding (fails on iOS 7.1 but not 8.0) case "NSUrlSessionTask": case "NSUrlSessionDataTask": case "NSUrlSessionUploadTask": case "NSUrlSessionDownloadTask": // case "NSUrlSessionConfiguration": case "NSMergeConflict": // new in iOS8 and 10.0 case "NSExtensionContext": case "NSItemProvider": // iOS9 / 10.11 case "CNSaveRequest": case "NSLayoutAnchor`1": case "NSLayoutDimension": case "NSLayoutXAxisAnchor": case "NSLayoutYAxisAnchor": case "GKCloudPlayer": case "GKGameSession": // iOS 10 : test throw because of generic usage case "NSMeasurement`1": // iOS 11 / tvOS 11 case "VSSubscription": return(true); } break; case "NSSecureCoding": switch (type.Name) { case "NSMergeConflict": // undocumented // only documented to support NSCopying (and OSX side only does that) case "NSUrlSessionTask": case "NSUrlSessionDataTask": case "NSUrlSessionUploadTask": case "NSUrlSessionDownloadTask": case "NSUrlSessionConfiguration": // new in iOS8 and 10.0 case "NSExtensionContext": case "NSItemProvider": case "NSParagraphStyle": //17770106 case "NSMutableParagraphStyle": //17770106 return(true); // skip // iOS9 / 10.11 case "CNSaveRequest": case "NSPersonNameComponentsFormatter": case "GKCloudPlayer": case "GKGameSession": // iOS 10 : test throw because of generic usage case "NSMeasurement`1": return(true); // skip // xcode 9 case "NSConstraintConflict": // Conformance not in headers case "VSSubscription": return(true); case "MPSImageAllocator": // Header shows NSSecureCoding, but intro gives: MPSImageAllocator conforms to NSSecureCoding but SupportsSecureCoding returned false return(true); } break; // conformance added in Xcode 8 (iOS 10 / macOS 10.12) case "MDLNamed": switch (type.Name) { case "MTKMeshBuffer": case "MDLVoxelArray": // base class changed to MDLObject (was NSObject before) return(true); } break; case "CALayerDelegate": switch (type.Name) { case "MTKView": return(true); } break; case "NSProgressReporting": if (!TestRuntime.CheckXcodeVersion(9, 0)) { return(true); } break; case "GKSceneRootNodeType": // it's an empty protocol, defined by a category and does not reply as expected switch (type.Name) { // GameplayKit.framework/Headers/SceneKit+Additions.h case "SCNScene": // GameplayKit.framework/Headers/SpriteKit+Additions.h case "SKScene": return(true); } break; } return(false); }
public void FinalizationRaceCondition() { if ((IntPtr.Size == 8) && TestRuntime.CheckXcodeVersion(7, 0)) { Assert.Ignore("NSString retainCount is nuint.MaxValue, so we won't collect them"); } #if __WATCHOS__ if (Runtime.Arch == Arch.DEVICE) { Assert.Ignore("This test uses too much memory for the watch."); } #endif NSDictionary dict = null; var thread = new Thread(() => { dict = new NSMutableDictionary(); dict["Hello"] = new NSString(@"World"); dict["Bye"] = new NSString(@"Bye"); }) { IsBackground = true }; thread.Start(); thread.Join(); var getter1 = new Func <string, string> ((key) => dict [key] as NSString); var getter2 = new Func <string, NSString> ((key) => dict [key] as NSString); var broken = 0; var count = 0; thread = new Thread(() => { var watch = new Stopwatch(); watch.Start(); while (broken == 0 && watch.ElapsedMilliseconds < 10000) { // try getting using Systen.String key string hello = getter1("Hello"); if (hello == null) { broken = 1; } string bye = getter1("Bye"); if (bye == null) { broken = 2; } // try getting using NSString key string nHello = getter2(new NSString(@"Hello")); string nBye = getter2(new NSString(@"Bye")); if (nHello == null) { broken = 3; } if (nBye == null) { broken = 4; } count++; } }) { IsBackground = true, }; thread.Start(); while (!thread.Join(1)) { NSRunLoop.Main.RunUntil(NSDate.Now.AddSeconds(0.1)); } Assert.AreEqual(0, broken, string.Format("broken after {0} iterations", count)); }
protected override bool Skip(Type type, string protocolName) { // some code cannot be run on the simulator (e.g. missing frameworks) switch (type.Namespace) { case "MonoTouch.Metal": case "Metal": case "MonoTouch.CoreAudioKit": case "CoreAudioKit": // they works with iOS9 beta 4 (but won't work on older simulators) if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; #if !__TVOS__ case "WatchConnectivity": case "MonoTouch.WatchConnectivity": if (!WCSession.IsSupported) { return(true); } break; #endif // !__TVOS__ } switch (type.Name) { case "CAMetalLayer": // that one still does not work with iOS9 beta 4 if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; #if !XAMCORE_3_0 // mistake (base type) fixed by a breaking change case "MFMailComposeViewControllerDelegate": if (protocolName == "UINavigationControllerDelegate") { return(true); } break; #endif // special case: the Delegate property is id<A,B> so we made A subclass B in managed // but this test see the conformance is not correct case "UIImagePickerControllerDelegate": case "UIVideoEditorControllerDelegate": if (protocolName == "UINavigationControllerDelegate") { return(true); } break; } switch (protocolName) { case "NSCoding": switch (type.Name) { case "GKPlayer": case "GKLocalPlayer": // NSSecureCoding is still undocumented, for iOS, and neither is NSCoding for OSX // and it did not respond before 6.0 (when NSSecureCoding was introduced) return(!TestRuntime.CheckXcodeVersion(4, 5)); case "UITableViewDataSource": // this is a *protocol( and we do not want to force people to conform to (an // undocumented "requirement") NSCoding - as ObjC do not have to do this return(true); // part of HomeKit are *privately* conforming to NSCoding case "HMCharacteristic": case "HMCharacteristicMetadata": case "HMHome": case "HMService": case "HMAccessory": case "HMActionSet": case "HMCharacteristicWriteAction": case "HMRoom": case "HMServiceGroup": case "HMTimerTrigger": case "HMTrigger": case "HMUser": case "HMZone": case "HMAccessoryCategory": case "HMCharacteristicEvent": case "HMEvent": case "HMEventTrigger": case "HMLocationEvent": // new PassKit for payment also *privately* conforms to NSCoding case "PKPayment": case "PKPaymentSummaryItem": case "PKShippingMethod": case "PKPaymentRequest": case "PKPaymentToken": case "PKLabeledValue": case "PKPaymentAuthorizationResult": case "PKPaymentRequestShippingMethodUpdate": case "PKPaymentRequestUpdate": case "PKPaymentRequestPaymentMethodUpdate": case "PKPaymentRequestShippingContactUpdate": // iOS9 case "UIFont": case "AVAssetTrackSegment": case "AVComposition": case "AVMutableComposition": case "AVCompositionTrackSegment": case "MKMapSnapshotOptions": case "WCSessionFile": case "WCSessionFileTransfer": // iOS10 case "CXCall": case "CXCallDirectoryExtensionContext": case "CXCallUpdate": case "CXProviderConfiguration": case "MSMessageTemplateLayout": case "MSSession": case "SFContentBlockerState": case "SFSafariViewControllerConfiguration": case "VSAccountMetadata": case "VSAccountMetadataRequest": // iOS 10.2 case "VSAccountProviderResponse": // iOS 10.3 case "MPMusicPlayerControllerMutableQueue": case "MPMusicPlayerControllerQueue": return(true); // iOS 11.0 case "UICollectionViewUpdateItem": // Conformance not in headers case "MKMapItem": // Conformance not in headers case "NSConstraintConflict": // Conformance not in headers case "NSQueryGenerationToken": // Conformance not in headers case "NSPersistentHistoryToken": // Conformance not in headers case "ARCamera": case "HMPresenceEvent": case "HMMutablePresenceEvent": case "HMSignificantTimeEvent": case "HMMutableSignificantTimeEvent": case "HMCalendarEvent": case "HMMutableCalendarEvent": case "HMCharacteristicThresholdRangeEvent": case "HMMutableCharacteristicThresholdRangeEvent": case "HMDurationEvent": case "HMMutableDurationEvent": case "HMMutableCharacteristicEvent": case "HMMutableLocationEvent": case "HMTimeEvent": case "ILMessageFilterExtensionContext": // Conformance not in headers case "MSMessageLiveLayout": case "NSFileProviderDomain": // Conformance not in headers case "FPUIActionExtensionContext": // Conformance not in headers case "UIDocumentBrowserAction": // Conformance not in headers return(true); // Header shows implementing NSSecureCoding, but supportsSecureCoding returns false. Radar #34800025 case "HKSeriesBuilder": case "HKWorkoutRouteBuilder": return(true); // Xcode 9.2 undocumented conformance (like due to new base type) case "HMHomeAccessControl": case "HMAccessControl": return(true); #if __WATCHOS__ case "CLKComplicationTemplate": case "CLKComplicationTemplateCircularSmallRingImage": case "CLKComplicationTemplateCircularSmallRingText": case "CLKComplicationTemplateCircularSmallSimpleImage": case "CLKComplicationTemplateCircularSmallSimpleText": case "CLKComplicationTemplateCircularSmallStackImage": case "CLKComplicationTemplateCircularSmallStackText": case "CLKComplicationTemplateModularLargeColumns": case "CLKComplicationTemplateModularLargeStandardBody": case "CLKComplicationTemplateModularLargeTable": case "CLKComplicationTemplateModularLargeTallBody": case "CLKComplicationTemplateModularSmallColumnsText": case "CLKComplicationTemplateModularSmallRingImage": case "CLKComplicationTemplateModularSmallRingText": case "CLKComplication": case "CLKComplicationTemplateModularSmallSimpleImage": case "CLKTextProvider": case "CLKComplicationTemplateModularSmallSimpleText": case "CLKTimeIntervalTextProvider": case "CLKComplicationTemplateModularSmallStackImage": case "CLKTimeTextProvider": case "CLKComplicationTemplateModularSmallStackText": case "CLKComplicationTemplateUtilitarianLargeFlat": case "CLKComplicationTemplateUtilitarianSmallFlat": case "CLKComplicationTemplateUtilitarianSmallRingImage": case "CLKComplicationTemplateUtilitarianSmallRingText": case "CLKComplicationTemplateUtilitarianSmallSquare": case "CLKComplicationTimelineEntry": case "CLKDateTextProvider": case "CLKImageProvider": case "CLKRelativeDateTextProvider": case "CLKSimpleTextProvider": case "WKAlertAction": // watchOS 3 case "CLKComplicationTemplateExtraLargeSimpleImage": case "CLKComplicationTemplateExtraLargeSimpleText": case "CLKComplicationTemplateExtraLargeStackImage": case "CLKComplicationTemplateExtraLargeStackText": case "CLKComplicationTemplateExtraLargeColumnsText": case "CLKComplicationTemplateExtraLargeRingImage": case "CLKComplicationTemplateExtraLargeRingText": return(true); #endif } break; case "NSSecureCoding": switch (type.Name) { // part of HomeKit are *privately* conforming to NSSecureCoding case "HMCharacteristic": case "HMCharacteristicMetadata": case "HMHome": case "HMService": case "HMAccessory": case "HMActionSet": case "HMCharacteristicWriteAction": case "HMRoom": case "HMServiceGroup": case "HMTimerTrigger": case "HMTrigger": case "HMUser": case "HMZone": case "HMAccessoryCategory": case "HMCharacteristicEvent": case "HMEvent": case "HMEventTrigger": case "HMLocationEvent": return(true); // new PassKit for payment also *privately* conforms to NSCoding case "PKPayment": case "PKPaymentSummaryItem": case "PKShippingMethod": case "PKPaymentRequest": case "PKPaymentToken": case "PKLabeledValue": case "PKPaymentAuthorizationResult": case "PKPaymentRequestShippingMethodUpdate": case "PKPaymentRequestUpdate": case "PKPaymentRequestPaymentMethodUpdate": case "PKPaymentRequestShippingContactUpdate": // iOS9 case "UIFont": case "AVAssetTrackSegment": case "AVComposition": case "AVMutableComposition": case "AVCompositionTrackSegment": case "MKMapSnapshotOptions": case "NSTextTab": case "WCSessionFile": case "WCSessionFileTransfer": // iOS10 case "CXCall": case "CXCallDirectoryExtensionContext": case "CXCallUpdate": case "CXProviderConfiguration": case "MSMessageTemplateLayout": case "MSSession": case "SFContentBlockerState": case "SFSafariViewControllerConfiguration": case "VSAccountMetadata": case "VSAccountMetadataRequest": // iOS 10.2 case "VSAccountProviderResponse": // iOS 10.3 case "MPMusicPlayerControllerMutableQueue": case "MPMusicPlayerControllerQueue": return(true); // iOS 11.0 case "MKMapItem": // Conformance not in headers case "NSQueryGenerationToken": // Conformance not in headers case "NSPersistentHistoryToken": // Conformance not in headers case "ARCamera": case "HMPresenceEvent": case "HMMutablePresenceEvent": case "HMSignificantTimeEvent": case "HMMutableSignificantTimeEvent": case "HMCalendarEvent": case "HMMutableCalendarEvent": case "HMCharacteristicThresholdRangeEvent": case "HMMutableCharacteristicThresholdRangeEvent": case "HMDurationEvent": case "HMMutableDurationEvent": case "HMMutableCharacteristicEvent": case "HMMutableLocationEvent": case "HMTimeEvent": case "ILMessageFilterExtensionContext": // Conformance not in headers case "NSAttributeDescription": case "NSEntityDescription": case "NSExpressionDescription": case "NSFetchedPropertyDescription": case "NSFetchIndexDescription": case "NSFetchIndexElementDescription": case "NSFetchRequest": case "NSManagedObjectModel": case "NSPropertyDescription": case "NSRelationshipDescription": case "MSMessageLiveLayout": case "NSFileProviderDomain": // Conformance not in headers case "FPUIActionExtensionContext": // Conformance not in headers case "UIDocumentBrowserAction": // Conformance not in headers return(true); // Header shows implementing NSSecureCoding, but supportsSecureCoding returns false. Radar #34800025 case "HKSeriesBuilder": case "HKWorkoutRouteBuilder": return(true); // Xcode 9.2 undocumented conformance (like due to new base type) case "HMHomeAccessControl": case "HMAccessControl": return(true); #if __WATCHOS__ case "CLKComplicationTemplate": case "CLKComplicationTemplateCircularSmallRingImage": case "CLKComplicationTemplateCircularSmallRingText": case "CLKComplicationTemplateCircularSmallSimpleImage": case "CLKComplicationTemplateCircularSmallSimpleText": case "CLKComplicationTemplateCircularSmallStackImage": case "CLKComplicationTemplateCircularSmallStackText": case "CLKComplicationTemplateModularLargeColumns": case "CLKComplicationTemplateModularLargeStandardBody": case "CLKComplicationTemplateModularLargeTable": case "CLKComplicationTemplateModularLargeTallBody": case "CLKComplicationTemplateModularSmallColumnsText": case "CLKComplicationTemplateModularSmallRingImage": case "CLKComplicationTemplateModularSmallRingText": case "CLKComplicationTemplateModularSmallSimpleImage": case "CLKComplicationTemplateModularSmallSimpleText": case "CLKComplicationTemplateModularSmallStackImage": case "CLKComplicationTemplateModularSmallStackText": case "CLKComplicationTemplateUtilitarianLargeFlat": case "CLKComplicationTemplateUtilitarianSmallFlat": case "CLKComplicationTemplateUtilitarianSmallRingImage": case "CLKComplicationTemplateUtilitarianSmallRingText": case "CLKComplicationTemplateUtilitarianSmallSquare": case "CLKComplicationTimelineEntry": case "CLKDateTextProvider": case "CLKImageProvider": case "CLKRelativeDateTextProvider": case "CLKSimpleTextProvider": case "CLKTextProvider": case "CLKTimeIntervalTextProvider": case "CLKTimeTextProvider": case "CLKComplication": case "WKAlertAction": // watchOS 3 case "CLKComplicationTemplateExtraLargeSimpleImage": case "CLKComplicationTemplateExtraLargeSimpleText": case "CLKComplicationTemplateExtraLargeStackImage": case "CLKComplicationTemplateExtraLargeStackText": case "CLKComplicationTemplateExtraLargeColumnsText": case "CLKComplicationTemplateExtraLargeRingImage": case "CLKComplicationTemplateExtraLargeRingText": return(true); #endif } break; case "NSCopying": switch (type.Name) { // undocumented conformance (up to 7.0) and conformity varies between iOS versions case "MKDirectionsRequest": case "MPMediaPlaylist": case "MPMediaItemCollection": case "MPMediaEntity": return(true); // skip // new PassKit for payment also *privately* conforms to NSCoding case "PKPaymentSummaryItem": case "PKShippingMethod": return(true); // skip // iOS9 case "ACAccount": case "HKCategorySample": case "HKCorrelation": case "HKObject": case "HKQuantitySample": case "HKSample": case "HKWorkout": case "PKPaymentMethod": // iOS 10 case "CXCallDirectoryExtensionContext": case "HKDocumentSample": case "HKCdaDocumentSample": case "SFSafariViewControllerConfiguration": case "VSAccountMetadata": case "VSAccountMetadataRequest": // iOS 10.2 case "VSAccountProviderResponse": return(true); // iOS 11.0 case "UICollectionViewUpdateItem": // Conformance not in headers case "ACAccountCredential": // b2: Conformance not in headers case "ILMessageFilterExtensionContext": // b2: Conformance not in headers case "HMCharacteristicEvent": // Selectors not available on 32 bit case "NSFileProviderDomain": // Conformance not in headers case "FPUIActionExtensionContext": // Conformance not in headers case "CXCall": // Conformance not in headers case "UIDocumentBrowserAction": // Conformance not in headers return(true); // iOS 11.1 case "ARDirectionalLightEstimate": return(true); #if __WATCHOS__ case "CLKComplicationTimelineEntry": return(true); #endif } break; case "NSMutableCopying": switch (type.Name) { case "UNNotificationSound": // iOS 10.3 case "MPMusicPlayerControllerMutableQueue": case "MPMusicPlayerControllerQueue": // iOS 11 case "INRideDriver": case "INRestaurantGuest": case "INPerson": case "HMCharacteristicEvent": // Selectors not available on 32 bit return(true); } break; case "UIAccessibilityIdentification": // UIView satisfy the contract - but return false for conformance (and so does all it's subclasses) return(true); case "UIAppearance": // we added UIAppearance to some types that do not conform to it // note: removing them cause the *Appearance types to be removed too switch (type.Name) { case "ABPeoplePickerNavigationController": case "EKEventEditViewController": case "GKAchievementViewController": case "GKFriendRequestComposeViewController": case "GKLeaderboardViewController": case "GKTurnBasedMatchmakerViewController": case "MFMailComposeViewController": case "MFMessageComposeViewController": return(true); } break; case "UITextInputTraits": // UISearchBar conformance fails before 7.1 - reference bug #33333 if ((type.Name == "UISearchBar") && !TestRuntime.CheckXcodeVersion(5, 1)) { return(true); } break; #if !XAMCORE_3_0 case "UINavigationControllerDelegate": switch (type.Name) { case "ABPeoplePickerNavigationControllerDelegate": // 37180 return(true); } break; #endif case "GKSavedGameListener": switch (type.Name) { case "GKLocalPlayerListener": // 37180 return(!TestRuntime.CheckXcodeVersion(6, 0)); } break; case "UIFocusEnvironment": switch (type.Name) { case "SK3DNode": case "SKAudioNode": case "SKCameraNode": case "SKCropNode": case "SKEffectNode": case "SKEmitterNode": case "SKFieldNode": case "SKLabelNode": case "SKLightNode": case "SKNode": case "SKReferenceNode": case "SKScene": case "SKShapeNode": case "SKVideoNode": case "SKSpriteNode": return(!TestRuntime.CheckXcodeVersion(8, 0)); case "SCNNode": case "SCNReferenceNode": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; case "CALayerDelegate": // UIView now conforms to CALayerDelegate in iOS 10 switch (type.Name) { case "UISearchBar": case "UISegmentedControl": case "UITableView": case "UITableViewCell": case "UITextField": case "UITextView": case "UIToolbar": case "UIView": case "MKPinAnnotationView": case "UIImageView": case "PHLivePhotoView": case "UIInputView": case "UILabel": case "UIActionSheet": case "UIButton": case "UICollectionView": case "UINavigationBar": case "UIControl": case "UIPickerView": case "UIPageControl": case "MPVolumeView": case "UIPopoverBackgroundView": case "UIProgressView": case "UIRefreshControl": case "HKActivityRingView": case "UIScrollView": case "CAInterAppAudioSwitcherView": case "CAInterAppAudioTransportView": case "UISlider": case "UIStackView": case "SCNView": case "UIStepper": case "UISwitch": case "UITabBar": case "UITableViewHeaderFooterView": case "GLKView": case "SKView": case "MKMapView": case "MKAnnotationView": case "PKAddPassButton": case "PKPaymentButton": case "UIActivityIndicatorView": case "UICollectionReusableView": case "UIWebView": case "UICollectionViewCell": case "UIWindow": case "UIDatePicker": case "UIVisualEffectView": case "WKWebView": case "ADBannerView": return(!TestRuntime.CheckXcodeVersion(8, 0)); } break; case "UIFocusItem": // UIView now conforms to UIFocusItem in iOS 10 switch (type.Name) { case "UIButton": case "UICollectionReusableView": case "UICollectionView": case "UICollectionViewCell": case "MKAnnotationView": case "UIControl": case "MKMapView": case "UISearchBar": case "UISegmentedControl": case "UITableView": case "UITableViewCell": case "UITextField": case "UITextView": case "MKPinAnnotationView": case "UIView": case "SKNode": case "SKShapeNode": case "SKVideoNode": case "UIImageView": case "UIInputView": case "UILabel": case "UINavigationBar": case "UIPageControl": case "UIPopoverBackgroundView": case "UIProgressView": case "SCNView": case "UIScrollView": case "SK3DNode": case "MTKView": case "SKAudioNode": case "SKCameraNode": case "SKCropNode": case "SKEffectNode": case "SKEmitterNode": case "SKFieldNode": case "SKLabelNode": case "SKLightNode": case "UIStackView": case "UITabBar": case "SKReferenceNode": case "GLKView": case "SKScene": case "SKSpriteNode": case "SKView": case "UITableViewHeaderFooterView": case "UIActivityIndicatorView": case "UIVisualEffectView": case "UIWindow": return(!TestRuntime.CheckXcodeVersion(8, 0)); case "SCNNode": case "SCNReferenceNode": return(!TestRuntime.CheckXcodeVersion(9, 0)); } break; case "UIContentSizeCategoryAdjusting": // new conformations of UIContentSizeCategoryAdjusting in iOS 10 switch (type.Name) { case "UITextField": case "UITextView": case "UILabel": return(!TestRuntime.CheckXcodeVersion(8, 0)); } break; case "UISpringLoadedInteractionSupporting": // types do not conform to protocol but protocol methods work on those types (see monotouch-test) switch (type.Name) { case "UIButton": case "UICollectionView": case "UISegmentedControl": case "UITableView": case "UITabBar": case "UIAlertController": case "PKPaymentButton": case "PKAddPassButton": return(true); } break; case "UIPasteConfigurationSupporting": // types do not conform to protocol but protocol methods work on those types (base type tests in monotouch-test) return(true); // Skip everything because 'UIResponder' implements 'UIPasteConfigurationSupporting' and that's 130+ types #if !__WATCHOS__ // Undocumented conformance (members were inlinded in 'UIViewController' before so all subtypes should conform) case "UIStateRestoring": return(type.Name == "UIViewController" || type.IsSubclassOf(typeof(UIViewController))); #endif } return(base.Skip(type, protocolName)); }
/// <summary> /// Check that specified encodedType match the type and caller. /// </summary> /// <param name="encodedType">Encoded type from the ObjC signature.</param> /// <param name="type">Managed type representing the encoded type.</param> /// <param name="caller">Caller's type. Useful to limit any special case.</param> protected virtual bool Check(char encodedType, Type type) { switch (encodedType) { case '@': // We use BindAsAttribute to wrap NSNumber/NSValue into more accurate Nullable<T> types // So we check if T of nullable is supported by bindAs var nullableType = Nullable.GetUnderlyingType(type); if (nullableType != null) { return(BindAsSupportedTypes.Contains(nullableType.Name)); } return((type.IsInterface || // protocol type.IsArray || // NSArray (type.Name == "NSArray") || // NSArray (type.FullName == "System.String") || // NSString (type.FullName == "System.IntPtr") || // unbinded, e.g. internal (type.BaseType.FullName == "System.MulticastDelegate") || // completion handler -> delegate NSObjectType.IsAssignableFrom(type)) || // NSObject derived inativeobject.IsAssignableFrom(type)); // e.g. CGImage case 'B': // 64 bits only encode this return(type.FullName == "System.Boolean"); case 'c': // char, used for C# bool switch (type.FullName) { case "System.Boolean": case "System.SByte": return(true); default: return(type.IsEnum && TypeSize(type) == 1); } case 'C': switch (type.FullName) { case "System.Byte": // GLKBaseEffect 'instance Boolean get_ColorMaterialEnabled()' selector: colorMaterialEnabled == C8@0:4 case "System.Boolean": return(true); default: return(false); } case 'd': switch (type.FullName) { case "System.Double": return(true); case "System.nfloat": return(IntPtr.Size == 8); default: return(false); } case 'f': switch (type.FullName) { case "System.Single": return(true); case "System.nfloat": return(IntPtr.Size == 4); default: return(false); } case 'i': switch (type.FullName) { case "System.Int32": return(true); case "System.nint": return(IntPtr.Size == 4); case "EventKit.EKSourceType": case "EventKit.EKCalendarType": case "EventKit.EKEventAvailability": case "EventKit.EKEventStatus": case "EventKit.EKParticipantRole": case "EventKit.EKParticipantStatus": case "EventKit.EKParticipantType": case "EventKit.EKRecurrenceFrequency": case "EventKit.EKSpan": case "EventKit.EKAlarmType": // EventKit.EK* enums are anonymous enums in 10.10 and iOS 8, but an NSInteger in 10.11 and iOS 9. if (TestRuntime.CheckXcodeVersion(7, 0)) { goto default; } return(true); default: return(type.IsEnum && TypeSize(type) == 4); } case 'I': switch (type.FullName) { case "System.UInt32": return(true); case "System.nint": // check case "System.nuint": return(IntPtr.Size == 4); default: return(type.IsEnum && TypeSize(type) == 4); } case 'l': switch (type.FullName) { case "System.Int32": return(true); case "System.nint": return(IntPtr.Size == 4); default: return(type.IsEnum && TypeSize(type) == 4); } case 'L': switch (type.FullName) { case "System.UInt32": return(true); case "System.nint": // check case "System.nuint": return(IntPtr.Size == 4); default: return(type.IsEnum && TypeSize(type) == 4); } case 'q': switch (type.FullName) { case "System.Int64": return(true); case "System.nint": return(IntPtr.Size == 8); default: return(type.IsEnum && TypeSize(type) == 8); } case 'Q': switch (type.FullName) { case "System.UInt64": return(true); case "System.nint": // check case "System.nuint": return(IntPtr.Size == 8); default: return(type.IsEnum && TypeSize(type) == 8); } case 's': return(type.FullName == "System.Int16"); // unsigned 16 bits case 'S': switch (type.FullName) { case "System.UInt16": // NSString 'instance Char _characterAtIndex(Int32)' selector: characterAtIndex: == S12@0:4I8 case "System.Char": return(true); default: return(type.IsEnum && TypeSize(type) == 2); } case ':': return(type.Name == "Selector"); case 'v': return(type.FullName == "System.Void"); case '?': return(type.BaseType.FullName == "System.MulticastDelegate"); // completion handler -> delegate case '#': return(type.FullName == "System.IntPtr" || type.Name == "Class"); // CAMediaTimingFunction 'instance Void GetControlPointAtIndex(Int32, IntPtr)' selector: getControlPointAtIndex:values: == v16@0:4L8[2f]12 case '[': return(type.FullName == "System.IntPtr"); // const uint8_t * -> IntPtr // NSCoder 'instance Void EncodeBlock(IntPtr, Int32, System.String)' selector: encodeBytes:length:forKey: == v20@0:4r*8I12@16 case '*': return(type.FullName == "System.IntPtr"); case '^': return(type.FullName == "System.IntPtr"); } return(false); }
protected override bool Skip(Type type) { switch (type.Namespace) { case "MetalKit": case "MonoTouch.MetalKit": case "MetalPerformanceShaders": case "MonoTouch.MetalPerformanceShaders": if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; case "CoreNFC": // Only available on devices that support NFC, so check if NFCNDEFReaderSession is present. if (Class.GetHandle("NFCNDEFReaderSession") == IntPtr.Zero) { return(true); } break; } switch (type.Name) { // Apple does not ship a PushKit for every arch on some devices :( case "PKPushCredentials": case "PKPushPayload": case "PKPushRegistry": if (Runtime.Arch != Arch.DEVICE) { return(true); } // Requires iOS 8.2 or later in 32-bit mode if (!TestRuntime.CheckXcodeVersion(6, 2) && IntPtr.Size == 4) { return(true); } break; case "MTLFence": case "MTLHeap": case "RPSystemBroadcastPickerView": // Symbol not available in simulator if (Runtime.Arch != Arch.DEVICE) { return(true); } // Requires iOS 10 if (!TestRuntime.CheckXcodeVersion(8, 0)) { return(true); } break; case "CMMovementDisorderManager": // From Xcode 10 beta 2: // This requires a special entitlement: // Usage of CMMovementDisorderManager requires a special entitlement. Please see for more information https://developer.apple.com/documentation/coremotion/cmmovementdisordermanager // but that web page doesn't explain anything (it's mostly empty, so this is probably just lagging documentation) // I also tried enabling every entitlement in Xcode, but it still didn't work. return(true); #if __WATCHOS__ && !XAMCORE_4_0 case "INCarAirCirculationModeResolutionResult": case "INCarAudioSourceResolutionResult": case "INCarDefrosterResolutionResult": case "INCarSeatResolutionResult": case "INRadioTypeResolutionResult": case "INRelativeSettingResolutionResult": case "INRelativeReferenceResolutionResult": // These were bound by mistake, and they're gone in XAMCORE_4_0. return(true); #endif case "SNClassificationResult": // Class is not being created properly return(true); case "SNClassifySoundRequest": // Class is not being created properly return(true); #if __IOS__ // new types - but marked as iOS 8/9 since they are new base types and // we need 32bits bindings to work (generator would not produce them for iOS 13) case "CNFetchRequest": case "PHChangeRequest": case "PHAssetChangeRequest": // subclass of PHChangeRequest case "PHAssetCollectionChangeRequest": // subclass of PHChangeRequest case "PHAssetCreationRequest": // subclass of PHAssetChangeRequest case "PHCollectionListChangeRequest": // subclass of PHChangeRequest if (!TestRuntime.CheckXcodeVersion(11, 0)) { return(true); } break; #endif } return(base.Skip(type)); }
public void Ctors() { SKTexture texture; #if !NET Vector2 V2; Vector3 V3; Vector4 V4; Matrix2 M2; Matrix3 M3; Matrix4 M4; #endif MatrixFloat2x2 M2x2; MatrixFloat3x3 M3x3; MatrixFloat4x4 M4x4; using (var obj = new SKUniform("name")) { #if !NET var M4Zero = new Matrix4(Vector4.Zero, Vector4.Zero, Vector4.Zero, Vector4.Zero); #endif var N4Zero = default(NMatrix4); var N3Zero = default(NMatrix3); var N2Zero = default(NMatrix2); Assert.AreEqual("name", obj.Name, "1 Name"); Assert.AreEqual(SKUniformType.None, obj.UniformType, "1 UniformType"); Assert.IsNull(obj.TextureValue, "1 TextureValue"); Assert.AreEqual(0.0f, obj.FloatValue, "1 FloatValue"); #if !NET Asserts.AreEqual(Vector2.Zero, obj.FloatVector2Value, "1 FloatVector2Value"); Asserts.AreEqual(Vector3.Zero, obj.FloatVector3Value, "1 FloatVector3Value"); Asserts.AreEqual(Vector4.Zero, obj.FloatVector4Value, "1 FloatVector4Value"); Asserts.AreEqual(Matrix2.Zero, obj.FloatMatrix2Value, "1 FloatMatrix2Value"); #endif Asserts.AreEqual(N2Zero, obj.MatrixFloat2x2Value, "1 MatrixFloat2x2Value"); #if !NET Asserts.AreEqual(Matrix3.Zero, obj.FloatMatrix3Value, "1 FloatMatrix3Value"); #endif Asserts.AreEqual(N3Zero, obj.MatrixFloat3x3Value, "1 MatrixFloat3x3Value"); #if !NET Asserts.AreEqual(M4Zero, obj.FloatMatrix4Value, "1 FloatMatrix4Value"); #endif Asserts.AreEqual(N4Zero, obj.MatrixFloat4x4Value, "1 MatrixFloat4x4Value"); texture = SKTexture.FromImageNamed("basn3p08.png"); #if !NET V2 = new Vector2(1, 2); V3 = new Vector3(3, 4, 5); V4 = new Vector4(6, 7, 8, 9); M2 = new Matrix2(1, 2, 3, 4); M3 = new Matrix3(1, 2, 3, 4, 5, 6, 7, 8, 9); M4 = new Matrix4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); M2x2 = (MatrixFloat2x2)M2; M3x3 = (MatrixFloat3x3)M3; M4x4 = (MatrixFloat4x4)M4; #endif obj.TextureValue = texture; Assert.AreEqual(texture, obj.TextureValue, "2 TextureValue"); obj.FloatValue = 0.5f; Assert.AreEqual(0.5f, obj.FloatValue, "2 FloatValue"); #if !NET obj.FloatVector2Value = V2; Asserts.AreEqual(V2, obj.FloatVector2Value, "2 FloatVector2Value"); obj.FloatVector3Value = V3; Asserts.AreEqual(V3, obj.FloatVector3Value, "2 FloatVector3Value"); obj.FloatVector4Value = V4; Asserts.AreEqual(V4, obj.FloatVector4Value, "2 FloatVector4Value"); obj.FloatMatrix2Value = M2; Asserts.AreEqual(M2, obj.FloatMatrix2Value, "2 FloatMatrix2Value"); obj.MatrixFloat2x2Value = M2x2; Asserts.AreEqual(M2x2, obj.MatrixFloat2x2Value, "2 MatrixFloat2x2Value"); obj.FloatMatrix3Value = M3; Asserts.AreEqual(M3, obj.FloatMatrix3Value, "2 FloatMatrix3Value"); obj.MatrixFloat3x3Value = M3x3; Asserts.AreEqual(M3x3, obj.MatrixFloat3x3Value, "2 MatrixFloat3x3Value"); obj.FloatMatrix4Value = M4; Asserts.AreEqual(M4, obj.FloatMatrix4Value, "2 FloatMatrix4Value"); obj.MatrixFloat4x4Value = M4x4; Asserts.AreEqual(M4x4, obj.MatrixFloat4x4Value, "2 MatrixFloat4x4Value"); #endif } bool hasSimdConstructors = TestRuntime.CheckXcodeVersion(8, 0); using (var obj = new SKUniform("name", texture)) { Assert.AreEqual(texture, obj.TextureValue, "3 TextureValue"); } using (var obj = new SKUniform("name", 3.1415f)) { Assert.AreEqual(3.1415f, obj.FloatValue, "4 FloatValue"); } #if !NET using (var obj = new SKUniform("name", V2)) { Asserts.AreEqual(V2, obj.FloatVector2Value, "5 FloatVector2Value"); } using (var obj = new SKUniform("name", V3)) { Asserts.AreEqual(V3, obj.FloatVector3Value, "6 FloatVector3Value"); } using (var obj = new SKUniform("name", V4)) { Asserts.AreEqual(V4, obj.FloatVector4Value, "7 FloatVector4Value"); } #if !NET using (var obj = new SKUniform("name", M2)) { Asserts.AreEqual(M2, obj.FloatMatrix2Value, "8 FloatMatrix2Value"); Asserts.AreEqual(M2, MatrixFloat2x2.Transpose(CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value")), "8b FloatMatrix2Value"); } using (var obj = new SKUniform("name", M3)) { Asserts.AreEqual(M3, obj.FloatMatrix3Value, "9 FloatMatrix3Value"); Asserts.AreEqual(M3, MatrixFloat3x3.Transpose(CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value")), "9b FloatMatrix3Value"); } using (var obj = new SKUniform("name", M4)) { Asserts.AreEqual(M4, obj.FloatMatrix4Value, "10 FloatMatrix4Value"); Asserts.AreEqual(M4, MatrixFloat4x4.Transpose(CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value")), "10b FloatMatrix4Value"); } #endif using (var obj = new SKUniform("name", M2x2)) { Asserts.AreEqual(M2x2, obj.MatrixFloat2x2Value, "11 MatrixFloat2x2Value"); Asserts.AreEqual(M2x2, CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value"), "11b MatrixFloat2x2Value"); var tmp2 = new MatrixFloat2x2(9, 8, 7, 6); obj.MatrixFloat2x2Value = tmp2; Asserts.AreEqual(tmp2, obj.MatrixFloat2x2Value, "11 MatrixFloat2x2Value second"); Asserts.AreEqual(tmp2, CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value"), "11b MatrixFloat2x2Value second"); } using (var obj = new SKUniform("name", M3x3)) { Asserts.AreEqual(M3x3, obj.MatrixFloat3x3Value, "12 MatrixFloat3x3Value"); Asserts.AreEqual(M3x3, CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value"), "12b MatrixFloat3x3Value"); var tmp3 = new MatrixFloat3x3(9, 8, 7, 6, 5, 4, 3, 2, 1); obj.MatrixFloat3x3Value = tmp3; Asserts.AreEqual(tmp3, obj.MatrixFloat3x3Value, "12 MatrixFloat3x3Value second"); Asserts.AreEqual(tmp3, CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value"), "12b MatrixFloat3x3Value second"); } using (var obj = new SKUniform("name", M4x4)) { Asserts.AreEqual(M4x4, obj.MatrixFloat4x4Value, "13 MatrixFloat4x4Value"); Asserts.AreEqual(M4x4, CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value"), "13b FloatMatrix4Value"); var tmp4 = new MatrixFloat4x4(9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6); obj.MatrixFloat4x4Value = tmp4; Asserts.AreEqual(tmp4, obj.MatrixFloat4x4Value, "13 MatrixFloat4x4Value second"); Asserts.AreEqual(tmp4, CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value"), "13b MatrixFloat4x4Value second"); } #endif }
protected override bool Skip(Type type) { switch (type.Namespace) { // all default ctor did not work and were replaced with [Obsolete("",true)] placeholders // reflecting on those would create invalid instances (no handle) that crash the app case "CoreBluetooth": case "MonoTouch.CoreBluetooth": return(true); case "CoreAudioKit": case "MonoTouch.CoreAudioKit": case "Metal": case "MonoTouch.Metal": // they works with iOS9 beta 4 (but won't work on older simulators) if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; #if !__WATCHOS__ case "MetalKit": case "MonoTouch.MetalKit": case "MetalPerformanceShaders": case "MonoTouch.MetalPerformanceShaders": if (Runtime.Arch == Arch.SIMULATOR) { return(true); } // some devices don't support metal and that crash some API that does not check that, e.g. #33153 if (!TestRuntime.CheckXcodeVersion(7, 0) || (MTLDevice.SystemDefault == null)) { return(true); } break; #endif // !__WATCHOS__ case "CoreNFC": // Only available on device case "DeviceCheck": // Only available on device if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; } switch (type.Name) { // under iOS7 creating this type will crash later (after test execution) with a stack similar to: // https://gist.github.com/rolfbjarne/457f78e20c8c31edef5c case "EKCalendarChooserDelegate": case "EKEventEditViewController": return(true); // Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: There can only be one UIApplication instance. case "UIApplication": return(true); // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: UISplitViewController is only supported when running under UIUserInterfaceIdiomPad case "UISplitViewController": #if !__WATCHOS__ // Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: ADInterstitialAd is available on iPad only. case "ADInterstitialAd": return(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone); #endif case "UIVideoEditorController": return(true); // shows an alert on the simulator case "MFMessageComposeViewController": return(true); // shows an alert on the device (if no email address is configured) case "MFMailComposeViewController": return(true); #if !__TVOS__ // PassKit is not available on iPads case "PKPassLibrary": return(!PKPassLibrary.IsAvailable); #endif // !__TVOS__ // default ctor started to throw on iOS7 - we should never have exposed it but, for API compatibility, // we now have an "empty" obsolete ctor case "UIFont": return(true); case "NSUrlSessionConfiguration": case "NSUrlSession": // This crashes when arc frees this object at the end of the scope: // { NSURLSession *var = [[NSURLSession alloc] init]; } return(true); case "GKAchievementViewController": case "GKLeaderboardViewController": // technically available since 4.1 - however it got a new base class in 6.0 // and that new base class GKGameCenterViewController did not exists before 6.0 // which makes the type unusable in 5.x, ref: https://gist.github.com/spouliot/271b6230a3aa2b58bc6e return(!TestRuntime.CheckXcodeVersion(4, 5)); // mistake - we should not have exposed those default ctor and now we must live with them case "GCControllerElement": case "GCControllerAxisInput": case "GCControllerButtonInput": case "GCControllerDirectionPad": case "GCGamepad": case "GCExtendedGamepad": case "GCController": return(true); // default constructor are not working on iOS8 so we removed them // and can't test them even in earlier iOS versions case "JSManagedValue": case "MKLocalSearch": case "MKTileOverlayRenderer": case "AVAssetResourceLoadingDataRequest": case "CLBeaconRegion": case "NSPersistentStoreCoordinator": return(true); // Metal is not available on the (iOS8) simulator case "CAMetalLayer": return(Runtime.Arch == Arch.SIMULATOR); #if !XAMCORE_2_0 // from iOS8 (beta4) they do not return a valid handle case "AVAssetResourceLoader": case "AVAssetResourceLoadingRequest": case "AVAssetResourceLoadingContentInformationRequest": return(true); // Started with iOS8 on simulator (always) but it looks like it can happen on devices too // NSInvalidArgumentException Use initWithAccessibilityContainer: case "UIAccessibilityElement": return(TestRuntime.CheckXcodeVersion(6, 0)); #endif // in 8.2 beta 1 this crash the app (simulator) without giving any details in the logs case "WKUserNotificationInterfaceController": return(true); // Both reported in radar #21548819 // NSUnknownKeyException [<CIDepthOfField 0x158586970> valueForUndefinedKey:]: this class is not key value coding-compliant for the key inputPoint2. case "CIDepthOfField": // NSUnknownKeyException [<CISunbeamsGenerator 0x1586d0810> valueForUndefinedKey:]: this class is not key value coding-compliant for the key inputCropAmount. case "CISunbeamsGenerator": return(true); case "MPMediaItemArtwork": // NSInvalidArgumentException Reason: image must be non-nil return(true); // these work only on devices, so we skip the simulator case "MTLHeapDescriptor": case "MTLSharedEventListener": return(Runtime.Arch == Arch.SIMULATOR); #if __WATCHOS__ // The following watchOS 3.2 Beta 2 types Fails, but they can be created we verified using an ObjC app, we will revisit before stable case "INRequestPaymentIntent": case "INRequestRideIntent": case "INResumeWorkoutIntent": case "INRideVehicle": case "INSearchCallHistoryIntent": case "INSearchForMessagesIntent": case "INSearchForPhotosIntent": case "INSendMessageIntent": case "INSendPaymentIntent": case "INStartAudioCallIntent": case "INStartPhotoPlaybackIntent": case "INStartWorkoutIntent": return(true); #endif // iOS 11 Beta 1 case "UICollectionViewFocusUpdateContext": // [Assert] -init is not a useful initializer for this class. Use one of the designated initializers instead case "UIFocusUpdateContext": // [Assert] -init is not a useful initializer for this class. Use one of the designated initializers instead case "EKCalendarItem": // Fails with NSInvalidArgumentException +[EKCalendarItem frozenClass]: unrecognized selector sent to class, will fill a radar case "EKParticipant": // ctor disabled in XAMCORE_3_0 case "UITableViewFocusUpdateContext": // Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Invalid parameter not satisfying: focusSystem, will fill a radar return(true); case "INBookRestaurantReservationIntentResponse": // iOS 11 beta 2: stack overflow in description. radar:32945914 return(true); case "IOSurface": // Only works on device case "NEHotspotEapSettings": // Wireless Accessory Configuration is not supported in the simulator. case "NEHotspotConfigurationManager": case "NEHotspotHS20Settings": return(Runtime.Arch == Arch.SIMULATOR); // iOS 12 case "INGetAvailableRestaurantReservationBookingDefaultsIntentResponse": // Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to initialize 'INGetAvailableRestaurantReservationBookingDefaultsIntentResponse'. Please make sure that your intent definition file is valid. case "INGetAvailableRestaurantReservationBookingsIntentResponse": // Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to initialize 'INGetAvailableRestaurantReservationBookingsIntentResponse'. Please make sure that your intent definition file is valid. case "INGetRestaurantGuestIntentResponse": // Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Unable to initialize 'INGetRestaurantGuestIntentResponse'. Please make sure that your intent definition file is valid. return(TestRuntime.CheckXcodeVersion(10, 0)); case "CMMovementDisorderManager": // Not available in simulator, added info to radar://41110708 case "RPSystemBroadcastPickerView": // Symbol not available in simulator return(Runtime.Arch == Arch.SIMULATOR); default: return(base.Skip(type)); } }
// only handle exception here (to return true) otherwise call base to deal with it // `caller` is provided to make it easier to detect "special" cases protected override bool Check(char encodedType, Type type) { // return an error if null (instead of throwing) so we can continue execution if (type == null) { return(false); } switch (encodedType) { case 'c': // char, used for C# bool #if !XAMCORE_2_0 switch (type.FullName) { // looks like it returns a bool even if documented as a void // UIPrintInteractionController 'instance Void Present(Boolean, MonoTouch.UIKit.UIPrintInteractionCompletionHandler)' selector: presentAnimated:completionHandler: // update: documentation (and header) mistake that Apple corrected (IIRC I filled that issue) case "System.Void": return(CurrentType.Name == "UIPrintInteractionController"); } #endif break; // float (32 bits) case 'f': switch (type.FullName) { // documented (web and header file) as NSInteger // UIImageView 'instance Void set_AnimationRepeatCount(Int32)' selector: setAnimationRepeatCount: == v12@0:4f8 case "System.Int32": return(CurrentType.FullName == "MonoTouch.UIKit.UIImageView"); } break; case 'i': switch (type.FullName) { case "MonoTouch.EventKitUI.EKCalendarChooserSelectionStyle": case "MonoTouch.EventKitUI.EKCalendarChooserDisplayStyle": case "EventKitUI.EKCalendarChooserSelectionStyle": case "EventKitUI.EKCalendarChooserDisplayStyle": return((IntPtr.Size == 4) || !TestRuntime.CheckXcodeVersion(7, 0)); case "System.UInt32": // numberOfTouchesRequired was signed before iOS6, unsigned since then return(true); } break; // unsigned 32 bits case 'I': switch (type.FullName) { case "System.Int32": // sign-ness mis-binding, several of them (not critical) // CBATTRequest 'instance Int32 get_Offset()' selector: offset == I8@0:4 return(true); } break; // unsigned 32 bits case 'L': switch (type.FullName) { // sign-ness mis-binding (not critical) e.g. // CAMediaTimingFunction 'instance Void GetControlPointAtIndex(Int32, IntPtr)' selector: getControlPointAtIndex:values: == v16@0:4L8[2f]12 case "System.Int32": return(true); } break; // unsigned 64 bits case 'Q': switch (type.FullName) { // sign-ness mis-binding (not critical) e.g. // NSIncrementalStoreNode 'instance Int64 get_Version()' selector: version == Q8@0:4 case "System.Int64": return(true); } break; } return(base.Check(encodedType, type)); }
public void ConstantsCheck() { var c = typeof(Constants); foreach (var fi in c.GetFields()) { if (!fi.IsPublic) { continue; } var s = fi.GetValue(null) as string; switch (fi.Name) { case "Version": case "SdkVersion": Assert.True(Version.TryParse(s, out _), fi.Name); break; #if !XAMCORE_4_0 #if __TVOS__ case "PassKitLibrary": // not part of tvOS break; #endif case "libcompression": // bad (missing) suffix Assert.True(CheckLibrary(s), fi.Name); break; #endif #if __TVOS__ case "MetalPerformanceShadersLibrary": // not supported in tvOS (12.1) simulator so load fails if (Runtime.Arch == Arch.SIMULATOR) { break; } goto default; #endif default: if (fi.Name.EndsWith("Library", StringComparison.Ordinal)) { #if __IOS__ // NFC is currently not available on iPad if (fi.Name == "CoreNFCLibrary" && UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { continue; } #endif #if __MACOS__ // Only available in macOS 10.15.4+ if (fi.Name == "AutomaticAssessmentConfigurationLibrary" && !TestRuntime.CheckXcodeVersion(11, 4)) { continue; } #endif Assert.True(CheckLibrary(s), fi.Name); } else { Assert.Fail($"Unknown '{fi.Name}' field cannot be verified - please fix me!"); } break; } } }
public void RoundtripRSAMinPKCS1() { NSError error; SecKey private_key; SecKey public_key; var label = $"KeyTest.RoundtripRSAMinPKCS1-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { using (var record = new SecRecord(SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = MinRsaKeySize; // it's not a performance test :) record.Label = label; Assert.That(SecKey.GenerateKeyPair(record.ToDictionary(), out public_key, out private_key), Is.EqualTo(SecStatusCode.Success), "GenerateKeyPair"); byte [] plain = new byte [20] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; byte [] cipher; if (TestRuntime.CheckXcodeVersion(8, 0)) { Assert.True(public_key.IsAlgorithmSupported(SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "public/IsAlgorithmSupported/Encrypt"); #if MONOMAC Assert.That(public_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), Is.EqualTo(TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 13)), "public/IsAlgorithmSupported/Decrypt"); using (var pub = public_key.GetPublicKey()) { // macOS behaviour is not consistent - but the test main goal is to check we get a key Assert.That(pub.Handle, Is.Not.EqualTo(IntPtr.Zero), "public/GetPublicKey"); } #else Assert.True(public_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "public/IsAlgorithmSupported/Decrypt"); using (var pub = public_key.GetPublicKey()) { // a new native instance of the key is returned (so having a new managed SecKey is fine) Assert.False(pub.Handle == public_key.Handle, "public/GetPublicKey"); } #endif using (var attrs = public_key.GetAttributes()) { Assert.That(attrs.Count, Is.GreaterThan((nuint)0), "public/GetAttributes"); } using (var data = public_key.GetExternalRepresentation(out error)) { Assert.Null(error, "public/error-1"); Assert.NotNull(data, "public/GetExternalRepresentation"); using (var key = SecKey.Create(data, SecKeyType.RSA, SecKeyClass.Public, MinRsaKeySize, null, out error)) { Assert.Null(error, "public/Create/error-1"); } } } Assert.That(public_key.Encrypt(SecPadding.PKCS1, plain, out cipher), Is.EqualTo(SecStatusCode.Success), "Encrypt"); byte[] result; if (TestRuntime.CheckXcodeVersion(8, 0)) { Assert.False(private_key.IsAlgorithmSupported(SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "private/IsAlgorithmSupported/Encrypt"); Assert.True(private_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "private/IsAlgorithmSupported/Decrypt"); using (var pub2 = private_key.GetPublicKey()) { // a new native instance of the key is returned (so having a new managed SecKey is fine) Assert.That(pub2.Handle, Is.Not.EqualTo(public_key.Handle), "private/GetPublicKey"); } using (var attrs = private_key.GetAttributes()) { Assert.That(attrs.Count, Is.GreaterThan((nuint)0), "private/GetAttributes"); } using (var data2 = private_key.GetExternalRepresentation(out error)) { Assert.Null(error, "private/error-1"); Assert.NotNull(data2, "private/GetExternalRepresentation"); using (var key = SecKey.Create(data2, SecKeyType.RSA, SecKeyClass.Private, MinRsaKeySize, null, out error)) { Assert.Null(error, "private/Create/error-1"); } } } public_key.Dispose(); var expectedResult = SecStatusCode.Success; #if __MACOS__ if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 8)) { expectedResult = SecStatusCode.InvalidData; } #endif Assert.That(private_key.Decrypt(SecPadding.PKCS1, cipher, out result), Is.EqualTo(expectedResult), "Decrypt"); if (expectedResult != SecStatusCode.InvalidData) { Assert.That(plain, Is.EqualTo(result), "match"); } private_key.Dispose(); } } finally { // Clean up after us DeleteKeysWithLabel(label); } }
void Trust_FullChain(SecTrust trust, SecPolicy policy, X509CertificateCollection certs) { // that certificate stopped being valid on September 30th, 2013 so we validate it with a date earlier than that trust.SetVerifyDate(new DateTime(635108745218945450, DateTimeKind.Utc)); SecTrustResult trust_result = SecTrustResult.Unspecified; var ios9 = TestRuntime.CheckXcodeVersion(7, 0); var ios10 = TestRuntime.CheckXcodeVersion(8, 0); var ios11 = TestRuntime.CheckXcodeVersion(9, 0); var ios13 = TestRuntime.CheckXcodeVersion(11, 0); if (ios10) { trust_result = SecTrustResult.FatalTrustFailure; } // iOS9 is not fully happy with the basic constraints: `SecTrustEvaluate [root AnchorTrusted BasicContraints]` else if (ios9) { trust_result = SecTrustResult.RecoverableTrustFailure; } var result = Evaluate(trust, true); Assert.That(result, Is.EqualTo(trust_result), "Evaluate"); // Evalute must be called prior to Count (Apple documentation) Assert.That(trust.Count, Is.EqualTo(3), "Count"); using (SecCertificate sc1 = trust [0]) { // seems the leaf gets an extra one Assert.That(CFGetRetainCount(sc1.Handle), Is.GreaterThanOrEqualTo((nint)2), "RetainCount(sc1)"); Assert.That(sc1.SubjectSummary, Is.EqualTo("mail.google.com"), "SubjectSummary(sc1)"); } using (SecCertificate sc2 = trust [1]) { Assert.That(CFGetRetainCount(sc2.Handle), Is.GreaterThanOrEqualTo((nint)2), "RetainCount(sc2)"); Assert.That(sc2.SubjectSummary, Is.EqualTo("Thawte SGC CA"), "SubjectSummary(sc2)"); } using (SecCertificate sc3 = trust [2]) { Assert.That(CFGetRetainCount(sc3.Handle), Is.GreaterThanOrEqualTo((nint)2), "RetainCount(sc3)"); Assert.That(sc3.SubjectSummary, Is.EqualTo("Class 3 Public Primary Certification Authority"), "SubjectSummary(sc3)"); } if (TestRuntime.CheckXcodeVersion(5, 0)) { Assert.That(trust.GetTrustResult(), Is.EqualTo(trust_result), "GetTrustResult"); trust.SetAnchorCertificates(certs); Assert.That(trust.GetCustomAnchorCertificates().Length, Is.EqualTo(certs.Count), "GetCustomAnchorCertificates"); #if __MACOS__ if (TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 15)) { trust_result = SecTrustResult.RecoverableTrustFailure; } else if (TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 13)) { trust_result = SecTrustResult.Unspecified; } else if (TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 12)) { trust_result = SecTrustResult.Invalid; } else if (TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 11)) { trust_result = SecTrustResult.RecoverableTrustFailure; } else { trust_result = SecTrustResult.Unspecified; } #else if (ios13) { trust_result = SecTrustResult.RecoverableTrustFailure; } else if (ios11) { trust_result = SecTrustResult.Unspecified; } else { trust_result = SecTrustResult.Invalid; } #endif // since we modified the `trust` instance it's result was invalidated (marked as unspecified on iOS 11) Assert.That(trust.GetTrustResult(), Is.EqualTo(trust_result), "GetTrustResult-2"); } if (TestRuntime.CheckXcodeVersion(12, 0)) { // old certificate (built in our tests) was not quite up to spec and it eventually became important Assert.False(trust.Evaluate(out var error), "Evaluate"); Assert.NotNull(error, "error"); Assert.That(error.LocalizedDescription, Is.EqualTo("“mail.google.com” certificate is not standards compliant"), "desc"); } else if (TestRuntime.CheckXcodeVersion(11, 0)) { Assert.False(trust.Evaluate(out var error), "Evaluate"); Assert.NotNull(error, "error"); Assert.That(error.LocalizedDescription, Does.Contain("\"mail.google.com\",\"Thawte SGC CA\",\"Class 3 Public Primary Certification Authority\" certificates do not meet pinning requirements")); var underlyingError = (NSError)error.UserInfo [NSError.UnderlyingErrorKey]; // Error is: // Certificate 0 “mail.google.com” has errors: Key size is not permitted for this use, SSL hostname does not match name(s) in certificate, Signature hash algorithm is not permitted for this use;Certificate 1 “Thawte SGC CA” has errors: Key size is not permitted for this use, Signature hash algorithm is not permitted for this use;Certificate 2 “Class 3 Public Primary Certification Authority” has errors: Key size is not permitted for this use; // But the exact format can vary // watchOS reports this: // Certificate 0 “mail.google.com” has errors: Key size is not permitted for this use, Signature hash algorithm is not permitted for this use, SSL hostname does not match name(s) in certificate;Certificate 1 “Thawte SGC CA” has errors: Key size is not permitted for this use, Signature hash algorithm is not permitted for this use;Certificate 2 “Class 3 Public Primary Certification Authority” has errors: Key size is not permitted for this use; Assert.That(underlyingError.LocalizedDescription, Does.Contain("Certificate 0 “mail.google.com” has errors: ")); Assert.That(underlyingError.LocalizedDescription, Does.Contain("Key size is not permitted for this use")); Assert.That(underlyingError.LocalizedDescription, Does.Contain("SSL hostname does not match name(s) in certificate").Or.Contain("Signature hash algorithm is not permitted for this use")); Assert.That(underlyingError.LocalizedDescription, Does.Contain("Certificate 1 “Thawte SGC CA” has errors: Key size is not permitted for this use")); Assert.That(underlyingError.LocalizedDescription, Does.Contain("Certificate 2 “Class 3 Public Primary Certification Authority” has errors:")); } else if (TestRuntime.CheckXcodeVersion(10, 0)) { Assert.True(trust.Evaluate(out var error), "Evaluate"); Assert.Null(error, "error"); } }
public void SetCaption() { TestRuntime.AssertXcodeVersion(11, 0); Assert.Throws <ArgumentNullException> (() => MAImageCaptioning.SetCaption(null, "xamarin", out _)); // note: calling on a remote URL crash the process - not that it should work but... var temp = String.Empty; using (NSUrl url = new NSUrl(NSBundle.MainBundle.ResourceUrl.AbsoluteString + "basn3p08.png")) { #if __MACOS__ var read_only = false; #else var read_only = Runtime.Arch == Arch.DEVICE; #endif if (read_only) { Assert.False(MAImageCaptioning.SetCaption(url, "xamarin", out var e), "Set"); Assert.NotNull(e, "ro / set / no error"); // weird, it can't be saved back to the file metadata var s = MAImageCaptioning.GetCaption(url, out e); Assert.Null(s, "ro / roundtrip"); // not very surprising since Set can't save it Assert.Null(e, "ro / get / no error"); Assert.False(MAImageCaptioning.SetCaption(url, "xamarin", out e), "Set 2"); s = MAImageCaptioning.GetCaption(url, out e); Assert.Null(s, "ro / back to original"); Assert.Null(e, "ro / get back / no error"); } else { Assert.True(MAImageCaptioning.SetCaption(url, "xamarin", out var e), "Set"); Assert.Null(e, "ro / set / no error"); // weird, it can't be saved back to the file metadata var s = MAImageCaptioning.GetCaption(url, out e); if (TestRuntime.CheckXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch)) { Assert.AreEqual("xamarin", s, "ro / roundtrip"); } else { Assert.Null(s, "ro / roundtrip"); // not very surprising since Set can't save it } Assert.Null(e, "ro / get / no error"); Assert.True(MAImageCaptioning.SetCaption(url, "xamarin", out e), "Set 2"); s = MAImageCaptioning.GetCaption(url, out e); if (TestRuntime.CheckXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch)) { Assert.AreEqual("xamarin", s, "ro / back to original"); } else { Assert.Null(s, "ro / back to original"); } Assert.Null(e, "ro / get back / no error"); // Restore original value Assert.True(MAImageCaptioning.SetCaption(url, null, out e), "Set 2"); s = MAImageCaptioning.GetCaption(url, out e); Assert.Null(s, "ro / back to null"); Assert.Null(e, "ro / get back null / no error"); } // 2nd try with a read/write copy temp = Path.Combine(Path.GetTempPath(), "basn3p08.png"); File.Copy(url.Path, temp, overwrite: true); } using (var rw_url = NSUrl.FromFilename(temp)) { Assert.True(MAImageCaptioning.SetCaption(rw_url, "xamarin", out var e), "Set"); Assert.Null(e, "rw / set / no error"); // weird, it can't be saved back to the file metadata var s = MAImageCaptioning.GetCaption(rw_url, out e); if (TestRuntime.CheckXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch)) { Assert.AreEqual("xamarin", s, "rw / roundtrip"); // :) } else { Assert.Null(s, "rw / roundtrip"); // :( } Assert.Null(e, "rw / get / no error"); Assert.True(MAImageCaptioning.SetCaption(rw_url, "xamarin", out e), "Set 2"); s = MAImageCaptioning.GetCaption(rw_url, out e); if (TestRuntime.CheckXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch)) { Assert.AreEqual("xamarin", s, "rw / back to original"); } else { Assert.Null(s, "rw / back to original"); } Assert.Null(e, "rw / get back / no error"); } }
public void CtorIPAddressPair() { var address = Dns.GetHostAddresses("apple.com")[0]; using (var nr = new NetworkReachability(IPAddress.Loopback, address)) { NetworkReachabilityFlags flags; Assert.IsTrue(nr.TryGetFlags(out flags), "#1"); // using Loopback iOS 10 / tvOS 10 returns no flags (0) on devices #if !MONOMAC if ((Runtime.Arch == Arch.DEVICE) && TestRuntime.CheckXcodeVersion(8, 0)) { Assert.That((int)flags, Is.EqualTo(0), "#1 Reachable"); } else #endif Assert.That(flags, Is.EqualTo(NetworkReachabilityFlags.Reachable), "#1 Reachable"); } using (var nr = new NetworkReachability(null, address)) { NetworkReachabilityFlags flags; Assert.IsTrue(nr.TryGetFlags(out flags), "#2"); Assert.That(flags, Is.EqualTo(NetworkReachabilityFlags.Reachable), "#2 Reachable"); } using (var nr = new NetworkReachability(IPAddress.Loopback, null)) { NetworkReachabilityFlags flags; Assert.IsTrue(nr.TryGetFlags(out flags), "#3"); // using Loopback iOS 10 / tvOS 10 / macOS 10.12 returns no flags (0) on devices var expected = (NetworkReachabilityFlags)0; #if MONOMAC if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 12)) { expected = NetworkReachabilityFlags.Reachable; if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 11)) { expected |= NetworkReachabilityFlags.IsLocalAddress; } } #else if ((Runtime.Arch == Arch.DEVICE) && TestRuntime.CheckXcodeVersion(8, 0)) { // } else { expected = NetworkReachabilityFlags.Reachable; if (!TestRuntime.CheckXcodeVersion(7, 0)) { expected |= NetworkReachabilityFlags.IsLocalAddress; } } #endif Assert.That(flags, Is.EqualTo(expected), "#3 Reachable"); } }
public void Ctors() { #if NET var id = NMatrix4.Identity; #else Matrix4 id = Matrix4.Identity; #endif var V3 = new Vector3(1, 2, 3); using (var obj = new MDLTransform(id)) { Asserts.AreEqual(Vector3.Zero, obj.Translation, "Translation"); Asserts.AreEqual(Vector3.One, obj.Scale, "Scale"); Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation"); Asserts.AreEqual(id, obj.Matrix, "Matrix"); if (TestRuntime.CheckXcodeVersion(8, 0)) { Asserts.AreEqual(false, obj.ResetsTransform, "ResetsTransform"); } obj.Translation = V3; Asserts.AreEqual(V3, obj.Translation, "Translation 2"); } if (TestRuntime.CheckXcodeVersion(8, 0)) { using (var obj = new MDLTransform(id, true)) { Asserts.AreEqual(Vector3.Zero, obj.Translation, "Translation"); Asserts.AreEqual(Vector3.One, obj.Scale, "Scale"); Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation"); Asserts.AreEqual(id, obj.Matrix, "Matrix"); Asserts.AreEqual(true, obj.ResetsTransform, "ResetsTransform"); obj.Translation = V3; Asserts.AreEqual(V3, obj.Translation, "Translation 2"); } } using (var obj = new MDLTransform(id)) { V3 *= 2; obj.Scale = V3; Asserts.AreEqual(V3, obj.Scale, "Scale 2"); } using (var obj = new MDLTransform(id)) { V3 *= 2; obj.Rotation = V3; Asserts.AreEqual(V3, obj.Rotation, "Rotation 2"); } using (var obj = new MDLTransform(id)) { V3 *= 2; obj.Rotation = V3; Asserts.AreEqual(V3, obj.Rotation, "Rotation 2"); } #if NET var m4 = new NMatrix4( 4, 0, 0, 2, 0, 3, 0, 3, 0, 0, 2, 4, 0, 0, 0, 1); #else var m4 = new Matrix4( 4, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 2, 3, 4, 1); #endif using (var obj = new MDLTransform(m4)) { Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation 3"); Asserts.AreEqual(new Vector3(4, 3, 2), obj.Scale, "Scale 3"); Asserts.AreEqual(new Vector3(2, 3, 4), obj.Translation, "Translation 3"); Asserts.AreEqual(m4, obj.Matrix, 0.0001f, "Matrix 3"); } #if !NET var m4x4 = new MatrixFloat4x4( 4, 0, 0, 2, 0, 3, 0, 3, 0, 0, 2, 4, 0, 0, 0, 1); using (var obj = new MDLTransform(m4x4)) { Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation 4"); Asserts.AreEqual(new Vector3(4, 3, 2), obj.Scale, "Scale 4"); Asserts.AreEqual(new Vector3(2, 3, 4), obj.Translation, "Translation 4"); #if NET Asserts.AreEqual(m4x4, obj.Matrix, 0.0001f, "Matrix4x4 4"); #else Asserts.AreEqual(m4x4, obj.GetMatrix4x4(), 0.0001f, "Matrix4x4 4"); #endif Asserts.AreEqual(m4x4, CFunctions.GetMatrixFloat4x4(obj, "matrix"), 0.0001f, "Matrix4x4-native 4"); } #endif }
protected override bool Skip(Type type) { switch (type.FullName) { #if !XAMCORE_4_0 case "AppKit.NSDraggingInfo": case "MonoMac.AppKit.NSDraggingInfo": // binding mistakes. return(true); #endif // Random failures on build machine case "QuickLookUI.QLPreviewPanel": case "MonoMac.QuickLookUI.QLPreviewPanel": return(true); // These should be DisableDefaultCtor but can't due to backward compat case "MonoMac.AppKit.NSCollectionViewTransitionLayout": case "AppKit.NSCollectionViewTransitionLayout": case "Foundation.NSUnitDispersion": // -init should never be called on NSUnit! case "Foundation.NSUnitVolume": // -init should never be called on NSUnit! case "Foundation.NSUnitDuration": // -init should never be called on NSUnit! case "Foundation.NSUnitElectricCharge": // -init should never be called on NSUnit! case "Foundation.NSUnitElectricCurrent": // -init should never be called on NSUnit! case "Foundation.NSUnitElectricPotentialDifference": // -init should never be called on NSUnit! case "Foundation.NSUnitElectricResistance": // -init should never be called on NSUnit! case "Foundation.NSUnit": // -init should never be called on NSUnit! case "Foundation.NSUnitEnergy": // -init should never be called on NSUnit! case "Foundation.NSUnitAcceleration": // -init should never be called on NSUnit! case "Foundation.NSUnitFrequency": // -init should never be called on NSUnit! case "Foundation.NSUnitAngle": // -init should never be called on NSUnit! case "Foundation.NSUnitFuelEfficiency": // -init should never be called on NSUnit! case "Foundation.NSUnitArea": // -init should never be called on NSUnit! case "Foundation.NSUnitIlluminance": // -init should never be called on NSUnit! case "Foundation.NSUnitConcentrationMass": // -init should never be called on NSUnit! case "Foundation.NSUnitLength": // -init should never be called on NSUnit! case "Foundation.NSUnitMass": // -init should never be called on NSUnit! case "Foundation.NSUnitPower": // -init should never be called on NSUnit! 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.EKParticipant": case "XamCore.CoreImage.CISampler": case "CoreImage.CISampler": return(true); // OSX 10.8+ case "MonoMac.AppKit.NSSharingService": case "AppKit.NSSharingService": case "MonoMac.AppKit.NSSharingServicePicker": case "AppKit.NSSharingServicePicker": case "MonoMac.Foundation.NSUserNotification": case "Foundation.NSUserNotification": case "MonoMac.Foundation.NSUserNotificationCenter": case "Foundation.NSUserNotificationCenter": case "MonoMac.AVFoundation.AVPlayerItemVideoOutput": case "AVFoundation.AVPlayerItemVideoOutput": case "MonoMac.Foundation.NSUuid": case "Foundation.NSUuid": if (!Mac.CheckSystemVersion(10, 8)) { return(true); } break; // Native exception coming from [NSWindow init] which calls // [NSWindow initWithContentRect:styleMask:backing:defer] case "MonoMac.AppKit.NSWindow": case "AppKit.NSWindow": return(true); case "MonoMac.Foundation.NSUrlSession": case "Foundation.NSUrlSession": case "MonoMac.Foundation.NSUrlSessionTask": case "Foundation.NSUrlSessionTask": case "MonoMac.Foundation.NSUrlSessionDataTask": case "Foundation.NSUrlSessionDataTask": case "MonoMac.Foundation.NSUrlSessionUploadTask": case "Foundation.NSUrlSessionUploadTask": case "MonoMac.Foundation.NSUrlSessionDownloadTask": case "Foundation.NSUrlSessionDownloadTask": case "MonoMac.Foundation.NSUrlSessionConfiguration": case "Foundation.NSUrlSessionConfiguration": // These types were introduced as 64-bit only in Mavericks, and 32+64bits in Yosemite. We can't // express that with our AvailabilityAttribute, we set it as available (for all architectures, since // we can't distinguish them) starting with Mavericks. if (Mac.Is32BitMavericks) { return(true); } break; case "GLKit.GLKSkyboxEffect": // Crashes inside libGL.dylib, most likely because something hasn't been initialized yet, because // I can reproduce in an Xcode project if I put [[GLKSkyboxEffect alloc] init]; in main, but it doesn't // crash in applicationDidFinishLaunching. // // frame #0: 0x00007fff8d570db1 libGL.dylib`glGetError + 13 // frame #1: 0x0000000100025542 GLKit`-[GLKEffect initWithPropertyArray:] + 1142 // frame #2: 0x0000000100022c2d GLKit`-[GLKSkyboxEffect init] + 493 // if (IntPtr.Size == 8) { return(true); } break; #if !XAMCORE_3_0 case "SpriteKit.SKView": // Causes a crash later. Filed as radar://18440271. // Apple said they won't fix this ('init' isn't a designated initializer) if (IntPtr.Size == 8) { return(true); } break; #endif case "MonoMac.AppKit.NSSpeechRecognizer": case "AppKit.NSSpeechRecognizer": // Makes OSX put up "a download is required for speech recognition" dialog. return(true); case "MonoMac.Foundation.NSUserActivity": case "Foundation.NSUserActivity": // Crashes by default: // Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Caller did not provide an activityType, and this process does not have a NSUserActivityTypes in its Info.plist. // but since it looks like the constructor is usable with the proper Info.plist, we can't remove it. return(true); case "MonoMac.AppKit.NSTextTableBlock": case "AppKit.NSTextTableBlock": case "MonoMac.AppKit.NSMutableFontCollection": case "AppKit.NSMutableFontCollection": return(true); // Crashes in 10.12 case "CoreBluetooth.CBCentralManager": case "MonoMac.CoreBluetooth.CBCentralManager": if (IntPtr.Size == 4 && Mac.CheckSystemVersion(10, 13)) // 32-bit removed unannounced in 10.13 { return(true); } break; case "EventKit.EKEventStore": case "MonoMac.EventKit.EKEventStore": if (Mac.CheckSystemVersion(10, 9) && !Mac.CheckSystemVersion(10, 10)) { // Calling the constructor on Mavericks will put up a permission dialog. return(true); } break; case "MonoMac.ImageKit.IKPictureTaker": case "ImageKit.IKPictureTaker": // https://bugzilla.xamarin.com/show_bug.cgi?id=46624 // https://trello.com/c/T6vkA2QF/62-29311598-ikpicturetaker-crashes-randomly-upon-deallocation?menu=filter&filter=corenfc return(true); case "Photos.PHProjectChangeRequest": if (TestRuntime.CheckSystemVersion(ObjCRuntime.PlatformName.MacOSX, 10, 15)) { /* * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This method can only be called from inside of -[PHPhotoLibrary performChanges:completionHandler:] or -[PHPhotoLibrary performChangesAndWait:error:]' * 0 CoreFoundation 0x00007fff34f29063 __exceptionPreprocess + 250 * 1 libobjc.A.dylib 0x00007fff6a6aa06b objc_exception_throw + 48 * 2 Photos 0x00007fff3fe8a643 +[PHPhotoLibrary stringFromPHPhotoLibraryType:] + 0 * 3 Photos 0x00007fff3ff6055d -[PHChangeRequest init] + 85 */ return(true); } break; case "AVKit.AVCaptureView": // Deallocating the AVCaptureView starts up the A/V capturing pipeline (!): /* * 24 com.apple.avfoundation 0x00007fff28298a2f -[AVCaptureSession startRunning] + 97 * 25 com.apple.AVKit 0x00007fff2866621f __72-[AVCaptureController _createDefaultSessionAndFileOutputAsynchronously:]_block_invoke_2 + 293 * 26 com.apple.AVKit 0x00007fff2866609a __72-[AVCaptureController _createDefaultSessionAndFileOutputAsynchronously:]_block_invoke + 489 * 27 com.apple.AVKit 0x00007fff28661bd4 -[AVCaptureController _createDefaultSessionAndFileOutputAsynchronously:] + 234 * 28 com.apple.AVKit 0x00007fff28661c53 -[AVCaptureController session] + 53 * 29 com.apple.AVKit 0x00007fff28670d2b -[AVCaptureView dealloc] + 124 * * This is unfortunate because capturing audio/video requires permission, * and since macOS tests don't execute in a session that can show UI, * the permission system (TCC) fails and the process ends up crashing * due to a privacy violation (even if the required entry is present in the Info.plist). */ return(true); case "AVFoundation.AVAudioRecorder": // Stopped working in macOS 10.15.2 return(TestRuntime.CheckXcodeVersion(11, 2)); } switch (type.Namespace) { // OSX 10.8+ case "MonoMac.Accounts": case "Accounts": case "MonoMac.GameKit": case "GameKit": case "MonoMac.Social": case "Social": case "MonoMac.StoreKit": case "StoreKit": if (!Mac.CheckSystemVersion(10, 8)) { return(true); } break; case "SceneKit": case "MonoMac.SceneKit": if (!Mac.CheckSystemVersion(10, 8) || IntPtr.Size != 8) { return(true); } break; case "MediaPlayer": case "MonoMac.MediaPlayer": if (!Mac.CheckSystemVersion(10, 12) || IntPtr.Size != 8) { return(true); } break; case "QTKit": if (Mac.CheckSystemVersion(10, 15)) // QTKit is gone in 10.15 { return(true); } break; } return(base.Skip(type)); }
public void Default_Properties() { TestRuntime.AssertXcodeVersion(5, 0); TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 9, throwIfOtherPlatform: false); var config = NSUrlSessionConfiguration.DefaultSessionConfiguration; // in iOS9 those selectors do not respond - but they do work (forwarded to __NSCFURLSessionConfiguration type ?) Assert.True(config.AllowsCellularAccess, "allowsCellularAccess"); config.AllowsCellularAccess = config.AllowsCellularAccess; // setAllowsCellularAccess: Assert.Null(config.ConnectionProxyDictionary, "connectionProxyDictionary"); config.ConnectionProxyDictionary = null; // setConnectionProxyDictionary: Assert.False(config.Discretionary, "isDiscretionary"); config.Discretionary = config.Discretionary; // setDiscretionary: Assert.Null(config.HttpAdditionalHeaders, "HTTPAdditionalHeaders"); config.HttpAdditionalHeaders = config.HttpAdditionalHeaders; // setHTTPAdditionalHeaders: Assert.That(config.HttpCookieAcceptPolicy, Is.EqualTo(NSHttpCookieAcceptPolicy.OnlyFromMainDocumentDomain), "HTTPCookieAcceptPolicy"); config.HttpCookieAcceptPolicy = config.HttpCookieAcceptPolicy; // setHTTPCookieAcceptPolicy: Assert.NotNull(config.HttpCookieStorage, "HTTPCookieStorage"); config.HttpCookieStorage = config.HttpCookieStorage; // setHTTPCookieStorage: // iOS 7.x returned 6 (instead of 4) Assert.That(config.HttpMaximumConnectionsPerHost, Is.GreaterThanOrEqualTo(4), "HTTPMaximumConnectionsPerHost"); config.HttpMaximumConnectionsPerHost = config.HttpMaximumConnectionsPerHost; // setHTTPMaximumConnectionsPerHost: Assert.True(config.HttpShouldSetCookies, "HTTPShouldSetCookies"); config.HttpShouldSetCookies = config.HttpShouldSetCookies; // setHTTPShouldSetCookies: Assert.False(config.HttpShouldUsePipelining, "HTTPShouldUsePipelining"); config.HttpShouldUsePipelining = config.HttpShouldUsePipelining; // setHTTPShouldUsePipelining: Assert.Null(config.Identifier, "identifier"); Assert.That(config.NetworkServiceType, Is.EqualTo(NSUrlRequestNetworkServiceType.Default), "networkServiceType"); config.NetworkServiceType = config.NetworkServiceType; // setNetworkServiceType: Assert.That(config.RequestCachePolicy, Is.EqualTo(NSUrlRequestCachePolicy.UseProtocolCachePolicy), "requestCachePolicy"); config.RequestCachePolicy = config.RequestCachePolicy; // setRequestCachePolicy: Assert.False(config.SessionSendsLaunchEvents, "sessionSendsLaunchEvents"); config.SessionSendsLaunchEvents = config.SessionSendsLaunchEvents; // setSessionSendsLaunchEvents: var hasSharedContainerIdentifier = true; #if __MACOS__ hasSharedContainerIdentifier = TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 10); #else hasSharedContainerIdentifier = TestRuntime.CheckXcodeVersion(6, 0); #endif if (hasSharedContainerIdentifier) { Assert.Null(config.SharedContainerIdentifier, "sharedContainerIdentifier"); config.SharedContainerIdentifier = config.SharedContainerIdentifier; // setSharedContainerIdentifier: } Assert.That(config.TimeoutIntervalForRequest, Is.GreaterThan(0), "timeoutIntervalForRequest"); config.TimeoutIntervalForRequest = config.TimeoutIntervalForRequest; // setTimeoutIntervalForRequest: Assert.That(config.TimeoutIntervalForResource, Is.GreaterThan(0), "timeoutIntervalForResource"); config.TimeoutIntervalForResource = config.TimeoutIntervalForResource; // setTimeoutIntervalForResource: var max = TestRuntime.CheckXcodeVersion(8, 0) ? SslProtocol.Unknown : SslProtocol.Tls_1_2; // Unknown also means default Assert.That(config.TLSMaximumSupportedProtocol, Is.EqualTo(max), "TLSMaximumSupportedProtocol"); config.TLSMaximumSupportedProtocol = config.TLSMaximumSupportedProtocol; // setTLSMaximumSupportedProtocol: Assert.That(config.TLSMinimumSupportedProtocol, Is.GreaterThanOrEqualTo(SslProtocol.Ssl_3_0), "TLSMinimumSupportedProtocol"); config.TLSMinimumSupportedProtocol = config.TLSMinimumSupportedProtocol; // setTLSMinimumSupportedProtocol: Assert.NotNull(config.URLCache, "URLCache"); config.URLCache = config.URLCache; // setURLCache: Assert.NotNull(config.URLCredentialStorage, "URLCredentialStorage"); config.URLCredentialStorage = config.URLCredentialStorage; // setURLCredentialStorage: var hasProtocolClasses = true; #if __MACOS__ hasProtocolClasses = TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 10); #else hasProtocolClasses = TestRuntime.CheckXcodeVersion(6, 0); #endif if (hasProtocolClasses) { Assert.NotNull(config.WeakProtocolClasses, "protocolClasses"); } else { Assert.Null(config.WeakProtocolClasses, "protocolClasses"); } config.WeakProtocolClasses = config.WeakProtocolClasses; // setProtocolClasses: }
protected override bool CheckStaticResponse(bool value, Type actualType, Type declaredType, ref string name) { switch (name) { // new API in iOS9 beta 5 but is does not respond when queried - https://bugzilla.xamarin.com/show_bug.cgi?id=33431 case "geometrySourceWithBuffer:vertexFormat:semantic:vertexCount:dataOffset:dataStride:": switch (declaredType.Name) { case "SCNGeometrySource": return(true); } break; case "imageWithIOSurface:": case "imageWithIOSurface:options:": switch (declaredType.Name) { case "CIImage": // works on both sim/device with Xcode 11 (continue main logic) if (TestRuntime.CheckXcodeVersion(11, 0)) { break; } // did not work on simulator before iOS 13 (shortcut logic) if (Runtime.Arch == Arch.SIMULATOR) { return(true); } // was a private framework (on iOS) before Xcode 9.0 (shortcut logic) if (!TestRuntime.CheckXcodeVersion(9, 0)) { return(true); } break; } break; case "objectWithItemProviderData:typeIdentifier:error:": case "readableTypeIdentifiersForItemProvider": switch (declaredType.Name) { case "PHLivePhoto": // not yet conforming to NSItemProviderReading if (!TestRuntime.CheckXcodeVersion(10, 0)) { return(true); } break; } break; #if __WATCHOS__ case "fetchAllRecordZonesOperation": case "fetchCurrentUserRecordOperation": case "notificationFromRemoteNotificationDictionary:": case "containerWithIdentifier:": case "defaultContainer": case "defaultRecordZone": // needs investigation, seems all class selectors from CloudKit don't answer if (declaredType.Namespace == "CloudKit") { return(true); } break; #endif } return(base.CheckStaticResponse(value, actualType, declaredType, ref name)); }
protected override bool Skip(PropertyInfo p) { switch (p.DeclaringType.Namespace) { case "CoreAudioKit": case "MonoTouch.CoreAudioKit": case "Metal": case "MonoTouch.Metal": // they works with iOS9 beta 4 (but won't work on older simulators) if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; case "MetalKit": case "MonoTouch.MetalKit": case "MetalPerformanceShaders": case "MonoTouch.MetalPerformanceShaders": case "CoreNFC": // Only available on devices that support NFC, so check if NFCNDEFReaderSession is present. if (Class.GetHandle("NFCNDEFReaderSession") == IntPtr.Zero) { return(true); } break; case "DeviceCheck": // Only available on device if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; case "IOSurface": // Available in the simulator starting with iOS 11 return(Runtime.Arch == Arch.SIMULATOR && !TestRuntime.CheckXcodeVersion(9, 0)); } switch (p.Name) { case "AutoConfigurationHTTPResponseKey": // kCFProxyAutoConfigurationHTTPResponseKey case "CFNetworkProxiesProxyAutoConfigJavaScript": // kCFNetworkProxiesProxyAutoConfigJavaScript return(true); // defined in Apple PDF (online) but not in the HTML documentation // but also inside CLError.h from iOS 5.1 SDK... case "ErrorUserInfoAlternateRegionKey": // kCLErrorUserInfoAlternateRegionKey return(true); // ImageIO: documented since iOS 4.3 but null in iOS5 (works on iOS 6.1) // https://developer.apple.com/library/ios/releasenotes/General/iOS43APIDiffs/ case "ExifCameraOwnerName": case "ExifBodySerialNumber": case "ExifLensSpecification": case "ExifLensMake": case "ExifLensModel": case "ExifLensSerialNumber": return(!TestRuntime.CheckXcodeVersion(4, 6)); // ImageIO: new in iOS 8 but returns nil (at least in beta 1) seems fixed in iOS9 case "PNGLoopCount": case "PNGDelayTime": case "PNGUnclampedDelayTime": return(!TestRuntime.CheckXcodeVersion(7, 0)); // CoreServices.CFHTTPMessage - document in 10.9 but returns null case "_AuthenticationSchemeOAuth1": return(true); // Apple does not ship a PushKit for every arch on some devices :( case "Voip": return(Runtime.Arch == Arch.DEVICE); // Just available on device case "UsageKey": return(Runtime.Arch == Arch.SIMULATOR); default: return(base.Skip(p)); } }
protected override bool Skip(Type type) { switch (type.Namespace) { // they don't answer on the simulator (Apple implementation does not work) but fine on devices case "GameController": case "MonoTouch.GameController": case "MLCompute": // xcode 12 beta 3 return(Runtime.Arch == Arch.SIMULATOR); case "CoreAudioKit": case "MonoTouch.CoreAudioKit": case "Metal": case "MonoTouch.Metal": // they works with iOS9 beta 4 (but won't work on older simulators) if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion(7, 0)) { return(true); } break; case "Chip": case "MetalKit": case "MonoTouch.MetalKit": case "MetalPerformanceShaders": case "MonoTouch.MetalPerformanceShaders": case "Phase": case "ThreadNetwork": if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; // Xcode 9 case "CoreNFC": // Only available on devices that support NFC, so check if NFCNDEFReaderSession is present. if (Class.GetHandle("NFCNDEFReaderSession") == IntPtr.Zero) { return(true); } break; case "DeviceCheck": if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; // Apple does not ship a PushKit for every arch on some devices :( // case "PushKit": // case "MonoTouch.PushKit": // if (Runtime.Arch == Arch.DEVICE) // return true; // break; #if HAS_WATCHCONNECTIVITY case "WatchConnectivity": case "MonoTouch.WatchConnectivity": if (!WCSession.IsSupported) { return(true); } break; #endif // HAS_WATCHCONNECTIVITY case "ShazamKit": // ShazamKit is not fully supported in the simulator if (Runtime.Arch == Arch.SIMULATOR) { return(true); } break; } switch (type.Name) { // abstract superclass case "UIBarItem": return(true); // does not answer to anything ? case "UILocalNotification": return(true); // Metal is not available on the simulator case "CAMetalLayer": return((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion(11, 0)); case "SKRenderer": return(Runtime.Arch == Arch.SIMULATOR); // iOS 10 - this type can only be instantiated on devices, but the selectors are forwarded // to a MTLHeapDescriptorInternal and don't respond - so we'll add unit tests for them case "MTLHeapDescriptor": case "MTLLinkedFunctions": case "MTLRenderPipelineDescriptor": case "MTLTileRenderPipelineDescriptor": case "MTLRasterizationRateLayerDescriptor": case "MTLRasterizationRateMapDescriptor": return(Runtime.Arch == Arch.SIMULATOR); #if __WATCHOS__ // The following watchOS 3.2 Beta 2 types Fails, but they can be created we verified using an ObjC app, we will revisit before stable case "INPersonResolutionResult": case "INPlacemarkResolutionResult": case "INPreferences": case "INRadioTypeResolutionResult": case "INRelativeReferenceResolutionResult": case "INRelativeSettingResolutionResult": case "INRideCompletionStatus": case "INSpeakableStringResolutionResult": case "INStringResolutionResult": case "INTemperatureResolutionResult": case "INWorkoutGoalUnitTypeResolutionResult": case "INWorkoutLocationTypeResolutionResult": case "INBillPayeeResolutionResult": case "INBillTypeResolutionResult": case "INBooleanResolutionResult": case "INCallRecordTypeResolutionResult": case "INCarAirCirculationModeResolutionResult": case "INCarAudioSourceResolutionResult": case "INCarDefrosterResolutionResult": case "INCarSeatResolutionResult": case "INCarSignalOptionsResolutionResult": case "INCurrencyAmountResolutionResult": case "INDateComponentsRangeResolutionResult": case "INDateComponentsResolutionResult": case "INDoubleResolutionResult": case "INImage": case "INIntegerResolutionResult": case "INInteraction": case "INMessageAttributeOptionsResolutionResult": case "INPaymentAmountResolutionResult": case "INMessageAttributeResolutionResult": case "INPaymentMethod": case "INPaymentStatusResolutionResult": case "INPaymentAccountResolutionResult": return(true); case "CMMovementDisorderManager": // From Xcode 10 beta 2: // This requires a special entitlement: // Usage of CMMovementDisorderManager requires a special entitlement. Please see for more information https://developer.apple.com/documentation/coremotion/cmmovementdisordermanager // but that web page doesn't explain anything (it's mostly empty, so this is probably just lagging documentation) // I also tried enabling every entitlement in Xcode, but it still didn't work. return(true); #endif default: return(base.Skip(type)); } }
protected override void CheckToString(NSObject obj) { string name = obj.GetType().Name; switch (name) { // crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /mono/ios/monotouch-ios7/monotouch/src/Foundation/NSObject.g.cs:500 case "SKTexture": case "MCSession": // crash at at MonoTouch.Foundation.NSObject.get_Description () [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.g.cs:554 case "AVPlayerItemTrack": case "AVCaptureConnection": return; // worked before ios6.0 beta 1 case "AVComposition": // new API in iOS7 case "AVAssetResourceLoadingDataRequest": // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Unable to create description in descriptionForLayoutAttribute_layoutItem_coefficient. Something is nil case "NSLayoutConstraint": // new in 6.0 case "AVAssetResourceLoadingRequest": case "GKScoreChallenge": // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[GKScoreChallenge challengeID]: unrecognized selector sent to instance 0x18acc340 case "GKAchievementChallenge": // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[GKAchievementChallenge challengeID]: unrecognized selector sent to instance 0x160f4840 if (TestRuntime.CheckXcodeVersion(4, 5)) { return; } break; // iOS 9 beta 1 - crash when called case "WKFrameInfo": case "WKNavigation": case "WKNavigationAction": if (TestRuntime.CheckXcodeVersion(7, 0)) { return; } break; // new iOS 10 beta 1 - crash when calling `description` selector case "AVAudioSessionDataSourceDescription": case "AVAudioSessionPortDescription": case "CLBeacon": case "CLCircularRegion": // beta 2 case "CTCallCenter": // beta 3 case "CNContainer": if (TestRuntime.CheckXcodeVersion(8, 0)) { return; } break; // Xcode 9 Beta 1 to avoid crashes case "CIImageAccumulator": if (TestRuntime.CheckXcodeVersion(9, 0)) { return; } break; default: base.CheckToString(obj); break; } }
public void StreamDefaults() { TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false); using (var ssl = new SslContext(SslProtocolSide.Client, SslConnectionType.Stream)) { Assert.That(ssl.BufferedReadSize, Is.EqualTo((nint)0), "BufferedReadSize"); Assert.That(ssl.ClientCertificateState, Is.EqualTo(SslClientCertificateState.None), "ClientCertificateState"); Assert.Null(ssl.Connection, "Connection"); Assert.That(ssl.DatagramWriteSize, Is.EqualTo((nint)0), "DatagramWriteSize"); Assert.That(ssl.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); Assert.That(ssl.MaxDatagramRecordSize, Is.EqualTo((nint)0), "MaxDatagramRecordSize"); Assert.That(ssl.MaxProtocol, Is.EqualTo(SslProtocol.Tls_1_2), "MaxProtocol"); if (TestRuntime.CheckXcodeVersion(8, 0)) { Assert.That(ssl.MinProtocol, Is.EqualTo(SslProtocol.Tls_1_0), "MinProtocol"); } else { Assert.That(ssl.MinProtocol, Is.EqualTo(SslProtocol.Ssl_3_0), "MinProtocol"); } Assert.That(ssl.NegotiatedCipher, Is.EqualTo(SslCipherSuite.SSL_NULL_WITH_NULL_NULL), "NegotiatedCipher"); Assert.That(ssl.NegotiatedProtocol, Is.EqualTo(SslProtocol.Unknown), "NegotiatedProtocol"); Assert.That(ssl.PeerDomainName, Is.Empty, "PeerDomainName"); ssl.PeerDomainName = "google.ca"; Assert.That(ssl.PeerDomainName, Is.EqualTo("google.ca"), "PeerDomainName-2"); ssl.PeerDomainName = null; Assert.That(ssl.PeerDomainName, Is.Empty, "PeerDomainName"); Assert.Null(ssl.PeerId, "PeerId"); ssl.PeerId = new byte [] { 0xff }; Assert.That(ssl.PeerId.Length, Is.EqualTo(1), "1a"); // note: SSLSetPeerID (see Apple open source code) does not accept a null/zero-length value ssl.PeerId = new byte [0]; Assert.That((int)ssl.GetLastStatus(), Is.EqualTo(errSecParam), "set_PeerId/empty"); Assert.That(ssl.PeerId.Length, Is.EqualTo(1), "1b"); ssl.PeerId = new byte [] { 0x01, 0x02 }; Assert.That(ssl.PeerId.Length, Is.EqualTo(2), "2"); Assert.Null(ssl.PeerTrust, "PeerTrust"); Assert.That(ssl.SessionState, Is.EqualTo(SslSessionState.Idle), "SessionState"); Assert.That((int)ssl.SetDatagramHelloCookie(new byte [32]), Is.EqualTo(-50), "no cookie in stream"); // Assert.Null (ssl.GetDistinguishedNames<string> (), "GetDistinguishedNames"); if (TestRuntime.CheckXcodeVersion(9, 0)) { Assert.That(ssl.SetSessionTickets(false), Is.EqualTo(0), "SetSessionTickets"); Assert.That(ssl.SetError(SecStatusCode.Success), Is.EqualTo(0), "SetError"); Assert.Throws <ArgumentNullException> (() => ssl.SetOcspResponse(null), "SetOcspResponse/null"); using (var data = new NSData()) Assert.That(ssl.SetOcspResponse(data), Is.EqualTo(0), "SetOcspResponse/empty"); #if MONOMAC if (TestRuntime.CheckXcodeVersion(9, 3)) { #endif int error; var alpn = ssl.GetAlpnProtocols(out error); Assert.That(alpn, Is.Empty, "alpn"); Assert.That(error, Is.EqualTo((int)SecStatusCode.Param), "GetAlpnProtocols"); var protocols = new [] { "HTTP/1.1", "SPDY/1" } ; Assert.That(ssl.SetAlpnProtocols(protocols), Is.EqualTo(0), "SetAlpnProtocols"); #if MONOMAC } #endif } } }
public void EnumValues_22351() { TestRuntime.AssertXcodeVersion(6, 0); foreach (HKQuantityTypeIdentifier value in Enum.GetValues(typeof(HKQuantityTypeIdentifier))) { // we need to have version checks for anything added after iOS 8.0 switch (value) { case HKQuantityTypeIdentifier.BasalBodyTemperature: case HKQuantityTypeIdentifier.DietaryWater: case HKQuantityTypeIdentifier.UVExposure: if (!TestRuntime.CheckXcodeVersion(7, 0)) { continue; } break; case HKQuantityTypeIdentifier.AppleExerciseTime: if (!TestRuntime.CheckXcodeVersion(7, 3)) { continue; } break; case HKQuantityTypeIdentifier.DistanceWheelchair: case HKQuantityTypeIdentifier.PushCount: case HKQuantityTypeIdentifier.DistanceSwimming: case HKQuantityTypeIdentifier.SwimmingStrokeCount: if (!TestRuntime.CheckXcodeVersion(8, 0)) { continue; } break; case HKQuantityTypeIdentifier.WaistCircumference: case HKQuantityTypeIdentifier.VO2Max: case HKQuantityTypeIdentifier.InsulinDelivery: case HKQuantityTypeIdentifier.RestingHeartRate: case HKQuantityTypeIdentifier.WalkingHeartRateAverage: case HKQuantityTypeIdentifier.HeartRateVariabilitySdnn: if (!TestRuntime.CheckXcodeVersion(9, 0)) { continue; } break; case HKQuantityTypeIdentifier.DistanceDownhillSnowSports: if (!TestRuntime.CheckXcodeVersion(9, 2)) { continue; } break; } try { using (var ct = HKQuantityType.Create(value)) { Assert.That(ct.Handle, Is.Not.EqualTo(IntPtr.Zero), value.ToString()); } } catch (Exception e) { Assert.Fail("{0} could not be created: {1}", value, e); } } }