feat: add prev and next buttons to the address bar on pointer platforms
This commit is contained in:
parent
28ff7ca327
commit
ac9118a453
3 changed files with 90 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:io' show File;
|
||||
|
||||
import 'package:actors/actors.dart';
|
||||
import 'package:flutter/foundation.dart' show TargetPlatform, debugDefaultTargetPlatformOverride;
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
|
@ -383,6 +384,45 @@ void main() {
|
|||
expect(find.textContaining('Page A'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('prev and next buttons navigate on pointer platforms',
|
||||
(tester) async {
|
||||
final stubDeps = AppDependencies(
|
||||
database: MewsDatabase.test(NativeDatabase.memory()),
|
||||
fetch: _FakeFetch({
|
||||
'https://example.com/a.html':
|
||||
_page('Page A', '<h1>Page A</h1><p>The first pages content.</p>'),
|
||||
'https://example.com/b.html':
|
||||
_page('Page B', '<h1>Page B</h1><p>The second pages content.</p>'),
|
||||
}),
|
||||
strings: strings,
|
||||
);
|
||||
// Test bindings default to android; a Linux host shows the buttons.
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
|
||||
|
||||
await tester.pumpWidget(MewsApp(deps: stubDeps, strings: strings));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final back = find.byIcon(Icons.arrow_back);
|
||||
final forward = find.byIcon(Icons.arrow_forward);
|
||||
expect(back, findsOneWidget);
|
||||
expect(forward, findsOneWidget);
|
||||
|
||||
await stubDeps.browser.open('https://example.com/a.html');
|
||||
await stubDeps.browser.open('https://example.com/b.html');
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(back);
|
||||
await tester.pumpAndSettle();
|
||||
expect(stubDeps.browser.currentPage.value?.url, 'https://example.com/a.html');
|
||||
|
||||
await tester.tap(forward);
|
||||
await tester.pumpAndSettle();
|
||||
expect(stubDeps.browser.currentPage.value?.url, 'https://example.com/b.html');
|
||||
|
||||
// The invariant check runs before test tear-downs, so reset by hand.
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('reports new posts once per page', (tester) async {
|
||||
await pumpApp(tester);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue