app.dart
977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import 'dart:async';
import 'package:flutter_driver/driver_extension.dart';
import 'package:test/test.dart';
import 'package:wakelock/wakelock.dart';
void main() {
final Completer<String> completer = Completer();
enableFlutterDriverExtension(handler: (_) => completer.future);
tearDownAll(() => completer.complete(null));
group('wakelock', () {
test('is disabled at start', () async {
expect(await Wakelock.isEnabled, false);
});
test('enable', () async {
await Wakelock.enable();
expect(await Wakelock.isEnabled, true);
});
test('disable', () async {
await Wakelock.disable();
expect(await Wakelock.isEnabled, false);
});
test('enable with toggle', () async {
await Wakelock.toggle(on: true);
expect(await Wakelock.isEnabled, true);
});
test('disable with toggle', () async {
await Wakelock.toggle(on: false);
expect(await Wakelock.isEnabled, false);
});
});
}