public void SystemInfoData(FieldInfo field) { var deviceJson = @" {{ ""friendlyName"": ""Minimal Device"", ""version"": 1, ""screens"": [ {{ ""width"": 1080, ""height"": 1920, ""dpi"": 450.0 }} ], ""systemInfo"": {{ ""operatingSystem"": ""Android"", ""{0}"": ""n/a"" }} }} "; deviceJson = string.Format(deviceJson, field.Name); DeviceInfoImporter.ParseDeviceInfo(deviceJson, out var parseErrors, out var e, out var g); Assert.IsTrue(parseErrors.Length == 0); var device = ScriptableObject.CreateInstance <DeviceInfoAsset>(); DeviceInfoImporter.FindOptionalFieldAvailability(device, e, g); Assert.AreEqual(1, device.availableSystemInfoFields.Count); Assert.True(device.availableSystemInfoFields.Contains(field.Name)); }
public void SystemInfoNoOptionalFields() { var deviceJson = @" { ""friendlyName"": ""Minimal Device"", ""version"": 1, ""screens"": [ { ""width"": 1080, ""height"": 1920, ""dpi"": 450.0 } ], ""systemInfo"": { ""operatingSystem"": ""Android"", ""graphicsDependentData"": [ { ""graphicsDeviceType"" : 16 }, { ""graphicsDeviceType"" : 21 } ] } } "; DeviceInfoImporter.ParseDeviceInfo(deviceJson, out var parseErrors, out var e, out var g); Assert.IsTrue(parseErrors.Length == 0); var device = ScriptableObject.CreateInstance <DeviceInfoAsset>(); DeviceInfoImporter.FindOptionalFieldAvailability(device, e, g); Assert.Zero(device.availableSystemInfoFields.Count); Assert.AreEqual(2, device.availableGraphicsSystemInfoFields.Count); foreach (var graphicsDeviceFields in device.availableGraphicsSystemInfoFields.Values) { Assert.Zero(graphicsDeviceFields.Count); } }
public void GraphicsSystemInfoData(FieldInfo field) { var deviceJson = @" {{ ""friendlyName"": ""Minimal Device"", ""version"": 1, ""screens"": [ {{ ""width"": 1080, ""height"": 1920, ""dpi"": 450.0 }} ], ""systemInfo"": {{ ""operatingSystem"": ""Android"", ""graphicsDependentData"": [ {{ ""graphicsDeviceType"" : 16, ""{0}"": ""n/a"" }} ] }} }} "; deviceJson = string.Format(deviceJson, field.Name); DeviceInfoImporter.ParseDeviceInfo(deviceJson, out var parseErrors, out var e, out var g); var errorMessage = parseErrors.Length == 0 ? "" : parseErrors.Aggregate((s1, s2) => s1 + "\n" + s2); Assert.IsTrue(parseErrors.Length == 0, errorMessage); var device = ScriptableObject.CreateInstance <DeviceInfoAsset>(); DeviceInfoImporter.FindOptionalFieldAvailability(device, e, g); Assert.AreEqual(1, device.availableGraphicsSystemInfoFields.Count); Assert.True(device.availableGraphicsSystemInfoFields.Values.First().Contains(field.Name)); }
public void MinimalDevice() { var deviceJson = @" { ""friendlyName"": ""Minimal Device"", ""version"": 1, ""screens"": [ { ""width"": 1080, ""height"": 1920, ""dpi"": 450.0 } ], ""systemInfo"": { ""operatingSystem"": ""Android"" } } "; var deviceInfo = DeviceInfoImporter.ParseDeviceInfo(deviceJson, out var parseErrors, out var e, out var g); Assert.IsTrue(parseErrors.Length == 0); DeviceInfoImporter.AddOptionalFields(deviceInfo); Assert.IsTrue(deviceInfo.screens[0].orientations.Length == 4); }
private static void MakeSureParsingFailed(string deviceJson) { DeviceInfoImporter.ParseDeviceInfo(deviceJson, out var parseErrors, out var e, out var g); Assert.IsTrue(parseErrors.Length > 0); Debug.Log(parseErrors.Aggregate((s1, s2) => s1 + "\n" + s2)); }