diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2013-01-09 00:56:18 +0100 |
---|---|---|
committer | Jorge Ruesga <jorge@ruesga.com> | 2013-01-09 00:56:18 +0100 |
commit | 3bf048a2ab6e0393055c4991dfaab6c84f0ecae7 (patch) | |
tree | c7dc0b9f2647328cb139abcd1d3839f84d437128 /tests | |
parent | 1530ad9a8b23fd1a599ad71057e029d2ada3e4a5 (diff) | |
download | android_packages_apps_CMFileManager-3bf048a2ab6e0393055c4991dfaab6c84f0ecae7.tar.gz android_packages_apps_CMFileManager-3bf048a2ab6e0393055c4991dfaab6c84f0ecae7.tar.bz2 android_packages_apps_CMFileManager-3bf048a2ab6e0393055c4991dfaab6c84f0ecae7.zip |
CMFM: Do not use cd and pwd commands
Remove cd and pwd commands and use / as working directory for shell process (this commands
are not used). This prevents that storage volumes from get busy on unmount file systems.
Signed-off-by: jruesga <jorge@ruesga.com>
Change-Id: I772866c00233351f505b61f53d43bac5de02a5e4
Diffstat (limited to 'tests')
4 files changed, 6 insertions, 154 deletions
diff --git a/tests/src/com/cyanogenmod/filemanager/commands/shell/AbstractConsoleTest.java b/tests/src/com/cyanogenmod/filemanager/commands/shell/AbstractConsoleTest.java index fa1b0908..202c07d7 100644 --- a/tests/src/com/cyanogenmod/filemanager/commands/shell/AbstractConsoleTest.java +++ b/tests/src/com/cyanogenmod/filemanager/commands/shell/AbstractConsoleTest.java @@ -20,15 +20,12 @@ import com.cyanogenmod.filemanager.FileManagerApplication; import com.cyanogenmod.filemanager.console.Console; import com.cyanogenmod.filemanager.console.ConsoleBuilder; import com.cyanogenmod.filemanager.console.shell.ShellConsole; -import com.cyanogenmod.filemanager.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 = FileHelper.ROOT_DIRECTORY; - private Console mConsole; /** @@ -46,9 +43,9 @@ public abstract class AbstractConsoleTest extends android.test.AndroidTestCase { //Setup the console if (isRootConsoleNeeded()) { FileManagerApplication.changeBackgroundConsoleToPriviligedConsole(); - this.mConsole = ConsoleBuilder.createPrivilegedConsole(getContext(), INITIAL_DIR); + this.mConsole = ConsoleBuilder.createPrivilegedConsole(getContext()); } else { - this.mConsole = ConsoleBuilder.createNonPrivilegedConsole(getContext(), INITIAL_DIR); + this.mConsole = ConsoleBuilder.createNonPrivilegedConsole(getContext()); } super.setUp(); diff --git a/tests/src/com/cyanogenmod/filemanager/commands/shell/ChangeCurrentDirCommandTest.java b/tests/src/com/cyanogenmod/filemanager/commands/shell/ChangeCurrentDirCommandTest.java deleted file mode 100644 index 2ef12a47..00000000 --- a/tests/src/com/cyanogenmod/filemanager/commands/shell/ChangeCurrentDirCommandTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.filemanager.commands.shell; - -import android.test.suitebuilder.annotation.SmallTest; - -import com.cyanogenmod.filemanager.console.NoSuchFileOrDirectory; -import com.cyanogenmod.filemanager.util.CommandHelper; -import com.cyanogenmod.filemanager.util.FileHelper; - -/** - * A class for testing the {@link ChangeCurrentDirCommand} command. - * - * @see ChangeCurrentDirCommand - */ -public class ChangeCurrentDirCommandTest extends AbstractConsoleTest { - - private static final String PATH_OK = FileHelper.ROOT_DIRECTORY; - private static final String PATH_ERROR = "/foo/foo121212"; //$NON-NLS-1$ - - /** - * {@inheritDoc} - */ - @Override - public boolean isRootConsoleNeeded() { - return false; - } - - /** - * Method that performs a test to change the directory. - * - * @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$ - - //Verify that current directory is PATH_OK - String curDir = CommandHelper.getCurrentDir(getContext(), getConsole()); - assertTrue( - String.format( - "curDir!=%s", PATH_OK), curDir.compareTo(PATH_OK) == 0); //$NON-NLS-1$ - } - - /** - * Method that performs a test to change the fake directory. - * - * @throws Exception If test failed - */ - @SmallTest - public void testChangeDirFail() throws Exception { - String oldPwd = CommandHelper.getCurrentDir(getContext(), getConsole()); - try { - CommandHelper.changeCurrentDir(getContext(), PATH_ERROR, getConsole()); - assertTrue("exit code==0", false); //$NON-NLS-1$ - } catch (NoSuchFileOrDirectory error) { - //This command must failed. exit code !=0 - } - - //Verify that current directory is PATH_OK - String newPwd = CommandHelper.getCurrentDir(getContext(), getConsole()); - assertTrue( - String.format( - "curDir!=%s", oldPwd), newPwd.compareTo(oldPwd) == 0); //$NON-NLS-1$ - } - - -} diff --git a/tests/src/com/cyanogenmod/filemanager/commands/shell/CurrentDirCommandTest.java b/tests/src/com/cyanogenmod/filemanager/commands/shell/CurrentDirCommandTest.java deleted file mode 100644 index 5cd5f3ba..00000000 --- a/tests/src/com/cyanogenmod/filemanager/commands/shell/CurrentDirCommandTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.filemanager.commands.shell; - -import android.os.Environment; -import android.test.suitebuilder.annotation.SmallTest; - -import com.cyanogenmod.filemanager.util.CommandHelper; - -/** - * A class for testing the {@link CurrentDirCommand} command. - * - * @see CurrentDirCommand - */ -public class CurrentDirCommandTest extends AbstractConsoleTest { - - private static final String PATH = - Environment.getExternalStorageDirectory().getAbsolutePath(); - - /** - * {@inheritDoc} - */ - @Override - public boolean isRootConsoleNeeded() { - return false; - } - - /** - * Method that performs a test for retrieve current directory. - * - * @throws Exception If test failed - */ - @SmallTest - public void testCurrentDir() throws Exception { - CommandHelper.changeCurrentDir(getContext(), PATH, getConsole()); - String curDir = CommandHelper.getCurrentDir(getContext(), getConsole()); - assertTrue( - String.format( - "current directory!=%s; %s", PATH, curDir), //$NON-NLS-1$ - curDir.compareTo(PATH) == 0); - } - - -} diff --git a/tests/src/com/cyanogenmod/filemanager/console/ConsoleBuilderTest.java b/tests/src/com/cyanogenmod/filemanager/console/ConsoleBuilderTest.java index 7d163095..6cfe481a 100644 --- a/tests/src/com/cyanogenmod/filemanager/console/ConsoleBuilderTest.java +++ b/tests/src/com/cyanogenmod/filemanager/console/ConsoleBuilderTest.java @@ -16,7 +16,6 @@ package com.cyanogenmod.filemanager.console; -import android.os.Environment; import android.test.suitebuilder.annotation.SmallTest; @@ -27,9 +26,6 @@ import android.test.suitebuilder.annotation.SmallTest; */ public class ConsoleBuilderTest extends android.test.AndroidTestCase { - private static final String PATH = - Environment.getExternalStorageDirectory().getAbsolutePath(); - /** * {@inheritDoc} */ @@ -50,11 +46,11 @@ public class ConsoleBuilderTest extends android.test.AndroidTestCase { * Method that performs a test over creating a privileged console. * * @throws Exception If test failed - * @{link {@link ConsoleBuilder#createPrivilegedConsole(android.content.Context, String)} + * @{link {@link ConsoleBuilder#createPrivilegedConsole(android.content.Context)} */ @SmallTest public void testCreatePrivilegedConsole() throws Exception { - Console console = ConsoleBuilder.createPrivilegedConsole(getContext(), PATH); + Console console = ConsoleBuilder.createPrivilegedConsole(getContext()); try { assertNotNull("console==null", console); //$NON-NLS-1$ } finally { @@ -70,11 +66,11 @@ public class ConsoleBuilderTest extends android.test.AndroidTestCase { * Method that performs a test over creating a non privileged console. * * @throws Exception If test failed - * @{link {@link ConsoleBuilder#createNonPrivilegedConsole(android.content.Context, String)} + * @{link {@link ConsoleBuilder#createNonPrivilegedConsole(android.content.Context)} */ @SmallTest public void testCreateNonPrivilegedConsole() throws Exception { - Console console = ConsoleBuilder.createNonPrivilegedConsole(getContext(), PATH); + Console console = ConsoleBuilder.createNonPrivilegedConsole(getContext()); try { assertNotNull("console==null", console); //$NON-NLS-1$ } finally { |