Example #1
0
        public void ResolveStorageDirectoryTest()
        {
            // Tests the path to the /storage/emulated/legacy folder on a Nexus 10 device.
            var device = this.GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);

            // Make sure the /storage/ folder is resolved correctly. It is not a symlink, but it may
            // contain symlinks - e.g. /storage/sdcard.
            // In previous builds, the /storage/ folder would be resolved to symlink of its children.
            FileEntry storage = fileListingService.FindFileEntry("/storage/");
            Assert.AreEqual("/storage/", storage.FullResolvedPath);

            FileEntry apk = fileListingService.FindFileEntry("/storage/emulated/legacy/a584a9d6-1e29-4a4b-b8fb-23aa3f378b56.apk");
            Assert.AreEqual("/mnt/shell/emulated/0/a584a9d6-1e29-4a4b-b8fb-23aa3f378b56.apk", apk.FullEscapedPath);
        }
Example #2
0
        public void SyncServicePullFileTest()
        {
            Device             device             = GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);

            using (ISyncService sync = device.SyncService)
            {
                String    rfile  = "/sdcard/bootanimations/bootanimation-cm.zip";
                FileEntry rentry = fileListingService.FindFileEntry(rfile);

                String     lpath  = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                String     lfile  = Path.Combine(lpath, LinuxPath.GetFileName(rfile));
                FileInfo   lfi    = new FileInfo(lfile);
                SyncResult result = sync.PullFile(rfile, lfile, new FileSyncProgressMonitor());

                Assert.IsTrue(lfi.Exists);
                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
                lfi.Delete();

                result = sync.PullFile(rentry, lfile, new FileSyncProgressMonitor());
                Assert.IsTrue(lfi.Exists);
                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
                lfi.Delete();
            }
        }
Example #3
0
        public void SyncServicePullFileTest()
        {
            Device device = GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);

            using (ISyncService sync = device.SyncService)
            {
                String rfile = "/sdcard/bootanimations/bootanimation-cm.zip";
                FileEntry rentry = fileListingService.FindFileEntry(rfile);

                String lpath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                String lfile = Path.Combine(lpath, LinuxPath.GetFileName(rfile));
                FileInfo lfi = new FileInfo(lfile);
                SyncResult result = sync.PullFile(rfile, lfile, new FileSyncProgressMonitor());

                Assert.IsTrue(lfi.Exists);
                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
                lfi.Delete();

                result = sync.PullFile(rentry, lfile, new FileSyncProgressMonitor());
                Assert.IsTrue(lfi.Exists);
                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
                lfi.Delete();

            }
        }
Example #4
0
        public void ResolveStorageDirectoryTest()
        {
            // Tests the path to the /storage/emulated/legacy folder on a Nexus 10 device.
            var device = this.GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);

            // Make sure the /storage/ folder is resolved correctly. It is not a symlink, but it may
            // contain symlinks - e.g. /storage/sdcard.
            // In previous builds, the /storage/ folder would be resolved to symlink of its children.
            FileEntry storage = fileListingService.FindFileEntry("/storage/");

            Assert.AreEqual("/storage/", storage.FullResolvedPath);

            FileEntry apk = fileListingService.FindFileEntry("/storage/emulated/legacy/a584a9d6-1e29-4a4b-b8fb-23aa3f378b56.apk");

            Assert.AreEqual("/mnt/shell/emulated/0/a584a9d6-1e29-4a4b-b8fb-23aa3f378b56.apk", apk.FullEscapedPath);
        }
Example #5
0
        public void SyncServicePullFilesTest()
        {
            Device             device             = GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);

            using (ISyncService sync = device.SyncService)
            {
                String        lpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "apps");
                String        rpath = "/system/app/";
                DirectoryInfo ldir  = new DirectoryInfo(lpath);
                if (!ldir.Exists)
                {
                    ldir.Create();
                }
                FileEntry fentry = fileListingService.FindFileEntry(rpath);
                Assert.IsTrue(fentry.IsDirectory);

                FileEntry[] entries = fileListingService.GetChildren(fentry, false, null);
                SyncResult  result  = sync.Pull(entries, ldir.FullName, new FileSyncProgressMonitor());

                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
            }
        }
Example #6
0
        public void SyncServicePushFileTest()
        {
            String             testFile           = CreateTestFile();
            FileInfo           localFile          = new FileInfo(testFile);
            String             remoteFile         = String.Format("/sdcard/{0}", Path.GetFileName(testFile));
            Device             device             = GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);


            using (ISyncService sync = device.SyncService)
            {
                SyncResult result = sync.PushFile(localFile.FullName, remoteFile, new FileSyncProgressMonitor());
                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
                FileEntry remoteEntry = null;
                remoteEntry = fileListingService.FindFileEntry(remoteFile);

                // check the size
                Assert.AreEqual <long>(localFile.Length, remoteEntry.Size);

                // clean up temp file on sdcard
                device.ExecuteShellCommand(String.Format("rm {0}", remoteEntry.FullEscapedPath), new ConsoleOutputReceiver());
            }
        }
Example #7
0
        public void SyncServicePullFilesTest()
        {
            Device device = GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);

            using (ISyncService sync = device.SyncService)
            {
                String lpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "apps");
                String rpath = "/system/app/";
                DirectoryInfo ldir = new DirectoryInfo(lpath);
                if (!ldir.Exists)
                {
                    ldir.Create();
                }
                FileEntry fentry = fileListingService.FindFileEntry(rpath);
                Assert.IsTrue(fentry.IsDirectory);

                FileEntry[] entries = fileListingService.GetChildren(fentry, false, null);
                SyncResult result = sync.Pull(entries, ldir.FullName, new FileSyncProgressMonitor());

                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
            }
        }
Example #8
0
        public void SyncServicePushFileTest()
        {
            String testFile = CreateTestFile();
            FileInfo localFile = new FileInfo(testFile);
            String remoteFile = String.Format("/sdcard/{0}", Path.GetFileName(testFile));
            Device device = GetFirstDevice();
            FileListingService fileListingService = new FileListingService(device);

            using (ISyncService sync = device.SyncService)
            {
                SyncResult result = sync.PushFile(localFile.FullName, remoteFile, new FileSyncProgressMonitor());
                Assert.IsTrue(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
                FileEntry remoteEntry = null;
                remoteEntry = fileListingService.FindFileEntry(remoteFile);

                // check the size
                Assert.AreEqual<long>(localFile.Length, remoteEntry.Size);

                // clean up temp file on sdcard
                device.ExecuteShellCommand(String.Format("rm {0}", remoteEntry.FullEscapedPath), new ConsoleOutputReceiver());
            }
        }