import com.cyanogenmod.explorer.console.Console;
import com.cyanogenmod.explorer.console.ConsoleBuilder;
import com.cyanogenmod.explorer.console.shell.ShellConsole;
+import com.cyanogenmod.explorer.util.FileHelper;
/**
* An abstract class that manages tests that needs a console.
*/
public abstract class AbstractConsoleTest extends android.test.AndroidTestCase {
- private static final String INITIAL_DIR = "/"; //$NON-NLS-1$
+ private static final String INITIAL_DIR = FileHelper.ROOT_DIRECTORY;
private Console mConsole;
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.console.NoSuchFileOrDirectory;
import com.cyanogenmod.explorer.util.CommandHelper;
+import com.cyanogenmod.explorer.util.FileHelper;
/**
* A class for testing the {@link ChangeCurrentDirCommand} command.
*/
public class ChangeCurrentDirCommandTest extends AbstractConsoleTest {
- private static final String PATH_OK = "/"; //$NON-NLS-1$
- private static final String PATH_ERROR = "/mnt/sdcard121212"; //$NON-NLS-1$
+ private static final String PATH_OK = FileHelper.ROOT_DIRECTORY;
+ private static final String PATH_ERROR = "/foo/foo121212"; //$NON-NLS-1$
/**
* {@inheritDoc}
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testChangeDirOk() throws Exception {
boolean ret = CommandHelper.changeCurrentDir(getContext(), PATH_OK, getConsole());
assertTrue("response==false", ret); //$NON-NLS-1$
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testChangeDirFail() throws Exception {
String oldPwd = CommandHelper.getCurrentDir(getContext(), getConsole());
try {
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.FileSystemObject;
import com.cyanogenmod.explorer.model.Group;
import com.cyanogenmod.explorer.model.User;
*/
public class ChangeOwnerCommandTest extends AbstractConsoleTest {
- private static final String PATH_FILE = "/data/chowntest.txt"; //$NON-NLS-1$
+ private static final String PATH_FILE =
+ Environment.getDataDirectory().getAbsolutePath() + "/chowntest.txt"; //$NON-NLS-1$
private static final String NEW_GROUP = "graphics"; //$NON-NLS-1$
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testChangeOwnerOk() throws Exception {
try {
//Create and list the file
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.FileSystemObject;
import com.cyanogenmod.explorer.model.Permissions;
import com.cyanogenmod.explorer.util.CommandHelper;
*/
public class ChangePermissionsCommandTest extends AbstractConsoleTest {
- private static final String PATH_FILE = "/data/chmodtest.txt"; //$NON-NLS-1$
+ private static final String PATH_FILE =
+ Environment.getDataDirectory().getAbsolutePath() + "/chmodtest.txt"; //$NON-NLS-1$
/**
* {@inheritDoc}
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testChangePermissionsOk() throws Exception {
try {
//Create and list the file
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
*/
public class CopyCommandTest extends AbstractConsoleTest {
- private static final String PATH_FILE_SRC = "/mnt/sdcard/copytest.txt"; //$NON-NLS-1$
- private static final String PATH_FILE_DST = "/mnt/sdcard/copytest2.txt"; //$NON-NLS-1$
+ private static final String PATH_FILE_SRC =
+ Environment.getDataDirectory().getAbsolutePath() + "/copytest.txt"; //$NON-NLS-1$
+ private static final String PATH_FILE_DST =
+ Environment.getDataDirectory().getAbsolutePath() + "/copytest2.txt"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCopyOk() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_FILE_SRC, getConsole());
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.console.NoSuchFileOrDirectory;
import com.cyanogenmod.explorer.util.CommandHelper;
*/
public class CreateDirCommandTest extends AbstractConsoleTest {
- private static final String PATH_NEWDIR_OK = "/mnt/sdcard/newtestdir"; //$NON-NLS-1$
- private static final String PATH_NEWDIR_ERROR = "/mnt/sdcard121212/newtestdir"; //$NON-NLS-1$
+ private static final String PATH_NEWDIR_OK =
+ Environment.getDataDirectory().getAbsolutePath() + "/newtestdir"; //$NON-NLS-1$
+ private static final String PATH_NEWDIR_ERROR = "/foo/foo121212/newtestdir"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateDirOk() throws Exception {
try {
boolean ret = CommandHelper.createDirectory(getContext(), PATH_NEWDIR_OK, getConsole());
} finally {
try {
CommandHelper.deleteDirectory(getContext(), PATH_NEWDIR_OK, getConsole());
- } catch (Throwable ex) {
- /**NON BLOCK**/
- }
+ } catch (Throwable ex) {/**NON BLOCK**/}
}
}
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateDirFail() throws Exception {
try {
CommandHelper.createDirectory(getContext(), PATH_NEWDIR_ERROR, getConsole());
assertTrue("exit code==0", false); //$NON-NLS-1$
} catch (NoSuchFileOrDirectory error) {
//This command must failed. exit code !=0
+ } finally {
+ try {
+ CommandHelper.deleteDirectory(getContext(), PATH_NEWDIR_ERROR, getConsole());
+ } catch (Throwable ex) {/**NON BLOCK**/}
}
}
package com.cyanogenmod.explorer.commands.shell;
-import com.cyanogenmod.explorer.console.ExecutionException;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.cyanogenmod.explorer.console.NoSuchFileOrDirectory;
import com.cyanogenmod.explorer.util.CommandHelper;
/**
*/
public class CreateFileCommandTest extends AbstractConsoleTest {
- private static final String PATH_NEWFILE_OK = "/mnt/sdcard/newtest.txt"; //$NON-NLS-1$
- private static final String PATH_NEWFILE_ERROR = "/mnt/sdcard121212/newtest.txt"; //$NON-NLS-1$
+ private static final String PATH_NEWFILE_OK =
+ Environment.getDataDirectory().getAbsolutePath() + "/newtest.txt"; //$NON-NLS-1$
+ private static final String PATH_NEWFILE_ERROR = "/foo/foo121212/newtest.txt"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateFileOk() throws Exception {
try {
boolean ret = CommandHelper.createFile(getContext(), PATH_NEWFILE_OK, getConsole());
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateFileFail() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_NEWFILE_ERROR, getConsole());
assertTrue("exit code==0", false); //$NON-NLS-1$
- } catch (ExecutionException error) {
+ } catch (NoSuchFileOrDirectory error) {
//This command must failed. exit code !=0
+ } finally {
+ try {
+ CommandHelper.deleteFile(getContext(), PATH_NEWFILE_ERROR, getConsole());
+ } catch (Throwable ex) {
+ /**NON BLOCK**/
+ }
}
}
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
*/
public class CurrentDirCommandTest extends AbstractConsoleTest {
- private static final String PATH = "/mnt/sdcard"; //$NON-NLS-1$
+ private static final String PATH =
+ Environment.getExternalStorageDirectory().getAbsolutePath();
/**
* {@inheritDoc}
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCurrentDir() throws Exception {
CommandHelper.changeCurrentDir(getContext(), PATH, getConsole());
String curDir = CommandHelper.getCurrentDir(getContext(), getConsole());
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.console.NoSuchFileOrDirectory;
import com.cyanogenmod.explorer.util.CommandHelper;
*/
public class DeleteDirCommandTest extends AbstractConsoleTest {
- private static final String PATH_DELDIR_OK = "/mnt/sdcard/deltestfolder"; //$NON-NLS-1$
- private static final String PATH_DELDIR_ERROR = "/mnt/sdcard121212/deltestfolder"; //$NON-NLS-1$
+ private static final String PATH_DELDIR_OK =
+ Environment.getDataDirectory().getAbsolutePath() + "/deltestfolder"; //$NON-NLS-1$
+ private static final String PATH_DELDIR_ERROR = "/foo/foo121212/deltestfolder"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testDeleteDirOk() throws Exception {
- CommandHelper.createDirectory(getContext(), PATH_DELDIR_OK, getConsole());
- boolean ret = CommandHelper.deleteDirectory(getContext(), PATH_DELDIR_OK, getConsole());
- assertTrue("response==false", ret); //$NON-NLS-1$
+ try {
+ CommandHelper.createDirectory(getContext(), PATH_DELDIR_OK, getConsole());
+ } finally {
+ boolean ret = CommandHelper.deleteDirectory(getContext(), PATH_DELDIR_OK, getConsole());
+ assertTrue("response==false", ret); //$NON-NLS-1$
+ }
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testDeleteDirFail() throws Exception {
try {
CommandHelper.deleteDirectory(getContext(), PATH_DELDIR_ERROR, getConsole());
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.console.NoSuchFileOrDirectory;
import com.cyanogenmod.explorer.util.CommandHelper;
*/
public class DeleteFileCommandTest extends AbstractConsoleTest {
- private static final String PATH_DELFILE_OK = "/mnt/sdcard/deltest.txt"; //$NON-NLS-1$
- private static final String PATH_DELFILE_ERROR = "/mnt/sdcard121212/deltest.txt"; //$NON-NLS-1$
+ private static final String PATH_DELFILE_OK =
+ Environment.getDataDirectory().getAbsolutePath() + "/deltest.txt"; //$NON-NLS-1$
+ private static final String PATH_DELFILE_ERROR = "/foo/foo121212/deltest.txt"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testDeleteFileOk() throws Exception {
CommandHelper.createFile(getContext(), PATH_DELFILE_OK, getConsole());
boolean ret = CommandHelper.deleteFile(getContext(), PATH_DELFILE_OK, getConsole());
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testDeleteFileFail() throws Exception {
try {
CommandHelper.deleteFile(getContext(), PATH_DELFILE_ERROR, getConsole());
import java.util.List;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.DiskUsage;
import com.cyanogenmod.explorer.util.CommandHelper;
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testDiskUsage() throws Exception {
List<DiskUsage> du = CommandHelper.getDiskUsage(getContext(), getConsole());
assertNotNull("diskusage==null", du); //$NON-NLS-1$
* {@link ListCommand#parse(String, String)}
*/
@SuppressWarnings("static-method")
+ @SmallTest
public void testParse() throws Exception {
DiskUsageCommand cmd = new DiskUsageCommand();
String in = "Filesystem Size Used Free Blksize\n" + //$NON-NLS-1$
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testEchoOk() throws Exception {
String echo = CommandHelper.getVariable(getContext(), ECHO_MSG, getConsole());
assertNotNull("echo==null", echo); //$NON-NLS-1$
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testEchoVoid() throws Exception {
String echo = CommandHelper.getVariable(getContext(), ECHO_MSG_VOID, getConsole());
assertNotNull("exitCode==null", echo); //$NON-NLS-1$
import java.io.File;
import java.io.FileWriter;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.MediumTest;
+
import com.cyanogenmod.explorer.commands.AsyncResultListener;
import com.cyanogenmod.explorer.util.CommandHelper;
*/
public class ExecCommandTest extends AbstractConsoleTest {
- private static final String EXEC_CMD = "/sdcard/source.sh"; //$NON-NLS-1$
+ private static final String EXEC_CMD =
+ Environment.getDataDirectory().getAbsolutePath() + "/source.sh"; //$NON-NLS-1$
private static final String EXEC_PROGRAM =
"#!/system/bin/sh\necho \"List of files:\"\nls -la\n"; //$NON-NLS-1$
*
* @throws Exception If test failed
*/
+ @MediumTest
public void testExecWithPartialResult() throws Exception {
try {
// Create the test program
public void onAsyncStart() {
/**NON BLOCK**/
}
- public void onAsyncEnd(boolean cancelled) {
+ public void onAsyncEnd(boolean canceled) {
synchronized (ExecCommandTest.this.mSync) {
ExecCommandTest.this.mSync.notifyAll();
}
import java.util.ArrayList;
import java.util.List;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.LargeTest;
+
+import com.cyanogenmod.explorer.commands.AsyncResultExecutable;
import com.cyanogenmod.explorer.commands.AsyncResultListener;
import com.cyanogenmod.explorer.model.FileSystemObject;
import com.cyanogenmod.explorer.model.Query;
*/
public class FindCommandTest extends AbstractConsoleTest {
- private static final String FIND_PATH = "/"; //$NON-NLS-1$
- private static final String FIND_TERM_PARTIAL = "xml"; //$NON-NLS-1$
+ private static final String FIND_PATH =
+ Environment.getDataDirectory().getAbsolutePath();
+ private static final String FIND_TERM_PARTIAL = "shared"; //$NON-NLS-1$
/**
* @hide
* @hide
*/
boolean mNewPartialData;
+ /**
+ * @hide
+ */
+ boolean mNormalEnd;
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @LargeTest
public void testFindWithPartialResult() throws Exception {
this.mNewPartialData = false;
+ this.mNormalEnd = false;
Query query = new Query().setSlot(FIND_TERM_PARTIAL, 0);
final List<FileSystemObject> files = new ArrayList<FileSystemObject>();
- CommandHelper.findFiles(getContext(), FIND_PATH, query, new AsyncResultListener() {
+ AsyncResultExecutable cmd =
+ CommandHelper.findFiles(getContext(), FIND_PATH, query, new AsyncResultListener() {
public void onAsyncStart() {
/**NON BLOCK**/
}
- public void onAsyncEnd(boolean cancelled) {
+ public void onAsyncEnd(boolean canceled) {
synchronized (FindCommandTest.this.mSync) {
+ FindCommandTest.this.mNormalEnd = true;
FindCommandTest.this.mSync.notifyAll();
}
}
synchronized (FindCommandTest.this.mSync) {
FindCommandTest.this.mSync.wait(15000L);
}
+ try {
+ if (!this.mNormalEnd && cmd != null && cmd.isCancelable() && !cmd.isCanceled()) {
+ cmd.cancel();
+ }
+ } catch (Exception e) {/**NON BLOCK**/}
assertTrue("no new partial data", this.mNewPartialData); //$NON-NLS-1$
assertNotNull("files==null", files); //$NON-NLS-1$
assertTrue("no objects returned", files.size() > 0); //$NON-NLS-1$
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;
+import com.cyanogenmod.explorer.commands.AsyncResultExecutable;
import com.cyanogenmod.explorer.commands.AsyncResultListener;
import com.cyanogenmod.explorer.model.FolderUsage;
import com.cyanogenmod.explorer.util.CommandHelper;
/**
* A class for testing folder usage command.
*
- * @see FindCommand
+ * @see FolderUsageCommand
*/
public class FolderUsageCommandTest extends AbstractConsoleTest {
private static final String TAG = "FolderUsageCommandTest"; //$NON-NLS-1$
- private static final String PATH = "/system"; //$NON-NLS-1$
+ private static final String PATH =
+ Environment.getDataDirectory().getAbsolutePath() + "/app"; //$NON-NLS-1$
/**
* @hide
/**
* @hide
*/
+ boolean mNormalEnd;
+ /**
+ * @hide
+ */
FolderUsage mUsage;
/**
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @LargeTest
public void testFolderUsageWithPartialResult() throws Exception {
this.mNewPartialData = false;
+ this.mNormalEnd = false;
this.mUsage = null;
- CommandHelper.getFolderUsage(getContext(), PATH, new AsyncResultListener() {
+ AsyncResultExecutable cmd =
+ CommandHelper.getFolderUsage(getContext(), PATH, new AsyncResultListener() {
public void onAsyncStart() {
/**NON BLOCK**/
}
- public void onAsyncEnd(boolean cancelled) {
+ public void onAsyncEnd(boolean canceled) {
synchronized (FolderUsageCommandTest.this.mSync) {
+ FolderUsageCommandTest.this.mNormalEnd = true;
FolderUsageCommandTest.this.mSync.notifyAll();
}
}
}
}, getConsole());
synchronized (FolderUsageCommandTest.this.mSync) {
- FolderUsageCommandTest.this.mSync.wait(25000L);
+ FolderUsageCommandTest.this.mSync.wait(15000L);
}
+ try {
+ if (!this.mNormalEnd && cmd != null && cmd.isCancelable() && !cmd.isCanceled()) {
+ cmd.cancel();
+ }
+ } catch (Exception e) {/**NON BLOCK**/}
assertTrue("no new partial data", this.mNewPartialData); //$NON-NLS-1$
assertNotNull("usage==null", this.mUsage); //$NON-NLS-1$
- assertTrue("no folder returned", this.mUsage.getNumberOfFolders() > 0); //$NON-NLS-1$
assertTrue("no files returned", this.mUsage.getNumberOfFiles() > 0); //$NON-NLS-1$
assertTrue("no size returned", this.mUsage.getTotalSize() > 0); //$NON-NLS-1$
assertTrue("no text category returned", //$NON-NLS-1$
- this.mUsage.getStatisticsForCategory(MimeTypeCategory.TEXT) > 0);
+ this.mUsage.getStatisticsForCategory(MimeTypeCategory.APP) > 0);
}
}
import java.util.List;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.Group;
import com.cyanogenmod.explorer.util.CommandHelper;
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testGroups() throws Exception {
List<Group> groups = CommandHelper.getGroups(getContext(), getConsole());
assertNotNull("groups==null", groups); //$NON-NLS-1$
* {@link GroupsCommand#parse(String, String)}
*/
@SuppressWarnings("static-method")
+ @SmallTest
public void testParse() throws Exception {
GroupsCommand cmd = new GroupsCommand();
String in =
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.Identity;
import com.cyanogenmod.explorer.util.CommandHelper;
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testId() throws Exception {
Identity identity = CommandHelper.getIdentity(getContext(), getConsole());
assertNotNull("identity==null", identity); //$NON-NLS-1$
* {@link IdentityCommand#parse(String, String)}
*/
@SuppressWarnings("static-method")
+ @SmallTest
public void testParse() throws Exception {
IdentityCommand cmd = new IdentityCommand();
String in = "uid=2000(shell) gid=2000(shell2) groups=1003(graphics)," //$NON-NLS-1$
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.console.InsufficientPermissionsException;
import com.cyanogenmod.explorer.model.FileSystemObject;
import com.cyanogenmod.explorer.model.Symlink;
*/
public class LinkCommandTest extends AbstractConsoleTest {
- private static final String PATH_SOURCE_OK = "/data/source.txt"; //$NON-NLS-1$
- private static final String PATH_LINK_OK = "/data/source-link"; //$NON-NLS-1$
- private static final String PATH_SOURCE_ERROR = "/sdcard/source.txt"; //$NON-NLS-1$
- private static final String PATH_LINK_ERROR = "/sdcard/source-link"; //$NON-NLS-1$
+ private static final String PATH_SOURCE_OK =
+ Environment.getDataDirectory().getAbsolutePath() + "/source.txt"; //$NON-NLS-1$
+ private static final String PATH_LINK_OK =
+ Environment.getDataDirectory().getAbsolutePath() + "/source-link"; //$NON-NLS-1$
+ private static final String PATH_SOURCE_ERROR =
+ Environment.getExternalStorageDirectory().getAbsolutePath() +
+ "/source.txt"; //$NON-NLS-1$
+ private static final String PATH_LINK_ERROR =
+ Environment.getExternalStorageDirectory().getAbsolutePath() +
+ "/source-link"; //$NON-NLS-1$
/**
* {@inheritDoc}
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateSymlinkOk() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_SOURCE_OK, getConsole());
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateSymlinkFail() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_SOURCE_ERROR, getConsole());
import java.util.List;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.BlockDevice;
import com.cyanogenmod.explorer.model.CharacterDevice;
import com.cyanogenmod.explorer.model.Directory;
import com.cyanogenmod.explorer.model.RegularFile;
import com.cyanogenmod.explorer.model.Symlink;
import com.cyanogenmod.explorer.util.CommandHelper;
+import com.cyanogenmod.explorer.util.FileHelper;
/**
* A class for testing list command.
*/
public class ListCommandTest extends AbstractConsoleTest {
- private static final String LS_PATH = "/"; //$NON-NLS-1$
+ private static final String LS_PATH = FileHelper.ROOT_DIRECTORY;
private static final String LS_INFOFILE = "/boot.txt"; //$NON-NLS-1$
private static final String LS_INFOFILE_NAME = "boot.txt"; //$NON-NLS-1$
*
* @throws Exception If test failed
*/
+ @MediumTest
public void testList() throws Exception {
List<FileSystemObject> files = CommandHelper.listFiles(getContext(), LS_PATH, getConsole());
assertNotNull("files==null", files); //$NON-NLS-1$
*
* @throws Exception If test failed
*/
+ @MediumTest
public void testListInfo() throws Exception {
FileSystemObject file = CommandHelper.getFileInfo(getContext(), LS_INFOFILE, getConsole());
assertNotNull("file==null", file); //$NON-NLS-1$
* @throws Exception If test failed
* {@link ListCommand#parse(String, String)}
*/
+ @SmallTest
public void testParse() throws Exception {
ListCommand cmd = new ListCommand(LS_PATH, getConsole());
String in =
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.MediumTest;
+
import com.cyanogenmod.explorer.model.MountPoint;
import com.cyanogenmod.explorer.util.CommandHelper;
import com.cyanogenmod.explorer.util.MountPointHelper;
*
* @throws Exception If test failed
*/
+ @MediumTest
public void testRemountOk() throws Exception {
MountPoint mp = MountPointHelper.getMountPointFromDirectory(getConsole(), MOUNT_POINT_DIR);
boolean rw = MountPointHelper.isReadWrite(mp);
import java.util.List;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.MountPoint;
import com.cyanogenmod.explorer.util.CommandHelper;
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testMountPoint() throws Exception {
List<MountPoint> mp = CommandHelper.getMountPoints(getContext(), getConsole());
assertNotNull("mountpoints==null", mp); //$NON-NLS-1$
* {@link ListCommand#parse(String, String)}
*/
@SuppressWarnings("static-method")
+ @SmallTest
public void testParse() throws Exception {
MountPointInfoCommand cmd = new MountPointInfoCommand();
String in = "rootfs / rootfs ro,relatime 0 0\n" + //$NON-NLS-1$
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
*/
public class MoveCommandTest extends AbstractConsoleTest {
- private static final String PATH_FILE_SRC = "/mnt/sdcard/movetest.txt"; //$NON-NLS-1$
- private static final String PATH_FILE_DST = "/mnt/sdcard/movetest2.txt"; //$NON-NLS-1$
+ private static final String PATH_FILE_SRC =
+ Environment.getDataDirectory().getAbsolutePath() + "/movetest.txt"; //$NON-NLS-1$
+ private static final String PATH_FILE_DST =
+ Environment.getDataDirectory().getAbsolutePath() + "/movetest2.txt"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testMoveOk() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_FILE_SRC, getConsole());
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
*/
public class ParentDirCommandTest extends AbstractConsoleTest {
- private static final String FILE = "/mnt/sdcard/parentdirtest.txt"; //$NON-NLS-1$
- private static final String PARENT = "/mnt/sdcard"; //$NON-NLS-1$
+ private static final String FILE =
+ Environment.getDataDirectory().getAbsolutePath() + "/parentdirtest.txt"; //$NON-NLS-1$
+ private static final String PARENT = Environment.getDataDirectory().getAbsolutePath();
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testParentDirOk() throws Exception {
try {
CommandHelper.createFile(getContext(), FILE, getConsole());
String.format(
"parent!=%s", PARENT), parent.compareTo(PARENT) == 0); //$NON-NLS-1$
} finally {
- CommandHelper.deleteFile(getContext(), FILE, getConsole());
+ try {
+ CommandHelper.deleteFile(getContext(), FILE, getConsole());
+ } catch (Throwable ex) {
+ /**NON BLOCK**/
+ }
}
}
return false;
}
- // Can't perform any test, because a running program in a shell is needed, and PID of
- // shell is not available for external use outside the console.
+ // Can't perform any test, because a running program in a shell is needed, and the PID of
+ // the shell is not available for external use outside the console.
}
import java.util.List;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.LargeTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
*/
public class QuickFolderSearchCommandTest extends AbstractConsoleTest {
- private static final String SEARCH_EXPRESSION = "/mnt/sdcard/And"; //$NON-NLS-1$
- private static final String SEARCH_FOLDER = "/mnt/sdcard/Android/"; //$NON-NLS-1$
+ private static final String SEARCH_EXPRESSION =
+ Environment.getDataDirectory().getAbsolutePath() + "/dal"; //$NON-NLS-1$
+ private static final String SEARCH_CONTAINS =
+ Environment.getDataDirectory().getAbsolutePath() + "/dalvik-cache/"; //$NON-NLS-1$
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
*
* @throws Exception If test failed
*/
+ @LargeTest
public void testQuickFolderSearchOk() throws Exception {
List<String> result =
CommandHelper.quickFolderSearch(getContext(), SEARCH_EXPRESSION, getConsole());
assertNotNull("result==null", result); //$NON-NLS-1$
assertTrue("result.size==0", result.size() != 0); //$NON-NLS-1$
assertTrue(
- String.format("result not contains %s", SEARCH_FOLDER), //$NON-NLS-1$
- result.contains(SEARCH_FOLDER));
+ String.format("result not contains %s", SEARCH_CONTAINS), //$NON-NLS-1$
+ result.contains(SEARCH_CONTAINS));
}
}
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.FileSystemObject;
import com.cyanogenmod.explorer.util.CommandHelper;
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testReadLinkOk() throws Exception {
FileSystemObject fso = CommandHelper.resolveSymlink(getContext(), LINK, getConsole());
assertNotNull("fso==null)", fso); //$NON-NLS-1$
package com.cyanogenmod.explorer.console;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
/**
* A class for testing list command.
*/
public class ConsoleBuilderTest extends android.test.AndroidTestCase {
- private static final String PATH = "/mnt/sdcard"; //$NON-NLS-1$
+ private static final String PATH =
+ Environment.getExternalStorageDirectory().getAbsolutePath();
/**
* {@inheritDoc}
* @throws Exception If test failed
* @{link {@link ConsoleBuilder#createPrivilegedConsole(android.content.Context, String)}
*/
+ @SmallTest
public void testCreatePrivilegedConsole() throws Exception {
Console console = ConsoleBuilder.createPrivilegedConsole(getContext(), PATH);
try {
* @throws Exception If test failed
* @{link {@link ConsoleBuilder#createNonPrivilegedConsole(android.content.Context, String)}
*/
+ @SmallTest
public void testCreateNonPrivilegedConsole() throws Exception {
Console console = ConsoleBuilder.createNonPrivilegedConsole(getContext(), PATH);
try {