Ejemplo n.º 1
0
        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((nint)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:
        }
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(9, 0);
     descriptor = new MTLArgumentDescriptor();
 }
 public void Setup()
 {
     TestRuntime.AssertXcodeVersion(7, 0);
 }
Ejemplo n.º 4
0
        public override void SupportsSecureCoding()
        {
            TestRuntime.AssertXcodeVersion(4, 5);

            base.SupportsSecureCoding();
        }
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(8, 0);
     descriptor = new MTLAttributeDescriptor();
 }
Ejemplo n.º 6
0
 public void GetSetMaxTotalThreadsPerThreadgroupTest()
 {
     TestRuntime.AssertXcodeVersion(10, 0);
     descriptor.MaxTotalThreadsPerThreadgroup = 10;
     Assert.AreEqual((nuint)10, descriptor.MaxTotalThreadsPerThreadgroup);
 }
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(12, 0);
     array = new MTLResourceStatePassSampleBufferAttachmentDescriptorArray();
 }
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(10, 0);
     descriptor = new MTLIndirectCommandBufferDescriptor();
 }
Ejemplo n.º 9
0
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(6, 0);
     TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);
     op = new CKModifyRecordsOperation(null, null);
 }
 public void GetSupportedVideoFormats_10_0()
 {
     TestRuntime.AssertXcodeVersion(10, 0);
     Assert.NotNull(ARImageTrackingConfiguration.GetSupportedVideoFormats(), "ARImageTrackingConfiguration");
     Assert.NotNull(ARObjectScanningConfiguration.GetSupportedVideoFormats(), "ARObjectScanningConfiguration");
 }
Ejemplo n.º 11
0
 public void CreateTooMany()
 {
     TestRuntime.AssertXcodeVersion(8, 0);
     Assert.Throws <ArgumentException> (() => new CGColorConversionInfo((CGColorConversionOptions)null, new GColorConversionInfoTriple [4]));
 }
        [Culture("en")]          // this setting depends on locale of the device according to apple docs on MACaptionAppearanceGetDisplayType, we know english works
        public void GetDisplayType()
        {
            TestRuntime.AssertXcodeVersion(5, 0, 1);

            Assert.That(MACaptionAppearance.GetDisplayType(MACaptionAppearanceDomain.Default), Is.EqualTo(MACaptionAppearanceDisplayType.Automatic).Or.EqualTo(MACaptionAppearanceDisplayType.AlwaysOn).Or.EqualTo(MACaptionAppearanceDisplayType.ForcedOnly), "Default");
        }
Ejemplo n.º 13
0
 public void MinimumSdkCheck()
 {
     TestRuntime.AssertXcodeVersion(7, 0);
 }
Ejemplo n.º 14
0
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(13, 0);
     endpoint = NWEndpoint.Create("https://microsoft.com");
 }
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(6, 0);
     TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);
     op = new CKFetchNotificationChangesOperation(token);
 }
Ejemplo n.º 16
0
        public void EnumValues_22351()
        {
            TestRuntime.AssertXcodeVersion(6, 0);

            foreach (HKCategoryTypeIdentifier value in Enum.GetValues(typeof(HKCategoryTypeIdentifier)))
            {
                switch (value)
                {
                case HKCategoryTypeIdentifier.SleepAnalysis:
                    break;

                case HKCategoryTypeIdentifier.MindfulSession:
                    if (!TestRuntime.CheckXcodeVersion(8, 0))
                    {
                        continue;
                    }
                    break;

                case HKCategoryTypeIdentifier.HighHeartRateEvent:
                case HKCategoryTypeIdentifier.LowHeartRateEvent:
                case HKCategoryTypeIdentifier.IrregularHeartRhythmEvent:
                    if (!TestRuntime.CheckXcodeVersion(10, 2))
                    {
                        continue;
                    }
                    break;

                case HKCategoryTypeIdentifier.AudioExposureEvent:
                case HKCategoryTypeIdentifier.ToothbrushingEvent:
                    if (!TestRuntime.CheckXcodeVersion(11, 0))
                    {
                        continue;
                    }
                    break;

#if !__WATCHOS__
                case HKCategoryTypeIdentifier.AbdominalCramps:
                case HKCategoryTypeIdentifier.Acne:
                case HKCategoryTypeIdentifier.AppetiteChanges:
                case HKCategoryTypeIdentifier.GeneralizedBodyAche:
                case HKCategoryTypeIdentifier.Bloating:
                case HKCategoryTypeIdentifier.BreastPain:
                case HKCategoryTypeIdentifier.ChestTightnessOrPain:
                case HKCategoryTypeIdentifier.Chills:
                case HKCategoryTypeIdentifier.Constipation:
                case HKCategoryTypeIdentifier.Coughing:
                case HKCategoryTypeIdentifier.Diarrhea:
                case HKCategoryTypeIdentifier.Dizziness:
                case HKCategoryTypeIdentifier.Fainting:
                case HKCategoryTypeIdentifier.Fatigue:
                case HKCategoryTypeIdentifier.Fever:
                case HKCategoryTypeIdentifier.Headache:
                case HKCategoryTypeIdentifier.Heartburn:
                case HKCategoryTypeIdentifier.HotFlashes:
                case HKCategoryTypeIdentifier.LowerBackPain:
                case HKCategoryTypeIdentifier.LossOfSmell:
                case HKCategoryTypeIdentifier.LossOfTaste:
                case HKCategoryTypeIdentifier.MoodChanges:
                case HKCategoryTypeIdentifier.Nausea:
                case HKCategoryTypeIdentifier.PelvicPain:
                case HKCategoryTypeIdentifier.RapidPoundingOrFlutteringHeartbeat:
                case HKCategoryTypeIdentifier.RunnyNose:
                case HKCategoryTypeIdentifier.ShortnessOfBreath:
                case HKCategoryTypeIdentifier.SinusCongestion:
                case HKCategoryTypeIdentifier.SkippedHeartbeat:
                case HKCategoryTypeIdentifier.SleepChanges:
                case HKCategoryTypeIdentifier.SoreThroat:
                case HKCategoryTypeIdentifier.Vomiting:
                case HKCategoryTypeIdentifier.Wheezing:
                    if (!TestRuntime.CheckXcodeVersion(11, 6))
                    {
                        continue;
                    }
                    break;
#endif
                default:
                    if (!TestRuntime.CheckXcodeVersion(7, 0))
                    {
                        continue;
                    }
                    break;
                }

                try {
                    using (var ct = HKCategoryType.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);
                }
            }
        }
 public void Init() => TestRuntime.AssertXcodeVersion(10, 0);
Ejemplo n.º 18
0
 public void Setup() => TestRuntime.AssertXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch);
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(9, 0);
     descriptor = new MTLPipelineBufferDescriptor();
 }
 public void EnumerateResolutionReportsTest()
 {
     TestRuntime.AssertXcodeVersion(13, 0);
 }
Ejemplo n.º 21
0
 public void MinimumSdkCheck()
 {
     TestRuntime.AssertXcodeVersion(8, 0);
     // The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
     TestRuntime.AssertSystemVersion(PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
 }
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(9, 0);
     reference = new MTLTextureReferenceType();
 }
Ejemplo n.º 23
0
        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;

            // 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)}");
                }
            }


#if __MACOS__
            string metal_code          = File.ReadAllText(Path.Combine(NSBundle.MainBundle.ResourcePath, "metal-sample.metal"));
            string metallib_path       = Path.Combine(NSBundle.MainBundle.ResourcePath, "default.metallib");
            string fragmentshader_path = Path.Combine(NSBundle.MainBundle.ResourcePath, "fragmentShader.metallib");
#else
            string metal_code          = File.ReadAllText(Path.Combine(NSBundle.MainBundle.BundlePath, "metal-sample.metal"));
            string metallib_path       = Path.Combine(NSBundle.MainBundle.BundlePath, "default.metallib");
            string fragmentshader_path = Path.Combine(NSBundle.MainBundle.BundlePath, "fragmentShader.metallib");

            if (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)) {
                // 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");
            }

            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))
                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__
                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__
                        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");
                }
        }
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(9, 0);
     descriptor = new MTLTileRenderPipelineDescriptor();
 }
Ejemplo n.º 25
0
 static void RequiresIos8()
 {
     TestRuntime.AssertXcodeVersion(6, 0);
 }
Ejemplo n.º 26
0
        public void Fields()
        {
            TestRuntime.AssertXcodeVersion(4, 5);

            Assert.That(PKPass.ErrorDomain.ToString(), Is.EqualTo("PKPassKitErrorDomain"), "ErrorDomain");
        }
Ejemplo n.º 27
0
 public void SetUp()
 {
     TestRuntime.AssertXcodeVersion(13, 0);
 }
Ejemplo n.º 28
0
        public void CreateDataTaskAsync()
        {
            TestRuntime.AssertXcodeVersion(5, 0);

            NSUrlSession session = NSUrlSession.SharedSession;
            var          url     = new NSUrl("https://www.microsoft.com");
            var          tmpfile = Path.GetTempFileName();

            File.WriteAllText(tmpfile, "TMPFILE");
            var file_url  = NSUrl.FromFilename(tmpfile);
            var file_data = NSData.FromFile(tmpfile);
            var request   = new NSUrlRequest(url);

            var completed = false;
            var timeout   = 30;

            /* CreateDataTask */
            completed = false;
            Assert.IsTrue(TestRuntime.RunAsync(DateTime.Now.AddSeconds(timeout), async() => {
                await session.CreateDataTaskAsync(request);
                completed = true;
            }, () => completed), "CreateDataTask a");

            completed = false;
            Assert.IsTrue(TestRuntime.RunAsync(DateTime.Now.AddSeconds(timeout), async() => {
                await session.CreateDataTaskAsync(url);
                completed = true;
            }, () => completed), "CreateDataTask b");

            /* CreateDownloadTask */
            completed = false;
            Assert.IsTrue(TestRuntime.RunAsync(DateTime.Now.AddSeconds(timeout), async() => {
                await session.CreateDownloadTaskAsync(request);
                completed = true;
            }, () => completed), "CreateDownloadTask a");


            completed = false;
            Assert.IsTrue(TestRuntime.RunAsync(DateTime.Now.AddSeconds(timeout), async() => {
                await session.CreateDownloadTaskAsync(url);
                completed = true;
            }, () => completed), "CreateDownloadTask b");

            /* CreateUploadTask */
            completed = false;
            Assert.IsTrue(TestRuntime.RunAsync(DateTime.Now.AddSeconds(timeout), async() => {
                try {
                    var uploadRequest        = new NSMutableUrlRequest(url);
                    uploadRequest.HttpMethod = "POST";
                    await session.CreateUploadTaskAsync(uploadRequest, file_url);
                } catch /* (Exception ex) */ {
//					Console.WriteLine ("Ex: {0}", ex);
                } finally {
                    completed = true;
                }
            }, () => completed), "CreateUploadTask a");

            completed = false;
            Assert.IsTrue(TestRuntime.RunAsync(DateTime.Now.AddSeconds(timeout), async() => {
                try {
                    var uploadRequest        = new NSMutableUrlRequest(url);
                    uploadRequest.HttpMethod = "POST";
                    await session.CreateUploadTaskAsync(uploadRequest, file_data);
                } catch /* (Exception ex) */ {
//					Console.WriteLine ("Ex: {0}", ex);
                } finally {
                    completed = true;
                }
            }, () => completed), "CreateUploadTask b");
        }
Ejemplo n.º 29
0
 public void Setup()
 {
     TestRuntime.AssertXcodeVersion(12, 0);
     // The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check
     TestRuntime.AssertSystemVersion(ApplePlatform.MacCatalyst, 14, 0, throwIfOtherPlatform: false);
 }
Ejemplo n.º 30
0
 public void MinimumSdkCheck()
 {
     TestRuntime.AssertXcodeVersion(7, 0);
     TestRuntime.RequestContactsPermission();
 }