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;
12 public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
14 private TestActivity mActivity;
15 private String mCurrentDate;
17 public CreateFolderTest() {
18 super(TestActivity.class);
20 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
21 mCurrentDate = sdf.format(new Date());
25 protected void setUp() throws Exception {
27 setActivityInitialTouchMode(false);
28 mActivity = getActivity();
31 public void testCreateFolder() {
33 String remotePath = "/testCreateFolder" + mCurrentDate;
34 boolean createFullPath = true;
36 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
37 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
40 public void testCreateFolderSpecialCharacters() {
41 boolean createFullPath = true;
43 String remotePath = "/testSpecialCharacters_//" + mCurrentDate;
44 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
45 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
47 remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
48 result = mActivity.createFolder(remotePath, createFullPath);
49 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
51 remotePath = "/testSpecialCharacters_<" + mCurrentDate;
52 result = mActivity.createFolder(remotePath, createFullPath);
53 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
55 remotePath = "/testSpecialCharacters_>" + mCurrentDate;
56 result = mActivity.createFolder(remotePath, createFullPath);
57 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
59 remotePath = "/testSpecialCharacters_:" + mCurrentDate;
60 result = mActivity.createFolder(remotePath, createFullPath);
61 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
63 remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
64 result = mActivity.createFolder(remotePath, createFullPath);
65 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
67 remotePath = "/testSpecialCharacters_|" + mCurrentDate;
68 result = mActivity.createFolder(remotePath, createFullPath);
69 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
71 remotePath = "/testSpecialCharacters_?" + mCurrentDate;
72 result = mActivity.createFolder(remotePath, createFullPath);
73 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
75 remotePath = "/testSpecialCharacters_*" + mCurrentDate;
76 result = mActivity.createFolder(remotePath, createFullPath);
77 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);