Skip to content

Commit b186891

Browse files
committed
[tests] Remove XASdkDeployTests
Most of our time intensive tests are in deploy and debug scenarios, and we have some duplication there that can be cleaned up. The `XASdkDeployTests` class has been removed, and non duplicated tests from this class have been moved into `InstallAndRunTests`. The `DotNetInstallAndRun` tests have been paired down to two tests for `net7.0-android` Debug and Release. The other permutations should be covered by existing install and run tests. The `DotNetDebug` tests have been removed, as they were effectively duplicates of `ApplicationRunsWithDebuggerAndBreaks`. The `Debugger` tests have had their connection settings adjusted to try fewer times to connect but wait longer in between attempts. We will now only wait for up to 7 minutes to connect rather than ~17 minutes.
1 parent 66a0389 commit b186891

File tree

3 files changed

+107
-251
lines changed

3 files changed

+107
-251
lines changed

tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ public override void OnCreate ()
242242
int port = rnd.Next (10000, 20000);
243243
TestContext.Out.WriteLine ($"{port}");
244244
var args = new SoftDebuggerConnectArgs ("", IPAddress.Loopback, port) {
245-
MaxConnectionAttempts = 2000, // we need a long delay here to get a reliable connection
245+
MaxConnectionAttempts = 210, // we need a long delay here to get a reliable connection
246+
TimeBetweenConnectionAttempts = 2000,
246247
};
247248
var startInfo = new SoftDebuggerStartInfo (args) {
248249
WorkingDirectory = Path.Combine (b.ProjectDirectory, proj.IntermediateOutputPath, "android", "assets"),
@@ -359,7 +360,7 @@ public override void OnCreate ()
359360
};
360361
#pragma warning restore 414
361362

362-
[Test, Category ("Debugger")]
363+
[Test, Category ("Debugger"), Category ("WearOS")]
363364
[TestCaseSource (nameof(DebuggerTestCases))]
364365
[Retry (5)]
365366
public void ApplicationRunsWithDebuggerAndBreaks (bool embedAssemblies, string fastDevType, bool allowDeltaInstall, string username, string packageFormat)
@@ -465,7 +466,8 @@ public Foo ()
465466
int port = rnd.Next (10000, 20000);
466467
TestContext.Out.WriteLine ($"{port}");
467468
var args = new SoftDebuggerConnectArgs ("", IPAddress.Loopback, port) {
468-
MaxConnectionAttempts = 2000,
469+
MaxConnectionAttempts = 210,
470+
TimeBetweenConnectionAttempts = 2000,
469471
};
470472
var startInfo = new SoftDebuggerStartInfo (args) {
471473
WorkingDirectory = Path.Combine (appBuilder.ProjectDirectory, app.IntermediateOutputPath, "android", "assets"),

tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Text;
56
using System.Text.RegularExpressions;
67
using System.Xml.Linq;
78
using System.Xml.XPath;
@@ -11,7 +12,7 @@
1112
namespace Xamarin.Android.Build.Tests
1213
{
1314
[TestFixture]
14-
[Category ("UsesDevice")]
15+
[Category ("UsesDevice"), Category ("WearOS")]
1516
public class InstallAndRunTests : DeviceTest
1617
{
1718
static ProjectBuilder builder;
@@ -1137,5 +1138,105 @@ public void CheckResouceIsOverridden ([Values (true, false)] bool useAapt2)
11371138
}
11381139
}
11391140

1141+
public void DotNetInstallAndRunPreviousSdk ([Values (false, true)] bool isRelease)
1142+
{
1143+
XamarinAndroidApplicationProject proj;
1144+
proj = new XamarinFormsAndroidApplicationProject {
1145+
TargetFramework = "net7.0-android",
1146+
IsRelease = isRelease,
1147+
EnableDefaultItems = true,
1148+
};
1149+
1150+
var builder = CreateApkBuilder ();
1151+
Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed");
1152+
RunProjectAndAssert (proj, builder);
1153+
1154+
WaitForPermissionActivity (Path.Combine (Root, builder.ProjectDirectory, "permission-logcat.log"));
1155+
bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity",
1156+
Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30);
1157+
Assert.IsTrue(didLaunch, "Activity should have started.");
1158+
}
1159+
1160+
[Test]
1161+
public void TypeAndMemberRemapping ([Values (false, true)] bool isRelease)
1162+
{
1163+
var proj = new XamarinAndroidApplicationProject () {
1164+
IsRelease = isRelease,
1165+
EnableDefaultItems = true,
1166+
OtherBuildItems = {
1167+
new AndroidItem._AndroidRemapMembers ("RemapActivity.xml") {
1168+
Encoding = Encoding.UTF8,
1169+
TextContent = () => ResourceData.RemapActivityXml,
1170+
},
1171+
new AndroidItem.AndroidJavaSource ("RemapActivity.java") {
1172+
Encoding = new UTF8Encoding (encoderShouldEmitUTF8Identifier: false),
1173+
TextContent = () => ResourceData.RemapActivityJava,
1174+
Metadata = {
1175+
{ "Bind", "True" },
1176+
},
1177+
},
1178+
},
1179+
};
1180+
proj.MainActivity = proj.DefaultMainActivity.Replace (": Activity", ": global::Example.RemapActivity");
1181+
var builder = CreateApkBuilder ();
1182+
Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed");
1183+
RunProjectAndAssert (proj, builder);
1184+
var appStartupLogcatFile = Path.Combine (Root, builder.ProjectDirectory, "logcat.log");
1185+
bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity", appStartupLogcatFile);
1186+
Assert.IsTrue (didLaunch, "MainActivity should have launched!");
1187+
var logcatOutput = File.ReadAllText (appStartupLogcatFile);
1188+
1189+
StringAssert.Contains (
1190+
"RemapActivity.onMyCreate() invoked!",
1191+
logcatOutput,
1192+
"Activity.onCreate() wasn't remapped to RemapActivity.onMyCreate()!"
1193+
);
1194+
StringAssert.Contains (
1195+
"ViewHelper.mySetOnClickListener() invoked!",
1196+
logcatOutput,
1197+
"View.setOnClickListener() wasn't remapped to ViewHelper.mySetOnClickListener()!"
1198+
);
1199+
}
1200+
1201+
[Test]
1202+
public void SupportDesugaringStaticInterfaceMethods ()
1203+
{
1204+
var proj = new XamarinAndroidApplicationProject () {
1205+
IsRelease = true,
1206+
EnableDefaultItems = true,
1207+
OtherBuildItems = {
1208+
new AndroidItem.AndroidJavaSource ("StaticMethodsInterface.java") {
1209+
Encoding = new UTF8Encoding (encoderShouldEmitUTF8Identifier: false),
1210+
TextContent = () => ResourceData.IdmStaticMethodsInterface,
1211+
Metadata = {
1212+
{ "Bind", "True" },
1213+
},
1214+
},
1215+
},
1216+
};
1217+
1218+
// Note: To properly test, Desugaring must be *enabled*, which requires that
1219+
// `$(SupportedOSPlatformVersion)` be *less than* 23. 21 is currently the default,
1220+
// but set this explicitly anyway just so that this implicit requirement is explicit.
1221+
proj.SupportedOSPlatformVersion = "21";
1222+
1223+
proj.MainActivity = proj.DefaultMainActivity.Replace ("//${AFTER_ONCREATE}", @"
1224+
Console.WriteLine ($""# jonp static interface default method invocation; IStaticMethodsInterface.Value={Example.IStaticMethodsInterface.Value}"");
1225+
");
1226+
var builder = CreateApkBuilder ();
1227+
Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed");
1228+
RunProjectAndAssert (proj, builder);
1229+
var appStartupLogcatFile = Path.Combine (Root, builder.ProjectDirectory, "logcat.log");
1230+
bool didLaunch = WaitForActivityToStart (proj.PackageName, "MainActivity", appStartupLogcatFile);
1231+
Assert.IsTrue (didLaunch, "MainActivity should have launched!");
1232+
var logcatOutput = File.ReadAllText (appStartupLogcatFile);
1233+
1234+
StringAssert.Contains (
1235+
"IStaticMethodsInterface.Value=3",
1236+
logcatOutput,
1237+
"Was IStaticMethodsInterface.Value executed?"
1238+
);
1239+
}
1240+
11401241
}
11411242
}

tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs

Lines changed: 0 additions & 247 deletions
This file was deleted.

0 commit comments

Comments
 (0)