Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,29 @@ protected static void ClickButton (string packageName, string buttonName, string
var bounds = GetControlBounds (packageName, buttonName, buttonText);
RunAdbInput ("input tap", bounds.x + ((bounds.w - bounds.x) / 2), bounds.y + ((bounds.h - bounds.y) / 2));
}
}
}

/// <summary>
/// Returns the first device listed via `adb devices`
///
/// Output is:
/// > adb devices
/// List of devices attached
/// 89RY0AEFA device
/// </summary>
/// <returns></returns>
protected static string GetAttachedDeviceSerial ()
{
var text = RunAdbCommand ("devices");
var lines = text.Split ('\n');
if (lines.Length < 2) {
Assert.Fail ($"Unexpected `adb devices` output: {text}");
}
var serial = lines [1];
var index = serial.IndexOf ('\t');
if (index != -1) {
serial = serial.Substring (0, index);
}
return serial.Trim ();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ because xbuild doesn't support framework reference assemblies.
WriteOnlyWhenDifferent="true"
/>
<WriteLinesToFile
Condition=" '$(DesignTimeBuild)' != 'True' "
Condition=" '$(DesignTimeBuild)' != 'True' And ('$(AdbTarget)' != '' Or !Exists('$(_AdbPropertiesCache)')) "
File="$(_AdbPropertiesCache)"
Lines="AdbTarget=$(AdbTarget);AdbOptions=$(AdbOptions)"
Overwrite="true"
Expand Down
25 changes: 24 additions & 1 deletion tests/MSBuildDeviceIntegration/Tests/InstallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Xamarin.Android.Build.Tests
[TestFixture]
[NonParallelizable] //These tests deploy to devices
[Category ("Commercial")]
public class InstallTests : BaseTest
public class InstallTests : DeviceTest
{
[Test]
public void ReInstallIfUserUninstalled ([Values (false, true)] bool isRelease)
Expand Down Expand Up @@ -298,5 +298,28 @@ public void ToggleFastDev ()
Assert.IsTrue (builder.Install (proj), "Third install should have succeeded.");
}
}

[Test]
public void BlankAdbTarget ()
{
if (!CommercialBuildAvailable) {
Assert.Ignore ("Not required on Open Source Builds");
}
if (!HasDevices) {
Assert.Ignore ("Test Skipped no devices or emulators found.");
}

var serial = GetAttachedDeviceSerial ();
var proj = new XamarinAndroidApplicationProject ();
proj.SetProperty (proj.DebugProperties, "AndroidUseSharedRuntime", true);
proj.SetProperty (proj.DebugProperties, "EmbedAssembliesIntoApk", false);

using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
b.Build (proj, parameters: new [] { $"AdbTarget=\"-e {serial}\"" });
// Build again, no $(AdbTarget)
b.Build (proj);
Assert.IsTrue (b.Output.IsTargetSkipped ("_BuildApkFastDev"), "_BuildApkFastDev should be skipped!");
}
}
}
}