예제 #1
0
        public void CameraMaker()
        {
            // since only Canon and Nikon have dictionary key values I assume the others are "placeholder" at the moment !?!
            Assert.NotNull(CGImageProperties.MakerCanonDictionary, "MakerCanonDictionary");
            Assert.NotNull(CGImageProperties.MakerNikonDictionary, "MakerNikonDictionary");

            // iOS 8.3 finally fixed them :)
            if (TestRuntime.CheckiOSSystemVersion(8, 3))
            {
                Assert.NotNull(CGImageProperties.MakerMinoltaDictionary, "MakerMinoltaDictionary");
                Assert.NotNull(CGImageProperties.MakerFujiDictionary, "MakerFujiDictionary");
                Assert.NotNull(CGImageProperties.MakerOlympusDictionary, "MakerOlympusDictionary");
                Assert.NotNull(CGImageProperties.MakerPentaxDictionary, "MakerPentaxDictionary");
                return;
            }

            // documented as new in iOS 4.0 - https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGImageProperties_Reference/Reference/reference.html
            // but symbols are not available in iOS 5.1.1
            // this test will fail if Apple decide to include them in the future
            IntPtr lib = Dlfcn.dlopen(Constants.ImageIOLibrary, 0);

            try {
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerMinoltaDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerMinoltaDictionary");
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerFujiDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerFujiDictionary");
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerOlympusDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerOlympusDictionary");
                Assert.That(Dlfcn.dlsym(lib, "kCGImagePropertyMakerPentaxDictionary"), Is.EqualTo(IntPtr.Zero), "kCGImagePropertyMakerPentaxDictionary");
            }
            finally {
                Dlfcn.dlclose(lib);
            }
        }
예제 #2
0
        public void EnumValues_22351()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(8, 0))
            {
                Assert.Inconclusive("Requires iOS8+");
            }

            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.CheckiOSSystemVersion(9, 0))
                    {
                        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);
                }
            }
        }
예제 #3
0
        public void NullFonts()
        {
            var invalidFontName = new NSString("Invalid Font Name");

            if (TestRuntime.CheckiOSSystemVersion(7, 0))
            {
                Assert.IsNotNull(UIFont.GetPreferredFontForTextStyle(invalidFontName), "GetPreferredFontForTextStyle");
                Assert.IsNotNull(UIFont.FromDescriptor(new UIFontDescriptor(), -2), "FromDescriptor (,)");
            }

            Assert.IsNull(UIFont.FromName(invalidFontName, 1), "FromName");

            Assert.IsNotNull(UIFont.SystemFontOfSize(-3), "SystemFontOfSize()");

            if (TestRuntime.CheckiOSSystemVersion(8, 2))
            {
                Assert.IsNotNull(UIFont.SystemFontOfSize(0, UIFontWeight.Regular), "SystemFontOfSize (nfloat, UIFontWeight)");
                Assert.IsNotNull(UIFont.SystemFontOfSize(0, (nfloat)0), "SystemFontOfSize (nfloat, nfloat)");
            }

            Assert.IsNotNull(UIFont.BoldSystemFontOfSize(-4), "BoldSystemFontOfSize");
            Assert.IsNotNull(UIFont.ItalicSystemFontOfSize(-5), "ItalicSystemFontOfSize");

            using (var font = UIFont.SystemFontOfSize(12)) {
                Assert.IsNotNull(font.WithSize(-6), "WithSize");
            }
        }
 public void MinimumSdkCheck()
 {
     if (!TestRuntime.CheckiOSSystemVersion(9, 0))
     {
         Assert.Inconclusive("Requires 9.0+");
     }
 }
        public void EnumValues_22351()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(8, 0))
            {
                Assert.Inconclusive("Requires iOS8+");
            }

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

                default:
                    if (!TestRuntime.CheckiOSSystemVersion(9, 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);
                }
            }
        }
예제 #6
0
        public void GenerateKeyPairTooLargeRSA()
        {
            SecKey private_key;
            SecKey public_key;

            using (var record = new SecRecord(SecKind.Key)) {
                record.KeyType = SecKeyType.RSA;
                // maximum documented as 2048, .NET maximum is 16384
                record.KeySizeInBits = 16384;
                Assert.That(SecKey.GenerateKeyPair(record.ToDictionary(), out public_key, out private_key), Is.EqualTo(SecStatusCode.Param), "16384");
                record.KeySizeInBits = 8192;
                if (TestRuntime.CheckiOSSystemVersion(9, 0))
                {
                    // It seems iOS 9 supports 8192, but it takes a long time to generate (~40 seconds on my iPad Air 2), so skip it.
//					Assert.That (SecKey.GenerateKeyPair (record.ToDictionary (), out public_key, out private_key), Is.EqualTo (SecStatusCode.Success), "8192");
                }
                else
                {
                    Assert.That(SecKey.GenerateKeyPair(record.ToDictionary(), out public_key, out private_key), Is.EqualTo(SecStatusCode.Param), "8192");
                }
            }

            /* On iOS 7.1 the device console logs will show:
             *
             * Mar 18 08:27:30 Mercure monotouchtest[1397] <Warning>:  SecRSAPrivateKeyInit Invalid or missing key size in: {
             *      bsiz = 16384;
             *      class = keys;
             *      type = 42;
             *  }
             * Mar 18 08:27:30 Mercure monotouchtest[1397] <Warning>:  SecKeyCreate init RSAPrivateKey key: -50
             */
        }
예제 #7
0
        public void DownloadDataAsync()
        {
            if (!TestRuntime.CheckiOSSystemVersion(7, 0))
            {
                Assert.Inconclusive("NSUrlSession is iOS7+");
            }

            bool completed        = false;
            int  failed_iteration = -1;

            TestRuntime.RunAsync(DateTime.Now.AddSeconds(30), async() => {
                for (int i = 0; i < 5; i++)
                {
                    // Use the default configuration so we can make use of the shared cookie storage.
                    var session = NSUrlSession.FromConfiguration(NSUrlSessionConfiguration.DefaultSessionConfiguration);

                    var downloadUri      = new Uri("https://google.com");
                    var downloadResponse = await session.CreateDownloadTaskAsync(downloadUri);

                    var tempLocation = downloadResponse.Location;
                    if (!File.Exists(tempLocation.Path))
                    {
                        Console.WriteLine("#{1} {0} does not exists", tempLocation, i);
                        failed_iteration = i;
                        break;
                    }
                }
                completed = true;
            }, () => completed);

            Assert.AreEqual(-1, failed_iteration, "Failed");
        }
 public void InitWithTerm()
 {
     if (Runtime.Arch == Arch.DEVICE && TestRuntime.CheckiOSSystemVersion(9, 0))
     {
         Assert.Ignore("crash on iOS9 devices");
     }
     using (UIReferenceLibraryViewController rlvc = new UIReferenceLibraryViewController("Mono")) {
     }
 }
예제 #9
0
 public void ToString_()
 {
     using (CFUrl url = CFUrl.FromFile("/")) {
         string value = TestRuntime.CheckiOSSystemVersion(7, 0, false) ? "file:///" : "file://localhost/";
         Assert.That(url.ToString(), Is.EqualTo(value), "FromFile");
     }
     using (CFUrl url = CFUrl.FromUrlString("/", null)) {
         Assert.That(url.ToString(), Is.EqualTo("/"), "FromUrlString");
     }
 }
예제 #10
0
        public void Remainder()
        {
            MKMapRect rect = new MKMapRect();

            Assert.False(rect.Spans180thMeridian, "default");
            MKMapRect remainder = rect.Remainder();

            Assert.True(remainder.IsNull, "IsNull");

            rect = new MKMapRect(-90, -90, 90, 90);
            Assert.That(rect.Spans180thMeridian, Is.EqualTo(!TestRuntime.CheckiOSSystemVersion(7, 1)), rect.ToString());
            remainder = rect.Remainder();
            Assert.That(remainder.ToString(), Is.EqualTo(@"{{268435366, -90}, {90, 90}}"), "remainder");
        }
예제 #11
0
        public void FromPNG()
        {
            string file = Path.Combine(NSBundle.MainBundle.ResourcePath, "basn3p08.png");

            using (var dp = new CGDataProvider(file))
                using (var img = CGImage.FromPNG(dp, null, false, CGColorRenderingIntent.Default))
                    using (var ui = new UIImage(img, 1.0f, UIImageOrientation.Up)) {
                        Assert.IsNotNull(ui.CGImage, "CGImage");

                        if (TestRuntime.CheckiOSSystemVersion(9, 0))
                        {
                            Assert.That(img.UTType.ToString(), Is.EqualTo("public.png"), "UTType");
                        }
                    }
        }
예제 #12
0
        public void Exceptions()
        {
            var data = NSData.FromString("dummy string");

            if (TestRuntime.CheckiOSSystemVersion(9, 0))
            {
                // iOS9 does not throw if it cannot get correct data, it simply returns null (much better)
                Assert.Null(NSKeyedUnarchiver.UnarchiveFile(Path.Combine(NSBundle.MainBundle.ResourcePath, "basn3p08.png")), "UnarchiveFile");
                Assert.Null(NSKeyedUnarchiver.UnarchiveObject(data), "UnarchiveObject");
            }
            else
            {
                Assert.Throws <MonoTouchException> (() => NSKeyedUnarchiver.UnarchiveFile(Path.Combine(NSBundle.MainBundle.ResourcePath, "basn3p08.png")), "UnarchiveFile");
                Assert.Throws <MonoTouchException> (() => NSKeyedUnarchiver.UnarchiveObject(data), "UnarchiveObject");
            }
        }
예제 #13
0
        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);

            if ((Runtime.Arch == Arch.DEVICE) && TestRuntime.CheckiOSSystemVersion(9, 0))
            {
                // Apple is doing some funky stuff with dlopen... this condition is to track if this change during betas
                Assert.That(err, Is.EqualTo(-1), "dlclose");
            }
            else
            {
                Assert.That(err, Is.EqualTo(0), "dlclose");
            }
        }
예제 #14
0
        public void Trust_FullChain()
        {
            X509CertificateCollection certs = new X509CertificateCollection();

            certs.Add(new X509Certificate(CertificateTest.mail_google_com));
            certs.Add(new X509Certificate(CertificateTest.thawte_sgc_ca));
            certs.Add(new X509Certificate(CertificateTest.verisign_class3_root));
            using (var policy = SecPolicy.CreateSslPolicy(true, "mail.google.com"))
                using (var trust = new SecTrust(certs, 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));
                    // iOS9 is not fully happy with the basic constraints: `SecTrustEvaluate  [root AnchorTrusted BasicContraints]`
                    var ios9   = TestRuntime.CheckiOSSystemVersion(9, 0);
                    var result = Evaluate(trust, ios9);
                    Assert.That(result, Is.EqualTo(ios9 ? SecTrustResult.RecoverableTrustFailure : SecTrustResult.Unspecified), "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.CheckSystemAndSDKVersion(7, 0))
                    {
                        Assert.That(trust.GetTrustResult(), Is.EqualTo(ios9 ? SecTrustResult.RecoverableTrustFailure : SecTrustResult.Unspecified), "GetTrustResult");

                        trust.SetAnchorCertificates(certs);
                        Assert.That(trust.GetCustomAnchorCertificates().Length, Is.EqualTo(certs.Count), "GetCustomAnchorCertificates");

                        // since we modified the `trust` instance it's result was invalidated
                        Assert.That(trust.GetTrustResult(), Is.EqualTo(SecTrustResult.Invalid), "GetTrustResult");
                    }
                }
        }
예제 #15
0
        public void GetGlobalQueue_Priority()
        {
            string qdefault, qlow, qhigh;

            if (TestRuntime.CheckiOSSystemVersion(8, 0, false))
            {
                qdefault = "com.apple.root.default-qos";
                qlow     = "com.apple.root.utility-qos";
                qhigh    = "com.apple.root.user-initiated-qos";
            }
            else
            {
                qdefault = "com.apple.root.default-priority";
                qlow     = "com.apple.root.low-priority";
                qhigh    = "com.apple.root.high-priority";
            }
            Assert.That(DispatchQueue.GetGlobalQueue(DispatchQueuePriority.Default).Label, Is.EqualTo(qdefault), "Default");
            Assert.That(DispatchQueue.GetGlobalQueue(DispatchQueuePriority.Low).Label, Is.EqualTo(qlow), "Low");
            Assert.That(DispatchQueue.GetGlobalQueue(DispatchQueuePriority.High).Label, Is.EqualTo(qhigh), "High");
        }
예제 #16
0
 public void Https()
 {
     using (var ps = new NSUrlProtectionSpace("mail.google.com", 443, NSUrlProtectionSpace.HTTPS, null, NSUrlProtectionSpace.AuthenticationMethodHTTPBasic)) {
         if (TestRuntime.CheckiOSSystemVersion(9, 0))
         {
             Assert.That(ps.AuthenticationMethod, Is.EqualTo("NSURLAuthenticationMethodHTTPBasic"), "AuthenticationMethod");
         }
         else
         {
             Assert.That(ps.AuthenticationMethod, Is.EqualTo("NSURLAuthenticationMethodDefault"), "AuthenticationMethod");
         }
         Assert.Null(ps.DistinguishedNames, "DistinguishedNames");
         Assert.That(ps.Host, Is.EqualTo("mail.google.com"), "Host");
         Assert.False(ps.IsProxy, "IsProxy");
         Assert.That(ps.Port, Is.EqualTo((nint)443), "Port");
         Assert.That(ps.Protocol, Is.EqualTo("https"), "Protocol");
         Assert.Null(ps.ProxyType, "ProxyType");
         Assert.Null(ps.Realm, "Realm");
         Assert.True(ps.ReceivesCredentialSecurely, "ReceivesCredentialSecurely");
         Assert.Null(ps.ServerSecTrust, "ServerSecTrust");
     }
 }
예제 #17
0
        public void Trust_NoRoot()
        {
            X509CertificateCollection certs = new X509CertificateCollection();

            certs.Add(new X509Certificate(CertificateTest.mail_google_com));
            certs.Add(new X509Certificate(CertificateTest.thawte_sgc_ca));
            using (var policy = SecPolicy.CreateSslPolicy(true, "mail.google.com"))
                using (var trust = new SecTrust(certs, 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));
                    // iOS9 is not fully happy with the basic constraints: `SecTrustEvaluate  [root AnchorTrusted BasicContraints]`
                    // so it returns RecoverableTrustFailure and that affects the Count of trust later (it does not add to what we provided)
                    var ios9   = TestRuntime.CheckiOSSystemVersion(9, 0);
                    var result = Evaluate(trust, ios9);
                    Assert.That(result, Is.EqualTo(ios9 ? SecTrustResult.RecoverableTrustFailure : SecTrustResult.Unspecified), "Evaluate");
                    // Evalute must be called prior to Count (Apple documentation)
                    Assert.That(trust.Count, Is.EqualTo(ios9 ? 2 : 3), "Count");

                    using (SecKey pkey = trust.GetPublicKey()) {
                        Assert.That(CFGetRetainCount(pkey.Handle), Is.EqualTo((nint)2), "RetainCount(pkey)");
                    }
                }
        }
예제 #18
0
        public void Fields()
        {
            // documented as new in iOS 5.0 - https://developer.apple.com/library/ios/DOCUMENTATION/CoreLocation/Reference/CoreLocationConstantsRef/CoreLocationConstantsRef.pdf
            // in PDF only, not in the HTML documentation - but it's also inside CLError.h
            // this test will fail if Apple decide to include them in the future
            IntPtr lib = Dlfcn.dlopen(Constants.CoreLocationLibrary, 0);

            try {
                string field = "kCLErrorUserInfoAlternateRegionKey";
                var    p     = Dlfcn.dlsym(lib, field);
                if (TestRuntime.CheckiOSSystemVersion(7, 1))
                {
                    Assert.That(p, Is.Not.EqualTo(IntPtr.Zero), field);
                }
                else
                {
                    Assert.That(p, Is.EqualTo(IntPtr.Zero), field);
                }
            }
            finally {
                Dlfcn.dlclose(lib);
            }
        }
예제 #19
0
        public void Match()
        {
            var rec = new SecRecord(SecKind.GenericPassword)
            {
                Account = "Username",
            };

            Assert.Null(rec.MatchIssuers, "MatchIssuers");
            // we do not have a way (except the getter) to craete SecKeyChain instances
            Assert.Null(rec.MatchItemList, "MatchItemList");

            using (var data = new NSData()) {
                rec.MatchIssuers = new NSData[] { data };
                Assert.AreSame(rec.MatchIssuers [0], data, "MatchIssuers [0]");
            }

            if (!TestRuntime.CheckiOSSystemVersion(9, 0))
            {
                return;
            }
            Assert.That(rec.AuthenticationUI, Is.EqualTo(SecAuthenticationUI.NotSet), "AuthenticationUI-get");
            rec.AuthenticationUI = SecAuthenticationUI.Allow;
            Assert.That(rec.AuthenticationUI, Is.EqualTo(SecAuthenticationUI.Allow), "AuthenticationUI-set");
        }
예제 #20
0
        public void NSStringConstants()
        {
            Assert.NotNull(UTType.ExportedTypeDeclarationsKey, "ExportedTypeDeclarationsKey");
            Assert.NotNull(UTType.ImportedTypeDeclarationsKey, "ImportedTypeDeclarationsKey");
            Assert.NotNull(UTType.IdentifierKey, "IdentifierKey");
            Assert.NotNull(UTType.TagSpecificationKey, "TagSpecificationKey");
            Assert.NotNull(UTType.ConformsToKey, "ConformsToKey");
            Assert.NotNull(UTType.DescriptionKey, "DescriptionKey");
            Assert.NotNull(UTType.IconFileKey, "IconFileKey");
            Assert.NotNull(UTType.ReferenceURLKey, "ReferenceURLKey");
            Assert.NotNull(UTType.VersionKey, "VersionKey");

            Assert.NotNull(UTType.TagClassFilenameExtension, "TagClassFilenameExtension");
            Assert.NotNull(UTType.TagClassMIMEType, "TagClassMIMEType");

            Assert.NotNull(UTType.Item, "Item");
            Assert.NotNull(UTType.Content, "Content");
            Assert.NotNull(UTType.CompositeContent, "CompositeContent");
            Assert.NotNull(UTType.Application, "Application");
            Assert.NotNull(UTType.Message, "Message");
            Assert.NotNull(UTType.Contact, "Contact");
            Assert.NotNull(UTType.Archive, "Archive");
            Assert.NotNull(UTType.DiskImage, "DiskImage");

            Assert.NotNull(UTType.Data, "Data");
            Assert.NotNull(UTType.Directory, "Directory");
            Assert.NotNull(UTType.Resolvable, "Resolvable");
            Assert.NotNull(UTType.SymLink, "SymLink");
            Assert.NotNull(UTType.MountPoint, "MountPoint");
            Assert.NotNull(UTType.AliasFile, "AliasFile");
            Assert.NotNull(UTType.AliasRecord, "AliasRecord");
            Assert.NotNull(UTType.URL, "URL");
            Assert.NotNull(UTType.FileURL, "FileURL");

            Assert.NotNull(UTType.Text, "Text");
            Assert.NotNull(UTType.PlainText, "PlainText");
            Assert.NotNull(UTType.UTF8PlainText, "UTF8PlainText");
            Assert.NotNull(UTType.UTF16ExternalPlainText, "UTF16ExternalPlainText");
            Assert.NotNull(UTType.UTF16PlainText, "UTF16PlainText");
            Assert.NotNull(UTType.RTF, "RTF");
            Assert.NotNull(UTType.HTML, "HTML");
            Assert.NotNull(UTType.XML, "XML");
            Assert.NotNull(UTType.SourceCode, "SourceCode");
            Assert.NotNull(UTType.CSource, "CSource");
            Assert.NotNull(UTType.ObjectiveCSource, "ObjectiveCSource");
            Assert.NotNull(UTType.CPlusPlusSource, "CPlusPlusSource");
            Assert.NotNull(UTType.ObjectiveCPlusPlusSource, "ObjectiveCPlusPlusSource");
            Assert.NotNull(UTType.CHeader, "CHeader");
            Assert.NotNull(UTType.CPlusPlusHeader, "CPlusPlusHeader");
            Assert.NotNull(UTType.JavaSource, "JavaSource");

            Assert.NotNull(UTType.PDF, "PDF");
            Assert.NotNull(UTType.RTFD, "RTFD");
            Assert.NotNull(UTType.FlatRTFD, "FlatRTFD");
            Assert.NotNull(UTType.TXNTextAndMultimediaData, "TXNTextAndMultimediaData");
            Assert.NotNull(UTType.WebArchive, "WebArchive");

            Assert.NotNull(UTType.Image, "Image");
            Assert.NotNull(UTType.JPEG, "JPEG");
            Assert.NotNull(UTType.JPEG2000, "JPEG2000");
            Assert.NotNull(UTType.TIFF, "TIFF");
            Assert.NotNull(UTType.GIF, "GIF");
            Assert.NotNull(UTType.PNG, "PNG");
            Assert.NotNull(UTType.QuickTimeImage, "QuickTimeImage");
            Assert.NotNull(UTType.AppleICNS, "AppleICNS");
            Assert.NotNull(UTType.BMP, "BMP");
            Assert.NotNull(UTType.ICO, "ICO");

            Assert.NotNull(UTType.AudiovisualContent, "AudiovisualContent");
            Assert.NotNull(UTType.Movie, "Movie");
            Assert.NotNull(UTType.Video, "Video");
            Assert.NotNull(UTType.Audio, "Audio");
            Assert.NotNull(UTType.QuickTimeMovie, "QuickTimeMovie");
            Assert.NotNull(UTType.MPEG, "MPEG");
            Assert.NotNull(UTType.MPEG4, "MPEG4");
            Assert.NotNull(UTType.MP3, "MP3");
            Assert.NotNull(UTType.MPEG4Audio, "MPEG4Audio");
            Assert.NotNull(UTType.AppleProtectedMPEG4Audio, "AppleProtectedMPEG4Audio");

            Assert.NotNull(UTType.Folder, "Folder");
            Assert.NotNull(UTType.Volume, "Volume");
            Assert.NotNull(UTType.Package, "Package");
            Assert.NotNull(UTType.Bundle, "Bundle");
            Assert.NotNull(UTType.Framework, "Framework");

            Assert.NotNull(UTType.ApplicationBundle, "ApplicationBundle");
            Assert.NotNull(UTType.ApplicationFile, "ApplicationFile");

            Assert.NotNull(UTType.VCard, "VCard");

            Assert.NotNull(UTType.InkText, "InkText");

            if (TestRuntime.CheckiOSSystemVersion(9, 0))
            {
                Assert.NotNull(UTType.SwiftSource, "SwiftSource");
            }
        }
예제 #21
0
        public void Default()
        {
            var qname = TestRuntime.CheckiOSSystemVersion(8, 0, false) ? "com.apple.root.default-qos" : "com.apple.root.default-priority";

            Assert.That(DispatchQueue.DefaultGlobalQueue.Label, Is.EqualTo(qname), "Default");
        }
예제 #22
0
        public void FinalizationRaceCondition()
        {
            if ((IntPtr.Size == 8) && TestRuntime.CheckiOSSystemVersion(9, 0))
            {
                Assert.Ignore("NSString retainCount is nuint.MaxValue, so we won't collect them");
            }

            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));
        }
        public void Default_Properties()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(7, 0))
            {
                Assert.Inconclusive("requires iOS7");
            }

            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:

            if (TestRuntime.CheckiOSSystemVersion(8, 0))
            {
                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:

            Assert.That(config.TLSMaximumSupportedProtocol, Is.EqualTo(SslProtocol.Tls_1_2), "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:

            if (TestRuntime.CheckiOSSystemVersion(8, 0))
            {
                Assert.NotNull(config.WeakProtocolClasses, "protocolClasses");
            }
            else
            {
                Assert.Null(config.WeakProtocolClasses, "protocolClasses");
            }
            config.WeakProtocolClasses = config.WeakProtocolClasses;             // setProtocolClasses:
        }