Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set adp permissions in test #1

Open
johnpryan opened this issue Mar 18, 2021 · 5 comments
Open

Set adp permissions in test #1

johnpryan opened this issue Mar 18, 2021 · 5 comments

Comments

@johnpryan
Copy link
Owner

The adb commands can be called directly by the test in main(), instead of requiring this in the instructions:

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.example.apppackage', 'android.permission.READ_EXTERNAL_STORAGE']);
  await Process.run(adbPath , ['shell' ,'pm', 'grant', 'com.example.apppackage', 'android.permission.READ_PHONE_STATE']);
  await integrationDriver();
}
@ccc-dvansevenant
Copy link

The adb commands can be called directly by the test in main(), instead of requiring this in the instructions:

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.example.apppackage', 'android.permission.READ_EXTERNAL_STORAGE']);
  await Process.run(adbPath , ['shell' ,'pm', 'grant', 'com.example.apppackage', 'android.permission.READ_PHONE_STATE']);
  await integrationDriver();
}

That seems to work, thanks!

@johnpryan
Copy link
Owner Author

Good to hear, I need to update this sample...

@nilsreichardt
Copy link

On macOS, you will get a Permission denied error:

  ProcessException: Permission denied
    Command: adb shell pm grant dev.steenbakker.mobile_scanner.example android.permission.CAMERA
  dart:io                                                                                                                Process.run
  Users/runner/work/mobile_scanner/mobile_scanner/example/integration_test/app_test.dart 15:15                           main.<fn>
  ===== asynchronous gap ===========================
  dart:io                                                                                                                Process.run
  Users/runner/work/mobile_scanne

@nilsreichardt
Copy link

On macOS, you will get a Permission denied error:

  ProcessException: Permission denied
    Command: adb shell pm grant dev.steenbakker.mobile_scanner.example android.permission.CAMERA
  dart:io                                                                                                                Process.run
  Users/runner/work/mobile_scanner/mobile_scanner/example/integration_test/app_test.dart 15:15                           main.<fn>
  ===== asynchronous gap ===========================
  dart:io                                                                                                                Process.run
  Users/runner/work/mobile_scanne

My problem was that I was running the command in the setUpAll() method. The command needs to be executed before calling integrationDriver().

@nilsreichardt
Copy link

We need also to keep in mind that you need to use the flutter drive command to start the tests. The flutter test integration_test is not working (does not grant the permissions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants