You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
samples/experimental/federated_plugin/federated_plugin_platform_i.../test/federated_plugin_platform_i...

31 lines
975 B

// Copyright 2020 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:federated_plugin_platform_interface/battery_method_channel.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('MethodChannel test', () {
const batteryLevel = 89;
testWidgets('getBatteryLevel method test', (tester) async {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
const MethodChannel('battery'),
(call) async {
if (call.method == 'getBatteryLevel') {
return batteryLevel;
}
return 0;
},
);
final locationMethodChannel = BatteryMethodChannel();
final result = await locationMethodChannel.getBatteryLevel();
expect(result, batteryLevel);
});
});
}