diff options
author | jruesga <jorge@ruesga.com> | 2012-09-30 01:39:06 +0200 |
---|---|---|
committer | jruesga <jorge@ruesga.com> | 2012-09-30 01:39:06 +0200 |
commit | 47c142cb6b2ac01f16d3aef2a3fdf83b9e3e9861 (patch) | |
tree | 428a9e13e9e8bc73271337783b5f0c5a5e937d8d /tests | |
parent | 43610bdc1d9d8ae2eb732f6f73c2783fbb46b247 (diff) | |
download | android_packages_apps_CMFileManager-47c142cb6b2ac01f16d3aef2a3fdf83b9e3e9861.tar.gz android_packages_apps_CMFileManager-47c142cb6b2ac01f16d3aef2a3fdf83b9e3e9861.tar.bz2 android_packages_apps_CMFileManager-47c142cb6b2ac01f16d3aef2a3fdf83b9e3e9861.zip |
Fix commands
* Fix cancelable commands
* New pid_shell and pid_cmd command
* New FolderUsage command
* New compute folder statistics in fso properties
* Add overlay file for device specific stuff
* Fix invalid executable drawable
* Clean up
Diffstat (limited to 'tests')
4 files changed, 99 insertions, 24 deletions
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml index 39b1415b..1fd0d883 100644 --- a/tests/AndroidManifest.xml +++ b/tests/AndroidManifest.xml @@ -4,6 +4,8 @@ <original-package android:name="com.cyanogenmod.explorer.test" /> + <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java index 870121d0..664e141d 100644 --- a/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java +++ b/tests/src/com/cyanogenmod/explorer/commands/shell/FindCommandTest.java @@ -51,7 +51,7 @@ public class FindCommandTest extends AbstractConsoleTest { * @throws Exception If test failed */ @SuppressWarnings("synthetic-access") - public void testListWithPartialResult() throws Exception { + public void testFindWithPartialResult() throws Exception { this.mNewPartialData = false; Query query = new Query().setSlot(FIND_TERM_PARTIAL, 0); final List<FileSystemObject> files = new ArrayList<FileSystemObject>(); @@ -67,9 +67,10 @@ public class FindCommandTest extends AbstractConsoleTest { public void onException(Exception cause) { fail(cause.toString()); } - public void onPartialResult(List<FileSystemObject> results) { + @SuppressWarnings("unchecked") + public void onPartialResult(Object results) { FindCommandTest.this.mNewPartialData = true; - files.addAll(results); + files.addAll((List<FileSystemObject>)results); } }, getConsole()); synchronized (FindCommandTest.this.mSync) { diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java new file mode 100644 index 00000000..29b43546 --- /dev/null +++ b/tests/src/com/cyanogenmod/explorer/commands/shell/FolderUsageCommandTest.java @@ -0,0 +1,91 @@ +/* + * 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 android.util.Log; + +import com.cyanogenmod.explorer.commands.AsyncResultListener; +import com.cyanogenmod.explorer.model.FolderUsage; +import com.cyanogenmod.explorer.util.CommandHelper; +import com.cyanogenmod.explorer.util.MimeTypeHelper.MimeTypeCategory; + +/** + * A class for testing folder usage command. + * + * @see FindCommand + */ +public class FolderUsageCommandTest extends AbstractConsoleTest { + + private static final String TAG = "FolderUsageCommandTest"; //$NON-NLS-1$ + + private static final String PATH = "/system"; //$NON-NLS-1$ + + private final Object mSync = new Object(); + private boolean mNewPartialData; + private FolderUsage mUsage; + + /** + * {@inheritDoc} + */ + @Override + public boolean isRootConsoleNeeded() { + return false; + } + + /** + * Method that performs a test over known search results. + * + * @throws Exception If test failed + */ + @SuppressWarnings("synthetic-access") + public void testFolderUsageWithPartialResult() throws Exception { + this.mNewPartialData = false; + this.mUsage = null; + CommandHelper.getFolderUsage(getContext(), PATH, new AsyncResultListener() { + public void onAsyncStart() { + /**NON BLOCK**/ + } + public void onAsyncEnd(boolean cancelled) { + synchronized (FolderUsageCommandTest.this.mSync) { + FolderUsageCommandTest.this.mSync.notifyAll(); + } + } + public void onException(Exception cause) { + fail(cause.toString()); + } + public void onPartialResult(Object result) { + FolderUsageCommandTest.this.mNewPartialData = true; + try { + FolderUsageCommandTest.this.mUsage = + (FolderUsage)(((FolderUsage)result).clone()); + } catch (Exception e) {/**NON BLOCK**/} + Log.d(TAG, FolderUsageCommandTest.this.mUsage.toString()); + } + }, getConsole()); + synchronized (FolderUsageCommandTest.this.mSync) { + FolderUsageCommandTest.this.mSync.wait(25000L); + } + 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); + } + +} diff --git a/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java b/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java index bdabcc53..61966903 100644 --- a/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java +++ b/tests/src/com/cyanogenmod/explorer/commands/shell/ProcessIdCommandTest.java @@ -15,10 +15,6 @@ */ package com.cyanogenmod.explorer.commands.shell; - -import com.cyanogenmod.explorer.ExplorerApplication; -import com.cyanogenmod.explorer.util.CommandHelper; - /** * A class for testing the {@link ProcessIdCommand} command. * @@ -34,21 +30,6 @@ public class ProcessIdCommandTest extends AbstractConsoleTest { return false; } - /** - * Method that performs a test over id command. - * - * @throws Exception If test failed - */ - public void testId() throws Exception { - Integer main = Integer.valueOf(android.os.Process.myPid()); - Integer pid = - CommandHelper.getProcessId( - getContext(), - ExplorerApplication.MAIN_PROCESS, getConsole()); - assertNotNull("pid==null", pid); //$NON-NLS-1$ - assertTrue( - String.format("pid != main process id (%d)", main), //$NON-NLS-1$ - pid.compareTo(main) == 0); - } - + // 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. } |