public void Ctor_3b_Null() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Inconclusive("Requires iOS7 or later"); } using (UIImage img = new UIImage()) { using (UITabBarItem tbi1 = new UITabBarItem(null, null, null)) { Assert.Null(tbi1.Title, "Title-1a"); Assert.Null(tbi1.Image, "Image-1a"); Assert.Null(tbi1.SelectedImage, "SelectedImage-1a"); } using (UITabBarItem tbi2 = new UITabBarItem("title", img, null)) { Assert.That(tbi2.Title, Is.EqualTo("title"), "Title-2a"); Assert.AreSame(tbi2.Image, img, "Image-2a"); // if not supplied Image is reused Assert.AreSame(tbi2.SelectedImage, img, "SelectedImage-2a"); } using (UITabBarItem tbi3 = new UITabBarItem(null, null, img)) { Assert.Null(tbi3.Title, "Title-3a"); Assert.Null(tbi3.Image, "Image-3a"); // looks like a select-only image is not something allowed on 7.1 if (UIDevice.CurrentDevice.CheckSystemVersion(7, 1)) { Assert.Null(tbi3.SelectedImage, "SelectedImage-3a"); } else { Assert.AreSame(tbi3.SelectedImage, img, "SelectedImage-3a"); } } } }
public void VersionCheck() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Inconclusive("requires iOS7+"); } }
void CheckEmpty(MKPolyline pl) { // MKAnnotation Assert.That(pl.Coordinate.Longitude, Is.NaN, "Coordinate.Longitude"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.That(pl.Coordinate.Latitude, Is.EqualTo(-90f), "Coordinate.Latitude"); } else { Assert.That(pl.Coordinate.Latitude, Is.NaN, "Coordinate.Latitude"); } Assert.Null(pl.Title, "Title"); Assert.Null(pl.Subtitle, "Subtitle"); // MKOverlay Assert.True(Double.IsPositiveInfinity(pl.BoundingMapRect.Origin.X), "BoundingMapRect.Origin.X"); Assert.True(Double.IsPositiveInfinity(pl.BoundingMapRect.Origin.Y), "BoundingMapRect.Origin.Y"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.That(pl.BoundingMapRect.Size.Height, Is.EqualTo(0.0f), "BoundingMapRect.Size.Height"); Assert.That(pl.BoundingMapRect.Size.Width, Is.EqualTo(0.0f), "BoundingMapRect.Size.Width"); } else { Assert.True(Double.IsNegativeInfinity(pl.BoundingMapRect.Size.Height), "BoundingMapRect.Size.Height"); Assert.True(Double.IsNegativeInfinity(pl.BoundingMapRect.Size.Width), "BoundingMapRect.Size.Width"); } Assert.False(pl.Intersects(pl.BoundingMapRect), "Intersect/Self"); MKMapRect rect = new MKMapRect(0, 0, 0, 0); Assert.False(pl.Intersects(rect), "Intersect/Empty"); ShapeTest.CheckShape(pl); }
public void FetchResultObjectsAt() { if (!TestRuntime.CheckSystemAndSDKVersion(8, 0)) { Assert.Inconclusive("Requires iOS8 or later"); } if (ALAssetsLibrary.AuthorizationStatus != ALAuthorizationStatus.Authorized) { Assert.Inconclusive("Requires access to the photo library"); } var collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null); if (collection.Count == 0) { XamagramImage.Image.SaveToPhotosAlbum(null); collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null); } // Actual Test var obj = collection.ObjectsAt <NSObject> (NSIndexSet.FromNSRange(new NSRange(0, 1))); Assert.That(obj != null && obj.Count() > 0); }
void Check(GKLeaderboard lb) { #if !__TVOS__ Assert.Null(lb.Category, "Category"); #endif if (TestRuntime.CheckSystemAndSDKVersion(6, 0)) { Assert.Null(lb.GroupIdentifier, "GroupIdentifier"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Null(lb.Identifier, "Identifier"); } } Assert.Null(lb.LocalPlayerScore, "LocalPlayerScore"); Assert.That(lb.MaxRange, Is.EqualTo((nint)0), "MaxRange"); Assert.That(lb.PlayerScope, Is.EqualTo(GKLeaderboardPlayerScope.Global), "PlayerScope"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { // depending on the ctor 1,10 (or 0,0) is returned before iOS7 - but 1,25 is documented (in iOS7) Assert.That(lb.Range.Location, Is.EqualTo((nint)1), "Range.Location"); Assert.That(lb.Range.Length, Is.EqualTo((nint)25), "Range.Length"); } Assert.Null(lb.Scores, "Scores"); Assert.That(lb.TimeScope, Is.EqualTo(GKLeaderboardTimeScope.AllTime), "TimeScope"); Assert.Null(lb.Title, "Title"); }
public void Trust_Leaf_Only() { X509Certificate x = new X509Certificate(CertificateTest.mail_google_com); using (var policy = SecPolicy.CreateSslPolicy(true, "mail.google.com")) using (var trust = new SecTrust(x, 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 Assert.That(Evaluate(trust, true), Is.EqualTo(SecTrustResult.RecoverableTrustFailure), "Evaluate"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { 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 Atlas_MissingResource() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("Requires iOS7"); } using (var atlas = new SKTextureAtlas()) { // that returns a texture, calling 'MissingResource.png' (128 x 128) using (var texture = atlas.TextureNamed("ship")) { // this completionHandler is *NOT* optional -> crash if null SKTexture.PreloadTextures(new [] { texture }, CrashAvoider); // this completionHandler is *NOT* optional -> crash if null texture.Preload(CrashAvoider); Assert.That(texture.FilteringMode, Is.EqualTo(SKTextureFilteringMode.Linear), "FilteringMode"); // FIXME: bug in iOS9 - it will randomly return 0,0 (but almost always on the first try) if (!UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { Assert.That(texture.Size, Is.EqualTo(new SizeF(128, 128)), "Size"); } Assert.That(texture.TextureRect, Is.EqualTo(new RectangleF(0, 0, 1, 1)), "TextureRect"); Assert.False(texture.UsesMipmaps, "UsesMipmaps"); } } }
public void ExportTest() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("requires iOS7+"); } if (RegistrarTest.CurrentRegistrar != Registrars.Static) { Assert.Ignore("Exporting protocols to JavaScriptCore requires the static registrar."); } var context = new JSContext(); JSValue exc = null; context.ExceptionHandler = (JSContext context2, JSValue exception) => { exc = exception; }; var obj = new MyJavaExporter(); context [(NSString)"obj"] = JSValue.From(obj, context); context.EvaluateScript("obj.myFunc ();"); Assert.IsNull(exc, "JS exception"); Assert.IsTrue(obj.MyFuncCalled, "Called"); context.EvaluateScript("obj.hello (42);"); context.EvaluateScript("obj.callMeBack (function() { return 314; });"); }
public void ProcessingTap() { if (!TestRuntime.CheckSystemAndSDKVersion(6, 0)) { Assert.Inconclusive("AudioQueueProcessingTapNew requires iOS 6"); } var aq = new InputAudioQueue(AudioStreamBasicDescription.CreateLinearPCM()); AudioQueueStatus ret; bool called = false; using (var tap = aq.CreateProcessingTap( delegate(AudioQueueProcessingTap audioQueueTap, uint numberOfFrames, ref AudioTimeStamp timeStamp, ref AudioQueueProcessingTapFlags flags, AudioBuffers data) { called = true; return(33); }, AudioQueueProcessingTapFlags.PreEffects, out ret)) { Assert.AreEqual(AudioQueueStatus.Ok, ret, "#1"); unsafe { AudioQueueBuffer *buffer; Assert.AreEqual(AudioQueueStatus.Ok, aq.AllocateBuffer(5000, out buffer), "#2"); Assert.AreEqual(AudioQueueStatus.Ok, aq.EnqueueBuffer(buffer), "#3"); //Assert.AreEqual (AudioQueueStatus.Ok, aq.Start (), "#4"); } } //Assert.That (called, Is.True, "#10"); }
public void SharedManager() { if (!TestRuntime.CheckSystemAndSDKVersion(8, 0)) { Assert.Inconclusive("Requires iOS 8.0+"); } var shared = NEVpnManager.SharedManager; // https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW59 // Enabling Personal VPN (iOS Only) if (shared == null) { Assert.Inconclusive("Requires enabling Personal PVN (entitlements)"); } Assert.That(shared.Connection.Status, Is.EqualTo(NEVpnStatus.Invalid), "Connection"); Assert.False(shared.Enabled, "Enabled"); if (TestRuntime.CheckSystemAndSDKVersion(9, 0)) { Assert.AreEqual("MonoTouchTest", shared.LocalizedDescription, "LocalizedDescription"); } else { Assert.IsNull(shared.LocalizedDescription, "LocalizedDescription"); } Assert.False(shared.OnDemandEnabled, "OnDemandEnabled"); Assert.Null(shared.OnDemandRules, "OnDemandRules"); Assert.Null(shared.Protocol, "Protocol"); }
public void GetAndRemoveTest() { if (!TestRuntime.CheckSystemAndSDKVersion(9, 0)) { Assert.Ignore("Ignoring GameplayKit tests: Requires iOS9+"); } var entity = GKEntity.GetEntity(); entity.AddComponent(new NumberComponent(10)); entity.AddComponent(new NameComponent("Ten")); Assert.IsTrue(entity.Components.Length == 2, "entity.Components length must be 2"); // Test component retrieval by type var component = entity.GetComponent(typeof(NumberComponent)) as NumberComponent; Assert.NotNull(component, "Component must not be null"); Assert.IsTrue(component.Id == 10, "Component Id must be 10"); // Test component removal by type Assert.NotNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must not be null"); entity.RemoveComponent(typeof(NameComponent)); Assert.IsTrue(entity.Components.Length == 1, "entity.Components length must be 1"); Assert.IsNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must be null"); }
public void Properties() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("requires iOS7+"); } var f1 = UIFont.PreferredBody; // the same instance will be returned (from an iOS cache) var f2 = UIFont.PreferredBody; // first instance will be disposed and the 2nd one needs to stay valid SemiFactory_25511(f1, f2, "PreferredBody"); f1 = UIFont.PreferredCaption1; f2 = UIFont.PreferredCaption1; SemiFactory_25511(f1, f2, "PreferredCaption1"); f1 = UIFont.PreferredCaption2; f2 = UIFont.PreferredCaption2; SemiFactory_25511(f1, f2, "PreferredCaption2"); f1 = UIFont.PreferredFootnote; f2 = UIFont.PreferredFootnote; SemiFactory_25511(f1, f2, "PreferredFootnote"); f1 = UIFont.PreferredHeadline; f2 = UIFont.PreferredHeadline; SemiFactory_25511(f1, f2, "PreferredHeadline"); f1 = UIFont.PreferredSubheadline; f2 = UIFont.PreferredSubheadline; SemiFactory_25511(f1, f2, "PreferredSubheadline"); }
public void BoardingPass() { if (!TestRuntime.CheckSystemAndSDKVersion(6, 0)) { Assert.Inconclusive("PassKit is new in 6.0"); } using (var pass = GetBoardingPass()) { Assert.That(pass.AuthenticationToken, Is.EqualTo("vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc"), "AuthenticationToken"); #if !__WATCHOS__ Assert.NotNull(pass.Icon, "Icon"); #endif // need to ensure it's english locale Assert.That(pass.LocalizedDescription, Is.EqualTo("Skyport Boarding Pass"), "LocalizedDescription"); Assert.That(pass.LocalizedName, Is.EqualTo("Boarding Pass"), "LocalizedName"); Assert.That(pass.OrganizationName, Is.EqualTo("Skyport Airways"), "OrganizationName"); Assert.That(pass.PassTypeIdentifier, Is.EqualTo("pass.com.apple.devpubs.example"), "PassTypeIdentifier"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.That(pass.PassUrl.AbsoluteString, Is.EqualTo("shoebox://card/1UuiGnfwxHgd0G0bIuPYPNpeRX8="), "PassUrl"); } else { Assert.Null(pass.PassUrl, "PassUrl"); } Assert.That(pass.RelevantDate.SecondsSinceReferenceDate, Is.EqualTo(364688700), "RelevantDate"); Assert.That(pass.SerialNumber, Is.EqualTo("gT6zrHkaW"), "SerialNumber"); Assert.That(pass.WebServiceUrl.AbsoluteString, Is.EqualTo("https://example.com/passes/"), "WebServiceUrl"); } }
public void TintColor() { using (UITabBar tb = new UITabBar()) { // TintColor is inherited in iOS7 so it won't be null by default if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.NotNull(tb.TintColor, "1"); } else { Assert.Null(tb.TintColor, "1"); } tb.TintColor = UIColor.White; Assert.That(tb.TintColor, Is.EqualTo(UIColor.White), "2"); tb.TintColor = null; if (TestRuntime.IsTVOS) { Assert.That(tb.TintColor, Is.EqualTo(UIColor.White), "3"); } else if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.That(tb.TintColor, Is.Not.EqualTo(UIColor.White), "3"); } else { Assert.Null(tb.TintColor, "3"); } } }
public void Client_Leaf_Only() { X509Certificate x = new X509Certificate(CertificateTest.mail_google_com); using (var policy = SecPolicy.CreateSslPolicy(false, null)) using (var trust = new SecTrust(x, 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)); // a host name is not meaningful for client certificates Assert.That(Evaluate(trust, true), Is.EqualTo(SecTrustResult.RecoverableTrustFailure), "Evaluate"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { // by default there's no *custom* anchors Assert.Null(trust.GetCustomAnchorCertificates(), "GetCustomAnchorCertificates"); using (var results = trust.GetResult()) { Assert.That(CFGetRetainCount(results.Handle), Is.EqualTo((nint)1), "RetainCount"); SecTrustResult value = (SecTrustResult)(int)(NSNumber)results [SecTrustResultKey.ResultValue]; Assert.That(value, Is.EqualTo(SecTrustResult.RecoverableTrustFailure), "ResultValue"); } } } }
public void DatagramDefaults() { nint dsize = TestRuntime.CheckSystemAndSDKVersion(8, 0) ? 1327 : 1387; using (var ssl = new SslContext(SslProtocolSide.Client, SslConnectionType.Datagram)) { Assert.That(ssl.BufferedReadSize, Is.EqualTo((nint)0), "BufferedReadSize"); Assert.Null(ssl.Connection, "Connection"); Assert.That(ssl.DatagramWriteSize, Is.EqualTo(dsize), "DatagramWriteSize"); Assert.That(ssl.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); Assert.That(ssl.MaxDatagramRecordSize, Is.EqualTo((nint)1400), "MaxDatagramRecordSize"); Assert.That(ssl.MaxProtocol, Is.EqualTo(SslProtocol.Dtls_1_0), "MaxProtocol"); Assert.That(ssl.MinProtocol, Is.EqualTo(SslProtocol.Dtls_1_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.Null(ssl.PeerId, "PeerId"); Assert.That(ssl.SessionState, Is.EqualTo(SslSessionState.Idle), "SessionState"); ssl.PeerId = new byte [] { 0xff }; Assert.That(ssl.PeerId.Length, Is.EqualTo(1), "1"); // note: SSLSetPeerID (see Apple open source code) does not accept a null/zero-length value ssl.PeerId = null; Assert.That((int)ssl.GetLastStatus(), Is.EqualTo(errSecParam), "set_PeerId/null"); Assert.That((int)ssl.SetDatagramHelloCookie(new byte [33]), Is.EqualTo(-50), "cookie to long"); Assert.That(ssl.SetDatagramHelloCookie(new byte [32]), Is.EqualTo(SslStatus.Success), "tasty cookie");; Assert.That(ssl.SetDatagramHelloCookie(new byte [1]), Is.EqualTo(SslStatus.Success), "fat free cookie"); Assert.That(ssl.SetDatagramHelloCookie(null), Is.EqualTo(SslStatus.Success), "no more cookies"); } }
public void Basic_Leaf_Only() { X509Certificate x = new X509Certificate(CertificateTest.mail_google_com); using (var policy = SecPolicy.CreateBasicX509Policy()) using (var trust = new SecTrust(x, 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)); // SSL certs are a superset of the basic X509 profile SecTrustResult result = SecTrustResult.RecoverableTrustFailure; Assert.That(Evaluate(trust, result == SecTrustResult.RecoverableTrustFailure), Is.EqualTo(result), "Evaluate"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { // call GetPolicies without a SetPolicy / SetPolicies var policies = trust.GetPolicies(); Assert.That(policies.Length, Is.EqualTo(1), "Policies.Length"); using (var data = new NSData()) { // we do not have an easy way to get the response but the API accepts an empty NSData trust.SetOCSPResponse(data); } } } }
public void CompressionSessionGetSupportedPropertiesTest() { if (!TestRuntime.CheckSystemAndSDKVersion(8, 0)) { Assert.Ignore("Ignoring VideoToolbox tests: Requires iOS8+"); } using (var session = CreateSession()) { var supportedProps = session.GetSupportedProperties(); Assert.NotNull(supportedProps, "GetSupportedProperties IsNull"); var key = new NSString("ShouldBeSerialized"); foreach (var item in supportedProps) { var dict = (NSDictionary)item.Value; if (dict == null) { continue; } NSObject value; if (dict.TryGetValue(key, out value) && value != null) { var number = (NSNumber)value; Assert.IsFalse(number.BoolValue, "CompressionSession GetSupportedPropertiesTest ShouldBeSerialized is True"); } } } }
public void HostName_Leaf_Only() { X509Certificate x = new X509Certificate(CertificateTest.mail_google_com); // a bad hostname (mismatched) is recoverable (e.g. if you change policy) using (var policy = SecPolicy.CreateSslPolicy(true, "mail.xamarin.com")) using (var trust = new SecTrust(x, 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)); Assert.That(Evaluate(trust, true), Is.EqualTo(SecTrustResult.RecoverableTrustFailure), "Evaluate"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.That(trust.GetTrustResult(), Is.EqualTo(SecTrustResult.RecoverableTrustFailure), "GetTrustResult"); using (var a = NSArray.FromNSObjects(policy)) trust.SetPolicies(a); var policies = trust.GetPolicies(); Assert.That(policies.Length, Is.EqualTo(1), "Policies.Length"); Assert.That(policies [0].Handle, Is.EqualTo(policy.Handle), "Handle"); // since we modified the `trust` instance it's result was invalidated Assert.That(trust.GetTrustResult(), Is.EqualTo(SecTrustResult.Invalid), "GetTrustResult-2"); } } }
public void Create() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("Requires iOS7"); } using (var s = new SKScene(new SizeF(320, 240))) using (var b1 = SKPhysicsBody.CreateCircularBody(1.0f)) using (var b2 = SKPhysicsBody.CreateCircularBody(2.0f)) { // <quote>The body must be connected to a node that is already part of the scene’s node tree.</quote> SKNode n1 = new SKNode(); n1.PhysicsBody = b1; s.AddChild(n1); SKNode n2 = new SKNode(); n2.PhysicsBody = b2; s.AddChild(n2); // if you create the SKPhysicsJointLimit *before* adding the nodes // to a scene then you'll crash and burn. ref: bug #14793 using (var j = SKPhysicsJointLimit.Create(b1, b2, PointF.Empty, new PointF(10, 20))) { Assert.That(j.BodyA, Is.SameAs(b1), "BodyA"); Assert.That(j.BodyB, Is.SameAs(b2), "BodyB"); s.PhysicsWorld.AddJoint(j); } } }
public void FetchResultIndex() { if (!TestRuntime.CheckSystemAndSDKVersion(8, 0)) { Assert.Inconclusive("Requires iOS8 or later"); } if (ALAssetsLibrary.AuthorizationStatus != ALAuthorizationStatus.Authorized) { Assert.Inconclusive("Requires access to the photo library"); } var collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null); if (collection.Count == 0) { XamagramImage.Image.SaveToPhotosAlbum(null); collection = PHAsset.FetchAssets(PHAssetMediaType.Image, null); } // Actual Test var obj = collection [0]; Assert.IsNotNull(obj); }
public void Ctor_Identity_Certificates() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("requires iOS7+"); } using (var id = IdentityTest.GetIdentity()) using (var trust = new SecTrust(id.Certificate, SecPolicy.CreateBasicX509Policy())) using (var peer = new MCPeerID("me")) { SecCertificate [] certs = new SecCertificate [trust.Count]; for (int i = 0; i < trust.Count; i++) { certs [i] = trust [i]; } using (var s = new MCSession(peer, id, certs, MCEncryptionPreference.Required)) { Assert.AreSame(s.MyPeerID, peer, "MyPeerID"); // it's a self-signed certificate that's used for the identity // so it's not added twice to the collection being returned Assert.That(s.SecurityIdentity.Count, Is.EqualTo(1), "SecurityIdentity"); Assert.That(s.SecurityIdentity.GetItem <SecIdentity> (0).Handle, Is.EqualTo(certs [0].Handle), "SecurityIdentity"); Assert.That(s.EncryptionPreference, Is.EqualTo(MCEncryptionPreference.Required), "EncryptionPreference"); Assert.That(s.ConnectedPeers, Is.Empty, "ConnectedPeers"); } } }
public void AppearanceWhenContainedIn() { if (!TestRuntime.CheckSystemAndSDKVersion(8, 0)) { Assert.Inconclusive("UITraitCollection requires iOS 8.0"); } using (var traits = new UITraitCollection()) { nfloat r, g, b, a; // it can be set Assert.IsNull(UILabel.AppearanceWhenContainedIn(typeof(UITextField)).TextColor, "null 1"); UILabel.AppearanceWhenContainedIn(typeof(UITextField)).TextColor = UIColor.Blue; UILabel.AppearanceWhenContainedIn(typeof(UITextField)).TextColor.GetRGBA(out r, out g, out b, out a); Assert.AreEqual(1, a, "a1"); Assert.AreEqual(0, r, "r1"); Assert.AreEqual(0, g, "g1"); Assert.AreEqual(1, b, "b1"); // check that other appearance instances didn't change (bug 26353) Assert.IsNull(UILabel.Appearance.TextColor, "other null 1"); Assert.IsNull(UILabel.GetAppearance(traits).TextColor, "other null 2"); Assert.IsNull(UILabel.GetAppearance(traits, typeof(UITextField)).TextColor, "other null 3"); // it can be cleared UILabel.AppearanceWhenContainedIn(typeof(UITextField)).TextColor = null; Assert.IsNull(UILabel.AppearanceWhenContainedIn(typeof(UITextField)).TextColor, "null 2"); } }
public void Setup() { if (!TestRuntime.CheckSystemAndSDKVersion(9, 0)) { Assert.Ignore("Ignoring GameplayKit tests: Requires iOS9+"); } }
public void GetSupportedInterfaces() { if (Runtime.Arch == Arch.SIMULATOR) { if (RunningOnSnowLeopard) { Assert.Inconclusive("This test crash on the simulator with Snow Leopard"); } if (TestRuntime.CheckSystemAndSDKVersion(6, 0)) { Assert.Inconclusive("This test crash on the iOS 6 simulator with Lion"); } } string [] interfaces = CaptiveNetwork.GetSupportedInterfaces(); if (Runtime.Arch == Arch.SIMULATOR) { // we can't assume much about the computer running the simulator Assert.NotNull(interfaces, "GetSupportedInterfaces"); } else { Assert.That(interfaces.Length, Is.EqualTo(1), "1"); Assert.That(interfaces [0], Is.EqualTo("en0"), "en0"); } }
public void Create() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("Requires iOS7"); } using (var s = new SKScene(new SizeF(320, 240))) using (var b1 = SKPhysicsBody.CreateCircularBody(1.0f)) using (var b2 = SKPhysicsBody.CreateCircularBody(2.0f)) { // according to Apple docs we should not create this joint before adding it to a scene // <quote>The body must be connected to a node that is already part of the scene’s node tree.</quote> // Note that doing the same for a `SKPhysicsJointLimit` does crash using (var j = SKPhysicsJointFixed.Create(b1, b2, new PointF(10, 20))) { Assert.That(j.BodyA, Is.SameAs(b1), "BodyA"); Assert.That(j.BodyB, Is.SameAs(b2), "BodyB"); SKNode n1 = new SKNode(); n1.PhysicsBody = b1; s.AddChild(n1); SKNode n2 = new SKNode(); n2.PhysicsBody = b2; s.AddChild(n2); // using the default ctor (for `j`) would crash (and no way to set the PointF argument) // https://bugzilla.xamarin.com/show_bug.cgi?id=14511 s.PhysicsWorld.AddJoint(j); } } }
public void RefcountTest() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("This test uses iOS 7 API"); } // Bug #27205 var auth = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video); switch (auth) { case AVAuthorizationStatus.Restricted: case AVAuthorizationStatus.Denied: case AVAuthorizationStatus.NotDetermined: Assert.Inconclusive("This test requires video recording permissions."); return; } using (var captureSession = new AVCaptureSession()) { using (var videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video)) { foreach (var format in videoDevice.Formats) { for (int i = 0; i < 10; i++) { using (var f = format.FormatDescription) { } } } } } }
public void NoHostName() { X509Certificate x = new X509Certificate(CertificateTest.mail_google_com); // a null host name means "*" (accept any name) which is not stated in Apple documentation using (var policy = SecPolicy.CreateSslPolicy(true, null)) using (var trust = new SecTrust(x, 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)); Assert.That(Evaluate(trust, true), Is.EqualTo(SecTrustResult.RecoverableTrustFailure), "Evaluate"); if (TestRuntime.CheckSystemAndSDKVersion(7, 0)) { using (var rev = SecPolicy.CreateRevocationPolicy(SecRevocation.UseAnyAvailableMethod)) { List <SecPolicy> list = new List <SecPolicy> () { policy, rev }; trust.SetPolicies(list); var policies = trust.GetPolicies(); Assert.That(policies.Length, Is.EqualTo(2), "Policies.Length"); } } } }
public void TraitMatch() { Assert.AreEqual((int)UIAccessibilityTrait.Adjustable, UIView.TraitAdjustable, "Adjustable"); Assert.AreEqual((int)UIAccessibilityTrait.AllowsDirectInteraction, UIView.TraitAllowsDirectInteraction, "AllowsDirectInteraction"); Assert.AreEqual((int)UIAccessibilityTrait.Button, UIView.TraitButton, "Button"); Assert.AreEqual((int)UIAccessibilityTrait.CausesPageTurn, UIView.TraitCausesPageTurn, "CausesPageTurn"); Assert.AreEqual((int)UIAccessibilityTrait.Image, UIView.TraitImage, "Image"); Assert.AreEqual((int)UIAccessibilityTrait.KeyboardKey, UIView.TraitKeyboardKey, "KeyboardKey"); Assert.AreEqual((int)UIAccessibilityTrait.Link, UIView.TraitLink, "Link"); Assert.AreEqual((int)UIAccessibilityTrait.None, UIView.TraitNone, "None"); Assert.AreEqual((int)UIAccessibilityTrait.NotEnabled, UIView.TraitNotEnabled, "NotEnabled"); Assert.AreEqual((int)UIAccessibilityTrait.PlaysSound, UIView.TraitPlaysSound, "PlaysSound"); Assert.AreEqual((int)UIAccessibilityTrait.SearchField, UIView.TraitSearchField, "SearchField"); Assert.AreEqual((int)UIAccessibilityTrait.Selected, UIView.TraitSelected, "Selected"); Assert.AreEqual((int)UIAccessibilityTrait.StartsMediaSession, UIView.TraitStartsMediaSession, "StartsMediaSession"); Assert.AreEqual((int)UIAccessibilityTrait.StaticText, UIView.TraitStaticText, "StaticText"); Assert.AreEqual((int)UIAccessibilityTrait.SummaryElement, UIView.TraitSummaryElement, "SummaryElement"); Assert.AreEqual((int)UIAccessibilityTrait.UpdatesFrequently, UIView.TraitUpdatesFrequently, "UpdatesFrequently"); // some [Field] won't return a valid value before iOS 6.0 if (TestRuntime.CheckSystemAndSDKVersion(6, 0)) { Assert.AreEqual((int)UIAccessibilityTrait.Header, UIView.TraitHeader, "Header"); } }
public void EmptyRequest() { if (!TestRuntime.CheckSystemAndSDKVersion(6, 1)) { Assert.Inconclusive("Requires iOS 6.1"); } using (var lsr = new MKLocalSearchRequest()) using (MKLocalSearch ls = new MKLocalSearch(lsr)) { lsr.Region = new MKCoordinateRegion(new CLLocationCoordinate2D(47, -71), new MKCoordinateSpan(1, 1)); bool wait = true; ls.Start((MKLocalSearchResponse response, NSError error) => { wait = false; }); Assert.True(ls.IsSearching, "IsSearching"); // wait a bit before cancelling the search (so it really starts) // otherwise IsSearching might never complete (on iOS8) and seems very random (in earlier versions) NSRunLoop.Main.RunUntil(NSDate.Now.AddSeconds(2)); ls.Cancel(); #if false // give it some time to cancel - but eventually time out int counter = 0; while (wait && (counter < 5)) { NSRunLoop.Main.RunUntil(DateTime.Now.AddSeconds(counter)); counter++; } Assert.False(ls.IsSearching, "IsSearching/Cancel"); #endif } }