com.openxc.TestUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openxc-it Show documentation
Show all versions of openxc-it Show documentation
Instrumentation test suite for OpenXC library
The newest version!
package com.openxc;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.io.FileUtils;
import android.content.Context;
import junit.framework.Assert;
public class TestUtils {
public static void pause(int millis) {
try {
Thread.sleep(millis);
} catch(InterruptedException e) {}
}
public static URI copyToStorage(Context context, int resource,
String filename) {
URI uri = null;
try {
uri = new URI("file:///sdcard/com.openxc/" + filename);
} catch(URISyntaxException e) {
Assert.fail("Couldn't construct resource URIs: " + e);
}
try {
FileUtils.copyInputStreamToFile(
context.getResources().openRawResource(resource),
new File(uri));
} catch(IOException e) {
Assert.fail("Couldn't copy trace files to SD card" + e);
}
return uri;
}
}