1 package com.owncloud.android.oc_framework_test_project.test;
3 import java.text.SimpleDateFormat;
6 import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
7 import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
8 import com.owncloud.android.oc_framework_test_project.TestActivity;
10 import android.test.ActivityInstrumentationTestCase2;
13 * Class to test Create Folder Operation
17 public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
19 private TestActivity mActivity;
20 private String mCurrentDate;
22 public CreateFolderTest() {
23 super(TestActivity.class);
25 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
26 mCurrentDate = sdf.format(new Date());
30 protected void setUp() throws Exception {
32 setActivityInitialTouchMode(false);
33 mActivity = getActivity();
39 public void testCreateFolder() {
41 String folderName = "testCreateFolder" + mCurrentDate;
42 String remotePath = "/testCreateFolder" + mCurrentDate;
43 boolean createFullPath = true;
45 RemoteOperationResult result = mActivity.createFolder(folderName, remotePath, createFullPath);
46 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
49 folderName = "testCreateFolder" + mCurrentDate;
50 remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
51 createFullPath = true;
53 result = mActivity.createFolder(folderName, remotePath, createFullPath);
54 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
59 * Test to Create Folder with special characters
61 public void testCreateFolderSpecialCharacters() {
62 boolean createFullPath = true;
64 String folderName = "testSpecialCharacters_//" + mCurrentDate;
65 String remotePath = "/testSpecialCharacters_//" + mCurrentDate;
66 RemoteOperationResult result = mActivity.createFolder(folderName, remotePath, createFullPath);
67 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
69 folderName = "testSpecialCharacters_\\" + mCurrentDate;
70 remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
71 result = mActivity.createFolder(folderName, remotePath, createFullPath);
72 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
74 folderName = "testSpecialCharacters_<" + mCurrentDate;
75 remotePath = "/testSpecialCharacters_<" + mCurrentDate;
76 result = mActivity.createFolder(folderName, remotePath, createFullPath);
77 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
79 folderName = "testSpecialCharacters_>" + mCurrentDate;
80 remotePath = "/testSpecialCharacters_>" + mCurrentDate;
81 result = mActivity.createFolder(folderName, remotePath, createFullPath);
82 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
84 folderName = "testSpecialCharacters_:" + mCurrentDate;
85 remotePath = "/testSpecialCharacters_:" + mCurrentDate;
86 result = mActivity.createFolder(folderName, remotePath, createFullPath);
87 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
89 folderName = "testSpecialCharacters_\"" + mCurrentDate;
90 remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
91 result = mActivity.createFolder(folderName, remotePath, createFullPath);
92 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
94 folderName = "testSpecialCharacters_|" + mCurrentDate;
95 remotePath = "/testSpecialCharacters_|" + mCurrentDate;
96 result = mActivity.createFolder(folderName, remotePath, createFullPath);
97 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
99 folderName = "testSpecialCharacters_?" + mCurrentDate;
100 remotePath = "/testSpecialCharacters_?" + mCurrentDate;
101 result = mActivity.createFolder(folderName, remotePath, createFullPath);
102 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
104 folderName = "testSpecialCharacters_*" + mCurrentDate;
105 remotePath = "/testSpecialCharacters_*" + mCurrentDate;
106 result = mActivity.createFolder(folderName, remotePath, createFullPath);
107 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);