84145022b7bfb7d029f239ff353377c80dd5a48f
[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 remotePath = "/testCreateFolder" + mCurrentDate;
42 boolean createFullPath = true;
43
44 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
45 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
46
47 // Create Subfolder
48 remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
49 createFullPath = true;
50
51 result = mActivity.createFolder(remotePath, createFullPath);
52 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
53 }
54
55
56 /**
57 * Test to Create Folder with special characters: / \ < > : " | ? *
58 */
59 public void testCreateFolderSpecialCharacters() {
60 boolean createFullPath = true;
61
62 String remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
63 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
64 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
65
66 remotePath = "/testSpecialCharacters_<" + mCurrentDate;
67 result = mActivity.createFolder(remotePath, createFullPath);
68 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
69
70 remotePath = "/testSpecialCharacters_>" + mCurrentDate;
71 result = mActivity.createFolder(remotePath, createFullPath);
72 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
73
74 remotePath = "/testSpecialCharacters_:" + mCurrentDate;
75 result = mActivity.createFolder(remotePath, createFullPath);
76 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
77
78 remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
79 result = mActivity.createFolder(remotePath, createFullPath);
80 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
81
82 remotePath = "/testSpecialCharacters_|" + mCurrentDate;
83 result = mActivity.createFolder(remotePath, createFullPath);
84 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
85
86 remotePath = "/testSpecialCharacters_?" + mCurrentDate;
87 result = mActivity.createFolder(remotePath, createFullPath);
88 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
89
90 remotePath = "/testSpecialCharacters_*" + mCurrentDate;
91 result = mActivity.createFolder(remotePath, createFullPath);
92 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
93 }
94
95
96 }