keyboard_android_test.dart 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:flutter_test/flutter_test.dart';
  2. import 'package:keyboard_android/keyboard_android.dart';
  3. import 'package:keyboard_android/keyboard_android_platform_interface.dart';
  4. import 'package:keyboard_android/keyboard_android_method_channel.dart';
  5. import 'package:plugin_platform_interface/plugin_platform_interface.dart';
  6. class MockKeyboardAndroidPlatform
  7. with MockPlatformInterfaceMixin
  8. implements KeyboardAndroidPlatform {
  9. @override
  10. Future<String?> getPlatformVersion() => Future.value('42');
  11. @override
  12. Future<void> initPlugin() {
  13. throw UnimplementedError();
  14. }
  15. @override
  16. Future<void> enableFloatingWindow(bool enable) {
  17. throw UnimplementedError();
  18. }
  19. @override
  20. Future<bool> isTargetKeyboardEnabled() {
  21. throw UnimplementedError();
  22. }
  23. @override
  24. Future<void> openInputMethodSettings() {
  25. throw UnimplementedError();
  26. }
  27. @override
  28. Future<bool> hasFloatingWindowPermission() {
  29. throw UnimplementedError();
  30. }
  31. @override
  32. void jumpFloatingWindowSetting() {
  33. throw UnimplementedError();
  34. }
  35. @override
  36. Future<bool> isDefaultKeyboard() {
  37. throw UnimplementedError();
  38. }
  39. @override
  40. void updateKeyboardInfo(String keyboardInfoJson) {
  41. throw UnimplementedError();
  42. }
  43. }
  44. void main() {
  45. final KeyboardAndroidPlatform initialPlatform =
  46. KeyboardAndroidPlatform.instance;
  47. test('$MethodChannelKeyboardAndroid is the default instance', () {
  48. expect(initialPlatform, isInstanceOf<MethodChannelKeyboardAndroid>());
  49. });
  50. test('getPlatformVersion', () async {
  51. KeyboardAndroid keyboardAndroidPlugin = KeyboardAndroid();
  52. MockKeyboardAndroidPlatform fakePlatform = MockKeyboardAndroidPlatform();
  53. KeyboardAndroidPlatform.instance = fakePlatform;
  54. expect(await keyboardAndroidPlugin.getPlatformVersion(), '42');
  55. });
  56. }