Esempio n. 1
0
        public void ProcessSuccessTest()
        {
            InstallReceiver receiver = new InstallReceiver();
            receiver.AddOutput("Success");
            receiver.Flush();

            Assert.IsTrue(receiver.Success);
        }
Esempio n. 2
0
        public void ProcessFailureNoMessageTest()
        {
            InstallReceiver receiver = new InstallReceiver();
            receiver.AddOutput("Failure");
            receiver.Flush();

            Assert.IsFalse(receiver.Success);
            Assert.AreEqual(InstallReceiver.UnknownError, receiver.ErrorMessage);
        }
Esempio n. 3
0
        public void ProcessFailureTest()
        {
            InstallReceiver receiver = new InstallReceiver();
            receiver.AddOutput("Failure [message]");
            receiver.Flush();

            Assert.IsFalse(receiver.Success);
            Assert.AreEqual("message", receiver.ErrorMessage);
        }
Esempio n. 4
0
        /// <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);
            }
        }
Esempio n. 5
0
        /// <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);
            }
        }
Esempio n. 6
0
        /// <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);
            }
        }
Esempio n. 7
0
        /// <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);
            }
        }
Esempio n. 8
0
        /// <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);
            }
        }