import 'package:flutter_test/flutter_test.dart'; import 'package:keyboard_android/keyboard_android.dart'; import 'package:keyboard_android/keyboard_android_platform_interface.dart'; import 'package:keyboard_android/keyboard_android_method_channel.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; class MockKeyboardAndroidPlatform with MockPlatformInterfaceMixin implements KeyboardAndroidPlatform { @override Future getPlatformVersion() => Future.value('42'); @override Future enableFloatingWindow(bool enable) { throw UnimplementedError(); } @override Future isTargetKeyboardEnabled() { throw UnimplementedError(); } @override Future openInputMethodSettings() { throw UnimplementedError(); } @override Future hasFloatingWindowPermission() { throw UnimplementedError(); } @override void jumpFloatingWindowSetting() { throw UnimplementedError(); } } void main() { final KeyboardAndroidPlatform initialPlatform = KeyboardAndroidPlatform.instance; test('$MethodChannelKeyboardAndroid is the default instance', () { expect(initialPlatform, isInstanceOf()); }); test('getPlatformVersion', () async { KeyboardAndroid keyboardAndroidPlugin = KeyboardAndroid(); MockKeyboardAndroidPlatform fakePlatform = MockKeyboardAndroidPlatform(); KeyboardAndroidPlatform.instance = fakePlatform; expect(await keyboardAndroidPlugin.getPlatformVersion(), '42'); }); }