Skip to content

Commit c663ee1

Browse files
authored
[Tests] Fix Designer Tests to use AndroidSdkResolver.GetMaxInstalledPlatform () (#8488)
Our designer tests were not using ` AndroidSdkResolver.GetMaxInstalledPlatform ()`. As a result if the `android-27` platform was NOT installed the unit tests would fail. Lets update the system to use the helper method to find the latest installed platform and use that.
1 parent 8928f11 commit c663ee1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ GenerateResourceDesigner CreateTask (string path)
398398
};
399399
task.CaseMapFile = Path.Combine (Root, path, "case_map.txt");
400400
task.IsApplication = true;
401-
task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", "android-27", "android.jar");
401+
int platform = AndroidSdkResolver.GetMaxInstalledPlatform ();
402+
task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", $"android-{platform}", "android.jar");
402403
return task;
403404
}
404405

@@ -496,7 +497,8 @@ public void UpdateLayoutIdIsIncludedInDesigner ([Values(true, false)] bool useRt
496497
task.CaseMapFile = Path.Combine (Root, path, "case_map.txt");
497498
File.WriteAllText (task.ResourceFlagFile, string.Empty);
498499
task.IsApplication = true;
499-
task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", "android-27", "android.jar");
500+
int platform = AndroidSdkResolver.GetMaxInstalledPlatform ();
501+
task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", $"android-{platform}", "android.jar");
500502
Assert.IsTrue (task.Execute (), "Task should have executed successfully.");
501503
Assert.IsTrue (File.Exists (task.NetResgenOutputFile), $"{task.NetResgenOutputFile} should have been created.");
502504
var expected = Path.Combine (ExpectedOutputDir, "GenerateDesignerFileExpected.cs");
@@ -811,7 +813,8 @@ int styleable ElevenAttributes_attr09 9
811813
task.ResourceDirectory = Path.Combine (Root, path, "res");
812814
task.Resources = new TaskItem [] {};
813815
task.IsApplication = true;
814-
task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", "android-27", "android.jar");
816+
int platform = AndroidSdkResolver.GetMaxInstalledPlatform ();
817+
task.JavaPlatformJarPath = Path.Combine (AndroidSdkDirectory, "platforms", $"android-{platform}", "android.jar");
815818
Assert.IsTrue (task.Execute (), "Task should have executed successfully.");
816819
Assert.IsTrue (File.Exists (task.NetResgenOutputFile), $"{task.NetResgenOutputFile} should have been created.");
817820
var expected = Path.Combine (ExpectedOutputDir, "GenerateDesignerFileWithElevenStyleableAttributesExpected.cs");

0 commit comments

Comments
 (0)