aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorjruesga <jorge@ruesga.com>2012-10-12 13:00:38 +0200
committerjruesga <jorge@ruesga.com>2012-10-12 13:00:38 +0200
commit438b5f65e7ddd2c91d9c242f22a0558d908d2162 (patch)
treec50dff2410b9f51ebbd0a0eb1fc205c42ad6cd8d /tests/src
parent19eddf238e7d7e8f9b3c1cfea1b17dd557df96fd (diff)
downloadandroid_packages_apps_CMFileManager-438b5f65e7ddd2c91d9c242f22a0558d908d2162.tar.gz
android_packages_apps_CMFileManager-438b5f65e7ddd2c91d9c242f22a0558d908d2162.tar.bz2
android_packages_apps_CMFileManager-438b5f65e7ddd2c91d9c242f22a0558d908d2162.zip
Fix TestCases
Still fails ExecCommandTest because we need a command to write content in a file (the test script to execute). Now, we haven't permissions to write to /data with standard java routines
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/AbstractConsoleTest.java3
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ChangeCurrentDirCommandTest.java9
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ChangeOwnerCommandTest.java7
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ChangePermissionsCommandTest.java7
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/CopyCommandTest.java12
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/CreateDirCommandTest.java20
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/CreateFileCommandTest.java22
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/CurrentDirCommandTest.java7
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/DeleteDirCommandTest.java21
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/DeleteFileCommandTest.java12
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/DiskUsageCommandTest.java4
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/EchoCommandTest.java4
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java9
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java28
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java32
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/GroupsCommandTest.java4
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/IdentityCommandTest.java4
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java19
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ListCommandTest.java9
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/MountCommandTest.java3
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/MountPointInfoCommandTest.java4
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/MoveCommandTest.java12
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ParentDirCommandTest.java17
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java4
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/QuickFolderSearchCommandTest.java16
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ResolveLinkCommandTest.java3
-rw-r--r--tests/src/com/cyanogenmod/explorer/console/ConsoleBuilderTest.java8
27 files changed, 236 insertions, 64 deletions
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/AbstractConsoleTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/AbstractConsoleTest.java
index 723d8460..21575091 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/AbstractConsoleTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/AbstractConsoleTest.java
@@ -19,13 +19,14 @@ package com.cyanogenmod.explorer.commands.shell;
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;
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeCurrentDirCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeCurrentDirCommandTest.java
index c52dffdf..99e3afa8 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeCurrentDirCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeCurrentDirCommandTest.java
@@ -16,8 +16,11 @@
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.
@@ -26,8 +29,8 @@ import com.cyanogenmod.explorer.util.CommandHelper;
*/
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}
@@ -42,6 +45,7 @@ public class ChangeCurrentDirCommandTest extends AbstractConsoleTest {
*
* @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$
@@ -58,6 +62,7 @@ public class ChangeCurrentDirCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testChangeDirFail() throws Exception {
String oldPwd = CommandHelper.getCurrentDir(getContext(), getConsole());
try {
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeOwnerCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeOwnerCommandTest.java
index eb94b804..ecab5627 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeOwnerCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ChangeOwnerCommandTest.java
@@ -16,6 +16,9 @@
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;
@@ -28,7 +31,8 @@ import com.cyanogenmod.explorer.util.CommandHelper;
*/
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$
/**
@@ -44,6 +48,7 @@ public class ChangeOwnerCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testChangeOwnerOk() throws Exception {
try {
//Create and list the file
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ChangePermissionsCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ChangePermissionsCommandTest.java
index c9dfe435..b2af590b 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ChangePermissionsCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ChangePermissionsCommandTest.java
@@ -16,6 +16,9 @@
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;
@@ -27,7 +30,8 @@ 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}
@@ -42,6 +46,7 @@ public class ChangePermissionsCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testChangePermissionsOk() throws Exception {
try {
//Create and list the file
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/CopyCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/CopyCommandTest.java
index 8aa44646..ede0b3e1 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/CopyCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/CopyCommandTest.java
@@ -16,6 +16,9 @@
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
@@ -25,15 +28,17 @@ 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;
}
/**
@@ -41,6 +46,7 @@ public class CopyCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCopyOk() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_FILE_SRC, getConsole());
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/CreateDirCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/CreateDirCommandTest.java
index bea04387..00e9abea 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/CreateDirCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/CreateDirCommandTest.java
@@ -16,6 +16,9 @@
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;
@@ -26,15 +29,16 @@ 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;
}
/**
@@ -42,6 +46,7 @@ public class CreateDirCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateDirOk() throws Exception {
try {
boolean ret = CommandHelper.createDirectory(getContext(), PATH_NEWDIR_OK, getConsole());
@@ -50,9 +55,7 @@ public class CreateDirCommandTest extends AbstractConsoleTest {
} finally {
try {
CommandHelper.deleteDirectory(getContext(), PATH_NEWDIR_OK, getConsole());
- } catch (Throwable ex) {
- /**NON BLOCK**/
- }
+ } catch (Throwable ex) {/**NON BLOCK**/}
}
}
@@ -61,12 +64,17 @@ public class CreateDirCommandTest extends AbstractConsoleTest {
*
* @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**/}
}
}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/CreateFileCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/CreateFileCommandTest.java
index 1da9e18d..192a40d2 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/CreateFileCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/CreateFileCommandTest.java
@@ -16,7 +16,10 @@
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;
/**
@@ -26,15 +29,16 @@ 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;
}
/**
@@ -42,6 +46,7 @@ public class CreateFileCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateFileOk() throws Exception {
try {
boolean ret = CommandHelper.createFile(getContext(), PATH_NEWFILE_OK, getConsole());
@@ -60,12 +65,19 @@ public class CreateFileCommandTest extends AbstractConsoleTest {
*
* @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**/
+ }
}
}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/CurrentDirCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/CurrentDirCommandTest.java
index fe802c56..1e201992 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/CurrentDirCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/CurrentDirCommandTest.java
@@ -16,6 +16,9 @@
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
@@ -25,7 +28,8 @@ 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}
@@ -40,6 +44,7 @@ public class CurrentDirCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCurrentDir() throws Exception {
CommandHelper.changeCurrentDir(getContext(), PATH, getConsole());
String curDir = CommandHelper.getCurrentDir(getContext(), getConsole());
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteDirCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteDirCommandTest.java
index ae0c3c96..816b4e16 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteDirCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteDirCommandTest.java
@@ -16,6 +16,9 @@
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;
@@ -26,15 +29,16 @@ 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;
}
/**
@@ -42,10 +46,14 @@ public class DeleteDirCommandTest extends AbstractConsoleTest {
*
* @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$
+ }
}
/**
@@ -53,6 +61,7 @@ public class DeleteDirCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testDeleteDirFail() throws Exception {
try {
CommandHelper.deleteDirectory(getContext(), PATH_DELDIR_ERROR, getConsole());
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteFileCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteFileCommandTest.java
index 40081c37..2783fd87 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteFileCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/DeleteFileCommandTest.java
@@ -16,6 +16,9 @@
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;
@@ -26,15 +29,16 @@ 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;
}
/**
@@ -42,6 +46,7 @@ public class DeleteFileCommandTest extends AbstractConsoleTest {
*
* @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());
@@ -53,6 +58,7 @@ public class DeleteFileCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testDeleteFileFail() throws Exception {
try {
CommandHelper.deleteFile(getContext(), PATH_DELFILE_ERROR, getConsole());
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/DiskUsageCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/DiskUsageCommandTest.java
index 95d710a6..db4b5d46 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/DiskUsageCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/DiskUsageCommandTest.java
@@ -18,6 +18,8 @@ package com.cyanogenmod.explorer.commands.shell;
import java.util.List;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.DiskUsage;
import com.cyanogenmod.explorer.util.CommandHelper;
@@ -41,6 +43,7 @@ public class DiskUsageCommandTest extends AbstractConsoleTest {
*
* @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$
@@ -54,6 +57,7 @@ public class DiskUsageCommandTest extends AbstractConsoleTest {
* {@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$
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/EchoCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/EchoCommandTest.java
index 6f1629a1..cf3f118e 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/EchoCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/EchoCommandTest.java
@@ -16,6 +16,8 @@
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
@@ -42,6 +44,7 @@ public class EchoCommandTest extends AbstractConsoleTest {
*
* @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$
@@ -53,6 +56,7 @@ public class EchoCommandTest extends AbstractConsoleTest {
*
* @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$
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java
index 5a9d6290..d6754236 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java
@@ -19,6 +19,9 @@ package com.cyanogenmod.explorer.commands.shell;
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;
@@ -29,7 +32,8 @@ 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$
@@ -55,6 +59,7 @@ public class ExecCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @MediumTest
public void testExecWithPartialResult() throws Exception {
try {
// Create the test program
@@ -68,7 +73,7 @@ public class ExecCommandTest extends AbstractConsoleTest {
public void onAsyncStart() {
/**NON BLOCK**/
}
- public void onAsyncEnd(boolean cancelled) {
+ public void onAsyncEnd(boolean canceled) {
synchronized (ExecCommandTest.this.mSync) {
ExecCommandTest.this.mSync.notifyAll();
}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java
index e382292e..978772c6 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java
@@ -19,6 +19,10 @@ package com.cyanogenmod.explorer.commands.shell;
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;
@@ -31,8 +35,9 @@ import com.cyanogenmod.explorer.util.CommandHelper;
*/
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
@@ -42,13 +47,17 @@ public class FindCommandTest extends AbstractConsoleTest {
* @hide
*/
boolean mNewPartialData;
+ /**
+ * @hide
+ */
+ boolean mNormalEnd;
/**
* {@inheritDoc}
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
@@ -56,16 +65,20 @@ public class FindCommandTest extends AbstractConsoleTest {
*
* @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();
}
}
@@ -81,6 +94,11 @@ public class FindCommandTest extends AbstractConsoleTest {
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$
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java
index a41617c2..c028aac8 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java
@@ -16,8 +16,11 @@
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;
@@ -26,13 +29,14 @@ import com.cyanogenmod.explorer.util.MimeTypeHelper.MimeTypeCategory;
/**
* 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
@@ -45,6 +49,10 @@ public class FolderUsageCommandTest extends AbstractConsoleTest {
/**
* @hide
*/
+ boolean mNormalEnd;
+ /**
+ * @hide
+ */
FolderUsage mUsage;
/**
@@ -52,7 +60,7 @@ public class FolderUsageCommandTest extends AbstractConsoleTest {
*/
@Override
public boolean isRootConsoleNeeded() {
- return false;
+ return true;
}
/**
@@ -60,15 +68,19 @@ public class FolderUsageCommandTest extends AbstractConsoleTest {
*
* @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();
}
}
@@ -85,15 +97,19 @@ public class FolderUsageCommandTest extends AbstractConsoleTest {
}
}, 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);
}
}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/GroupsCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/GroupsCommandTest.java
index 52a176f0..e5982eab 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/GroupsCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/GroupsCommandTest.java
@@ -18,6 +18,8 @@ package com.cyanogenmod.explorer.commands.shell;
import java.util.List;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.Group;
import com.cyanogenmod.explorer.util.CommandHelper;
@@ -41,6 +43,7 @@ public class GroupsCommandTest extends AbstractConsoleTest {
*
* @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$
@@ -54,6 +57,7 @@ public class GroupsCommandTest extends AbstractConsoleTest {
* {@link GroupsCommand#parse(String, String)}
*/
@SuppressWarnings("static-method")
+ @SmallTest
public void testParse() throws Exception {
GroupsCommand cmd = new GroupsCommand();
String in =
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/IdentityCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/IdentityCommandTest.java
index bc413efc..857fe9c0 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/IdentityCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/IdentityCommandTest.java
@@ -16,6 +16,8 @@
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.Identity;
import com.cyanogenmod.explorer.util.CommandHelper;
@@ -39,6 +41,7 @@ public class IdentityCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testId() throws Exception {
Identity identity = CommandHelper.getIdentity(getContext(), getConsole());
assertNotNull("identity==null", identity); //$NON-NLS-1$
@@ -55,6 +58,7 @@ public class IdentityCommandTest extends AbstractConsoleTest {
* {@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$
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java
index f8ef322e..2e0281bf 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java
@@ -16,6 +16,9 @@
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;
@@ -28,10 +31,16 @@ import com.cyanogenmod.explorer.util.CommandHelper;
*/
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}
@@ -46,6 +55,7 @@ public class LinkCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateSymlinkOk() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_SOURCE_OK, getConsole());
@@ -70,6 +80,7 @@ public class LinkCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testCreateSymlinkFail() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_SOURCE_ERROR, getConsole());
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ListCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ListCommandTest.java
index 79b5aa13..891d8172 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ListCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ListCommandTest.java
@@ -18,6 +18,9 @@ package com.cyanogenmod.explorer.commands.shell;
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;
@@ -27,6 +30,7 @@ import com.cyanogenmod.explorer.model.NamedPipe;
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.
@@ -35,7 +39,7 @@ import com.cyanogenmod.explorer.util.CommandHelper;
*/
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$
@@ -53,6 +57,7 @@ public class ListCommandTest extends AbstractConsoleTest {
*
* @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$
@@ -65,6 +70,7 @@ public class ListCommandTest extends AbstractConsoleTest {
*
* @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$
@@ -79,6 +85,7 @@ public class ListCommandTest extends AbstractConsoleTest {
* @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 =
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/MountCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/MountCommandTest.java
index f3cbc7d7..48465e0d 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/MountCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/MountCommandTest.java
@@ -16,6 +16,8 @@
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;
@@ -42,6 +44,7 @@ public class MountCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @MediumTest
public void testRemountOk() throws Exception {
MountPoint mp = MountPointHelper.getMountPointFromDirectory(getConsole(), MOUNT_POINT_DIR);
boolean rw = MountPointHelper.isReadWrite(mp);
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/MountPointInfoCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/MountPointInfoCommandTest.java
index edf6f9a7..674ad2a9 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/MountPointInfoCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/MountPointInfoCommandTest.java
@@ -18,6 +18,8 @@ package com.cyanogenmod.explorer.commands.shell;
import java.util.List;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.MountPoint;
import com.cyanogenmod.explorer.util.CommandHelper;
@@ -41,6 +43,7 @@ public class MountPointInfoCommandTest extends AbstractConsoleTest {
*
* @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$
@@ -54,6 +57,7 @@ public class MountPointInfoCommandTest extends AbstractConsoleTest {
* {@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$
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/MoveCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/MoveCommandTest.java
index 782e6666..5bb5621e 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/MoveCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/MoveCommandTest.java
@@ -16,6 +16,9 @@
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
@@ -25,15 +28,17 @@ 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;
}
/**
@@ -41,6 +46,7 @@ public class MoveCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testMoveOk() throws Exception {
try {
CommandHelper.createFile(getContext(), PATH_FILE_SRC, getConsole());
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ParentDirCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ParentDirCommandTest.java
index f42a9695..9717e7e4 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ParentDirCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ParentDirCommandTest.java
@@ -16,6 +16,9 @@
package com.cyanogenmod.explorer.commands.shell;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
@@ -25,15 +28,16 @@ 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;
}
/**
@@ -41,6 +45,7 @@ public class ParentDirCommandTest extends AbstractConsoleTest {
*
* @throws Exception If test failed
*/
+ @SmallTest
public void testParentDirOk() throws Exception {
try {
CommandHelper.createFile(getContext(), FILE, getConsole());
@@ -50,7 +55,11 @@ public class ParentDirCommandTest extends AbstractConsoleTest {
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**/
+ }
}
}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java
index 61966903..0e4818b1 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java
@@ -30,6 +30,6 @@ public class ProcessIdCommandTest extends AbstractConsoleTest {
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.
}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/QuickFolderSearchCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/QuickFolderSearchCommandTest.java
index 6009f1e2..14e3f01c 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/QuickFolderSearchCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/QuickFolderSearchCommandTest.java
@@ -18,6 +18,9 @@ package com.cyanogenmod.explorer.commands.shell;
import java.util.List;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.LargeTest;
+
import com.cyanogenmod.explorer.util.CommandHelper;
/**
@@ -27,15 +30,17 @@ 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;
}
/**
@@ -43,14 +48,15 @@ public class QuickFolderSearchCommandTest extends AbstractConsoleTest {
*
* @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));
}
}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ResolveLinkCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ResolveLinkCommandTest.java
index 20650654..e0685c8f 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/ResolveLinkCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ResolveLinkCommandTest.java
@@ -16,6 +16,8 @@
package com.cyanogenmod.explorer.commands.shell;
+import android.test.suitebuilder.annotation.SmallTest;
+
import com.cyanogenmod.explorer.model.FileSystemObject;
import com.cyanogenmod.explorer.util.CommandHelper;
@@ -42,6 +44,7 @@ public class ResolveLinkCommandTest extends AbstractConsoleTest {
*
* @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$
diff --git a/tests/src/com/cyanogenmod/explorer/console/ConsoleBuilderTest.java b/tests/src/com/cyanogenmod/explorer/console/ConsoleBuilderTest.java
index dd9bcca9..2b5d1242 100644
--- a/tests/src/com/cyanogenmod/explorer/console/ConsoleBuilderTest.java
+++ b/tests/src/com/cyanogenmod/explorer/console/ConsoleBuilderTest.java
@@ -16,6 +16,9 @@
package com.cyanogenmod.explorer.console;
+import android.os.Environment;
+import android.test.suitebuilder.annotation.SmallTest;
+
/**
* A class for testing list command.
@@ -24,7 +27,8 @@ package com.cyanogenmod.explorer.console;
*/
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}
@@ -48,6 +52,7 @@ public class ConsoleBuilderTest extends android.test.AndroidTestCase {
* @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 {
@@ -67,6 +72,7 @@ public class ConsoleBuilderTest extends android.test.AndroidTestCase {
* @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 {