Compare commits

...
Author SHA1 Message Date
tobiasKaminsky b4a7528b05 add tests
Signed-off-by: tobiasKaminsky <[email protected]>
2020-11-24 08:19:44 +01:00
tobiasKaminsky 8d59f51319 test for #6905
Signed-off-by: tobiasKaminsky <[email protected]>
2020-11-24 08:06:02 +01:00
2 changed files with 67 additions and 4 deletions

No files matched your search

@@ -43,6 +43,9 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.contrib.DrawerActions;
import androidx.test.espresso.contrib.NavigationViewActions;
@@ -175,4 +178,47 @@ public class FileDisplayActivityIT extends AbstractOnServerIT {
Espresso.onView(withId(R.id.switch_account_button)).perform(click());
}
@Test
public void audioPlayerRemoveFile() {
FileDisplayActivity sut = activityRule.launchActivity(null);
sut.tryStopPlaying(new OCFile("/test.mp3"));
longSleep();
Assert.assertTrue(true); // if we reach this, everything is ok
}
@Test
public void start() throws IOException {
FileDisplayActivity sut = activityRule.launchActivity(null);
File videoFile = getFile("videoFile.mp4");
// Assert.assertTrue(new UploadFileRemoteOperation(videoFile.getAbsolutePath(),
// "/videoFile.mp4",
// "video/mpeg",
// String.valueOf(System.currentTimeMillis() / 1000))
// .execute(client).isSuccess());
//sut.updateListOfFilesFragment();getFileByPath("/videoFile.mp4")
OCFile ocFile = new OCFile("/videoFile.mp4", "123");
ocFile.setStoragePath(videoFile.getAbsolutePath());
sut.start(ocFile);
longSleep();
Assert.assertTrue(true); // if we reach this, everything is ok
}
@Test
public void stop() {
FileDisplayActivity sut = activityRule.launchActivity(null);
sut.stop();
longSleep();
Assert.assertTrue(true); // if we reach this, everything is ok
}
}
@@ -131,6 +131,7 @@ import javax.annotation.Nullable;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SearchView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
@@ -1782,16 +1783,32 @@ public class FileDisplayActivity extends FileActivity
}
}
private void tryStopPlaying(OCFile file) {
@VisibleForTesting
public void tryStopPlaying(OCFile file) {
// placeholder for stop-on-delete future code
if(mPlayerConnection != null) {
if (mPlayerConnection != null) {
mPlayerConnection.stop(file);
}
}
@VisibleForTesting
public void start(OCFile file) {
// placeholder for stop-on-delete future code
if (mPlayerConnection != null) {
mPlayerConnection.start(getUser().get(), file, true, 0);
}
}
@VisibleForTesting
public void stop() {
// placeholder for stop-on-delete future code
if (mPlayerConnection != null) {
mPlayerConnection.stop();
}
}
/**
* Updates the view associated to the activity after the finish of an operation trying to move a
* file.
* Updates the view associated to the activity after the finish of an operation trying to move a file.
*
* @param operation Move operation performed.
* @param result Result of the move operation.