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
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "external/debugger-libs"]
path = external/debugger-libs
url = git://github.com/mono/debugger-libs
branch = master
[submodule "external/dlfcn-win32"]
path = external/dlfcn-win32
url = https://github.com/dlfcn-win32/dlfcn-win32.git
Expand Down Expand Up @@ -30,6 +34,10 @@
path = external/mxe
url = https://github.com/xamarin/mxe.git
branch = xamarin
[submodule "external/nrefactory"]
path = external/nrefactory
url = git://github.com/icsharpcode/NRefactory.git
branch = master
[submodule "external/opentk"]
path = external/opentk
url = https://github.com/mono/opentk.git
Expand Down
6 changes: 6 additions & 0 deletions Configuration.props
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,11 @@
<RemapAssemblyRefTool>$(ManagedRuntime) $(ManagedRuntimeArgs) &quot;$(MSBuildThisFileDirectory)bin\Build$(Configuration)\remap-assembly-ref.exe&quot;</RemapAssemblyRefTool>
</PropertyGroup>

<!-- Unit Test Properties -->
<PropertyGroup>
<_Runtime Condition=" '$(HostOS)' != 'Windows' ">$(ManagedRuntime) $(ManagedRuntimeArgs)</_Runtime>
<_NUnit>$(_Runtime) packages\NUnit.ConsoleRunner.3.9.0\tools\nunit3-console.exe</_NUnit>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)build-tools\scripts\Ndk.targets" />
</Project>
45 changes: 45 additions & 0 deletions Xamarin.Android.Build.Tasks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Xamarin.Android.Build.Tests
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.ProjectTools", "src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Xamarin.ProjectTools.csproj", "{2DD1EE75-6D8D-4653-A800-0A24367F7F38}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "external", "external", "{385E71CC-BAE5-488B-805E-ACAE55F01DF5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuildDeviceIntegration", "tests\MSBuildDeviceIntegration\MSBuildDeviceIntegration.csproj", "{16DB2680-399B-4111-AA26-6CDBBFA334D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.CSharp", "external\nrefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj", "{53DCA265-3C3C-42F9-B647-F72BA678122B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Debugging", "external\debugger-libs\Mono.Debugging\Mono.Debugging.csproj", "{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Debugger.Soft", "external\debugger-libs\Mono.Debugger.Soft\Mono.Debugger.Soft.csproj", "{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Debugging.Soft", "external\debugger-libs\Mono.Debugging.Soft\Mono.Debugging.Soft.csproj", "{DE40756E-57F6-4AF2-B155-55E3A88CCED8}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{3f1f2f50-af1a-4a5a-bedb-193372f068d7}*SharedItemsImports = 4
Expand All @@ -34,11 +48,42 @@ Global
{2DD1EE75-6D8D-4653-A800-0A24367F7F38}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DD1EE75-6D8D-4653-A800-0A24367F7F38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DD1EE75-6D8D-4653-A800-0A24367F7F38}.Release|Any CPU.Build.0 = Release|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Release|Any CPU.Build.0 = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|Any CPU.Build.0 = Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|Any CPU.Build.0 = Release|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Release|Any CPU.Build.0 = Release|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Release|Any CPU.Build.0 = Release|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F32556C5-6FD4-4F1D-884A-DEDF2EE865F6}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371} = {385E71CC-BAE5-488B-805E-ACAE55F01DF5}
{53DCA265-3C3C-42F9-B647-F72BA678122B} = {385E71CC-BAE5-488B-805E-ACAE55F01DF5}
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2} = {385E71CC-BAE5-488B-805E-ACAE55F01DF5}
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E} = {385E71CC-BAE5-488B-805E-ACAE55F01DF5}
{DE40756E-57F6-4AF2-B155-55E3A88CCED8} = {385E71CC-BAE5-488B-805E-ACAE55F01DF5}
EndGlobalSection
EndGlobal
44 changes: 44 additions & 0 deletions Xamarin.Android.sln
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "create-pkg", "build-tools\c
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vswhere", "tools\vswhere\vswhere.csproj", "{DBDC804F-8406-4F5E-83C6-720CB0CB6C6F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuildDeviceIntegration", "tests\MSBuildDeviceIntegration\MSBuildDeviceIntegration.csproj", "{16DB2680-399B-4111-AA26-6CDBBFA334D8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "external", "external", "{05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory", "external\nrefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj", "{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.NRefactory.CSharp", "external\nrefactory\ICSharpCode.NRefactory.CSharp\ICSharpCode.NRefactory.CSharp.csproj", "{53DCA265-3C3C-42F9-B647-F72BA678122B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Debugger.Soft", "external\debugger-libs\Mono.Debugger.Soft\Mono.Debugger.Soft.csproj", "{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Debugging", "external\debugger-libs\Mono.Debugging\Mono.Debugging.csproj", "{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Debugging.Soft", "external\debugger-libs\Mono.Debugging.Soft\Mono.Debugging.Soft.csproj", "{DE40756E-57F6-4AF2-B155-55E3A88CCED8}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Xamarin.Android.NamingCustomAttributes\Xamarin.Android.NamingCustomAttributes.projitems*{3f1f2f50-af1a-4a5a-bedb-193372f068d7}*SharedItemsImports = 4
Expand Down Expand Up @@ -383,6 +397,30 @@ Global
{DBDC804F-8406-4F5E-83C6-720CB0CB6C6F}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{DBDC804F-8406-4F5E-83C6-720CB0CB6C6F}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{DBDC804F-8406-4F5E-83C6-720CB0CB6C6F}.Release|AnyCPU.Build.0 = Release|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{16DB2680-399B-4111-AA26-6CDBBFA334D8}.Release|AnyCPU.Build.0 = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}.Release|AnyCPU.Build.0 = Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|AnyCPU.Build.0 = Release|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E}.Release|AnyCPU.Build.0 = Release|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2}.Release|AnyCPU.Build.0 = Release|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Debug|AnyCPU.Build.0 = Debug|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Release|AnyCPU.ActiveCfg = Release|Any CPU
{DE40756E-57F6-4AF2-B155-55E3A88CCED8}.Release|AnyCPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -446,6 +484,12 @@ Global
{0C31DE30-F9DF-4312-BFFE-DCAD558CCF08} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{A0AEF446-3368-4591-9DE6-BC3B2B33337D} = {04E3E11E-B47D-4599-8AFC-50515A95E715}
{DBDC804F-8406-4F5E-83C6-720CB0CB6C6F} = {864062D3-A415-4A6F-9324-5820237BA058}
{16DB2680-399B-4111-AA26-6CDBBFA334D8} = {CAB438D8-B0F5-4AF0-BEBD-9E2ADBD7B483}
{3B2A5653-EC97-4001-BB9B-D90F1AF2C371} = {05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}
{53DCA265-3C3C-42F9-B647-F72BA678122B} = {05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}
{372E8E3E-29D5-4B4D-88A2-4711CD628C4E} = {05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}
{90C99ADB-7D4B-4EB4-98C2-40BD1B14C7D2} = {05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}
{DE40756E-57F6-4AF2-B155-55E3A88CCED8} = {05C3B1D6-A4CE-4534-A9E4-E9117591ADF7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {53A1F287-EFB2-4D97-A4BB-4A5E145613F6}
Expand Down
2 changes: 0 additions & 2 deletions build-tools/scripts/RunTests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.RunParallelTargets" />
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\xa-prep-tasks.dll" TaskName="Xamarin.Android.BuildTools.PrepTasks.SetEnvironmentVariable" />
<PropertyGroup>
<_Runtime Condition=" '$(HostOS)' != 'Windows' ">$(ManagedRuntime) $(ManagedRuntimeArgs)</_Runtime>
<_NUnit>$(_Runtime) packages\NUnit.ConsoleRunner.3.9.0\tools\nunit3-console.exe</_NUnit>
<_Test Condition=" '$(TEST)' != '' ">--test=&quot;$(TEST)&quot;</_Test>
<_XABuild>$(_TopDir)\bin\$(Configuration)\bin\xabuild</_XABuild>
<_XABinLogPrefix>/v:normal /binaryLogger:"$(MSBuildThisFileDirectory)\..\..\bin\Test$(Configuration)\msbuild</_XABinLogPrefix>
Expand Down
1 change: 1 addition & 0 deletions external/debugger-libs
Submodule debugger-libs added at b45303
1 change: 1 addition & 0 deletions external/nrefactory
Submodule nrefactory added at 0607a4
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,6 @@ protected override void OnCreate (Bundle bundle)
string.Format ("Unexpected Files found! {0}",
string.Join (Environment.NewLine, additionalFiles.Select (x => x.FullName))));
}
if (!HasDevices)
Assert.Ignore ("Skipping Installation. No devices available.");
Assert.IsTrue (ab.RunTarget (app, "Install"), "App should have installed.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Xamarin.ProjectTools;
using XABuildPaths = Xamarin.Android.Build.Paths;

Expand Down Expand Up @@ -154,13 +158,13 @@ public static string AndroidNdkPath {
}
}

protected void WaitFor(int milliseconds)
protected static void WaitFor(int milliseconds)
{
var pause = new ManualResetEvent(false);
pause.WaitOne(milliseconds);
}

protected static string RunAdbCommand (string command, bool ignoreErrors = true)
protected static string RunAdbCommand (string command, bool ignoreErrors = true, int timeout = 30)
{
string ext = Environment.OSVersion.Platform != PlatformID.Unix ? ".exe" : "";
string adb = Path.Combine (AndroidSdkPath, "platform-tools", "adb" + ext);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Xamarin.ProjectTools;
using XABuildPaths = Xamarin.Android.Build.Paths;

namespace Xamarin.Android.Build.Tests
{
public class DeviceTest: BaseTest
{
protected static void RunAdbInput (string command, params object [] args)
{
RunAdbCommand ($"shell {command} {string.Join (" ", args)}");
}

protected static string ClearAdbLogcat ()
{
return RunAdbCommand ("logcat -c");
}

protected static string ClearDebugProperty ()
{
return RunAdbCommand ("shell setprop debug.mono.extra \"\"");
}

protected static void AdbStartActivity (string activity)
{
RunAdbCommand ($"shell am start -S -n \"{activity}\"");
}

protected void WaitFor (TimeSpan timeSpan, Func<bool> func)
{
var pause = new ManualResetEvent (false);
TimeSpan total = timeSpan;
TimeSpan interval = TimeSpan.FromMilliseconds (10);
while (total.TotalMilliseconds > 0) {
pause.WaitOne (interval);
total = total.Subtract (interval);
if (func ()) {
break;
}
}
}

protected static bool MonitorAdbLogcat (Func<string, bool> action, int timeout = 10)
{
string ext = Environment.OSVersion.Platform != PlatformID.Unix ? ".exe" : "";
string adb = Path.Combine (AndroidSdkPath, "platform-tools", "adb" + ext);
var info = new ProcessStartInfo (adb, "logcat") {
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
};
using (var proc = Process.Start (info)) {
var sw = new Stopwatch ();
try {
TimeSpan time = TimeSpan.FromSeconds (timeout);
while (time.TotalMilliseconds > 0) {
sw.Start ();
if (action (proc.StandardOutput.ReadLine ()))
return true;
time = time.Subtract (TimeSpan.FromMilliseconds (sw.ElapsedMilliseconds));
sw.Reset ();
}
} finally {
sw.Stop ();
proc.Kill ();
proc.WaitForExit ();
}
return false;
}
}

protected static bool WaitForDebuggerToStart (out string output, int timeout = 60)
{
var sb = new StringBuilder ();
bool result = MonitorAdbLogcat ((line) => {
sb.AppendLine (line);
return line.IndexOf ("monodroid-debug: Trying to initialize the debugger with options", StringComparison.OrdinalIgnoreCase) > 0;
}, timeout: timeout);
output = sb.ToString ();
return result;
}

protected static bool WaitForActivityToStart (string activityNamespace, string activityName, out string output, int timeout = 60)
{
var sb = new StringBuilder ();
bool result = MonitorAdbLogcat ((line) => {
sb.AppendLine (line);
return line.IndexOf ("ActivityManager: Displayed", StringComparison.OrdinalIgnoreCase) > 0 && line.Contains (activityNamespace) && line.Contains (activityName);
}, timeout: timeout);
output = sb.ToString ();
return result;
}

protected static (int x, int y, int w, int h) GetControlBounds (string packageName, string uiElement, string text)
{
var regex = new Regex (@"[(0-9)]\d*", RegexOptions.Compiled);
var result = (x: 0, y: 0, w: 0, h: 0);
var ui = RunAdbCommand ("exec-out uiautomator dump /dev/tty");
while (ui.Contains ("ERROR:")) {
ui = RunAdbCommand ("exec-out uiautomator dump /dev/tty");
WaitFor (1);
}
ui = ui.Replace ("UI hierchary dumped to: /dev/tty", string.Empty).Trim ();
try {
var uiDoc = XDocument.Parse (ui);
var node = uiDoc.XPathSelectElement ($"//node[contains(@resource-id,'{uiElement}')]");
if (node == null)
node = uiDoc.XPathSelectElement ($"//node[contains(@content-desc,'{uiElement}')]");
if (node == null)
node = uiDoc.XPathSelectElement ($"//node[contains(@text,'{text}')]");
if (node == null)
return result;
var bounds = node.Attribute ("bounds");
var matches = regex.Matches (bounds.Value);
int.TryParse (matches [0].Value, out int x);
int.TryParse (matches [1].Value, out int y);
int.TryParse (matches [2].Value, out int w);
int.TryParse (matches [3].Value, out int h);
return (x: x, y: y, w: w, h: h);
} catch (Exception ex) {
// Ignore any error and return and empty
throw new InvalidOperationException ($"uiautomator returned invalid xml {ui}", ex);
}
}

protected static void ClickButton (string packageName, string buttonName, string buttonText)
{
var bounds = GetControlBounds (packageName, buttonName, buttonText);
RunAdbInput ("input tap", bounds.x + ((bounds.w - bounds.x) / 2), bounds.y + ((bounds.h - bounds.y) / 2));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ManifestTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PackagingTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\BaseTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\DeviceTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\BuildHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\FilesTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Utilities\MockBuildEngine.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<Reference Include="Xamarin.Build.AsyncTask">
<HintPath>..\..\..\..\packages\Xamarin.Build.AsyncTask.0.3.4\lib\netstandard2.0\Xamarin.Build.AsyncTask.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Numerics" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ public bool Build (XamarinProject project, bool doNotCleanupOnUpdate = false, st
return result;
}

public bool Install (XamarinProject project, bool doNotCleanupOnUpdate = false)
{
return RunTarget (project, "Install", doNotCleanupOnUpdate);
}

public bool Uninstall (XamarinProject project, bool doNotCleanupOnUpdate = false)
{
return RunTarget (project, "Uninstall", doNotCleanupOnUpdate);
}

public bool Restore (XamarinProject project, bool doNotCleanupOnUpdate = false)
{
return RunTarget (project, "Restore", doNotCleanupOnUpdate);
Expand Down
Loading