public void Constructors() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(7, 0); MPSImageHistogramInfo info = new MPSImageHistogramInfo(); info.NumberOfHistogramEntries = 256; using (var obj = new MPSImageHistogram(MTLDevice.SystemDefault, ref info)) { var rv = obj.HistogramInfo; Asserts.AreEqual(info, rv, "HistogramForAlpha"); Assert.IsTrue(obj.ZeroHistogram, "ZeroHistogram"); if (TestRuntime.CheckXcodeVersion(8, 0)) { // HistogramSizeForSourceFormat was introduced in iOS 9, but no matter which MTLPixelFormat value I pass in, // the native histogramSizeForSourceFormat: function rudely aborts the entire process with an abrupt: // > /BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalImage/MetalImage-39.3/MetalImage/Filters/MIHistogram.mm:103: failed assertion `[MPSImageHistogram histogramSizeForSourceFormat:] unsupported texture format: 114' // I made sure the MTLPixelFormat values I tested with were also added in iOS 9, so that's not the problem. // Conclusion: just avoid executing HistogramSizeForSourceFormat on anything below iOS 10.rm Assert.AreEqual(3072, obj.HistogramSizeForSourceFormat(MTLPixelFormat.RGBA16Sint), "HistogramSizeForSourceFormat"); } var crs = obj.ClipRectSource; Assert.AreEqual(0, crs.Origin.X, "ClipRectSource.Origin.X"); Assert.AreEqual(0, crs.Origin.Y, "ClipRectSource.Origin.Y"); Assert.AreEqual(0, crs.Origin.Z, "ClipRectSource.Origin.Z"); Assert.AreEqual(-1, crs.Size.Depth, "ClipRectSource.Size.Depth"); Assert.AreEqual(-1, crs.Size.Height, "ClipRectSource.Size.Height"); Assert.AreEqual(-1, crs.Size.Width, "ClipRectSource.Size.Width"); } }
public void SetUp() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(10, 0); queue = new DispatchQueue("myQueue"); listener = new MTLSharedEventListener(queue); }
public void SetUp() { // XML serialization mechanism is controlled by RuntimeFeature.IsDynamicCodeSupported // which will be true for simulator / JIT builds // so the optimization is disabled unless AOT is used TestRuntime.AssertDevice(); }
public void AvailableDepthDataTypesTest() { #if !MONOMAC TestRuntime.AssertDevice(); #endif TestRuntime.AssertXcodeVersion(9, 0); // xamarinmonkey.heic is the new photo format, also this one includes depth data var imgdata = NSData.FromUrl(NSBundle.MainBundle.GetUrlForResource("xamarinmonkey", "heic", "CoreImage")); Assert.NotNull(imgdata, "imgdata"); var imageSource = CGImageSource.FromData(imgdata); Assert.NotNull(imageSource, "imageSource"); // fetching the image count works around a crash in CopyAuxiliaryDataInfo on macOS 10.15 (https://github.com/xamarin/maccore/issues/1802). Assert.AreNotEqual(0, imageSource.ImageCount, "ImageCount"); var info = imageSource.CopyAuxiliaryDataInfo(0, CGImageAuxiliaryDataType.Disparity); Assert.NotNull(info, "info"); NSError err; var depthData = AVDepthData.Create(info, out err); Assert.NotNull(depthData, "depthData"); Assert.NotNull(depthData.AvailableDepthDataTypes, "AvailableDepthDataTypes"); }
public void Init() { TestRuntime.AssertXcodeVersion(13, 0); TestRuntime.AssertDevice(); // connect so that we can later when the report and test with it connectedEvent = new AutoResetEvent(false); reportEvent = new AutoResetEvent(false); resolutionEvent = new AutoResetEvent(false); host = NetworkResources.MicrosoftUri.Host; // we create a connection which we are going to use to get the availabe // interfaces, that way we can later test protperties of the NWParameters class. using (var parameters = NWParameters.CreateUdp()) using (var endpoint = NWEndpoint.Create(host, "80")) { using (var protocolStack = parameters.ProtocolStack) { var ipOptions = protocolStack.InternetProtocol; ipOptions.IPSetVersion(NWIPVersion.Version4); } connection = new NWConnection(endpoint, parameters); connection.SetQueue(DispatchQueue.DefaultGlobalQueue); // important, else we will get blocked connection.SetStateChangeHandler(ConnectionStateHandler); connection.Start(); Assert.True(connectedEvent.WaitOne(20000), "Connection timed out."); connection.GetEstablishmentReport(DispatchQueue.DefaultGlobalQueue, (r) => { report = r; reportEvent.Set(); }); Assert.True(reportEvent.WaitOne(20000), "Connection timed out."); report.EnumerateResolutionReports((r) => { resolutionReport = r; resolutionEvent.Set(); }); Assert.True(resolutionEvent.WaitOne(20000), "Connection timed out."); } }
public void MPSImageLaplacianPyramidCtorArrTest() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(10, 2); var validArr = new float [] { 0, 1, 0, 1, -4, 1, 0, 1, 0, }; var invalidArr = new float [] { 0, 1, 0, 1, -4, 1, }; var bigvalidArr = new float [] { 0, 1, 0, 1, -4, 1, 0, 1, 0, 0, 1, 0, 1, -4, 1, 0, 1, 0, }; var valid = new MPSImageLaplacianPyramid(device, 3, 3, validArr); Assert.NotNull(valid, "Valid Arr"); Assert.Throws <ArgumentException> (() => new MPSImageLaplacianPyramid(device, 3, 3, invalidArr), "Invalid Arr"); var bigvalid = new MPSImageLaplacianPyramid(device, 3, 3, bigvalidArr); Assert.NotNull(valid, "Big valid Arr"); }
public void Setup() { TestRuntime.AssertXcodeVersion(13, 0); // not supported in simulator TestRuntime.AssertDevice(); engine = new PhaseEngine(PhaseUpdateMode.Automatic); phaseObject = new PhaseObject(engine); }
public void INUIAddVoiceShortcutButtonTest() { TestRuntime.AssertXcodeVersion(10, 0); TestRuntime.AssertDevice(); var shortcutButton = new INUIAddVoiceShortcutButton(INUIAddVoiceShortcutButtonStyle.Black); shortcutButton.SpringLoaded = true; Assert.IsTrue(shortcutButton.SpringLoaded); }
public void CompressionSessionCreateTest() { // The FileProvider's NSData constants are only available running on device. TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(9, 0); Assert.IsNotNull(NSFileProviderPage.InitialPageSortedByDate, "InitialPageSortedByDate should not be null"); Assert.IsNotNull(NSFileProviderPage.InitialPageSortedByName, "InitialPageSortedByName should not be null"); }
public void Metal () { TestRuntime.AssertDevice (); TestRuntime.AssertXcodeVersion (10, 0); device = MTLDevice.SystemDefault; // some older hardware won't have a default if (device == null || !MPSKernel.Supports (device)) Assert.Inconclusive ("Metal is not supported"); }
public void SetPrivacyContextTest() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(13, 0); using (var privacy = NWPrivacyContext.Default) using (var parameters = new NWParameters()) { Assert.DoesNotThrow(() => { parameters.SetPrivacyContext(privacy); }); } }
public void FromDeviceTest() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(9, 0); var d = MTLDevice.SystemDefault; var cache = CVMetalTextureCache.FromDevice(d, new CVMetalTextureAttributes { Usage = MTLTextureUsage.PixelFormatView }); Assert.NotNull(cache); }
public void MetadataObjectTypesTest() { TestRuntime.AssertSystemVersion(ApplePlatform.iOS, 8, 0, throwIfOtherPlatform: false); TestRuntime.AssertDevice("This test only runs on device (requires camera access)"); TestRuntime.RequestCameraPermission(AVMediaTypes.Video.GetConstant(), true); using (var captureSession = new AVCaptureSession()) { using (var videoDevice = AVCaptureDevice.GetDefaultDevice(AVMediaTypes.Video.GetConstant())) { NSError error; using (var videoInput = new AVCaptureDeviceInput(videoDevice, out error)) { if (captureSession.CanAddInput(videoInput)) { captureSession.AddInput(videoInput); } using (var metadataOutput = new AVCaptureMetadataOutput()) { if (captureSession.CanAddOutput(metadataOutput)) { captureSession.AddOutput(metadataOutput); } AVMetadataObjectType all = AVMetadataObjectType.None; foreach (AVMetadataObjectType val in Enum.GetValues(typeof(AVMetadataObjectType))) { switch (val) { case AVMetadataObjectType.CatBody: case AVMetadataObjectType.DogBody: case AVMetadataObjectType.HumanBody: case AVMetadataObjectType.SalientObject: // fail *and crash* on iOS 8 (at least on 32bits devices) if (!TestRuntime.CheckXcodeVersion(11, 0)) { continue; } // xcode 12 beta 1 on device if (TestRuntime.IsDevice && TestRuntime.CheckXcodeVersion(12, 0)) { continue; } break; } metadataOutput.MetadataObjectTypes = val; all |= val; Assert.AreEqual(val, metadataOutput.MetadataObjectTypes, val.ToString()); } metadataOutput.MetadataObjectTypes = all; Assert.AreEqual(all, metadataOutput.MetadataObjectTypes, all.ToString()); } } } } }
public void MPSRnnMatrixInferenceLayerTest() { #if !MONOMAC TestRuntime.AssertDevice(); #endif TestRuntime.AssertXcodeVersion(9, 0); var layer = new MPSRnnMatrixInferenceLayer(MTLDevice.SystemDefault, MPSRnnSingleGateDescriptor.Create(1, 1)); var layer2 = layer.Copy(NSZone.Default, MTLDevice.SystemDefault); Assert.That(layer2.RetainCount, Is.EqualTo(1)); }
public void MPSKernelCopyTest() { #if !MONOMAC TestRuntime.AssertDevice(); #endif TestRuntime.AssertXcodeVersion(9, 0); var kernel = new MPSKernel(MTLDevice.SystemDefault); var kernel2 = kernel.CopyWithZone(NSZone.Default, MTLDevice.SystemDefault); Assert.That(kernel2.RetainCount, Is.EqualTo(1)); }
public void Constructors() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(7, 0); MPSImageHistogramInfo info = new MPSImageHistogramInfo(); info.NumberOfHistogramEntries = 256; using (var obj = new MPSImageHistogramEqualization(MTLDevice.SystemDefault, ref info)) { var rv = obj.HistogramInfo; Asserts.AreEqual(info, rv, "HistogramForAlpha"); } }
public void AppStoreReceiptURL() { if (!TestRuntime.CheckXcodeVersion(5, 0)) { Assert.Inconclusive("Requires iOS7 or later"); } // The AppStoreReceiptUrl property may or may not return anything useful on the simulator, so run this only on device. TestRuntime.AssertDevice(); // on iOS8 device this now ends with "/StoreKit/sandboxReceipt" // instead of "/StokeKit/receipt" Assert.That(main.AppStoreReceiptUrl.AbsoluteString, Does.EndWith("eceipt"), "AppStoreReceiptUrl"); }
public void SubmitTaskRequestTest() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(11, 0); Assert.True(registered, "Task was not registered."); // get the shared scheduler, create a request and submit it, this will be called asap // and the autoreset event set. var request = new BGProcessingTaskRequest(taskIdentifier); NSError error; BGTaskScheduler.Shared.Submit(request, out error); Assert.IsNull(error, $"Error submiting request {error}"); LaunchBGTask(); autoResetEvent.WaitOne(300); Assert.True(taskWasCalled, "Called task."); }
public void Metal() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(10, 0); device = MTLDevice.SystemDefault; // some older hardware won't have a default if (device == null || !MPSKernel.Supports(device)) { Assert.Inconclusive("Metal is not supported"); } cache = NSArray <MPSImage> .FromNSObjects( new MPSImage (device, MPSImageDescriptor.GetImageDescriptor(MPSImageFeatureChannelFormat.Float32, 224, 224, 3)), new MPSImage (device, MPSImageDescriptor.GetImageDescriptor(MPSImageFeatureChannelFormat.Float32, 224, 224, 3)), new MPSImage (device, MPSImageDescriptor.GetImageDescriptor(MPSImageFeatureChannelFormat.Float32, 224, 224, 3)), new MPSImage (device, MPSImageDescriptor.GetImageDescriptor(MPSImageFeatureChannelFormat.Float32, 224, 224, 3)), new MPSImage (device, MPSImageDescriptor.GetImageDescriptor(MPSImageFeatureChannelFormat.Float32, 224, 224, 3)) ); }
public void Metal() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(10, 0); device = MTLDevice.SystemDefault; // some older hardware won't have a default if (device == null || !MPSKernel.Supports(device)) { Assert.Inconclusive("Metal is not supported"); } cache = NSArray <MPSState> .FromNSObjects( new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA32Float, 220, 220, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA32Float, 221, 221, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA32Float, 222, 222, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA32Float, 223, 223, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA32Float, 224, 224, false)), new MPSState (device, MTLTextureDescriptor.CreateTexture2DDescriptor(MTLPixelFormat.RGBA32Float, 225, 225, false)) ); }
public void FunctionNames() { TestRuntime.AssertDevice(); Collect(); bool aot = symbols [1].Contains("MonoTouchFixtures_Symbols_Collect"); bool llvmonly = symbols [1].Contains("mono_llvmonly_runtime_invoke"); // LLVM inlines the Collect function, so 'Collect' doesn't show up in the stack trace :/ bool interp = false; if (!aot) { for (int i = 0; i < 5 && !interp; i++) { /* ves_pinvoke_method (slow path) and do_icall (fast path) are * MONO_NEVER_INLINE, so they should show up in the backtrace * reliably */ interp |= symbols [i].Contains("ves_pinvoke_method") || symbols [i].Contains("do_icall"); } } Assert.IsTrue(aot || interp || llvmonly, $"#1\n\t{string.Join ("\n\t", symbols)}"); }
public void AvailableDepthDataTypesTest() { #if !MONOMAC TestRuntime.AssertDevice(); #endif TestRuntime.AssertXcodeVersion(9, 0); // xamarinmonkey.heic is the new photo format, also this one includes depth data var imgdata = NSData.FromUrl(NSBundle.MainBundle.GetUrlForResource("xamarinmonkey", "heic", "CoreImage")); Assert.NotNull(imgdata, "imgdata"); var imageSource = CGImageSource.FromData(imgdata); Assert.NotNull(imageSource, "imageSource"); var info = imageSource.CopyAuxiliaryDataInfo(0, CGImageAuxiliaryDataType.Disparity); Assert.NotNull(info, "info"); NSError err; var depthData = AVDepthData.Create(info, out err); Assert.NotNull(depthData, "depthData"); Assert.NotNull(depthData.AvailableDepthDataTypes, "AvailableDepthDataTypes"); }
public void Constructors() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(7, 0); MPSImageHistogramInfo info = new MPSImageHistogramInfo(); info.NumberOfHistogramEntries = 256; using (var obj = new MPSImageHistogram(MTLDevice.SystemDefault, ref info)) { var rv = obj.HistogramInfo; Asserts.AreEqual(info, rv, "HistogramForAlpha"); Assert.IsTrue(obj.ZeroHistogram, "ZeroHistogram"); Assert.AreEqual(3072, obj.HistogramSizeForSourceFormat(MTLPixelFormat.RGBA16Sint), "HistogramSizeForSourceFormat"); var crs = obj.ClipRectSource; Assert.AreEqual(0, crs.Origin.X, "ClipRectSource.Origin.X"); Assert.AreEqual(0, crs.Origin.Y, "ClipRectSource.Origin.Y"); Assert.AreEqual(0, crs.Origin.Z, "ClipRectSource.Origin.Z"); Assert.AreEqual(-1, crs.Size.Depth, "ClipRectSource.Size.Depth"); Assert.AreEqual(-1, crs.Size.Height, "ClipRectSource.Size.Height"); Assert.AreEqual(-1, crs.Size.Width, "ClipRectSource.Size.Width"); } }
public void AvailableDepthDataTypesTest() { TestRuntime.AssertDevice(); TestRuntime.AssertXcodeVersion(9, 0); // xamarinmonkey.heic is the new photo format, also this one includes depth data var imgdata = NSData.FromFile("CoreImage/xamarinmonkey.heic"); Assert.NotNull(imgdata, "imgdata"); var imageSource = CGImageSource.FromData(imgdata); Assert.NotNull(imageSource, "imageSource"); var info = imageSource.CopyAuxiliaryDataInfo(0, CGImageAuxiliaryDataType.Disparity); Assert.NotNull(info, "info"); NSError err; var depthData = AVDepthData.Create(info, out err); Assert.NotNull(depthData, "depthData"); Assert.NotNull(depthData.AvailableDepthDataTypes, "AvailableDepthDataTypes"); }
public void FromMetalBuffer() { if (!TestRuntime.CheckXcodeVersion(7, 0)) { Assert.Ignore("Requires iOS 9.0 or macOS 10.11"); } TestRuntime.AssertDevice(); var device = MTLDevice.SystemDefault; if (device == null) { Assert.Inconclusive("Device does not support Metal"); } using (var buffer = device.CreateBuffer(1024, MTLResourceOptions.CpuCacheModeDefault)) { using (var source = SCNGeometrySource.FromMetalBuffer(buffer, MTLVertexFormat.Char2, SCNGeometrySourceSemantic.Vertex, 36, 0, 0)) { // the fact that it works means the lack of respondToSelector (in introspection tests) is no // big deal and that the API really exists Assert.NotNull(source); } } }
public void DefaultValues() { TestRuntime.AssertDevice(); TestRuntime.RequestMediaLibraryPermission(true); using (var q = new MPMediaQuery()) { var items = q.Items; if (items == null) { Assert.Inconclusive("This test needs media library privacy permission to be executed."); } if (items.Length == 0) { Assert.Inconclusive("This test needs music in the music library on the device."); } var six_dot_oh = true; var nine_dot_two = TestRuntime.CheckSystemVersion(ApplePlatform.iOS, 9, 2); var ten_dot_oh = TestRuntime.CheckSystemVersion(ApplePlatform.iOS, 10, 0); var ten_dot_three = TestRuntime.CheckSystemVersion(ApplePlatform.iOS, 10, 3); foreach (var i in items) { object dummy; Assert.DoesNotThrow(() => dummy = i.AlbumArtist, "AlbumArtist"); Assert.DoesNotThrow(() => dummy = i.AlbumArtistPersistentID, "AlbumArtistPersistentID"); Assert.DoesNotThrow(() => dummy = i.AlbumPersistentID, "AlbumPersistentID"); Assert.DoesNotThrow(() => dummy = i.AlbumTitle, "AlbumTitle"); Assert.DoesNotThrow(() => dummy = i.AlbumTrackCount, "AlbumTrackCount"); Assert.DoesNotThrow(() => dummy = i.AlbumTrackNumber, "AlbumTrackNumber"); Assert.DoesNotThrow(() => dummy = i.Artist, "Artist"); Assert.DoesNotThrow(() => dummy = i.ArtistPersistentID, "ArtistPersistentID"); Assert.DoesNotThrow(() => dummy = i.Artwork, "Artwork"); Assert.DoesNotThrow(() => dummy = i.AssetURL, "AssetURL"); Assert.DoesNotThrow(() => dummy = i.BeatsPerMinute, "BeatsPerMinute"); Assert.DoesNotThrow(() => dummy = i.BookmarkTime, "BookmarkTime"); Assert.DoesNotThrow(() => dummy = i.Comments, "Comments"); Assert.DoesNotThrow(() => dummy = i.Composer, "Composer"); Assert.DoesNotThrow(() => dummy = i.ComposerPersistentID, "ComposerPersistentID"); Assert.DoesNotThrow(() => dummy = i.DiscCount, "DiscCount"); Assert.DoesNotThrow(() => dummy = i.DiscNumber, "DiscNumber"); Assert.DoesNotThrow(() => dummy = i.Genre, "Genre"); Assert.DoesNotThrow(() => dummy = i.GenrePersistentID, "GenrePersistentID"); if (six_dot_oh) { Assert.DoesNotThrow(() => dummy = i.IsCloudItem, "IsCloudItem"); } Assert.DoesNotThrow(() => dummy = i.IsCompilation, "IsCompilation"); Assert.DoesNotThrow(() => dummy = i.LastPlayedDate, "LastPlayedDate"); Assert.DoesNotThrow(() => dummy = i.Lyrics, "Lyrics"); Assert.DoesNotThrow(() => dummy = i.MediaType, "MediaType"); Assert.DoesNotThrow(() => dummy = i.PersistentID, "PersistentID"); Assert.DoesNotThrow(() => dummy = i.PlaybackDuration, "PlaybackDuration"); Assert.DoesNotThrow(() => dummy = i.PlayCount, "PlayCount"); Assert.DoesNotThrow(() => dummy = i.PodcastPersistentID, "PodcastPersistentID"); Assert.DoesNotThrow(() => dummy = i.PodcastTitle, "PodcastTitle"); Assert.DoesNotThrow(() => dummy = i.Rating, "Rating"); Assert.DoesNotThrow(() => dummy = i.ReleaseDate, "ReleaseDate"); Assert.DoesNotThrow(() => dummy = i.SkipCount, "SkipCount"); Assert.DoesNotThrow(() => dummy = i.Title, "Title"); Assert.DoesNotThrow(() => dummy = i.UserGrouping, "UserGrouping"); if (nine_dot_two) { Assert.DoesNotThrow(() => dummy = i.HasProtectedAsset, "HasProtectedAsset"); } if (ten_dot_oh) { Assert.DoesNotThrow(() => dummy = i.IsExplicitItem, "IsExplicitItem"); Assert.DoesNotThrow(() => dummy = i.DateAdded, "DateAdded"); } if (ten_dot_three) { Assert.DoesNotThrow(() => dummy = i.PlaybackStoreID, "PlaybackStoreID"); } } } }
public void Setup() { TestRuntime.AssertXcodeVersion(13, 0); // not supported in simulator TestRuntime.AssertDevice(); }