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 remotePath = "/testCreateFolder" + mCurrentDate;
42 boolean createFullPath = true;
44 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
45 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
48 remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
49 createFullPath = true;
51 result = mActivity.createFolder(remotePath, createFullPath);
52 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
57 * Test to Create Folder with special characters: / \ < > : " | ? *
59 public void testCreateFolderSpecialCharacters() {
60 boolean createFullPath = true;
62 String remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
63 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
64 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
66 remotePath = "/testSpecialCharacters_<" + mCurrentDate;
67 result = mActivity.createFolder(remotePath, createFullPath);
68 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
70 remotePath = "/testSpecialCharacters_>" + mCurrentDate;
71 result = mActivity.createFolder(remotePath, createFullPath);
72 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
74 remotePath = "/testSpecialCharacters_:" + mCurrentDate;
75 result = mActivity.createFolder(remotePath, createFullPath);
76 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
78 remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
79 result = mActivity.createFolder(remotePath, createFullPath);
80 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
82 remotePath = "/testSpecialCharacters_|" + mCurrentDate;
83 result = mActivity.createFolder(remotePath, createFullPath);
84 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
86 remotePath = "/testSpecialCharacters_?" + mCurrentDate;
87 result = mActivity.createFolder(remotePath, createFullPath);
88 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
90 remotePath = "/testSpecialCharacters_*" + mCurrentDate;
91 result = mActivity.createFolder(remotePath, createFullPath);
92 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);