forked from cropsly/ffmpeg-android-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
566c46a
commit 2dc2a4b
Showing
1 changed file
with
42 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 42 additions & 2 deletions
44
FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/ShellCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,52 @@ | ||
package com.github.hiteshsondhi88.libffmpeg; | ||
|
||
import com.github.hiteshsondhi88.libffmpeg.utils.AssertionHelper; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ShellCommandTest extends CommonTestCase { | ||
|
||
public void testRun() throws Exception { | ||
// TODO | ||
ShellCommand shellCommand = new ShellCommand(); | ||
final Process process = shellCommand.run("logcat"); | ||
assertNotNull(process); | ||
assertEquals(false, Util.isProcessCompleted(process)); | ||
|
||
Util.destroyProcess(process); | ||
|
||
ExecutorService executor = Executors.newSingleThreadExecutor(); | ||
|
||
Future<?> future = executor.submit(new Runnable() { | ||
@Override | ||
public void run() { | ||
String errorStream = Util.convertInputStreamToString(process.getErrorStream()); | ||
String inputStream = Util.convertInputStreamToString(process.getInputStream()); | ||
|
||
assertEquals(null, errorStream); | ||
assertEquals(null, inputStream); | ||
} | ||
}); | ||
|
||
try { | ||
future.get(1, TimeUnit.SECONDS); | ||
} catch (TimeoutException e) { | ||
AssertionHelper.assertError("could not destroy process"); | ||
} | ||
|
||
executor.shutdownNow(); | ||
} | ||
|
||
public void testRunWaitFor() throws Exception { | ||
// TODO | ||
ShellCommand shellCommand = new ShellCommand(); | ||
CommandResult commandResult = shellCommand.runWaitFor("ls /sdcard/"); | ||
assertNotNull(commandResult); | ||
assertEquals(true, commandResult.success); | ||
assertThat(commandResult.output).isNotEmpty(); | ||
} | ||
} |