public void ProcessSuccessTest() { InstallReceiver receiver = new InstallReceiver(); receiver.AddOutput("Success"); receiver.Flush(); Assert.IsTrue(receiver.Success); }
public void ProcessFailureNoMessageTest() { InstallReceiver receiver = new InstallReceiver(); receiver.AddOutput("Failure"); receiver.Flush(); Assert.IsFalse(receiver.Success); Assert.AreEqual(InstallReceiver.UnknownError, receiver.ErrorMessage); }
public void ProcessFailureTest() { InstallReceiver receiver = new InstallReceiver(); receiver.AddOutput("Failure [message]"); receiver.Flush(); Assert.IsFalse(receiver.Success); Assert.AreEqual("message", receiver.ErrorMessage); }
/// <summary> /// Uninstalls a package from the device. /// </summary> /// <param name="packageName"> /// The name of the package to uninstall. /// </param> public void UninstallPackage(string packageName) { this.ValidateDevice(); InstallReceiver receiver = new InstallReceiver(); this.Device.ExecuteShellCommand($"pm uninstall {packageName}", receiver); if (!string.IsNullOrEmpty(receiver.ErrorMessage)) { throw new PackageInstallationException(receiver.ErrorMessage); } }
/// <summary> /// Uninstalls a package from the device. /// </summary> /// <param name="packageName"> /// The name of the package to uninstall. /// <param name="keepData"> /// Keep the data and cache directories around after package removal. /// </param> public void UninstallPackage(string packageName, bool keepData = false) { this.ValidateDevice(); InstallReceiver receiver = new InstallReceiver(); this.Device.ExecuteShellCommand(this.client, $"pm uninstall {(keepData ? "-k " : "")}{packageName}", receiver); if (!string.IsNullOrEmpty(receiver.ErrorMessage)) { throw new PackageInstallationException(receiver.ErrorMessage); } }
/// <summary> /// Installs the application package that was pushed to a temporary location on the device. /// </summary> /// <param name="remoteFilePath">absolute file path to package file on device</param> /// <param name="reinstall">set to <see langword="true"/> if re-install of app should be performed</param> public void InstallRemotePackage(string remoteFilePath, bool reinstall) { this.ValidateDevice(); InstallReceiver receiver = new InstallReceiver(); var reinstallSwitch = reinstall ? "-r " : string.Empty; string cmd = $"pm install {reinstallSwitch}{remoteFilePath}"; this.Device.ExecuteShellCommand(cmd, receiver); if (!string.IsNullOrEmpty(receiver.ErrorMessage)) { throw new PackageInstallationException(receiver.ErrorMessage); } }
/// <summary> /// Uninstalls a package from the device. /// </summary> /// <param name="packageName"> /// The name of the package to uninstall. /// </param> public void UninstallPackage(string packageName) { this.ValidateDevice(); InstallReceiver receiver = new InstallReceiver(); this.Device.ExecuteShellCommand($"pm uninstall {packageName}", receiver); if (!string.IsNullOrEmpty(receiver.ErrorMessage)) { throw new PackageInstallationException(receiver.ErrorMessage); } }
/// <summary> /// Installs the application package that was pushed to a temporary location on the device. /// </summary> /// <param name="remoteFilePath">absolute file path to package file on device</param> /// <param name="reinstall">set to <see langword="true"/> if re-install of app should be performed</param> public void InstallRemotePackage(string remoteFilePath, bool reinstall) { this.ValidateDevice(); InstallReceiver receiver = new InstallReceiver(); var reinstallSwitch = reinstall ? "-r " : string.Empty; string cmd = $"pm install {reinstallSwitch}{remoteFilePath}"; this.Device.ExecuteShellCommand(cmd, receiver); if (!string.IsNullOrEmpty(receiver.ErrorMessage)) { throw new PackageInstallationException(receiver.ErrorMessage); } }