This repository has been archived by the owner on Jul 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migrate platform_interface to pigeon 0.2.1 * Format * Fix Analysis * Update SDK version constraints * Update generated messages * Add empty test
- Loading branch information
1 parent
22a46ba
commit 8d6197e
Showing
8 changed files
with
58 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,9 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:wakelock/wakelock.dart'; | ||
import 'package:wakelock_platform_interface/messages.dart'; | ||
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('$Wakelock', () { | ||
late FakeWakelockApi fakeWakelock; | ||
|
||
setUpAll(() { | ||
if (Platform.isMacOS) { | ||
// See the member documentation for the reason behind this. | ||
// todo(creativecreatorormaybenot): remove this once macOS is migrated | ||
// todo| to pigeon. | ||
wakelockPlatformInstance = WakelockPlatformInterface.instance; | ||
} | ||
fakeWakelock = FakeWakelockApi(); | ||
}); | ||
|
||
test('enable', () async { | ||
await Wakelock.enable(); | ||
|
||
expect(fakeWakelock.calls.last, 'toggle'); | ||
expect(fakeWakelock.toggleMessage.enable, isTrue); | ||
}); | ||
|
||
test('disable', () async { | ||
await Wakelock.disable(); | ||
|
||
expect(fakeWakelock.calls.last, 'toggle'); | ||
expect(fakeWakelock.toggleMessage.enable, isFalse); | ||
}); | ||
|
||
test('toggle', () async { | ||
await Wakelock.toggle(enable: false); | ||
|
||
expect(fakeWakelock.calls.last, 'toggle'); | ||
expect(fakeWakelock.toggleMessage.enable, isFalse); | ||
|
||
await Wakelock.toggle(enable: true); | ||
|
||
expect(fakeWakelock.calls.last, 'toggle'); | ||
expect(fakeWakelock.toggleMessage.enable, isTrue); | ||
}); | ||
|
||
test('enabled', () async { | ||
expect(Wakelock.enabled, completion(isTrue)); | ||
expect(fakeWakelock.calls.last, 'isEnabled'); | ||
}); | ||
}); | ||
} | ||
|
||
class FakeWakelockApi extends TestWakelockApi { | ||
FakeWakelockApi() { | ||
TestWakelockApi.setup(this); | ||
} | ||
|
||
final calls = <String>[]; | ||
late ToggleMessage toggleMessage; | ||
|
||
@override | ||
IsEnabledMessage isEnabled() { | ||
calls.add('isEnabled'); | ||
return IsEnabledMessage()..enabled = true; | ||
} | ||
|
||
@override | ||
void toggle(ToggleMessage message) { | ||
calls.add('toggle'); | ||
toggleMessage = message; | ||
; | ||
} | ||
// There are no unit tests here as the API in this package only forwards the | ||
// calls to the platform interface (unit tested) → platform implementations. | ||
// Instead, this is all tested via e2e tests in the integration tests in the | ||
// example app. | ||
test('no unit tests', () {}); | ||
} |