intent receiver plugin initial

This commit is contained in:
Fabian Freund
2025-05-04 21:56:54 +02:00
parent 603004ec23
commit fd34a84d68
45 changed files with 934 additions and 0 deletions
@@ -0,0 +1,27 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:simple_intent_receiver/simple_intent_receiver_method_channel.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
MethodChannelSimpleIntentReceiver platform = MethodChannelSimpleIntentReceiver();
const MethodChannel channel = MethodChannel('simple_intent_receiver');
setUp(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(
channel,
(MethodCall methodCall) async {
return '42';
},
);
});
tearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null);
});
test('getPlatformVersion', () async {
expect(await platform.getPlatformVersion(), '42');
});
}
@@ -0,0 +1,29 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:simple_intent_receiver/simple_intent_receiver.dart';
import 'package:simple_intent_receiver/simple_intent_receiver_platform_interface.dart';
import 'package:simple_intent_receiver/simple_intent_receiver_method_channel.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class MockSimpleIntentReceiverPlatform
with MockPlatformInterfaceMixin
implements SimpleIntentReceiverPlatform {
@override
Future<String?> getPlatformVersion() => Future.value('42');
}
void main() {
final SimpleIntentReceiverPlatform initialPlatform = SimpleIntentReceiverPlatform.instance;
test('$MethodChannelSimpleIntentReceiver is the default instance', () {
expect(initialPlatform, isInstanceOf<MethodChannelSimpleIntentReceiver>());
});
test('getPlatformVersion', () async {
SimpleIntentReceiver simpleIntentReceiverPlugin = SimpleIntentReceiver();
MockSimpleIntentReceiverPlatform fakePlatform = MockSimpleIntentReceiverPlatform();
SimpleIntentReceiverPlatform.instance = fakePlatform;
expect(await simpleIntentReceiverPlugin.getPlatformVersion(), '42');
});
}