本文整理汇总了Java中com.robotium.solo.Solo.Config.ScreenshotFileType类的典型用法代码示例。如果您正苦于以下问题:Java ScreenshotFileType类的具体用法?Java ScreenshotFileType怎么用?Java ScreenshotFileType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScreenshotFileType类属于com.robotium.solo.Solo.Config包,在下文中一共展示了ScreenshotFileType类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileName
import com.robotium.solo.Solo.Config.ScreenshotFileType; //导入依赖的package包/类
/**
* Returns a proper filename depending on if name is given or not.
*
* @param name the given name
* @return a proper filename depedning on if a name is given or not
*
*/
private String getFileName(final String name){
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyy-hhmmss");
String fileName = null;
if(name == null){
if(config.screenshotFileType == ScreenshotFileType.JPEG){
fileName = sdf.format( new Date()).toString()+ ".jpg";
}
else{
fileName = sdf.format( new Date()).toString()+ ".png";
}
}
else {
if(config.screenshotFileType == ScreenshotFileType.JPEG){
fileName = name + ".jpg";
}
else {
fileName = name + ".png";
}
}
return fileName;
}
示例2: setUp
import com.robotium.solo.Solo.Config.ScreenshotFileType; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
//setUp() is run before a test case is started.
//This is where the solo object is created.
Config config = new Config();
config.screenshotFileType = ScreenshotFileType.JPEG;
File sdcard = Environment.getExternalStorageDirectory();
File data = new File(sdcard, "/Data");
config.screenshotSavePath = data.getAbsolutePath() + "/Robotium/";
Log.i(MapAppRobotiumTests.TAG, config.screenshotSavePath);
config.shouldScroll = false;
solo = new Solo(getInstrumentation(), config);
if (!MapAppRobotiumTests.mPermissionsGranted){
Log.i(MapAppRobotiumTests.TAG, "Seeking permissions");
requestWritePermission();
}
getActivity();
}
示例3: saveFile
import com.robotium.solo.Solo.Config.ScreenshotFileType; //导入依赖的package包/类
/**
* Saves a file.
*
* @param name the name of the file
* @param b the bitmap to save
* @param quality the compression rate. From 0 (compress for lowest size) to 100 (compress for maximum quality).
*
*/
private void saveFile(String name, Bitmap b, int quality){
FileOutputStream fos = null;
String fileName = getFileName(name);
File directory = new File(config.screenshotSavePath);
directory.mkdir();
File fileToSave = new File(directory,fileName);
try {
fos = new FileOutputStream(fileToSave);
if(config.screenshotFileType == ScreenshotFileType.JPEG){
if (b.compress(Bitmap.CompressFormat.JPEG, quality, fos) == false){
Log.d(LOG_TAG, "Compress/Write failed");
}
}
else{
if (b.compress(Bitmap.CompressFormat.PNG, quality, fos) == false){
Log.d(LOG_TAG, "Compress/Write failed");
}
}
fos.flush();
fos.close();
} catch (Exception e) {
Log.d(LOG_TAG, "Can't save the screenshot! Requires write permission (android.permission.WRITE_EXTERNAL_STORAGE) in AndroidManifest.xml of the application under test.");
e.printStackTrace();
}
}