在Android测试中比较Google Maps v2屏幕截图
我想在Android测试中比较2个Google Maps v2屏幕截图。有什么建议我应该从哪里开始 我已经使用过了,但它仍然无法捕获GoogleMapsV2(因为地图是在OpenGL上渲染的)在Android测试中比较Google Maps v2屏幕截图,android,google-maps,gradle,integration-testing,Android,Google Maps,Gradle,Integration Testing,我想在Android测试中比较2个Google Maps v2屏幕截图。有什么建议我应该从哪里开始 我已经使用过了,但它仍然无法捕获GoogleMapsV2(因为地图是在OpenGL上渲染的) 我的想法是:创建一个gradle任务,使用SnapshotReadyCallback拍摄Google Maps v2的快照,然后使用OpenCV进行比较。有什么想法吗?这是使用Maps v2拍摄快照的方式: Button button = (Button) findViewById(R.id.mB
我的想法是:创建一个gradle任务,使用SnapshotReadyCallback拍摄Google Maps v2的快照,然后使用OpenCV进行比较。有什么想法吗?这是使用Maps v2拍摄快照的方式:
Button button = (Button) findViewById(R.id.mButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SnapshotReadyCallback callback = new SnapshotReadyCallback() {
Bitmap bitmap;
@Override
public void onSnapshotReady(Bitmap snapshot) {
bitmap = snapshot;
try {
FileOutputStream out = new FileOutputStream("/mnt/sdcard/Download/globe.png");
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
// OR
ImageView im1 = (ImageView)findViewById(R.id.myImView);
im1.setImageBitmap(bitmap);
}
};
map.snapshot(callback);
}
});
我以前实现过您的解决方案,它是有效的,但我打算在Instrumentation测试中使用屏幕截图,并将其与本地计算机磁盘中的另一个屏幕截图进行比较。