public void BuildProject() { if (File.Exists(LlvmReadobj)) { elfReaderPath = LlvmReadobj; elfReaderLlvm = true; } else if (File.Exists(GccReadelf)) { elfReaderPath = GccReadelf; elfReaderLlvm = false; } else { Assert.Fail($"No ELF reader found. Tried '{LlvmReadobj}' and '{GccReadelf}'"); } Console.WriteLine($"Will use the following ELF reader: {elfReaderPath}"); testProjectPath = PrepareProject(ProjectName); apk = Path.Combine(testProjectPath, "bin", XABuildPaths.Configuration, $"{ProjectPackageName}-Signed.apk"); string projectPath = Path.Combine(testProjectPath, $"{ProjectName}.csproj"); LocalBuilder builder = GetBuilder("Xamarin.Android.MakeBundle-Tests"); bool success = builder.Build(projectPath, "SignAndroidPackage", new [] { "UnitTestsMode=true", $"Configuration={XABuildPaths.Configuration}" }); Assert.That(success, Is.True, "Should have been built"); }
void SuccessfulBuild_RunTest(TestProjectInfo testInfo, bool many, bool dtb, LocalBuilder builder) { string[] parameters = GetBuildProperties(builder, many, dtb); bool success = builder.Build(testInfo.ProjectPath, GetBuildTarget(dtb), parameters); CopyLogs(testInfo, true); Assert.That(success, Is.True, "Build should have succeeded"); CopyGeneratedFiles(testInfo); foreach (SourceFile src in generated_sources) { foreach (SourceFileMember member in src) { string generatedFile = Path.Combine(testInfo.GeneratedPath, src.Path); if (member.IsMethod) { Assert.That(SourceHasMethod(generatedFile, member.Visibility, member.Type, member.Name, member.Arguments), Is.True, $"Method {member.Name} must exist in {generatedFile}"); } else { Assert.That(SourceHasProperty(generatedFile, member.Visibility, member.Type, member.Name, member.IsExpressionBody), Is.True, $"Property {member.Name} must exist in {generatedFile}"); } } } if (dtb) { return; // DTB doesn't produce binaries } foreach (string binaryName in produced_binaries) { AssertExists(testInfo.TestName, Path.Combine(testInfo.BinPath, binaryName)); } }
void FailedBuild_ConflictingRelativeLayout_RunTest(TestProjectInfo testInfo, bool many, bool dtb, LocalBuilder builder) { string[] parameters = GetBuildProperties(builder, many, dtb, "NOT_CONFLICTING_RELATIVELAYOUT"); bool success = builder.Build(testInfo.ProjectPath, GetBuildTarget(dtb), parameters); CopyLogs(testInfo, true); Assert.That(success, Is.False, "Build should have failed"); string logPath = GetTestLogPath(testInfo); bool haveError = HaveCompilerError_CS0266(logPath, "OnboardingActivityPartial.cs", 43, "Android.Views.View", "Android.Widget.RelativeLayout"); AssertHaveCompilerError(haveError, "OnboardingActivityPartial.cs", 43); haveError = HaveCompilerError_CS0266(logPath, "OnboardingActivity.cs", 38, "Android.Views.View", "Android.Widget.RelativeLayout"); AssertHaveCompilerError(haveError, "OnboardingActivity.cs", 38); }
void FailedBuild_ConflictingFragment_RunTest(TestProjectInfo testInfo, bool many, bool dtb, LocalBuilder builder) { string[] parameters = GetBuildProperties(builder, many, dtb, "NOT_CONFLICTING_FRAGMENT"); bool success = builder.Build(testInfo.ProjectPath, GetBuildTarget(dtb), parameters); CopyLogs(testInfo, true); Assert.That(success, Is.False, "Build should have failed"); string logPath = GetTestLogPath(testInfo); bool haveError = HaveCompilerError_CS0266(logPath, "MainActivity.cs", 26, "Android.App.Fragment", "CommonSampleLibrary.LogFragment"); AssertHaveCompilerError(haveError, "MainActivity.cs", 26); haveError = HaveCompilerError_CS0266(logPath, "AnotherMainActivity.cs", 23, "Android.App.Fragment", "CommonSampleLibrary.LogFragment"); AssertHaveCompilerError(haveError, "AnotherMainActivity.cs", 23); }
public void BuildProject() { testProjectPath = PrepareProject(ProjectName); string projectPath = Path.Combine(testProjectPath, $"{ProjectName}.csproj"); LocalBuilder builder = GetBuilder("EmbeddedDSO", testProjectPath); string targetAbis = Xamarin.Android.Tools.XABuildConfig.SupportedABIs.Replace(";", ":"); bool success = builder.Build(projectPath, "SignAndroidPackage", new [] { "UnitTestsMode=true", $"Configuration={XABuildPaths.Configuration}", $"AndroidSupportedTargetJitAbis=\"{targetAbis}\"", }); Assert.That(success, Is.True, "Should have been built"); androidSdkDir = AndroidSdkResolver.GetAndroidSdkPath(); }