[introspection tests] Do version checks using Xcode version instead of specific platform versions.

This commit is contained in:
Rolf Bjarne Kvinge 2016-06-09 19:37:23 +02:00
Родитель f35e8b8b35
Коммит f0b709b8bf
9 изменённых файлов: 52 добавлений и 99 удалений

Просмотреть файл

@ -141,6 +141,8 @@ partial class TestRuntime
switch (minor) {
case 5:
return CheckiOSSystemVersion (6, 0);
case 6:
return CheckiOSSystemVersion (6, 1);
default:
throw new NotImplementedException ();
}

Просмотреть файл

@ -217,55 +217,5 @@ namespace Introspection {
return Path.Combine (prefix, libname + ".framework", libname);
}
protected bool IsOSX11OrIOS9 {
get {
#if MONOMAC
return Mac.IsElCapitanOrHigher;
#elif __WATCHOS__
return false;
#else
return UIDevice.CurrentDevice.CheckSystemVersion (9, 0);
#endif
}
}
protected bool CheckiOSSystemVersion (int major, int minor)
{
#if __IOS__
return UIDevice.CurrentDevice.CheckSystemVersion (major, minor);
#else
throw new InvalidOperationException ("Can only check iOS system version on iOS.");
#endif
}
// This only works for API introduced in the same numeric version in both iOS and tvOS.
protected bool CheckiOSOrTVOSSystemVersion (int major, int minor)
{
#if __IOS__ || __TVOS__
return UIDevice.CurrentDevice.CheckSystemVersion (major, minor);
#else
throw new InvalidOperationException ("Can only check iOS or tvOS system version on iOS or tvOS.");
#endif
}
protected bool CheckWatchOSSystemVersion (int major, int minor)
{
#if __WATCHOS__
throw new NotImplementedException ();
// return UIDevice.CurrentDevice.CheckSystemVersion (major, minor);
#else
throw new InvalidOperationException ("Can only check watchOS system version on watchOS.");
#endif
}
protected bool CheckTVOSSystemVersion (int major, int minor)
{
#if __TVOS__
return UIDevice.CurrentDevice.CheckSystemVersion (major, minor);
#else
throw new InvalidOperationException ("Can only check tvOS system version on tvOS.");
#endif
}
}
}

Просмотреть файл

@ -140,7 +140,7 @@ namespace Introspection {
case "EKSpan":
case "EKRecurrenceFrequency":
case "EKEventAvailability":
if (!IsOSX11OrIOS9)
if (!TestRuntime.CheckXcodeVersion (7, 0))
return 4;
break;
case "MDLAxisAlignedBoundingBox":
@ -670,7 +670,7 @@ namespace Introspection {
case "EventKit.EKSpan":
case "EventKit.EKAlarmType":
// EventKit.EK* enums are anonymous enums in 10.10 and iOS 8, but an NSInteger in 10.11 and iOS 9.
if (IsOSX11OrIOS9)
if (TestRuntime.CheckXcodeVersion (7, 0))
goto default;
return true;
default:

Просмотреть файл

@ -58,7 +58,7 @@ namespace Introspection {
case "Metal":
case "MonoTouch.Metal":
// they works with iOS9 beta 4 (but won't work on older simulators)
if ((Runtime.Arch == Arch.SIMULATOR) && !CheckiOSOrTVOSSystemVersion (9,0))
if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
#if !__WATCHOS__
@ -69,7 +69,7 @@ namespace Introspection {
if (Runtime.Arch == Arch.SIMULATOR)
return true;
// some devices don't support metal and that crash some API that does not check that, e.g. #33153
if (!CheckiOSOrTVOSSystemVersion (9,0) || (MTLDevice.SystemDefault == null))
if (!TestRuntime.CheckXcodeVersion (7, 0) || (MTLDevice.SystemDefault == null))
return true;
break;
#endif // !__WATCHOS__
@ -125,7 +125,7 @@ namespace Introspection {
// technically available since 4.1 - however it got a new base class in 6.0
// and that new base class GKGameCenterViewController did not exists before 6.0
// which makes the type unusable in 5.x, ref: https://gist.github.com/spouliot/271b6230a3aa2b58bc6e
return !CheckiOSSystemVersion (6,0);
return !TestRuntime.CheckXcodeVersion (4, 5);
// mistake - we should not have exposed those default ctor and now we must live with them
case "GCControllerElement":
@ -160,7 +160,7 @@ namespace Introspection {
// Started with iOS8 on simulator (always) but it looks like it can happen on devices too
// NSInvalidArgumentException Use initWithAccessibilityContainer:
case "UIAccessibilityElement":
return CheckiOSSystemVersion (8,0);
return TestRuntime.CheckXcodeVersion (6, 0);
#endif
// in 8.2 beta 1 this crash the app (simulator) without giving any details in the logs
case "WKUserNotificationInterfaceController":
@ -247,7 +247,7 @@ namespace Introspection {
return;
// iOS9 - the instance was "kind of valid" before
case "PKPaymentAuthorizationViewController":
if (CheckiOSSystemVersion (9,0))
if (TestRuntime.CheckXcodeVersion (7, 0))
return;
break;
}
@ -276,7 +276,7 @@ namespace Introspection {
case "AVAssetResourceLoadingRequest":
case "GKScoreChallenge": // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[GKScoreChallenge challengeID]: unrecognized selector sent to instance 0x18acc340
case "GKAchievementChallenge": // Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[GKAchievementChallenge challengeID]: unrecognized selector sent to instance 0x160f4840
if (CheckiOSOrTVOSSystemVersion (6,0))
if (TestRuntime.CheckXcodeVersion (4, 5))
return;
break;
// crash (when asking `description`) under iOS5 (only) simulator
@ -286,7 +286,7 @@ namespace Introspection {
case "WKFrameInfo":
case "WKNavigation":
case "WKNavigationAction":
if (CheckiOSSystemVersion (9,0))
if (TestRuntime.CheckXcodeVersion (7, 0))
return;
break;
default:
@ -301,7 +301,7 @@ namespace Introspection {
switch (obj.GetType ().Name) {
case "NSString":
// according to bots `isKindOf (null)` returns true before iOS 8, ref: #36726
if (!CheckiOSOrTVOSSystemVersion (8, 0))
if (!TestRuntime.CheckXcodeVersion (6, 0))
return;
break;
}

Просмотреть файл

@ -46,7 +46,7 @@ namespace Introspection {
case "Metal":
case "MonoTouch.Metal":
// they works with iOS9 beta 4 (but won't work on older simulators)
if ((Runtime.Arch == Arch.SIMULATOR) && !CheckiOSSystemVersion (9,0))
if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
case "MetalKit":
@ -83,13 +83,13 @@ namespace Introspection {
case "ExifLensMake":
case "ExifLensModel":
case "ExifLensSerialNumber":
return !CheckiOSOrTVOSSystemVersion (6,1);
return !TestRuntime.CheckXcodeVersion (4, 6);
// ImageIO: new in iOS 8 but returns nil (at least in beta 1) seems fixed in iOS9
case "PNGLoopCount":
case "PNGDelayTime":
case "PNGUnclampedDelayTime":
return !CheckiOSOrTVOSSystemVersion (9,0);
return !TestRuntime.CheckXcodeVersion (7, 0);
// CoreServices.CFHTTPMessage - document in 10.9 but returns null
case "_AuthenticationSchemeOAuth1":

Просмотреть файл

@ -57,7 +57,7 @@ namespace Introspection {
return true;
// Requires iOS 8.2 or later in 32-bit mode
if (!CheckiOSSystemVersion (8, 2) && IntPtr.Size == 4)
if (!TestRuntime.CheckXcodeVersion (6, 2) && IntPtr.Size == 4)
return true;
break;
@ -75,7 +75,7 @@ namespace Introspection {
case "MonoTouch.CoreAudioKit":
case "CoreAudioKit":
// they works with iOS9 beta 4 (but won't work on older simulators)
if ((Runtime.Arch == Arch.SIMULATOR) && !CheckiOSOrTVOSSystemVersion (9,0))
if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
@ -117,7 +117,7 @@ namespace Introspection {
case "GKLocalPlayer":
// NSSecureCoding is still undocumented, for iOS, and neither is NSCoding for OSX
// and it did not respond before 6.0 (when NSSecureCoding was introduced)
return !CheckiOSOrTVOSSystemVersion (6,0);
return !TestRuntime.CheckXcodeVersion (4, 5);
case "UITableViewDataSource":
// this is a *protocol( and we do not want to force people to conform to (an
// undocumented "requirement") NSCoding - as ObjC do not have to do this
@ -244,7 +244,7 @@ namespace Introspection {
break;
case "UITextInputTraits":
// UISearchBar conformance fails before 7.1 - reference bug #33333
if ((type.Name == "UISearchBar") && !CheckiOSOrTVOSSystemVersion (7,1))
if ((type.Name == "UISearchBar") && !TestRuntime.CheckXcodeVersion (5, 1))
return true;
break;
#if !XAMCORE_3_0
@ -258,7 +258,7 @@ namespace Introspection {
case "GKSavedGameListener":
switch (type.Name) {
case "GKLocalPlayerListener": // 37180
return !CheckiOSOrTVOSSystemVersion (8, 0);
return !TestRuntime.CheckXcodeVersion (6, 0);
}
break;
}
@ -268,8 +268,7 @@ namespace Introspection {
[Test]
public override void SecureCoding ()
{
if (!CheckiOSOrTVOSSystemVersion (6,0))
Assert.Inconclusive ("Requires iOS 6+");
TestRuntime.AssertXcodeVersion (4, 5);
base.SecureCoding ();
}
@ -277,8 +276,7 @@ namespace Introspection {
[Test]
public override void SupportsSecureCoding ()
{
if (!CheckiOSOrTVOSSystemVersion (6,0))
Assert.Inconclusive ("Requires iOS 6+");
TestRuntime.AssertXcodeVersion (4, 5);
base.SupportsSecureCoding ();
}

Просмотреть файл

@ -51,7 +51,7 @@ namespace Introspection {
case "Metal":
case "MonoTouch.Metal":
// they works with iOS9 beta 4 (but won't work on older simulators)
if ((Runtime.Arch == Arch.SIMULATOR) && !CheckiOSOrTVOSSystemVersion (9,0))
if ((Runtime.Arch == Arch.SIMULATOR) && !TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
case "MetalKit":
@ -110,7 +110,7 @@ namespace Introspection {
case "setSessionDescription:":
case "delegate":
// does not respond anymore but the properties works (see monotouch-test)
if (CheckiOSOrTVOSSystemVersion (9, 0))
if (TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
}
@ -130,7 +130,7 @@ namespace Introspection {
case "setTaskDescription:":
case "taskIdentifier":
// does not respond anymore but the properties works (see monotouch-test)
if (CheckiOSOrTVOSSystemVersion (9, 0))
if (TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
}
@ -138,7 +138,7 @@ namespace Introspection {
case "NSUrlSessionConfiguration":
case "NSUrlSessionStreamTask":
// does not respond anymore but the properties works (see monotouch-test for a partial list)
if (CheckiOSOrTVOSSystemVersion (9, 0))
if (TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
@ -147,7 +147,7 @@ namespace Introspection {
case "currentRequest":
case "originalRequest":
case "response":
if (CheckiOSOrTVOSSystemVersion (9, 0))
if (TestRuntime.CheckXcodeVersion (7, 0))
return true;
break;
}
@ -159,7 +159,7 @@ namespace Introspection {
// https://trello.com/c/pKLOLjVJ/29-24231250-coremotion-api-removal-without-deprecation
case "accelerometerDataFromDate:toDate:":
case "recordAccelerometerForDuration:":
if (!CheckiOSOrTVOSSystemVersion (9, 3))
if (!TestRuntime.CheckXcodeVersion (7, 3))
return true;
break;
}
@ -223,7 +223,7 @@ namespace Introspection {
// UITextInputTraits and UITextInputProtocol
if (declaredType.Name == "UITextField" || declaredType.Name == "UITextView")
return true;
if (CheckiOSOrTVOSSystemVersion (7,1) && declaredType.Name == "UISearchBar")
if (TestRuntime.CheckXcodeVersion (5, 1) && declaredType.Name == "UISearchBar")
return true;
break;
case "keyboardAppearance":
@ -250,7 +250,7 @@ namespace Introspection {
if (declaredType.Name == "UITextField" || declaredType.Name == "UITextView")
return true;
// ignore UISearchBar before iOS8 - it did not really implement UITextInput
if (declaredType.Name == "UISearchBar" && !CheckiOSSystemVersion (8,0))
if (declaredType.Name == "UISearchBar" && !TestRuntime.CheckXcodeVersion (6, 0))
return true;
break;
case "dictationRecognitionFailed":
@ -293,16 +293,16 @@ namespace Introspection {
case "useApplicationAudioSession":
case "setUseApplicationAudioSession:":
if (declaredType.Name == "MPMoviePlayerController")
return CheckiOSSystemVersion (6,0);
return TestRuntime.CheckXcodeVersion (4, 5);
break;
// iOS6 - headers says readwrite but they do not respond
case "setUUID:":
case "setIsPrimary:":
if (declaredType.Name == "CBMutableService")
return CheckiOSSystemVersion (6, 0);
return TestRuntime.CheckXcodeVersion (4, 5);
if (declaredType.Name == "CBMutableCharacteristic")
return CheckiOSSystemVersion (9, 0);
return TestRuntime.CheckXcodeVersion (7, 0);
break;
// documented since 4.0 - but does not answer on an iPad1 with 5.1.1
@ -405,7 +405,7 @@ namespace Introspection {
case "scrollViewWillBeginZooming:withView:":
case "scrollViewWillEndDragging:withVelocity:targetContentOffset:":
if (declaredType.Name == "UICollectionViewController")
return CheckiOSOrTVOSSystemVersion (6,0);
return TestRuntime.CheckXcodeVersion (4, 5);
break;
// failing (check why)
@ -414,7 +414,7 @@ namespace Introspection {
case "finalLayoutAttributesForDeletedItemAtIndexPath:":
case "finalLayoutAttributesForDeletedSupplementaryElementOfKind:atIndexPath:":
if (declaredType.Name == "UICollectionViewLayout")
return CheckiOSSystemVersion (6,0);
return TestRuntime.CheckXcodeVersion (4, 5);
break;
// This is implemented by internal concrete classes of NSFileHandle
@ -499,25 +499,25 @@ namespace Introspection {
switch (declaredType.Name) {
// not conforming to NSCopying in 5.1 SDK
case "UIFont":
return !CheckiOSSystemVersion (6,0);
return !TestRuntime.CheckXcodeVersion (4, 5);
// not conforming to NSCopying before 7.0 SDK
case "CBPeripheral":
return !CheckiOSSystemVersion (7,0);
return !TestRuntime.CheckXcodeVersion (5, 0);
// not conforming to NSCopying before 8.0 SDK
case "AVMetadataFaceObject":
return !CheckiOSSystemVersion (8,0);
return !TestRuntime.CheckXcodeVersion (6, 0);
// not conforming to NSCopying before 8.2 SDK
case "HKUnit":
return !CheckiOSSystemVersion (8,2);
return !TestRuntime.CheckXcodeVersion (6, 2);
case "HKBiologicalSexObject":
case "HKBloodTypeObject":
return !CheckiOSSystemVersion (9,0);
return !TestRuntime.CheckXcodeVersion (7, 0);
}
break;
// on iOS8.0 this does not work on the simulator (but works on devices)
case "language":
if (declaredType.Name == "AVSpeechSynthesisVoice" && CheckiOSSystemVersion (8,0) && Runtime.Arch == Arch.SIMULATOR)
if (declaredType.Name == "AVSpeechSynthesisVoice" && TestRuntime.CheckXcodeVersion (6, 0) && Runtime.Arch == Arch.SIMULATOR)
return true;
break;
@ -553,11 +553,11 @@ namespace Introspection {
switch (declaredType.Name) {
// UITextInputMode was added in 4.2 but conformed to NSSecureCoding only from 7.0+
case "UITextInputMode":
return !CheckiOSSystemVersion (7,0);
return !TestRuntime.CheckXcodeVersion (5, 0);
// iOS9
case "HKBiologicalSexObject":
case "HKBloodTypeObject":
return !CheckiOSSystemVersion (9,0);
return !TestRuntime.CheckXcodeVersion (7, 0);
}
break;
#else
@ -565,7 +565,7 @@ namespace Introspection {
// we'll ignore them for compat - but won't provide them in the new assemblies
case "backgroundImageForBarMetrics:":
case "setBackgroundImage:forBarMetrics:":
if (declaredType.Name == "UISearchBar" && CheckiOSSystemVersion (8,0))
if (declaredType.Name == "UISearchBar" && TestRuntime.CheckXcodeVersion (6, 0))
return true;
break;
#endif

Просмотреть файл

@ -42,7 +42,7 @@ namespace Introspection {
// EventKit.EK* enums are anonymous enums in 10.10 and iOS 8, but an NSInteger in 10.11 and iOS 9.
case "EKCalendarChooserSelectionStyle":
case "EKCalendarChooserDisplayStyle":
if (!IsOSX11OrIOS9)
if (!TestRuntime.CheckXcodeVersion (7, 0))
return 4;
break;
}
@ -64,7 +64,7 @@ namespace Introspection {
// (they used to return `bool`)
case "beginAppearanceTransition:animated:":
case "endAppearanceTransition":
if (!CheckiOSOrTVOSSystemVersion (6,0))
if (!TestRuntime.CheckXcodeVersion (4, 5))
return true;
break;
}
@ -74,12 +74,12 @@ namespace Introspection {
// sadly, and even with a bug report with a few exchanges, this was not fixed before iOS8 GM :-(
// 64bits application for iOS 7.x will be uncommon so we prefer to be forward compatible
if (selector == "status")
return !CheckiOSSystemVersion (8,0);
return !TestRuntime.CheckXcodeVersion (6, 0);
break;
case "CMMotionManager":
// iOS 8.3 changed CMMotionManager from 4 to 8 bytes on 64bits CPU and we have to follow that breaking
// change unless Apple revert that before final. [radar 20295259]
if ((IntPtr.Size == 4) || CheckiOSSystemVersion (8,3))
if ((IntPtr.Size == 4) || TestRuntime.CheckXcodeVersion (6, 3))
return false;
// which means iOS 8.2 (and earlier can't match)
switch (selector) {
@ -140,7 +140,7 @@ namespace Introspection {
case "MonoTouch.EventKitUI.EKCalendarChooserDisplayStyle":
case "EventKitUI.EKCalendarChooserSelectionStyle":
case "EventKitUI.EKCalendarChooserDisplayStyle":
return (IntPtr.Size == 4) || !IsOSX11OrIOS9;
return (IntPtr.Size == 4) || !TestRuntime.CheckXcodeVersion (7, 0);
case "System.UInt32":
// numberOfTouchesRequired was signed before iOS6, unsigned since then
return true;

Просмотреть файл

@ -159,6 +159,9 @@
<Compile Include="..\..\common\PlatformInfo.cs">
<Link>PlatformInfo.cs</Link>
</Compile>
<Compile Include="..\..\common\TestRuntime.cs">
<Link>TestRuntime.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />