我正在使用Robolectric进行单元测试.在我的应用程序中,我有一个以编程方式调用onBackPressed的方法.但是我不知道如何用RoboLectric测试这个方法是否正确执行.我已经在设备上测试过了,方法运行正常.但现在:我如何使用Robolectric进行验证?
我目前遇到以下问题:当我想从库中检索图像时,我使用以下代码来启动库的意图.
public void useGallery() {
this.intentbasedleave=true;
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(
Intent.createChooser(intent, getString(R.string.pleaseselect_image)), IMAGE_PICK);
}
Run Code Online (Sandbox Code Playgroud)
当我从库中获取数据时,我使用此方法:
private void imageFromGallery(int resultCode, Intent data) {
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
this.updateImageView(BitmapFactory.decodeFile(filePath));
}
Run Code Online (Sandbox Code Playgroud)
这是有效的,除非所选图像来自Google+或即时上传.然后BitmapFactory.decodeFile(filePath))似乎为空?因为该方法引发了一个nullpointer异常.
因此,我的问题是:如何使用Google+中的图片以及图库中的即时上传?
我想基于ARM的TrustZone技术启动一个项目,我想在其中为Android进行身份验证启动.
我应该使用哪种电路板?
最低要求:
到目前为止,我发现了飞思卡尔i.MX53,Pandaboard,Beagle主板xM(显然已经禁用了TrustZone),基于Atmel的主板,Versiatile Express A9x4和用于ARM1176JZF-S的RealView平台底板.但通常不清楚是否启用了TrustZone扩展.
我目前有一项服务,取决于$ cookies中设置的变量.但是,当我想要对服务和$ cookies中存储的值之间的交互进行单元测试时,则在实际初始化$ cookie值之前始终初始化服务.
所以,我的问题是:如何正确地测试服务和$ cookie值之间的交互?(例如:如何在我的服务初始化之前设置$ cookies中的值?)
注意:我使用Angular 1.2和Karma进行单元测试.
cookies unit-testing angularjs angularjs-service karma-runner
android ×3
unit-testing ×2
angularjs ×1
arm ×1
cookies ×1
google-plus ×1
karma-runner ×1
robolectric ×1
trustzone ×1