aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjruesga <jorge@ruesga.com>2012-10-12 02:19:52 +0200
committerjruesga <jorge@ruesga.com>2012-10-12 02:19:52 +0200
commit63dc579b45ded75b59330e5db9e55b4040d9ad5e (patch)
treea64daf38a91c6a9ace526841d4bd8382064ecb88 /tests
parentc0a0acd87d57de98f6f342698c55ce5d45a45b07 (diff)
downloadandroid_packages_apps_CMFileManager-63dc579b45ded75b59330e5db9e55b4040d9ad5e.tar.gz
android_packages_apps_CMFileManager-63dc579b45ded75b59330e5db9e55b4040d9ad5e.tar.bz2
android_packages_apps_CMFileManager-63dc579b45ded75b59330e5db9e55b4040d9ad5e.zip
New command: ExecCommand (for execute commands)
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java95
-rw-r--r--tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java6
2 files changed, 98 insertions, 3 deletions
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java
new file mode 100644
index 00000000..518630ab
--- /dev/null
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ExecCommandTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.explorer.commands.shell;
+
+import java.io.File;
+import java.io.FileWriter;
+
+import com.cyanogenmod.explorer.commands.AsyncResultListener;
+import com.cyanogenmod.explorer.util.CommandHelper;
+
+/**
+ * A class for testing exec command.
+ *
+ * @see ExecCommand
+ */
+public class ExecCommandTest extends AbstractConsoleTest {
+
+ private static final String EXEC_CMD = "/sdcard/source.sh"; //$NON-NLS-1$
+ private static final String EXEC_PROGRAM =
+ "#!/system/bin/sh\necho \"List of files:\"\nls -la\n"; //$NON-NLS-1$
+
+ /**
+ * @hide
+ */
+ final Object mSync = new Object();
+ /**
+ * @hide
+ */
+ boolean mNewPartialData;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRootConsoleNeeded() {
+ return true;
+ }
+
+ /**
+ * Method that performs a test over known search results.
+ *
+ * @throws Exception If test failed
+ */
+ public void testFindWithPartialResult() throws Exception {
+ try {
+ // Create the test program
+ FileWriter fw = new FileWriter(new File(EXEC_CMD));
+ fw.write(EXEC_PROGRAM);
+ fw.close();
+
+ // Execute the test program
+ this.mNewPartialData = false;
+ CommandHelper.exec(getContext(), EXEC_CMD, new AsyncResultListener() {
+ public void onAsyncStart() {
+ /**NON BLOCK**/
+ }
+ public void onAsyncEnd(boolean cancelled) {
+ synchronized (ExecCommandTest.this.mSync) {
+ ExecCommandTest.this.mSync.notifyAll();
+ }
+ }
+ public void onException(Exception cause) {
+ fail(cause.toString());
+ }
+ public void onPartialResult(Object results) {
+ ExecCommandTest.this.mNewPartialData = true;
+ }
+ }, getConsole());
+ synchronized (ExecCommandTest.this.mSync) {
+ ExecCommandTest.this.mSync.wait(15000L);
+ }
+ assertTrue("no new partial data", this.mNewPartialData); //$NON-NLS-1$
+
+ } finally {
+ try {
+ CommandHelper.deleteFile(getContext(), EXEC_CMD, getConsole());
+ } catch (Exception e) {/**NON BLOCK**/}
+ }
+ }
+
+}
diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java
index 318475f2..f8ef322e 100644
--- a/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java
+++ b/tests/src/com/cyanogenmod/explorer/commands/shell/LinkCommandTest.java
@@ -24,7 +24,7 @@ import com.cyanogenmod.explorer.util.CommandHelper;
/**
* A class for testing the {@link LinkCommandTest} command.
*
- * @see DeleteFileCommand
+ * @see LinkCommand
*/
public class LinkCommandTest extends AbstractConsoleTest {
@@ -42,7 +42,7 @@ public class LinkCommandTest extends AbstractConsoleTest {
}
/**
- * Method that performs a test to delete a file.
+ * Method that performs a test to link to a file.
*
* @throws Exception If test failed
*/
@@ -66,7 +66,7 @@ public class LinkCommandTest extends AbstractConsoleTest {
}
/**
- * Method that performs a test to delete an invalid file.
+ * Method that performs a test to link to an invalid file.
*
* @throws Exception If test failed
*/