keyboard_android_test.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. }
  24. void main() {
  25. final KeyboardAndroidPlatform initialPlatform =
  26. KeyboardAndroidPlatform.instance;
  27. test('$MethodChannelKeyboardAndroid is the default instance', () {
  28. expect(initialPlatform, isInstanceOf<MethodChannelKeyboardAndroid>());
  29. });
  30. test('getPlatformVersion', () async {
  31. KeyboardAndroid keyboardAndroidPlugin = KeyboardAndroid();
  32. MockKeyboardAndroidPlatform fakePlatform = MockKeyboardAndroidPlatform();
  33. KeyboardAndroidPlatform.instance = fakePlatform;
  34. expect(await keyboardAndroidPlugin.getPlatformVersion(), '42');
  35. });
  36. }