Skip to content

Commit

Permalink
Clean up DotNetIgnore Unit Tests (#8163)
Browse files Browse the repository at this point in the history
We have recently begun to remove suport for Xamarin.Android Classic.
Many of the Unit Tests labeled with the "DotNetIgnore" Category were flagged
as such because they did not work under .Net Android. This commit goes through
and removes tests which are not relevant in the .Net Android context. It also
modifies some of these tests which are relevant to work under .Net Android.
  • Loading branch information
dellis1972 authored Jul 20, 2023
1 parent 3a89e8d commit 83bdddb
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 933 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1102,40 +1102,25 @@ public void BuildAppWithManagedResourceParserAndLibraries ()
}

[Test]
[Category ("DotNetIgnore")] // n/a in .NET 5, not possible to use $(TFV) of v8.0
public void CheckMaxResWarningIsEmittedAsAWarning([Values (false, true)] bool useAapt2)
public void CheckMaxResWarningIsEmittedAsAWarning()
{
AssertAaptSupported (useAapt2);
var path = Path.Combine ("temp", TestName);
var proj = new XamarinAndroidApplicationProject () {
TargetFrameworkVersion = "v8.0",
TargetSdkVersion = "26",
MinSdkVersion = null,
UseLatestPlatformSdk = false,
IsRelease = true,
OtherBuildItems = {
new BuildItem.Folder ("Resources\\values-v27\\") {
new BuildItem.Folder ("Resources\\values-v33\\") {
},
},
};
proj.AndroidUseAapt2 = useAapt2;
proj.AndroidResources.Add (new AndroidItem.AndroidResource ("Resources\\values-v27\\Strings.xml") {
proj.AndroidResources.Add (new AndroidItem.AndroidResource ("Resources\\values-v33\\Strings.xml") {
TextContent = () => @"<?xml version=""1.0"" encoding=""utf-8""?>
<resources>
<string name=""test"" >Test</string>
</resources>",
});
using (var builder = CreateApkBuilder (path)) {
if (!builder.TargetFrameworkExists (proj.TargetFrameworkVersion)) {
Assert.Ignore ($"Skipping Test. TargetFrameworkVersion {proj.TargetFrameworkVersion} was not available.");
}
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
if (useAapt2) {
StringAssertEx.DoesNotContain ("APT0000", builder.LastBuildOutput, "Build output should not contain an APT0000 warning");
} else {
var expected = "warning APT1146: max res 26, skipping values-v27";
StringAssertEx.Contains (expected, builder.LastBuildOutput, "Build output should contain an APT1146 warning about 'max res 26, skipping values-v27'");
}
StringAssertEx.DoesNotContain ("APT0000", builder.LastBuildOutput, "Build output should not contain an APT0000 warning");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,30 +442,6 @@ public void RemoveEventHandlerResolution ()
}
}

[Test]
[Category ("DotNetIgnore")]
public void JavaDocJar ()
{
var binding = new XamarinAndroidBindingProject () {
AndroidClassParser = "class-parse",
};
binding.SetProperty ("DocumentationFile", "UnnamedProject.xml");
using (var bindingBuilder = CreateDllBuilder ()) {
binding.Jars.Add (new AndroidItem.EmbeddedJar ("javasourcejartest.jar") {
BinaryContent = () => ResourceData.JavaSourceJarTestJar,
});
binding.OtherBuildItems.Add (new BuildItem ("JavaDocJar", "javasourcejartest-javadoc.jar") {
BinaryContent = () => ResourceData.JavaSourceJarTestJavadocJar,
});
Assert.IsTrue (bindingBuilder.Build (binding), "binding build should have succeeded");

var cs_file = bindingBuilder.Output.GetIntermediaryPath (
Path.Combine ("generated", "src", "Com.Xamarin.Android.Test.Msbuildtest.JavaSourceJarTest.cs"));
FileAssert.Exists (cs_file);
StringAssert.Contains ("Greet (string name, global::Java.Util.Date date)", File.ReadAllText (cs_file));
}
}

[Test]
public void JavaSourceJar ()
{
Expand Down Expand Up @@ -622,26 +598,6 @@ public void NothingToBind (string classParser)
}
}

[Test]
[Category ("DotNetIgnore")] //TODO: @(LibraryProjectProperties) not supported yet in .NET 5+
public void BugzillaBug11964 ()
{
var proj = new XamarinAndroidBindingProject ();

proj.Sources.Add (new BuildItem ("LibraryProjectProperties", "project.properties") {
TextContent = () => ""
});

using (var builder = CreateDllBuilder ()) {
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (proj), "Build should have failed.");
string error = builder.LastBuildOutput
.SkipWhile (x => !x.StartsWith ("Build FAILED.", StringComparison.Ordinal))
.FirstOrDefault (x => x.Contains ("error XA1019:"));
Assert.IsNotNull (error, "Build should have failed with XA1019.");
}
}

[Test]
public void BindingWithAndroidJavaSource ()
{
Expand Down
Loading

0 comments on commit 83bdddb

Please sign in to comment.