Skip to content

Commit a08c2be

Browse files
authored
Disable permission popups during testing (#486)
1 parent 8e40681 commit a08c2be

File tree

5 files changed

+55
-14
lines changed

5 files changed

+55
-14
lines changed

.github/recipe.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ plugins:
66
flutter_app_badger: ["wearable-5.5"]
77
flutter_secure_storage: ["wearable-5.5", "tv-6.5"]
88
flutter_tts: ["wearable-5.5", "tv-6.5"]
9+
google_maps_flutter: ["wearable-5.5", "tv-6.5"]
910
integration_test: ["wearable-5.5", "tv-6.5"]
1011
messageport: ["wearable-5.5", "tv-6.5"]
1112
package_info_plus: ["wearable-5.5", "tv-6.5"]
12-
path_provider: ["tv-6.5"]
13+
path_provider: ["wearable-5.5", "tv-6.5"]
14+
permission_handler: ["wearable-5.5"]
1315
sensors_plus: ["wearable-5.5"]
1416
shared_preferences: ["wearable-5.5", "tv-6.5"]
1517
sqflite: ["wearable-5.5", "tv-6.5"]
@@ -21,26 +23,25 @@ plugins:
2123
url_launcher: ["wearable-5.5", "tv-6.5"]
2224
wakelock: ["wearable-5.5"]
2325

24-
# Not supported by emulators.
25-
camera: []
26-
google_maps_flutter: []
27-
network_info_plus: []
28-
webview_flutter: []
29-
webview_flutter_lwe: []
30-
3126
# No tests.
3227
google_sign_in: []
3328
image_picker: []
3429
tizen_log: []
3530
tizen_notification: []
3631
wearable_rotary: []
3732

38-
# Permission cannot be granted without manual interaction.
33+
# Functionality not available on emulator.
34+
camera: []
3935
geolocator: []
40-
permission_handler: []
36+
network_info_plus: []
4137

4238
# Only testable with the drive command: https://github.com/flutter-tizen/plugins/issues/272
4339
tizen_app_control: []
4440

4541
# Test frequently breaks due to memory issue: https://github.com/flutter-tizen/plugins/issues/135
4642
video_player: []
43+
44+
# Temporarily disabled due to test_api error. Testable with the drive command.
45+
# https://github.com/flutter-tizen/plugins/pull/397#issuecomment-1139299838
46+
webview_flutter: []
47+
webview_flutter_lwe: []

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
- name: Install Tizen Studio
2525
if: ${{ env.HAS_CHANGED_PACKAGES == 'true' }}
2626
run: |
27-
sudo apt install -y pciutils zip libncurses5 python libpython2.7 make gettext
28-
curl http://download.tizen.org/sdk/Installer/tizen-studio_4.6/web-cli_Tizen_Studio_4.6_ubuntu-64.bin -o install.bin
27+
sudo apt install -y libncurses5 python2.7 libpython2.7 gettext
28+
curl http://download.tizen.org/sdk/Installer/tizen-studio_5.0/web-cli_Tizen_Studio_5.0_ubuntu-64.bin -o install.bin
2929
chmod a+x install.bin
3030
./install.bin --accept-license $HOME/tizen-studio
3131
rm install.bin

packages/permission_handler/example/integration_test/permission_handler_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void main() {
66
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
77

88
testWidgets('get permission status', (tester) async {
9-
expect(await Permission.camera.status.isDenied, true);
9+
expect(await Permission.camera.status.isGranted, true);
1010
});
1111

1212
testWidgets('get location service status', (tester) async {

tools/lib/src/device.dart

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,45 @@ class EmulatorDevice extends Device {
272272
);
273273
}
274274

275+
/// Grants all privacy-related permissions to apps by default.
276+
///
277+
/// This only applies to apps newly installed to the device after this call.
278+
bool _disablePermissionPopups() {
279+
if (!isConnected) {
280+
return false;
281+
}
282+
final Map<String, String> capability = _tizenSdk.sdbCapability(serial!);
283+
final bool rooted = capability['rootonoff_support'] == 'enabled';
284+
if (!rooted) {
285+
return false;
286+
}
287+
288+
io.ProcessResult result = _processRunner.runSync(
289+
_tizenSdk.sdb.path,
290+
<String>['-s', serial!, 'root', 'on'],
291+
);
292+
if (result.exitCode != 0) {
293+
print('Error: running "sdb root on" failed.');
294+
return false;
295+
}
296+
297+
result = _processRunner.runSync(
298+
_tizenSdk.sdb.path,
299+
<String>['-s', serial!, 'shell', 'touch', '/opt/share/askuser_disable'],
300+
);
301+
final String stdout = result.stdout as String;
302+
if (result.exitCode != 0 || stdout.trim().isNotEmpty) {
303+
print('Error: running sdb shell command failed: $stdout');
304+
return false;
305+
}
306+
307+
_processRunner.runSync(
308+
_tizenSdk.sdb.path,
309+
<String>['-s', serial!, 'root', 'off'],
310+
);
311+
return true;
312+
}
313+
275314
/// Deletes this emulator.
276315
Future<void> delete() async => await _processRunner.runAndStream(
277316
_tizenSdk.emCli.path,
@@ -368,6 +407,7 @@ class EmulatorDevice extends Device {
368407
autoLaunched = true;
369408
await launch();
370409
}
410+
_disablePermissionPopups();
371411
result = await super.runIntegrationTest(workingDir, timeout);
372412
} finally {
373413
if (autoLaunched) {

tools/lib/src/integration_test_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class IntegrationTestCommand extends PackageLoopingCommand {
8181
// Tizen SDK installed on the system.
8282
late final TizenSdk _tizenSdk = TizenSdk.locateTizenSdk();
8383

84-
Duration _timeout = const Duration(seconds: 120);
84+
Duration _timeout = const Duration(seconds: 300);
8585

8686
Recipe? _recipe;
8787

0 commit comments

Comments
 (0)