Skip to content

Commit 1f005dd

Browse files
author
Julian Kast
committed
add unit test to FileManager
1 parent d032f81 commit 1f005dd

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,43 @@ public void run() {
850850
});
851851
}
852852

853+
/**
854+
* Tests to make sure files are not being uploaded to head unit multiple times in a row
855+
*/
856+
@Test
857+
public void testFileNotOnHmi() {
858+
final ISdl internalInterface = createISdlMock();
859+
860+
doAnswer(onListFilesSuccess).when(internalInterface).sendRPC(any(ListFiles.class));
861+
doAnswer(onPutFileSuccess).when(internalInterface).sendRPC(any(PutFile.class));
862+
863+
final SdlArtwork validFile2 = new SdlArtwork(TestValues.GENERAL_STRING + "2", FileType.GRAPHIC_JPEG, TestValues.GENERAL_STRING.getBytes(), false);
864+
865+
final List<SdlArtwork> list = Arrays.asList(validFile2, validFile2);
866+
867+
FileManagerConfig fileManagerConfig = new FileManagerConfig();
868+
869+
final FileManager fileManager = new FileManager(internalInterface, mTestContext, fileManagerConfig);
870+
fileManager.start(new CompletionListener() {
871+
@Override
872+
public void onComplete(boolean success) {
873+
fileManager.uploadArtworks(list, new MultipleFileCompletionListener() {
874+
@Override
875+
public void onComplete(final Map<String, String> errors) {
876+
assertOnMainThread(new Runnable() {
877+
@Override
878+
public void run() {
879+
assertTrue(errors != null);
880+
assertTrue(errors.containsValue(fileManager.fileManagerCannotOverwriteError));
881+
}
882+
});
883+
}
884+
});
885+
}
886+
});
887+
}
888+
889+
853890
/**
854891
* Test custom overridden SdlFile equals method
855892
*/

0 commit comments

Comments
 (0)