From 61876ee6ae2846a51765927bafef6d4b44d9ba33 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Mon, 31 Oct 2016 15:31:10 +0000 Subject: [PATCH 1/5] Explicitly set C# version to 5.0 --- .../Microsoft.Phone.Tools.Deploy.Patched.csproj | 1 + Winium/Winium.Mobile.Common/Winium.Mobile.Common.csproj | 1 + .../Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj | 1 + Winium/Winium.Mobile.Driver/Winium.Mobile.Driver.csproj | 1 + Winium/Winium.Mobile.Logging/Winium.Mobile.Logging.csproj | 1 + .../Winium.Silverlight.InnerServer.csproj | 1 + .../Winium.StoreApps.InnerServer.csproj | 1 + .../Winium.StoreApps.Inspector/Winium.StoreApps.Inspector.csproj | 1 + 8 files changed, 8 insertions(+) diff --git a/Winium/Microsoft.Phone.Tools.Deploy.Patched/Microsoft.Phone.Tools.Deploy.Patched.csproj b/Winium/Microsoft.Phone.Tools.Deploy.Patched/Microsoft.Phone.Tools.Deploy.Patched.csproj index 4f85007..12051d6 100644 --- a/Winium/Microsoft.Phone.Tools.Deploy.Patched/Microsoft.Phone.Tools.Deploy.Patched.csproj +++ b/Winium/Microsoft.Phone.Tools.Deploy.Patched/Microsoft.Phone.Tools.Deploy.Patched.csproj @@ -20,6 +20,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 5 bin\x86\Release\ diff --git a/Winium/Winium.Mobile.Common/Winium.Mobile.Common.csproj b/Winium/Winium.Mobile.Common/Winium.Mobile.Common.csproj index 0671718..71e115f 100644 --- a/Winium/Winium.Mobile.Common/Winium.Mobile.Common.csproj +++ b/Winium/Winium.Mobile.Common/Winium.Mobile.Common.csproj @@ -26,6 +26,7 @@ DEBUG;TRACE prompt 4 + 5 pdbonly diff --git a/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj b/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj index 8d2a959..3aa4b8a 100644 --- a/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj +++ b/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj @@ -20,6 +20,7 @@ x86 prompt MinimumRecommendedRules.ruleset + 5 bin\x86\Release\ diff --git a/Winium/Winium.Mobile.Driver/Winium.Mobile.Driver.csproj b/Winium/Winium.Mobile.Driver/Winium.Mobile.Driver.csproj index 1e14598..462b8a9 100644 --- a/Winium/Winium.Mobile.Driver/Winium.Mobile.Driver.csproj +++ b/Winium/Winium.Mobile.Driver/Winium.Mobile.Driver.csproj @@ -25,6 +25,7 @@ prompt MinimumRecommendedRules.ruleset true + 5 bin\x86\Release\ diff --git a/Winium/Winium.Mobile.Logging/Winium.Mobile.Logging.csproj b/Winium/Winium.Mobile.Logging/Winium.Mobile.Logging.csproj index ba42856..8ceeeaa 100644 --- a/Winium/Winium.Mobile.Logging/Winium.Mobile.Logging.csproj +++ b/Winium/Winium.Mobile.Logging/Winium.Mobile.Logging.csproj @@ -22,6 +22,7 @@ DEBUG;TRACE prompt 4 + 5 pdbonly diff --git a/Winium/Winium.Silverlight.InnerServer/Winium.Silverlight.InnerServer.csproj b/Winium/Winium.Silverlight.InnerServer/Winium.Silverlight.InnerServer.csproj index b77c031..07afad0 100644 --- a/Winium/Winium.Silverlight.InnerServer/Winium.Silverlight.InnerServer.csproj +++ b/Winium/Winium.Silverlight.InnerServer/Winium.Silverlight.InnerServer.csproj @@ -34,6 +34,7 @@ true prompt 4 + 5 pdbonly diff --git a/Winium/Winium.StoreApps.InnerServer/Winium.StoreApps.InnerServer.csproj b/Winium/Winium.StoreApps.InnerServer/Winium.StoreApps.InnerServer.csproj index 5aa99e3..b165b19 100644 --- a/Winium/Winium.StoreApps.InnerServer/Winium.StoreApps.InnerServer.csproj +++ b/Winium/Winium.StoreApps.InnerServer/Winium.StoreApps.InnerServer.csproj @@ -26,6 +26,7 @@ DEBUG;TRACE prompt 4 + 5 pdbonly diff --git a/Winium/Winium.StoreApps.Inspector/Winium.StoreApps.Inspector.csproj b/Winium/Winium.StoreApps.Inspector/Winium.StoreApps.Inspector.csproj index 6d394e4..1c4ba72 100644 --- a/Winium/Winium.StoreApps.Inspector/Winium.StoreApps.Inspector.csproj +++ b/Winium/Winium.StoreApps.Inspector/Winium.StoreApps.Inspector.csproj @@ -42,6 +42,7 @@ prompt 4 MinimumRecommendedRules.ruleset + 5 AnyCPU From 759a115c2dce22161d2a37bee3c6b1eb58c9b9aa Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Mon, 31 Oct 2016 16:50:54 +0000 Subject: [PATCH 2/5] Impement closeApp for silverlight apps --- .../Utils.cs | 37 +++++++++---------- Winium/Winium.Mobile.Connectivity/AppType.cs | 9 +++++ Winium/Winium.Mobile.Connectivity/Deployer.cs | 17 +++++++-- .../Winium.Mobile.Connectivity/IDeployer.cs | 2 + .../Winium.Mobile.Connectivity.csproj | 1 + .../CommandExecutors/CloseAppExecutor.cs | 14 +++++-- 6 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 Winium/Winium.Mobile.Connectivity/AppType.cs diff --git a/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs b/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs index a88f16d..6700d6f 100644 --- a/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs +++ b/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs @@ -105,6 +105,24 @@ public static IAppManifestInfo ReadAppManifestInfoFromPackage(string path) } } + public static TypeOfApp DetermineAppType(string packagePath) + { + var extension = Path.GetExtension(packagePath); + if (!string.IsNullOrEmpty(extension)) + { + switch (extension.ToLower(CultureInfo.InvariantCulture)) + { + case ".appxbundle": + return TypeOfApp.APPXBUNDLE; + case ".appx": + return TypeOfApp.APPX; + case ".xap": + return TypeOfApp.XAP; + } + } + + throw new NotImplementedException("This file extension is not supported by the tool."); + } #endregion #region Methods @@ -127,25 +145,6 @@ internal static void ApplySideloadFlags(IAppManifestInfo manifestInfo, ref Deplo } } - internal static TypeOfApp DetermineAppType(string packagePath) - { - var extension = Path.GetExtension(packagePath); - if (!string.IsNullOrEmpty(extension)) - { - switch (extension.ToLower(CultureInfo.InvariantCulture)) - { - case ".appxbundle": - return TypeOfApp.APPXBUNDLE; - case ".appx": - return TypeOfApp.APPX; - case ".xap": - return TypeOfApp.XAP; - } - } - - throw new NotImplementedException("This file extension is not supported by the tool."); - } - internal static string GenerateNDeployMdil( string packageFile, IRemoteApplication app, diff --git a/Winium/Winium.Mobile.Connectivity/AppType.cs b/Winium/Winium.Mobile.Connectivity/AppType.cs new file mode 100644 index 0000000..85c99f9 --- /dev/null +++ b/Winium/Winium.Mobile.Connectivity/AppType.cs @@ -0,0 +1,9 @@ +namespace Winium.Mobile.Connectivity +{ + public enum AppType + { + XAP = Microsoft.Phone.Tools.Deploy.TypeOfApp.XAP, + APPX = Microsoft.Phone.Tools.Deploy.TypeOfApp.APPX, + APPXBUNDLE = Microsoft.Phone.Tools.Deploy.TypeOfApp.APPXBUNDLE + } +} diff --git a/Winium/Winium.Mobile.Connectivity/Deployer.cs b/Winium/Winium.Mobile.Connectivity/Deployer.cs index 5cfd723..6c466e8 100644 --- a/Winium/Winium.Mobile.Connectivity/Deployer.cs +++ b/Winium/Winium.Mobile.Connectivity/Deployer.cs @@ -52,8 +52,8 @@ public Deployer(string desiredDevice, bool strict) { throw new AutomationException( string.Format( - "Could not find a device to launch. You requested '{0}', but the available devices were:\n{1}", - desiredDevice, + "Could not find a device to launch. You requested '{0}', but the available devices were:\n{1}", + desiredDevice, Devices.Instance)); } @@ -77,6 +77,8 @@ public string DeviceName } } + public AppType AppType { get; private set; } + #endregion #region Properties @@ -99,6 +101,7 @@ public void UsePreInstalledApplication(string appPath) { var appManifest = Utils.ReadAppManifestInfoFromPackage(appPath); this.RemoteApplication = this.Device.GetApplication(appManifest.ProductId); + this.AppType = (AppType)((int)Utils.DetermineAppType(appPath)); } public void Launch() @@ -136,7 +139,14 @@ public void SendFiles(List> files) public void Terminate() { - throw new NotImplementedException("Deployer.Terminate"); + if (this.AppType == AppType.XAP) + { + this.RemoteApplication.TerminateRunningInstances(); + } + else + { + throw new NotImplementedException("Deployer.Terminate"); + } } public void Uninstall() @@ -162,6 +172,7 @@ private void InstallApp(string appPath) var appManifestInfo = this.InstallApplicationPackage(appPath); this.installed = true; this.RemoteApplication = this.Device.GetApplication(appManifestInfo.ProductId); + this.AppType = (AppType)((int)Utils.DetermineAppType(appPath)); } private IAppManifestInfo InstallApplicationPackage(string path) diff --git a/Winium/Winium.Mobile.Connectivity/IDeployer.cs b/Winium/Winium.Mobile.Connectivity/IDeployer.cs index 791cc21..98c4dd7 100644 --- a/Winium/Winium.Mobile.Connectivity/IDeployer.cs +++ b/Winium/Winium.Mobile.Connectivity/IDeployer.cs @@ -12,6 +12,8 @@ public interface IDeployer string DeviceName { get; } + AppType AppType { get; } + #endregion #region Public Methods and Operators diff --git a/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj b/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj index 3aa4b8a..e8f1a05 100644 --- a/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj +++ b/Winium/Winium.Mobile.Connectivity/Winium.Mobile.Connectivity.csproj @@ -67,6 +67,7 @@ + diff --git a/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs b/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs index ad7a573..ccea39e 100644 --- a/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs +++ b/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs @@ -1,5 +1,6 @@ namespace Winium.Mobile.Driver.CommandExecutors { + using Connectivity; using System; using System.Threading; @@ -12,9 +13,16 @@ internal class CloseAppExecutor : CommandExecutorBase public static void CloseApp(Automator automator) { - var remoteCommand = new Command(DriverCommand.CloseApp); - automator.CommandForwarder.ForwardCommand(remoteCommand); - Thread.Sleep(TimeSpan.FromMilliseconds(500)); + if (automator.Deployer.AppType == AppType.XAP) + { + automator.Deployer.Terminate(); + } + else + { + var remoteCommand = new Command(DriverCommand.CloseApp); + automator.CommandForwarder.ForwardCommand(remoteCommand); + Thread.Sleep(TimeSpan.FromMilliseconds(500)); + } } #endregion From e4d2a39a7806fef2b7b28568cf12bbdd0e92c723 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Tue, 1 Nov 2016 10:25:29 +0000 Subject: [PATCH 3/5] Move DetermineAppType to Deployer --- .../Utils.cs | 37 ++++++++++--------- Winium/Winium.Mobile.Connectivity/Deployer.cs | 24 ++++++++++-- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs b/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs index 6700d6f..a88f16d 100644 --- a/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs +++ b/Winium/Microsoft.Phone.Tools.Deploy.Patched/Utils.cs @@ -105,24 +105,6 @@ public static IAppManifestInfo ReadAppManifestInfoFromPackage(string path) } } - public static TypeOfApp DetermineAppType(string packagePath) - { - var extension = Path.GetExtension(packagePath); - if (!string.IsNullOrEmpty(extension)) - { - switch (extension.ToLower(CultureInfo.InvariantCulture)) - { - case ".appxbundle": - return TypeOfApp.APPXBUNDLE; - case ".appx": - return TypeOfApp.APPX; - case ".xap": - return TypeOfApp.XAP; - } - } - - throw new NotImplementedException("This file extension is not supported by the tool."); - } #endregion #region Methods @@ -145,6 +127,25 @@ internal static void ApplySideloadFlags(IAppManifestInfo manifestInfo, ref Deplo } } + internal static TypeOfApp DetermineAppType(string packagePath) + { + var extension = Path.GetExtension(packagePath); + if (!string.IsNullOrEmpty(extension)) + { + switch (extension.ToLower(CultureInfo.InvariantCulture)) + { + case ".appxbundle": + return TypeOfApp.APPXBUNDLE; + case ".appx": + return TypeOfApp.APPX; + case ".xap": + return TypeOfApp.XAP; + } + } + + throw new NotImplementedException("This file extension is not supported by the tool."); + } + internal static string GenerateNDeployMdil( string packageFile, IRemoteApplication app, diff --git a/Winium/Winium.Mobile.Connectivity/Deployer.cs b/Winium/Winium.Mobile.Connectivity/Deployer.cs index 6c466e8..dd80810 100644 --- a/Winium/Winium.Mobile.Connectivity/Deployer.cs +++ b/Winium/Winium.Mobile.Connectivity/Deployer.cs @@ -91,6 +91,25 @@ public string DeviceName #region Public Methods and Operators + public static AppType DetermineAppType(string packagePath) + { + var extension = Path.GetExtension(packagePath); + if (!string.IsNullOrEmpty(extension)) + { + switch (extension.ToLower(CultureInfo.InvariantCulture)) + { + case ".appxbundle": + return AppType.APPXBUNDLE; + case ".appx": + return AppType.APPX; + case ".xap": + return AppType.XAP; + } + } + + throw new NotImplementedException("This file extension is not supported by the tool."); + } + public void Install(string appPath, List dependencies) { this.InstallDependencies(dependencies); @@ -101,7 +120,7 @@ public void UsePreInstalledApplication(string appPath) { var appManifest = Utils.ReadAppManifestInfoFromPackage(appPath); this.RemoteApplication = this.Device.GetApplication(appManifest.ProductId); - this.AppType = (AppType)((int)Utils.DetermineAppType(appPath)); + this.AppType = DetermineAppType(appPath); } public void Launch() @@ -162,7 +181,6 @@ public void Uninstall() this.Device.Disconnect(); } - #endregion #region Methods @@ -172,7 +190,7 @@ private void InstallApp(string appPath) var appManifestInfo = this.InstallApplicationPackage(appPath); this.installed = true; this.RemoteApplication = this.Device.GetApplication(appManifestInfo.ProductId); - this.AppType = (AppType)((int)Utils.DetermineAppType(appPath)); + this.AppType = DetermineAppType(appPath); } private IAppManifestInfo InstallApplicationPackage(string path) From 329e2db453a8430e866572928364240fb08932e9 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Fri, 4 Nov 2016 13:28:41 +0000 Subject: [PATCH 4/5] Make DetermineAppType private again --- Winium/Winium.Mobile.Connectivity/Deployer.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Winium/Winium.Mobile.Connectivity/Deployer.cs b/Winium/Winium.Mobile.Connectivity/Deployer.cs index dd80810..b8b52cd 100644 --- a/Winium/Winium.Mobile.Connectivity/Deployer.cs +++ b/Winium/Winium.Mobile.Connectivity/Deployer.cs @@ -91,25 +91,6 @@ public string DeviceName #region Public Methods and Operators - public static AppType DetermineAppType(string packagePath) - { - var extension = Path.GetExtension(packagePath); - if (!string.IsNullOrEmpty(extension)) - { - switch (extension.ToLower(CultureInfo.InvariantCulture)) - { - case ".appxbundle": - return AppType.APPXBUNDLE; - case ".appx": - return AppType.APPX; - case ".xap": - return AppType.XAP; - } - } - - throw new NotImplementedException("This file extension is not supported by the tool."); - } - public void Install(string appPath, List dependencies) { this.InstallDependencies(dependencies); @@ -185,6 +166,25 @@ public void Uninstall() #region Methods + private static AppType DetermineAppType(string packagePath) + { + var extension = Path.GetExtension(packagePath); + if (!string.IsNullOrEmpty(extension)) + { + switch (extension.ToLower(CultureInfo.InvariantCulture)) + { + case ".appxbundle": + return AppType.APPXBUNDLE; + case ".appx": + return AppType.APPX; + case ".xap": + return AppType.XAP; + } + } + + throw new NotImplementedException("This file extension is not supported by the tool."); + } + private void InstallApp(string appPath) { var appManifestInfo = this.InstallApplicationPackage(appPath); From 1b9f13e6f6a4f0a25cd1ecece4652c8897237f79 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Sun, 6 Nov 2016 10:42:29 +0000 Subject: [PATCH 5/5] Deployer.Terminate returns false if it is not supported --- Winium/Winium.Mobile.Connectivity/Deployer.cs | 6 ++++-- Winium/Winium.Mobile.Connectivity/IDeployer.cs | 2 +- .../CommandExecutors/CloseAppExecutor.cs | 7 ++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Winium/Winium.Mobile.Connectivity/Deployer.cs b/Winium/Winium.Mobile.Connectivity/Deployer.cs index b8b52cd..37fd25f 100644 --- a/Winium/Winium.Mobile.Connectivity/Deployer.cs +++ b/Winium/Winium.Mobile.Connectivity/Deployer.cs @@ -137,15 +137,17 @@ public void SendFiles(List> files) } } - public void Terminate() + public bool Terminate() { if (this.AppType == AppType.XAP) { this.RemoteApplication.TerminateRunningInstances(); + return true; } else { - throw new NotImplementedException("Deployer.Terminate"); + Logger.Debug("Could not terminate application from outside."); + return false; } } diff --git a/Winium/Winium.Mobile.Connectivity/IDeployer.cs b/Winium/Winium.Mobile.Connectivity/IDeployer.cs index 98c4dd7..838bd2c 100644 --- a/Winium/Winium.Mobile.Connectivity/IDeployer.cs +++ b/Winium/Winium.Mobile.Connectivity/IDeployer.cs @@ -30,7 +30,7 @@ public interface IDeployer void SendFile(string isoStoreRoot, string sourceDesktopFilePath, string targetDeviceFilePath); - void Terminate(); + bool Terminate(); void Uninstall(); diff --git a/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs b/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs index ccea39e..d0953d1 100644 --- a/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs +++ b/Winium/Winium.Mobile.Driver/CommandExecutors/CloseAppExecutor.cs @@ -13,11 +13,8 @@ internal class CloseAppExecutor : CommandExecutorBase public static void CloseApp(Automator automator) { - if (automator.Deployer.AppType == AppType.XAP) - { - automator.Deployer.Terminate(); - } - else + var terminated = automator.Deployer.Terminate(); + if (!terminated) { var remoteCommand = new Command(DriverCommand.CloseApp); automator.CommandForwarder.ForwardCommand(remoteCommand);