fix(player): 修正评论输入浮层初始键盘高度与聚焦
This commit is contained in:
1 parent
6c72f8bf22
commit
a66cdb2e1b
2 files changed
+219
-131
No files matched your search
@@ -2,7 +2,9 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/comment.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
@@ -33,6 +35,50 @@ const _drama = Drama(
|
||||
);
|
||||
|
||||
void main() {
|
||||
testWidgets('should_ignore_stale_keyboard_inset_when_composer_opens', (
|
||||
tester,
|
||||
) async {
|
||||
const keyboardChannel = MethodChannel('com.stormg.lumadrama/keyboard');
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
keyboardChannel,
|
||||
(call) async => call.method == 'get' ? 300 : null,
|
||||
);
|
||||
addTearDown(() {
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
||||
keyboardChannel,
|
||||
null,
|
||||
);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final repository = FakeCommentRepository(pages: [const CommentPage()]);
|
||||
|
||||
await _pumpSheet(tester, repository: repository);
|
||||
await tester.tap(find.byKey(const Key('comment-input-placeholder')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final composer = find.byKey(const Key('comment-composer-sheet'));
|
||||
final panel = find.byKey(const Key('comment-composer-panel'));
|
||||
final input = find.byKey(const Key('comment-composer-input'));
|
||||
expect(
|
||||
find.byKey(const Key('comment-composer-focus-scope')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.getSize(composer).height, inInclusiveRange(100, 150));
|
||||
expect(
|
||||
tester.getSize(panel).height,
|
||||
closeTo(tester.getSize(composer).height, 1),
|
||||
);
|
||||
expect(tester.getBottomLeft(panel).dy, closeTo(844, 0.1));
|
||||
expect(tester.widget<TextField>(input).focusNode?.hasFocus, isTrue);
|
||||
expect(tester.testTextInput.isVisible, isTrue);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
setUp(() {
|
||||
SharedPreferencesAsyncPlatform.instance =
|
||||
InMemorySharedPreferencesAsync.withData({
|
||||
|
||||
Reference in new issue
Block a user