5f847476e9d0e874075f4cd5fec5591e44781d10
[pub/Android/ownCloud.git] /
1 package com.owncloud.android.oc_framework_test_project.test;
2
3 import java.text.SimpleDateFormat;
4 import java.util.Date;
5
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;
9
10 import android.test.ActivityInstrumentationTestCase2;
11
12 /**
13 * Class to test Create Folder Operation
14 * @author masensio
15 *
16 */
17 public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
18
19 private TestActivity mActivity;
20 private String mCurrentDate;
21
22 public CreateFolderTest() {
23 super(TestActivity.class);
24
25 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
26 mCurrentDate = sdf.format(new Date());
27 }
28
29 @Override
30 protected void setUp() throws Exception {
31 super.setUp();
32 setActivityInitialTouchMode(false);
33 mActivity = getActivity();
34 }
35
36 /**
37 * Test Create Folder
38 */
39 public void testCreateFolder() {
40
41 String folderName = "testCreateFolder" + mCurrentDate;
42 String remotePath = "/testCreateFolder" + mCurrentDate;
43 boolean createFullPath = true;
44
45 RemoteOperationResult result = mActivity.createFolder(folderName, remotePath, createFullPath);
46 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
47
48 // Create Subfolder
49 folderName = "testCreateFolder" + mCurrentDate;
50 remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
51 createFullPath = true;
52
53 result = mActivity.createFolder(folderName, remotePath, createFullPath);
54 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
55 }
56
57
58 /**
59 * Test to Create Folder with special characters
60 */
61 public void testCreateFolderSpecialCharacters() {
62 boolean createFullPath = true;
63
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);
68
69 folderName = "testSpecialCharacters_\\" + mCurrentDate;
70 remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
71 result = mActivity.createFolder(folderName, remotePath, createFullPath);
72 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
73
74 folderName = "testSpecialCharacters_<" + mCurrentDate;
75 remotePath = "/testSpecialCharacters_<" + mCurrentDate;
76 result = mActivity.createFolder(folderName, remotePath, createFullPath);
77 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
78
79 folderName = "testSpecialCharacters_>" + mCurrentDate;
80 remotePath = "/testSpecialCharacters_>" + mCurrentDate;
81 result = mActivity.createFolder(folderName, remotePath, createFullPath);
82 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
83
84 folderName = "testSpecialCharacters_:" + mCurrentDate;
85 remotePath = "/testSpecialCharacters_:" + mCurrentDate;
86 result = mActivity.createFolder(folderName, remotePath, createFullPath);
87 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
88
89 folderName = "testSpecialCharacters_\"" + mCurrentDate;
90 remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
91 result = mActivity.createFolder(folderName, remotePath, createFullPath);
92 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
93
94 folderName = "testSpecialCharacters_|" + mCurrentDate;
95 remotePath = "/testSpecialCharacters_|" + mCurrentDate;
96 result = mActivity.createFolder(folderName, remotePath, createFullPath);
97 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
98
99 folderName = "testSpecialCharacters_?" + mCurrentDate;
100 remotePath = "/testSpecialCharacters_?" + mCurrentDate;
101 result = mActivity.createFolder(folderName, remotePath, createFullPath);
102 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
103
104 folderName = "testSpecialCharacters_*" + mCurrentDate;
105 remotePath = "/testSpecialCharacters_*" + mCurrentDate;
106 result = mActivity.createFolder(folderName, remotePath, createFullPath);
107 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
108 }
109
110
111 }