Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BatteryPlusLinuxPlugin extends BatteryPlatform {
return client
.connect()
.then((_) => client.displayDevice.state.toBatteryState())
.whenComplete(() => client.close);
.whenComplete(() => client.close());
}

/// Fires whenever the battery state changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ void main() {
expect(battery.batteryState, completion(BatteryState.charging));
});

test('battery state closes the client', () async {
late MockUPowerClient client;
final battery = BatteryPlusLinuxPlugin();
battery.createClient = () {
client = createMockClient(state: UPowerDeviceState.charging);
return client;
};
await battery.batteryState;
verify(client.close()).called(1);
});

test('battery state changes', () {
final battery = BatteryPlusLinuxPlugin();
battery.createClient = () {
Expand Down
Loading