2ec2d3af797cd178287e94fdd78e6011b164f219
[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 public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
13
14 private TestActivity mActivity;
15 private String mCurrentDate;
16
17 public CreateFolderTest() {
18 super(TestActivity.class);
19
20 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
21 mCurrentDate = sdf.format(new Date());
22 }
23
24 @Override
25 protected void setUp() throws Exception {
26 super.setUp();
27 setActivityInitialTouchMode(false);
28 mActivity = getActivity();
29 }
30
31 public void testCreateFolder() {
32
33 String remotePath = "/testCreateFolder" + mCurrentDate;
34 boolean createFullPath = true;
35
36 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
37 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
38 }
39
40 public void testCreateFolderSpecialCharacters() {
41 boolean createFullPath = true;
42
43 String remotePath = "/testSpecialCharacters_//" + mCurrentDate;
44 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
45 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
46
47 remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
48 result = mActivity.createFolder(remotePath, createFullPath);
49 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
50
51 remotePath = "/testSpecialCharacters_<" + mCurrentDate;
52 result = mActivity.createFolder(remotePath, createFullPath);
53 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
54
55 remotePath = "/testSpecialCharacters_>" + mCurrentDate;
56 result = mActivity.createFolder(remotePath, createFullPath);
57 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
58
59 remotePath = "/testSpecialCharacters_:" + mCurrentDate;
60 result = mActivity.createFolder(remotePath, createFullPath);
61 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
62
63 remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
64 result = mActivity.createFolder(remotePath, createFullPath);
65 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
66
67 remotePath = "/testSpecialCharacters_|" + mCurrentDate;
68 result = mActivity.createFolder(remotePath, createFullPath);
69 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
70
71 remotePath = "/testSpecialCharacters_?" + mCurrentDate;
72 result = mActivity.createFolder(remotePath, createFullPath);
73 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
74
75 remotePath = "/testSpecialCharacters_*" + mCurrentDate;
76 result = mActivity.createFolder(remotePath, createFullPath);
77 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
78 }
79
80
81 }