keyboard_android_test.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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> enableFloatingWindow(bool enable) {
  13. throw UnimplementedError();
  14. }
  15. @override
  16. Future<bool> isTargetKeyboardEnabled() {
  17. throw UnimplementedError();
  18. }
  19. @override
  20. Future<void> openInputMethodSettings() {
  21. throw UnimplementedError();
  22. }
  23. @override
  24. Future<bool> hasFloatingWindowPermission() {
  25. throw UnimplementedError();
  26. }
  27. @override
  28. void jumpFloatingWindowSetting() {
  29. throw UnimplementedError();
  30. }
  31. }
  32. void main() {
  33. final KeyboardAndroidPlatform initialPlatform =
  34. KeyboardAndroidPlatform.instance;
  35. test('$MethodChannelKeyboardAndroid is the default instance', () {
  36. expect(initialPlatform, isInstanceOf<MethodChannelKeyboardAndroid>());
  37. });
  38. test('getPlatformVersion', () async {
  39. KeyboardAndroid keyboardAndroidPlugin = KeyboardAndroid();
  40. MockKeyboardAndroidPlatform fakePlatform = MockKeyboardAndroidPlatform();
  41. KeyboardAndroidPlatform.instance = fakePlatform;
  42. expect(await keyboardAndroidPlugin.getPlatformVersion(), '42');
  43. });
  44. }