Skip to content

Commit 738af48

Browse files
author
Julian Kast
committed
Added testOverWriteFilePropertyListFiles to FileManagerTest
1 parent 448c66c commit 738af48

1 file changed

Lines changed: 49 additions & 2 deletions

File tree

android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/file/FileManagerTests.java

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,8 @@ public void testFileManagerConfig() {
873873
}
874874

875875
/**
876-
* Testing Overwrite property for uploading a file.
877-
* Checks to make sure file does not overwrite itself
876+
* Tests overwrite property for uploading a file.
877+
* Checks to make sure file does not overwrite itself if overwrite property is set to false
878878
*/
879879
public void testOverwriteFileProperty() {
880880
ISdl internalInterface = mock(ISdl.class);
@@ -907,4 +907,51 @@ public void onComplete(boolean success) {
907907
});
908908
verify(internalInterface, times(2)).sendRPC(any(RPCMessage.class));
909909
}
910+
911+
/**
912+
* Tests overwrite property for uploading a list of files.
913+
* Checks to make sure files do not overwrite themselves if overwrite property is set to false.
914+
*/
915+
public void testOverWriteFilePropertyListFiles() {
916+
final ISdl internalInterface = mock(ISdl.class);
917+
918+
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
919+
doAnswer(onListFileUploadSuccess).when(internalInterface).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
920+
921+
final SdlFile validFile2 = new SdlFile();
922+
validFile2.setName(Test.GENERAL_STRING + "2");
923+
validFile2.setFileData(Test.GENERAL_BYTE_ARRAY);
924+
validFile2.setPersistent(false);
925+
validFile2.setType(FileType.GRAPHIC_JPEG);
926+
927+
final List<SdlFile> list = new ArrayList<>();
928+
list.add(validFile);
929+
list.add(validFile2);
930+
931+
FileManagerConfig fileManagerConfig = new FileManagerConfig();
932+
fileManagerConfig.setArtworkRetryCount(2);
933+
fileManagerConfig.setFileRetryCount(4);
934+
935+
final FileManager fileManager = new FileManager(internalInterface, mTestContext, fileManagerConfig);
936+
fileManager.start(new CompletionListener() {
937+
@Override
938+
public void onComplete(boolean success) {
939+
fileManager.uploadFiles(list, new MultipleFileCompletionListener() {
940+
@Override
941+
public void onComplete(Map<String, String> errors) {
942+
validFile.setOverwrite(false);
943+
validFile2.setOverwrite(false);
944+
fileManager.uploadFiles(list, new MultipleFileCompletionListener() {
945+
@Override
946+
public void onComplete(Map<String, String> errors) {
947+
assertNull(errors);
948+
}
949+
});
950+
}
951+
});
952+
953+
}
954+
});
955+
verify(internalInterface, times(1)).sendRequests(any(List.class), any(OnMultipleRequestListener.class));
956+
}
910957
}

0 commit comments

Comments
 (0)