1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-06 03:31:03 +00:00

[federated_plugin_sample] modify the sample to expose battery API instead of geolocation API (#526)

This commit is contained in:
Ayush Bherwani
2020-08-25 11:52:42 +05:30
committed by GitHub
parent 033ae11733
commit 60691d00c0
17 changed files with 116 additions and 211 deletions

View File

@@ -10,17 +10,16 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('Federated Plugin Test', () {
final location = Location(latitude: 131.0, longitude: 221.0);
MethodChannel('location').setMockMethodCallHandler((call) async {
if (call.method == 'getLocation') {
return [location.longitude, location.latitude];
final batteryLevel = 34;
MethodChannel('battery').setMockMethodCallHandler((call) async {
if (call.method == 'getBatteryLevel') {
return batteryLevel;
}
});
test('getLocation method test', () async {
final result = await getLocation();
expect(result.longitude, location.longitude);
expect(result.latitude, location.latitude);
test('getBatteryLevel method test', () async {
final result = await getBatteryLevel();
expect(result, batteryLevel);
});
});
}