Showing
4 changed files
with
57 additions
and
0 deletions
example/test_driver/app.dart
0 → 100644
| 1 | +import 'dart:async'; | ||
| 2 | + | ||
| 3 | +import 'package:flutter_driver/driver_extension.dart'; | ||
| 4 | +import 'package:test/test.dart'; | ||
| 5 | +import 'package:wakelock/wakelock.dart'; | ||
| 6 | + | ||
| 7 | +void main() { | ||
| 8 | + final Completer<String> completer = Completer(); | ||
| 9 | + enableFlutterDriverExtension(handler: (_) => completer.future); | ||
| 10 | + tearDownAll(() => completer.complete(null)); | ||
| 11 | + | ||
| 12 | + group('wakelock', () { | ||
| 13 | + test('is disabled on start', () async { | ||
| 14 | + expect(await Wakelock.isEnabled, false); | ||
| 15 | + }); | ||
| 16 | + | ||
| 17 | + test('enable', () async { | ||
| 18 | + await Wakelock.enable(); | ||
| 19 | + | ||
| 20 | + expect(await Wakelock.isEnabled, true); | ||
| 21 | + }); | ||
| 22 | + | ||
| 23 | + test('disable', () async { | ||
| 24 | + await Wakelock.disable(); | ||
| 25 | + | ||
| 26 | + expect(await Wakelock.isEnabled, false); | ||
| 27 | + }); | ||
| 28 | + | ||
| 29 | + test('enable with toggle', () async { | ||
| 30 | + await Wakelock.toggle(on: true); | ||
| 31 | + | ||
| 32 | + expect(await Wakelock.isEnabled, true); | ||
| 33 | + }); | ||
| 34 | + | ||
| 35 | + test('disable with toggle', () async { | ||
| 36 | + await Wakelock.toggle(on: false); | ||
| 37 | + | ||
| 38 | + expect(await Wakelock.isEnabled, false); | ||
| 39 | + }); | ||
| 40 | + }); | ||
| 41 | +} |
-
Please register or login to post a comment