Skip to content

Commit

Permalink
[tests] Update ManifestTest.cs
Browse files Browse the repository at this point in the history
Context: https://github.com/xamarin/xamarin-android/blob/f1d59181c8daaa8d2abcdfd151b592ece49155ca/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs#L650-L651

The `ModifyManifest` test actually writes "too much" to the
`AndroidManifest.xml` file, removing the `<application>` element,
causing the latest version of `bundletool` to error with:

    BT One element <application> was expected, but none were found.

To solve this, let's just set `application:versionCode` in the test
instead.
  • Loading branch information
jonathanpeppers committed Jun 20, 2023
1 parent e2b763c commit 43fe871
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,11 @@ public void ModifyManifest ([Values (true, false)] bool isRelease)
<Namespace Prefix=""android"" Uri=""http://schemas.android.com/apk/res/android"" />
</Namespace>
</PropertyGroup>
<ItemGroup>
<_Permissions Include=""&lt;uses-permission android:name=&quot;android.permission.READ_CONTACTS&quot; /&gt;"" />
</ItemGroup>
<Target Name=""_Foo"">
<XmlPoke
XmlInputPath=""$(IntermediateOutputPath)android\AndroidManifest.xml""
Value=""@(_Permissions)""
Query=""/manifest""
Value=""12345""
Query=""/manifest/@android:versionCode""
Namespaces=""$(Namespace)""
/>
</Target>
Expand All @@ -684,7 +681,7 @@ public void ModifyManifest ([Values (true, false)] bool isRelease)
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (builder.Build (proj), "Build should have succeeded");
var manifest = builder.Output.GetIntermediaryAsText (Root, Path.Combine ("android", "AndroidManifest.xml"));
Assert.IsTrue (manifest.Contains ("READ_CONTACTS"), $"Manifest should contain the READ_CONTACTS");
Assert.IsTrue (manifest.Contains ("12345"), $"Manifest should contain versionCode=12345");
}
}

Expand Down

0 comments on commit 43fe871

Please sign in to comment.