Skip to content

Commit

Permalink
Add Test
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Mar 16, 2023
1 parent 45465dc commit b4345d8
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,44 @@ public void VersionCodeTests (bool seperateApk, string abis, string versionCode,
}
}

[Test]
[TestCase ("1", false, "manifest=1")]
[TestCase ("1", true, "x86_64=500001;arm64-v8a=400001")]
[TestCase ("2", false, "manifest=2")]
[TestCase ("2", true, "x86_64=500002;arm64-v8a=400002")]
public void ApplicationVersionTests (string applicationVersion, bool seperateApk, string expected)
{
var proj = new XamarinAndroidApplicationProject () {
IsRelease = true,
MinSdkVersion = null,
};
proj.SetProperty (proj.ReleaseProperties, "ApplicationVersion", applicationVersion);
proj.SetProperty (proj.ReleaseProperties, "ApplicationDisplayVersion", applicationVersion);
proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, seperateApk);
proj.AndroidManifest = proj.AndroidManifest
.Replace ("android:versionCode=\"1\"", string.Empty)
.Replace ("android:versionName=\"1.0\"", string.Empty);
using (var builder = CreateApkBuilder ()) {
Assert.True (builder.Build (proj), "Build should have succeeded.");
XNamespace aNS = "http://schemas.android.com/apk/res/android";

var expectedItems = expected.Split (';');
foreach (var item in expectedItems) {
var items = item.Split ('=');
var path = seperateApk ? Path.Combine ("android", items [0], "AndroidManifest.xml") : Path.Combine ("android", "manifest", "AndroidManifest.xml");
var manifest = builder.Output.GetIntermediaryAsText (Root, path);
var doc = XDocument.Parse (manifest);
var m = doc.XPathSelectElement ("/manifest") as XElement;
Assert.IsNotNull (m, "no manifest element found");
var vc = m.Attribute (aNS + "versionCode");
Assert.IsNotNull (vc, "no versionCode attribute found");
StringAssert.AreEqualIgnoringCase (items [1], vc.Value,
$"Version Code is incorrect. Found {vc.Value} expect {items [1]}");
}

}
}

[Test]
public void ManifestPlaceholders ([Values ("legacy", "manifestmerger.jar")] string manifestMerger)
{
Expand Down

0 comments on commit b4345d8

Please # to comment.