Esempio n. 1
0
        public void InstallPackageTest()
        {
            var syncService = new DummySyncService();

            Factories.SyncServiceFactory = (c, d) => syncService;

            var adbClient = new DummyAdbClient();

            adbClient.Commands.Add("pm list packages -f", "package:/system/app/Gallery2/Gallery2.apk=com.android.gallery3d");
            adbClient.Commands.Add("pm install /data/local/tmp/test.txt", string.Empty);
            adbClient.Commands.Add("rm /data/local/tmp/test.txt", string.Empty);

            DeviceData device = new DeviceData()
            {
                State = DeviceState.Online
            };

            PackageManager manager = new PackageManager(adbClient, device);

            manager.InstallPackage("test.txt", false);
            Assert.Equal(3, adbClient.ReceivedCommands.Count);
            Assert.Equal("pm install /data/local/tmp/test.txt", adbClient.ReceivedCommands[1]);
            Assert.Equal("rm /data/local/tmp/test.txt", adbClient.ReceivedCommands[2]);

            Assert.Single(syncService.UploadedFiles);
            Assert.True(syncService.UploadedFiles.ContainsKey("/data/local/tmp/test.txt"));
        }
Esempio n. 2
0
        public void InstallPackageTest()
        {
            var syncService = new DummySyncService();
            Factories.SyncServiceFactory = (d) => syncService;

            var adbClient = new DummyAdbClient();

            adbClient.Commands.Add("pm list packages -f", "package:/system/app/Gallery2/Gallery2.apk=com.android.gallery3d");
            adbClient.Commands.Add("pm install /storage/sdcard0/tmp/test.txt", string.Empty);
            adbClient.Commands.Add("rm /storage/sdcard0/tmp/test.txt", string.Empty);

            AdbClient.Instance = adbClient;

            DeviceData device = new DeviceData()
            {
                State = DeviceState.Online
            };

            PackageManager manager = new PackageManager(device);
            manager.InstallPackage("test.txt", false);
            Assert.AreEqual(3, adbClient.ReceivedCommands.Count);
            Assert.AreEqual("pm install /storage/sdcard0/tmp/test.txt", adbClient.ReceivedCommands[1]);
            Assert.AreEqual("rm /storage/sdcard0/tmp/test.txt", adbClient.ReceivedCommands[2]);

            Assert.AreEqual(1, syncService.UploadedFiles.Count);
            Assert.IsTrue(syncService.UploadedFiles.ContainsKey("/storage/sdcard0/tmp/test.txt"));
        }