keyboard_android_test.dart 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. @override
  44. void refreshCharacterList() {
  45. throw UnimplementedError();
  46. }
  47. }
  48. void main() {
  49. final KeyboardAndroidPlatform initialPlatform =
  50. KeyboardAndroidPlatform.instance;
  51. test('$MethodChannelKeyboardAndroid is the default instance', () {
  52. expect(initialPlatform, isInstanceOf<MethodChannelKeyboardAndroid>());
  53. });
  54. test('getPlatformVersion', () async {
  55. KeyboardAndroid keyboardAndroidPlugin = KeyboardAndroid();
  56. MockKeyboardAndroidPlatform fakePlatform = MockKeyboardAndroidPlatform();
  57. KeyboardAndroidPlatform.instance = fakePlatform;
  58. expect(await keyboardAndroidPlugin.getPlatformVersion(), '42');
  59. });
  60. }