public void CompareVersionsWithFirstSmaller() { Assert.That(MoPubUtils.CompareVersions("0", "1"), Is.EqualTo(-1)); Assert.That(MoPubUtils.CompareVersions("0.9", "1.0"), Is.EqualTo(-1)); Assert.That(MoPubUtils.CompareVersions("0.9.99", "1.0.0"), Is.EqualTo(-1)); Assert.That(MoPubUtils.CompareVersions("0.9.99", "0.10.0"), Is.EqualTo(-1)); Assert.That(MoPubUtils.CompareVersions("0.9.99", "0.9.100"), Is.EqualTo(-1)); }
public void CompareVersionsWithEmptyValues() { Assert.That(MoPubUtils.CompareVersions("", ""), Is.EqualTo(0)); Assert.That(MoPubUtils.CompareVersions("", "1"), Is.EqualTo(-1)); Assert.That(MoPubUtils.CompareVersions("1", ""), Is.EqualTo(1)); Assert.That(MoPubUtils.CompareVersions(null, null), Is.EqualTo(0)); Assert.That(MoPubUtils.CompareVersions(null, "1"), Is.EqualTo(-1)); Assert.That(MoPubUtils.CompareVersions("1", null), Is.EqualTo(1)); }
public void CompareVersionsWithEqual() { Assert.That(MoPubUtils.CompareVersions("1", "1"), Is.EqualTo(0)); Assert.That(MoPubUtils.CompareVersions("1.0", "1.0"), Is.EqualTo(0)); Assert.That(MoPubUtils.CompareVersions("1.0.0", "1.0.0"), Is.EqualTo(0)); }
private void SdkRow(SdkInfo info, Func <bool, bool> customButton = null) { var lat = info.LatestVersion; var cur = info.CurrentVersion; var isInst = !string.IsNullOrEmpty(cur); var canInst = !string.IsNullOrEmpty(lat) && (!isInst || MoPubUtils.CompareVersions(cur, lat) < 0); // Is any async job in progress? var stillWorking = coroutine != null || downloader != null; string tooltip = string.Empty; if (isInst && (MoPubUtils.CompareVersions(cur, lat) != 0 || testing)) { tooltip += "\n Installed: " + cur; } if (info.NetworkVersions != null) { string version; if (info.NetworkVersions.TryGetValue(PackageConfig.Platform.ANDROID, out version)) { tooltip += "\n Android SDK: " + version; } if (info.NetworkVersions.TryGetValue(PackageConfig.Platform.IOS, out version)) { tooltip += "\n iOS SDK: " + version; } } if (!string.IsNullOrEmpty(tooltip)) { tooltip = info.Name + "\n Package: " + (lat ?? "n/a") + tooltip; } GUILayout.Space(4); using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(false))) { GUILayout.Space(10); EditorGUILayout.LabelField(new GUIContent { text = info.Name, tooltip = tooltip }); GUILayout.Button(new GUIContent { text = lat ?? "--", tooltip = tooltip }, canInst ? EditorStyles.boldLabel : EditorStyles.label); GUILayout.Space(3); if (customButton == null || !customButton(canInst)) { GUI.enabled = !stillWorking && (canInst || testing); if (GUILayout.Button(new GUIContent { text = isInst ? "Upgrade" : "Install", tooltip = tooltip }, fieldWidth)) { this.StartCoroutine(DownloadSDK(info)); } GUI.enabled = true; } if (!string.IsNullOrEmpty(info.Instructions) && (info.Instructions != helpLink || testing)) { if (GUILayout.Button("?", GUILayout.ExpandWidth(false))) { Application.OpenURL(info.Instructions); } } else { // Need to fill space so that the Install/Upgrade buttons all line up nicely. GUILayout.Button(" ", EditorStyles.label, GUILayout.Width(17)); } GUILayout.Space(5); } GUILayout.Space(4); }