Esempio n. 1
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();
            }
        }
Esempio n. 2
0
        public void SyncServicePullFilesTest( )
        {
            Device device = GetFirstDevice( );

            using (SyncService 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 = device.FileListingService.FindFileEntry(rpath);
                Assert.True(fentry.IsDirectory);

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

                Assert.True(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
            }
        }
Esempio n. 3
0
        public void SyncServicePushFileTest( )
        {
            String   testFile   = CreateTestFile( );
            FileInfo localFile  = new FileInfo(testFile);
            String   remoteFile = String.Format("/sdcard/{0}", Path.GetFileName(testFile));
            Device   device     = GetFirstDevice( );


            using (SyncService sync = device.SyncService) {
                SyncResult result = sync.PushFile(localFile.FullName, remoteFile, new FileSyncProgressMonitor( ));
                Assert.True(ErrorCodeHelper.RESULT_OK == result.Code, ErrorCodeHelper.ErrorCodeToString(result.Code));
                FileEntry remoteEntry = null;
                Assert.DoesNotThrow(new Assert.ThrowsDelegate(delegate() {
                    remoteEntry = device.FileListingService.FindFileEntry(remoteFile);
                }));

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

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