Restore requested navigation and mobile chat controls
This commit is contained in:
@@ -38,7 +38,7 @@ void _useNarrowText(WidgetTester tester) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('short large-text header scrolls controls without overflow', (
|
||||
testWidgets('short large-text header keeps controls in its single row', (
|
||||
tester,
|
||||
) async {
|
||||
_useNarrowText(tester);
|
||||
@@ -55,15 +55,9 @@ void main() {
|
||||
onInfo: () {},
|
||||
showBack: true,
|
||||
onBack: () {},
|
||||
controls: [
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text('Current model'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
child: const Text('Ask for permission'),
|
||||
),
|
||||
controls: const [
|
||||
IconButton(onPressed: null, icon: Icon(Icons.memory_outlined)),
|
||||
IconButton(onPressed: null, icon: Icon(Icons.shield_outlined)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -73,9 +67,10 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.ensureVisible(find.text('Ask for permission'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Ask for permission').hitTestable(), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(const Key('chat-model-permission-island')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
@@ -83,7 +78,7 @@ void main() {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets(
|
||||
'$host narrow header keeps native back/title and readable model',
|
||||
'$host narrow header keeps native back/title and compact model icon',
|
||||
(tester) async {
|
||||
_useNarrowText(tester);
|
||||
final semantics = tester.ensureSemantics();
|
||||
@@ -124,19 +119,22 @@ void main() {
|
||||
|
||||
// One floating row of separate pieces: the round Back, the title pill
|
||||
// (which is the information control and holds the title), then the
|
||||
// model in the trailing pill.
|
||||
// selector island in the trailing row.
|
||||
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
||||
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
||||
expect(
|
||||
tester.getTopLeft(model).dy,
|
||||
greaterThanOrEqualTo(tester.getBottomLeft(info).dy),
|
||||
);
|
||||
expect((centerY(model) - centerY(info)).abs(), lessThan(16));
|
||||
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
||||
double right(Finder finder) => tester.getTopRight(finder).dx;
|
||||
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
||||
if (!cupertino) {
|
||||
final semantics = tester.getSemantics(model);
|
||||
expect(semantics.label, contains('Change model'));
|
||||
expect(semantics.label, contains('currently'));
|
||||
}
|
||||
expect(
|
||||
find.textContaining('an-extremely-long-recorded-model-id'),
|
||||
findsOneWidget,
|
||||
findsNothing,
|
||||
);
|
||||
|
||||
await tester.tap(back);
|
||||
@@ -199,21 +197,43 @@ void main() {
|
||||
final actions = find.byKey(const Key('chat-actions-island'));
|
||||
expect(selectors, findsOneWidget);
|
||||
expect(actions, findsOneWidget);
|
||||
if (width / 2 >= 800) {
|
||||
expect(
|
||||
tester.getTopRight(selectors).dx,
|
||||
lessThan(tester.getTopLeft(actions).dx),
|
||||
);
|
||||
} else {
|
||||
expect(
|
||||
tester.getTopLeft(selectors).dy,
|
||||
greaterThanOrEqualTo(tester.getBottomLeft(actions).dy),
|
||||
);
|
||||
}
|
||||
expect(
|
||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy)
|
||||
.abs(),
|
||||
lessThan(16),
|
||||
);
|
||||
expect(find.byKey(const Key('chat-next')), findsNothing);
|
||||
expect(find.text('Next chat'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-model')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-mode')), findsOneWidget);
|
||||
if (width < 600) {
|
||||
expect(find.text('model-a'), findsNothing);
|
||||
expect(find.text('Ask before making changes'), findsNothing);
|
||||
expect(find.byIcon(Icons.memory_outlined), findsOneWidget);
|
||||
expect(
|
||||
find.byIcon(
|
||||
cupertino
|
||||
? CupertinoIcons.shield_lefthalf_fill
|
||||
: Icons.shield_outlined,
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
if (!cupertino) {
|
||||
expect(
|
||||
tester.getSemantics(find.byKey(const Key('chat-model'))).label,
|
||||
contains('Change model, currently'),
|
||||
);
|
||||
expect(
|
||||
tester.getSemantics(find.byKey(const Key('chat-mode'))).label,
|
||||
contains('Change mode, currently'),
|
||||
);
|
||||
}
|
||||
expect(
|
||||
(tester.getCenter(selectors).dy - tester.getCenter(actions).dy)
|
||||
.abs(),
|
||||
lessThan(16),
|
||||
);
|
||||
}
|
||||
for (final key in ['chat-model', 'chat-mode']) {
|
||||
expect(
|
||||
tester.getSize(find.byKey(Key(key))).width,
|
||||
|
||||
Reference in New Issue
Block a user