【发布时间】:2021-08-14 15:40:49
【问题描述】:
我正在为 Flutter App 编写集成测试。该应用程序让用户可以拍摄视频。在编写测试时,当权限对话框出现时,如何在脚本中允许我的应用程序的相机权限以进行集成测试?
【问题讨论】:
标签: flutter integration-testing
我正在为 Flutter App 编写集成测试。该应用程序让用户可以拍摄视频。在编写测试时,当权限对话框出现时,如何在脚本中允许我的应用程序的相机权限以进行集成测试?
【问题讨论】:
标签: flutter integration-testing
有了新的integration_test包,你可以在test_driver/integration_test.dart里面的android中授予权限:
// this permission grant workaround works only for android for now
Future<void> main() async {
final Map<String, String> envVars = Platform.environment;
final String adbPath =
envVars['ANDROID_SDK_ROOT']! + '/platform-tools/adb.exe';
await Process.run(adbPath, [
'shell',
'pm',
'grant',
'com.app.name',
'android.permission.CAMERA'
]);
await Process.run(adbPath, [
'shell',
'pm',
'grant',
'com.app.name',
'android.permission.RECORD_AUDIO'
]);
await integrationDriver();
}
【讨论】:
ProcessException: Permission denied 吗?