perf: short-circuit granted mic permission checks
This commit is contained in:
@@ -371,8 +371,8 @@ void main() {
|
||||
});
|
||||
|
||||
test(
|
||||
'SWE4-UV-041 / SDD-106 §1: ensureRecordAudio() resolves from the '
|
||||
'platform return value even when the resolved state is unchanged',
|
||||
'SWE4-UV-041 / SDD-106 §1: ensureRecordAudio() short-circuits when '
|
||||
'the cached state is already granted',
|
||||
() async {
|
||||
final svc = AndroidPermissionsService(channel: channel)..start();
|
||||
|
||||
@@ -392,7 +392,7 @@ void main() {
|
||||
expect(result, AndroidRecordAudioPermissionState.granted);
|
||||
expect(
|
||||
outgoingCalls.where((c) => c.method == methodRequestRecordAudio),
|
||||
hasLength(1),
|
||||
isEmpty,
|
||||
);
|
||||
svc.dispose();
|
||||
},
|
||||
@@ -411,6 +411,46 @@ void main() {
|
||||
svc.dispose();
|
||||
});
|
||||
|
||||
test('startup permissions request emits outbound method and records '
|
||||
'multiple returned states', () async {
|
||||
final svc = AndroidPermissionsService(channel: channel)..start();
|
||||
|
||||
outgoingResponder = (call) async {
|
||||
if (call.method == methodRequestStartupPermissions) {
|
||||
return {
|
||||
'android.permission.RECORD_AUDIO': 'Granted',
|
||||
'android.permission.BLUETOOTH_CONNECT': 'Denied',
|
||||
'android.permission.POST_NOTIFICATIONS': 'PermanentlyDenied',
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
final result = await svc.ensureStartupPermissions();
|
||||
|
||||
expect(
|
||||
outgoingCalls.where((c) => c.method == methodRequestStartupPermissions),
|
||||
hasLength(1),
|
||||
);
|
||||
expect(
|
||||
result[AndroidPermissionKind.recordAudio],
|
||||
AndroidRecordAudioPermissionState.granted,
|
||||
);
|
||||
expect(
|
||||
result[AndroidPermissionKind.bluetoothConnect],
|
||||
AndroidRecordAudioPermissionState.denied,
|
||||
);
|
||||
expect(
|
||||
result[AndroidPermissionKind.postNotifications],
|
||||
AndroidRecordAudioPermissionState.permanentlyDenied,
|
||||
);
|
||||
expect(
|
||||
svc.permissionState(AndroidPermissionKind.bluetoothConnect).value,
|
||||
AndroidRecordAudioPermissionState.denied,
|
||||
);
|
||||
svc.dispose();
|
||||
});
|
||||
|
||||
test('SWE4-UV-041 / SDD-106: non-Android short-circuit — when channel '
|
||||
'is null, recordAudioState seeds to granted and ensureRecordAudio '
|
||||
'resolves synchronously without touching any channel', () async {
|
||||
|
||||
Reference in New Issue
Block a user