1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package com.owncloud.android.oc_framework_test_project.test;
20 import java.text.SimpleDateFormat;
21 import java.util.Date;
23 import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
24 import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
25 import com.owncloud.android.oc_framework_test_project.TestActivity;
27 import android.test.ActivityInstrumentationTestCase2;
30 * Class to test Create Folder Operation
34 public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
36 private TestActivity mActivity;
37 private String mCurrentDate;
39 public CreateFolderTest() {
40 super(TestActivity.class);
42 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
43 mCurrentDate = sdf.format(new Date());
47 protected void setUp() throws Exception {
49 setActivityInitialTouchMode(false);
50 mActivity = getActivity();
56 public void testCreateFolder() {
58 String remotePath = "/testCreateFolder" + mCurrentDate;
59 boolean createFullPath = true;
61 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
62 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
65 remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
66 createFullPath = true;
68 result = mActivity.createFolder(remotePath, createFullPath);
69 assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
74 * Test to Create Folder with special characters: / \ < > : " | ? *
76 public void testCreateFolderSpecialCharacters() {
77 boolean createFullPath = true;
79 String remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
80 RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
81 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
83 remotePath = "/testSpecialCharacters_<" + mCurrentDate;
84 result = mActivity.createFolder(remotePath, createFullPath);
85 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
87 remotePath = "/testSpecialCharacters_>" + mCurrentDate;
88 result = mActivity.createFolder(remotePath, createFullPath);
89 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
91 remotePath = "/testSpecialCharacters_:" + mCurrentDate;
92 result = mActivity.createFolder(remotePath, createFullPath);
93 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
95 remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
96 result = mActivity.createFolder(remotePath, createFullPath);
97 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
99 remotePath = "/testSpecialCharacters_|" + mCurrentDate;
100 result = mActivity.createFolder(remotePath, createFullPath);
101 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
103 remotePath = "/testSpecialCharacters_?" + mCurrentDate;
104 result = mActivity.createFolder(remotePath, createFullPath);
105 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
107 remotePath = "/testSpecialCharacters_*" + mCurrentDate;
108 result = mActivity.createFolder(remotePath, createFullPath);
109 assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);