mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Add failed test cases into moving file test
This commit is contained in:
		
							parent
							
								
									e5010c1a6b
								
							
						
					
					
						commit
						3a5df9dcdf
					
				| @ -37,6 +37,7 @@ import com.owncloud.android.lib.common.OwnCloudClientFactory; | |||||||
| import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; | import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; | ||||||
| import com.owncloud.android.lib.common.network.NetworkUtils; | import com.owncloud.android.lib.common.network.NetworkUtils; | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult; | import com.owncloud.android.lib.common.operations.RemoteOperationResult; | ||||||
|  | import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; | ||||||
| import com.owncloud.android.lib.resources.files.MoveRemoteFileOperation; | import com.owncloud.android.lib.resources.files.MoveRemoteFileOperation; | ||||||
| import com.owncloud.android.lib.test_project.R; | import com.owncloud.android.lib.test_project.R; | ||||||
| import com.owncloud.android.lib.test_project.SelfSignedConfidentSslSocketFactory; | import com.owncloud.android.lib.test_project.SelfSignedConfidentSslSocketFactory; | ||||||
| @ -75,15 +76,19 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 	/// Paths to files and folders in fixture | 	/// Paths to files and folders in fixture | ||||||
| 	 | 	 | ||||||
| 	private static final String SRC_BASE_FOLDER = "/src/"; | 	private static final String SRC_BASE_FOLDER = "/src/"; | ||||||
|  | 	private static final String SRC_BASE_FOLDER_NON_CREATED = "/src_non_created/"; | ||||||
| 	private static final String TARGET_BASE_FOLDER = "/target/"; | 	private static final String TARGET_BASE_FOLDER = "/target/"; | ||||||
| 	private static final String FILE1 = "file1.txt"; | 	private static final String FILE1 = "file1.txt"; | ||||||
| 	private static final String FILE2 = "file2.txt"; | 	private static final String FILE2 = "file2.txt"; | ||||||
| 	private static final String FILE3 = "file3.txt"; | 	private static final String FILE3 = "file3.txt"; | ||||||
| 	private static final String FILE4 = "file4.txt"; | 	private static final String FILE4 = "file4.txt"; | ||||||
|  | 	private static final String FILE5 = "file5.txt"; | ||||||
| 	private static final String EMPTY = "empty/"; | 	private static final String EMPTY = "empty/"; | ||||||
| 	private static final String FOLDER1 = "folder1/"; | 	private static final String FOLDER1 = "folder1/"; | ||||||
| 	private static final String FOLDER2 = "folder2/"; | 	private static final String FOLDER2 = "folder2/"; | ||||||
| 	private static final String FOLDER3 = "folder3/"; | 	private static final String FOLDER3 = "folder3/"; | ||||||
|  | 	private static final String FOLDER4 = "folder4/"; | ||||||
|  | 	private static final String FOLDER5 = "folder5/"; | ||||||
| 
 | 
 | ||||||
| 	private static final String SRC_PATH_TO_FILE_1 = SRC_BASE_FOLDER + FILE1; | 	private static final String SRC_PATH_TO_FILE_1 = SRC_BASE_FOLDER + FILE1; | ||||||
| 	private static final String TARGET_PATH_TO_FILE_1 = TARGET_BASE_FOLDER + FILE1; | 	private static final String TARGET_PATH_TO_FILE_1 = TARGET_BASE_FOLDER + FILE1; | ||||||
| @ -97,6 +102,8 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 
 | 
 | ||||||
| 	private static final String SRC_PATH_TO_FILE_4 = SRC_BASE_FOLDER + FILE4; | 	private static final String SRC_PATH_TO_FILE_4 = SRC_BASE_FOLDER + FILE4; | ||||||
| 	 | 	 | ||||||
|  | 	private static final String SRC_PATH_TO_FILE_NON_EXISTS = SRC_BASE_FOLDER + FILE5; | ||||||
|  | 
 | ||||||
| 	private static final String SRC_PATH_TO_EMPTY_FOLDER = SRC_BASE_FOLDER + EMPTY; | 	private static final String SRC_PATH_TO_EMPTY_FOLDER = SRC_BASE_FOLDER + EMPTY; | ||||||
| 	private static final String TARGET_PATH_TO_EMPTY_FOLDER = TARGET_BASE_FOLDER + EMPTY; | 	private static final String TARGET_PATH_TO_EMPTY_FOLDER = TARGET_BASE_FOLDER + EMPTY; | ||||||
| 
 | 
 | ||||||
| @ -109,10 +116,18 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 			TARGET_BASE_FOLDER + "renamed_" + FOLDER2; | 			TARGET_BASE_FOLDER + "renamed_" + FOLDER2; | ||||||
| 
 | 
 | ||||||
| 	private static final String SRC_PATH_TO_FULL_FOLDER_3 = SRC_BASE_FOLDER + FOLDER3; | 	private static final String SRC_PATH_TO_FULL_FOLDER_3 = SRC_BASE_FOLDER + FOLDER3; | ||||||
|  | 	private static final String SRC_PATH_TO_FULL_FOLDER_4 = SRC_BASE_FOLDER + FOLDER4; | ||||||
|  | 	private static final String SRC_PATH_TO_FULL_FOLDER_5 = SRC_BASE_FOLDER + FOLDER5; | ||||||
| 
 | 
 | ||||||
| 	private static final String SRC_PATH_TO_FULL_FOLDER_3_RENAMED =  | 	private static final String SRC_PATH_TO_FULL_FOLDER_3_RENAMED =  | ||||||
| 			SRC_BASE_FOLDER + "renamed_" + FOLDER3; | 			SRC_BASE_FOLDER + "renamed_" + FOLDER3; | ||||||
| 
 | 
 | ||||||
|  | 	private static final String SRC_PATH_TO_FULL_FOLDER_4_RENAMED_INVALID_CHARS = | ||||||
|  | 					SRC_BASE_FOLDER + "renamed:??_" + FOLDER4; | ||||||
|  | 
 | ||||||
|  | 	private static final String SRC_PATH_TO_FULL_FOLDER_5_INSIDE_FOLDER_4 = SRC_BASE_FOLDER  | ||||||
|  | 					+ FOLDER4 + FOLDER5; | ||||||
|  | 
 | ||||||
| 	 | 	 | ||||||
| 	private static final String[] FOLDERS_IN_FIXTURE = { | 	private static final String[] FOLDERS_IN_FIXTURE = { | ||||||
| 		SRC_PATH_TO_EMPTY_FOLDER, | 		SRC_PATH_TO_EMPTY_FOLDER, | ||||||
| @ -135,7 +150,10 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 		SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FOLDER1, | 		SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FOLDER1, | ||||||
| 		SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FOLDER2, | 		SRC_PATH_TO_FULL_FOLDER_3 + FOLDER2 + FOLDER2, | ||||||
| 		 | 		 | ||||||
| 		TARGET_BASE_FOLDER | 		SRC_PATH_TO_FULL_FOLDER_5, | ||||||
|  | 		SRC_PATH_TO_FULL_FOLDER_5_INSIDE_FOLDER_4, | ||||||
|  | 
 | ||||||
|  | 		TARGET_BASE_FOLDER, | ||||||
| 	}; | 	}; | ||||||
| 	 | 	 | ||||||
| 	private static final String[] FILES_IN_FIXTURE = { | 	private static final String[] FILES_IN_FIXTURE = { | ||||||
| @ -303,16 +321,62 @@ public class MoveFileTest extends ActivityInstrumentationTestCase2<TestActivity> | |||||||
| 		result = moveOperation.execute(mClient); | 		result = moveOperation.execute(mClient); | ||||||
| 		assertTrue(result.isSuccess()); | 		assertTrue(result.isSuccess()); | ||||||
| 		 | 		 | ||||||
|  | 		// move to the same name folder but overwrite it | ||||||
|  | 		moveOperation = new MoveRemoteFileOperation( | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_5, | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_5_INSIDE_FOLDER_4, | ||||||
|  | 						true | ||||||
|  | 		); | ||||||
|  | 		result = moveOperation.execute(mClient); | ||||||
|  | 		assertTrue(result.isSuccess()); | ||||||
| 
 | 
 | ||||||
| 		/// TODO failed cases | 
 | ||||||
|  | 		// Failed cases | ||||||
| 		 | 		 | ||||||
| 		// file to move does not exist | 		// file to move does not exist | ||||||
|  | 		moveOperation = new MoveRemoteFileOperation( | ||||||
|  | 						SRC_PATH_TO_FILE_NON_EXISTS, | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_4, | ||||||
|  | 						false | ||||||
|  | 		); | ||||||
|  | 		result = moveOperation.execute(mClient); | ||||||
|  | 		assertTrue(result.getCode() == ResultCode.INVALID_OVERWRITE); | ||||||
| 
 | 
 | ||||||
| 		// folder to move into does no exist | 		// folder to move into does no exist | ||||||
|  | 		moveOperation = new MoveRemoteFileOperation( | ||||||
|  | 						SRC_BASE_FOLDER_NON_CREATED, | ||||||
|  | 						SRC_PATH_TO_FILE_4, | ||||||
|  | 						false | ||||||
|  | 		); | ||||||
|  | 		result = moveOperation.execute(mClient); | ||||||
|  | 		assertTrue(result.getCode() == ResultCode.INVALID_OVERWRITE); | ||||||
| 
 | 
 | ||||||
| 		// target location (renaming) has invalid characters | 		// target location (renaming) has invalid characters | ||||||
|  | 		moveOperation = new MoveRemoteFileOperation( | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_4, | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_4_RENAMED_INVALID_CHARS, | ||||||
|  | 						false | ||||||
|  | 		); | ||||||
|  | 		result = moveOperation.execute(mClient); | ||||||
|  | 		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME); | ||||||
| 
 | 
 | ||||||
| 		// name collision | 		// name collision | ||||||
|  | 		moveOperation = new MoveRemoteFileOperation( | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_5, | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_5_INSIDE_FOLDER_4, | ||||||
|  | 						false | ||||||
|  | 		); | ||||||
|  | 		result = moveOperation.execute(mClient); | ||||||
|  | 		assertTrue(result.getCode() == ResultCode.INVALID_OVERWRITE); | ||||||
|  | 
 | ||||||
|  | 		// move a folder into a descendant | ||||||
|  | 		moveOperation = new MoveRemoteFileOperation( | ||||||
|  | 						SRC_BASE_FOLDER, | ||||||
|  | 						SRC_PATH_TO_FULL_FOLDER_4, | ||||||
|  | 						false | ||||||
|  | 		); | ||||||
|  | 		result = moveOperation.execute(mClient); | ||||||
|  | 		assertTrue(result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT); | ||||||
| 		 | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user