-
Notifications
You must be signed in to change notification settings - Fork 530
/
DeleteBinObjTest.cs
98 lines (90 loc) · 3.81 KB
/
DeleteBinObjTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using NUnit.Framework;
using System.Collections.Generic;
using System.IO;
using Xamarin.ProjectTools;
namespace Xamarin.Android.Build.Tests
{
[TestFixture]
[Category ("DotNetIgnore"), Category ("Node-1")] // .csproj files are legacy projects that won't build under dotnet
public class DeleteBinObjTest : DeviceTest
{
const string BaseUrl = "https://github.com/dellis1972/xamarin-android-unittest-files/blob/main/";
readonly DownloadedCache Cache = new DownloadedCache ();
string HostOS => IsWindows ? "Windows" : "Darwin";
void RunTest (string name, string sln, string csproj, string version, string revision, string packageName, string javaPackageName, bool isRelease)
{
var configuration = isRelease ? "Release" : "Debug";
var zipPath = Cache.GetAsFile ($"{BaseUrl}{name}-{version}-{HostOS}-{revision}.7z?raw=true");
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName)))
using (var zip = SevenZipHelper.Open (zipPath, FileMode.Open)) {
builder.AutomaticNuGetRestore = false;
if (!builder.TargetFrameworkExists ("v9.0")) {
Assert.Ignore ("TargetFrameworkVersion=v9.0 required for this test.");
return;
}
var projectDir = Path.Combine (Root, builder.ProjectDirectory);
if (Directory.Exists (projectDir))
Directory.Delete (projectDir, recursive: true);
zip.ExtractAll (projectDir);
var solution = new ExistingProject {
IsRelease = isRelease,
ProjectFilePath = Path.Combine (projectDir, sln),
};
// RestoreNoCache will bypass a global cache on CI machines
Assert.IsTrue (builder.Restore (solution, doNotCleanupOnUpdate: true, parameters: new [] { "RestoreNoCache=True" }), "Restore should have succeeded.");
var project = new ExistingProject {
IsRelease = isRelease,
ProjectFilePath = Path.Combine (projectDir, csproj),
};
var parameters = new List<string> {
"Configuration=" + configuration,
// Move the $(IntermediateOutputPath) directory to match zips
"IntermediateOutputPath=" + Path.Combine ("obj", isRelease ? "Release" : "Debug", "90") + Path.DirectorySeparatorChar
};
if (isRelease || !CommercialBuildAvailable) {
parameters.Add (KnownProperties.AndroidSupportedAbis + "=\"armeabi-v7a;x86;x86_64\"");
} else {
parameters.Add (KnownProperties.AndroidSupportedAbis + "=\"armeabi-v7a;arm64-v8a;x86;x86_64\"");
}
if (HasDevices) {
Assert.IsTrue (builder.Install (project, doNotCleanupOnUpdate: true, parameters: parameters.ToArray (), saveProject: false),
"Install should have succeeded.");
ClearAdbLogcat ();
if (CommercialBuildAvailable)
Assert.True (builder.RunTarget (project, "_Run", doNotCleanupOnUpdate: true, parameters: parameters.ToArray ()), "Project should have run.");
else
AdbStartActivity ($"{packageName}/{javaPackageName}.MainActivity");
Assert.True (WaitForActivityToStart (packageName, "MainActivity",
Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30), "Activity should have started.");
} else {
Assert.IsTrue (builder.Build (project, doNotCleanupOnUpdate: true, parameters: parameters.ToArray (), saveProject: false),
"Build should have succeeded.");
}
}
}
[Test, Category ("UsesDevice")]
public void HelloForms15_9 ([Values (false, true)] bool isRelease)
{
RunTest ("HelloForms",
"HelloForms.sln",
Path.Combine ("HelloForms.Android", "HelloForms.Android.csproj"),
"15.9",
"ecb13a9",
"com.companyname",
"crc6450e568c951913723",
isRelease);
}
[Test, Category ("UsesDevice")]
public void HelloForms16_4 ([Values (false, true)] bool isRelease)
{
RunTest ("HelloForms",
"HelloForms.sln",
Path.Combine ("HelloForms.Android", "HelloForms.Android.csproj"),
"16.4",
"dea8b8d",
"com.companyname",
"crc6450e568c951913723",
isRelease);
}
}
}