mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Fixup experimental/federated_plugin (#1776)
Replaces https://github.com/flutter/samples/pull/1749 FYI @negotoyolo ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. <!-- Links --> [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/wiki/Chat [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md
This commit is contained in:
@@ -10,15 +10,17 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
group('federated plugin demo tests', () {
|
group('federated plugin demo tests', () {
|
||||||
const batteryLevel = 45;
|
const batteryLevel = 45;
|
||||||
setUpAll(() {
|
|
||||||
const MethodChannel('battery').setMockMethodCallHandler((call) async {
|
|
||||||
if (call.method == 'getBatteryLevel') {
|
|
||||||
return batteryLevel;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('get current battery level from platform', (tester) async {
|
testWidgets('get current battery level from platform', (tester) async {
|
||||||
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
|
const MethodChannel('battery'),
|
||||||
|
(call) async {
|
||||||
|
if (call.method == 'getBatteryLevel') {
|
||||||
|
return batteryLevel;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
);
|
||||||
await tester.pumpWidget(const MyApp());
|
await tester.pumpWidget(const MyApp());
|
||||||
|
|
||||||
// Tap button to retrieve current battery level from platform.
|
// Tap button to retrieve current battery level from platform.
|
||||||
|
|||||||
@@ -11,13 +11,17 @@ void main() {
|
|||||||
|
|
||||||
group('Federated Plugin Test', () {
|
group('Federated Plugin Test', () {
|
||||||
const batteryLevel = 34;
|
const batteryLevel = 34;
|
||||||
const MethodChannel('battery').setMockMethodCallHandler((call) async {
|
|
||||||
if (call.method == 'getBatteryLevel') {
|
|
||||||
return batteryLevel;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('getBatteryLevel method test', () async {
|
testWidgets('getBatteryLevel method test', (tester) async {
|
||||||
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||||
|
const MethodChannel('battery'),
|
||||||
|
(call) async {
|
||||||
|
if (call.method == 'getBatteryLevel') {
|
||||||
|
return batteryLevel;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
);
|
||||||
final result = await getBatteryLevel();
|
final result = await getBatteryLevel();
|
||||||
expect(result, batteryLevel);
|
expect(result, batteryLevel);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,13 +11,17 @@ void main() {
|
|||||||
|
|
||||||
group('MethodChannel test', () {
|
group('MethodChannel test', () {
|
||||||
const batteryLevel = 89;
|
const batteryLevel = 89;
|
||||||
const MethodChannel('battery').setMockMethodCallHandler((call) async {
|
|
||||||
if (call.method == 'getBatteryLevel') {
|
|
||||||
return batteryLevel;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test('getBatteryLevel method test', () async {
|
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 locationMethodChannel = BatteryMethodChannel();
|
||||||
final result = await locationMethodChannel.getBatteryLevel();
|
final result = await locationMethodChannel.getBatteryLevel();
|
||||||
expect(result, batteryLevel);
|
expect(result, batteryLevel);
|
||||||
|
|||||||
@@ -26,13 +26,10 @@ declare -ar PROJECT_NAMES=(
|
|||||||
"desktop_photo_search/material"
|
"desktop_photo_search/material"
|
||||||
"experimental/context_menus"
|
"experimental/context_menus"
|
||||||
"experimental/element_embedding_demo"
|
"experimental/element_embedding_demo"
|
||||||
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
|
"experimental/federated_plugin/federated_plugin"
|
||||||
# "experimental/federated_plugin/federated_plugin"
|
"experimental/federated_plugin/federated_plugin/example"
|
||||||
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
|
|
||||||
# "experimental/federated_plugin/federated_plugin/example"
|
|
||||||
"experimental/federated_plugin/federated_plugin_macos"
|
"experimental/federated_plugin/federated_plugin_macos"
|
||||||
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
|
"experimental/federated_plugin/federated_plugin_platform_interface"
|
||||||
# "experimental/federated_plugin/federated_plugin_platform_interface"
|
|
||||||
"experimental/federated_plugin/federated_plugin_web"
|
"experimental/federated_plugin/federated_plugin_web"
|
||||||
"experimental/federated_plugin/federated_plugin_windows"
|
"experimental/federated_plugin/federated_plugin_windows"
|
||||||
"experimental/linting_tool"
|
"experimental/linting_tool"
|
||||||
|
|||||||
@@ -27,13 +27,10 @@ declare -ar PROJECT_NAMES=(
|
|||||||
# TODO(DomesticMouse): The function can't be unconditionally invoked because it can be 'null'.
|
# TODO(DomesticMouse): The function can't be unconditionally invoked because it can be 'null'.
|
||||||
# "experimental/context_menus"
|
# "experimental/context_menus"
|
||||||
"experimental/element_embedding_demo"
|
"experimental/element_embedding_demo"
|
||||||
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
|
"experimental/federated_plugin/federated_plugin"
|
||||||
# "experimental/federated_plugin/federated_plugin"
|
"experimental/federated_plugin/federated_plugin/example"
|
||||||
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
|
|
||||||
# "experimental/federated_plugin/federated_plugin/example"
|
|
||||||
"experimental/federated_plugin/federated_plugin_macos"
|
"experimental/federated_plugin/federated_plugin_macos"
|
||||||
# TODO(DomesticMouse): 'setMockMethodCallHandler' is deprecated and shouldn't be used.
|
"experimental/federated_plugin/federated_plugin_platform_interface"
|
||||||
# "experimental/federated_plugin/federated_plugin_platform_interface"
|
|
||||||
"experimental/federated_plugin/federated_plugin_web"
|
"experimental/federated_plugin/federated_plugin_web"
|
||||||
"experimental/federated_plugin/federated_plugin_windows"
|
"experimental/federated_plugin/federated_plugin_windows"
|
||||||
"experimental/linting_tool"
|
"experimental/linting_tool"
|
||||||
|
|||||||
Reference in New Issue
Block a user