Skip to content

Commit

Permalink
Check for file removal
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Feb 19, 2024
1 parent 5e7fda4 commit 1c9521d
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/MSBuildDeviceIntegration/Tests/InstallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,21 @@ public void AdbTargetChangesAppBundle ()
public void AppWithAndroidJavaSource ()
{
var path = Path.Combine ("temp", TestName);
var itemToDelete = new AndroidItem.AndroidJavaSource ("TestJavaClass2.java") {
Encoding = Encoding.ASCII,
TextContent = () => @"package com.test.java;
public class TestJavaClass2 {
public String test(){
return ""Java is called"";
}
}",
Metadata = {
{ "Bind", "True" },
},
};
var proj = new XamarinAndroidApplicationProject {
OtherBuildItems = {
new AndroidItem.AndroidJavaSource ("TestJavaClass.java") {
Expand All @@ -632,6 +647,7 @@ public String test(){
{ "Bind", "True" },
},
},
itemToDelete,
}
};
using (var b = CreateApkBuilder ()) {
Expand All @@ -640,12 +656,19 @@ public String test(){
b.AssertHasNoWarnings ();
var generatedCode = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
"generated", "src", "Com.Test.Java.TestJavaClass.cs");
var generatedCode2 = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
"generated", "src", "Com.Test.Java.TestJavaClass2.cs");
FileAssert.Exists (generatedCode, $"'{generatedCode}' should have been generated.");
FileAssert.Exists (generatedCode2, $"'{generatedCode2}' should have been generated.");
Assert.IsTrue (b.DesignTimeBuild (proj, target: "UpdateGeneratedFiles"), "DTB should have succeeded.");
Assert.IsTrue (b.Output.IsTargetSkipped ("_ClearGeneratedManagedBindings", defaultIfNotUsed: true), $"`_ClearGeneratedManagedBindings` should be skipped on DTB build!");
FileAssert.Exists (generatedCode, $"'{generatedCode}' should have not be deleted on DTB build.");
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, saveProject: false), "Second build should have succeeded.");
FileAssert.Exists (generatedCode2, $"'{generatedCode2}' should have not be deleted on DTB build.");
proj.OtherBuildItems.Remove (itemToDelete);
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, saveProject: true), "Second build should have succeeded.");
FileAssert.Exists (generatedCode, $"'{generatedCode}' should have not be deleted on second build.");
FileAssert.DoesNotExist (generatedCode2, $"'{generatedCode2}' should have be deleted on second build.");
Assert.IsFalse (b.Output.IsTargetSkipped ("_CompileBindingJava"), $"`_CompileBindingJava` should run on second build!");
Assert.IsTrue (b.Output.IsTargetSkipped ("_ClearGeneratedManagedBindings"), $"`_ClearGeneratedManagedBindings` should be skipped on second build!");
// Call Install directly so Build does not get called automatically
Assert.IsTrue (b.RunTarget (proj, "Install", doNotCleanupOnUpdate: true, saveProject: false), "Install build should have succeeded.");
Expand Down

0 comments on commit 1c9521d

Please sign in to comment.