import android.test.ActivityInstrumentationTestCase2;
+/**
+ * Class to test Create Folder Operation
+ * @author masensio
+ *
+ */
public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
private TestActivity mActivity;
mActivity = getActivity();
}
+ /**
+ * Test Create Folder
+ */
public void testCreateFolder() {
String remotePath = "/testCreateFolder" + mCurrentDate;
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
}
+ /**
+ * Test to Create Folder with special characters
+ */
public void testCreateFolderSpecialCharacters() {
boolean createFullPath = true;
--- /dev/null
+package com.owncloud.android.oc_framework.utils;
+
+import java.io.File;
+
+import android.util.Log;
+
+public class FileUtils {
+
+ public static final String PATH_SEPARATOR = "/";
+
+
+ public static String getParentPath(String remotePath) {
+ String parentPath = new File(remotePath).getParent();
+ parentPath = parentPath.endsWith(PATH_SEPARATOR) ? parentPath : parentPath + PATH_SEPARATOR;
+ return parentPath;
+ }
+
+ /**
+ * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , : , " , | , ? , *
+ * @param fileName
+ * @return
+ */
+ public static boolean validateName(String fileName) {
+ boolean result = true;
+
+ Log.d("FileUtils", "fileName =======" + fileName);
+ String name = fileName.substring(1);
+ if ((fileName.indexOf("/") > 0 && name.indexOf("/") < (name.length() - 1 ) ) ||
+ fileName.contains("\\") || fileName.contains("<") || fileName.contains(">") ||
+ fileName.contains(":") || fileName.contains("\"") || fileName.contains("|") ||
+ fileName.contains("?") || fileName.contains("*")) {
+ result = false;
+ }
+ return result;
+ }
+}
<string name="sync_file_fail_msg">Remote file could not be checked</string>
<string name="sync_file_nothing_to_do_msg">File contents already synchronized</string>
<string name="create_dir_fail_msg">Directory could not be created</string>
+ <string name="create_dir_fail_msg_invalid_characters">Invalid character in foldername: / \\ < > : " | ? *</string>
<string name="wait_a_moment">Wait a moment</string>
<string name="filedisplay_unexpected_bad_get_content">"Unexpected problem ; please select the file from a different app"</string>
<string name="filedisplay_no_file_selected">No file was selected</string>
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.IntentFilter.AuthorityEntry;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SyncRequest;
} else {
dismissLoadingDialog();
+ if (result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME) {
+ Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg_invalid_characters, Toast.LENGTH_LONG).show();
+ } else {
try {
Toast msg = Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg, Toast.LENGTH_LONG);
msg.show();
} catch (NotFoundException e) {
Log_OC.e(TAG, "Error while trying to show fail message " , e);
}
+ }
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry combineaccessrules="false" kind="src" path="/owncloud-android"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>