22ab20077b
A browser reports no system insets, so inset-dependent layout (anchored menus) could not be captured on web. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.8 KiB
Dart
57 lines
1.8 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:pipelines_app/application/server_endpoint.dart';
|
|
import 'package:web/web.dart' as web;
|
|
|
|
import '../perf/backdrop_census.dart';
|
|
import '../perf/chat_scroll_probe.dart';
|
|
import '../perf/design_probe.dart';
|
|
import '../perf/frame_log.dart';
|
|
import 'inset_view.dart';
|
|
|
|
/// The fixture options: the page URL's query.
|
|
Map<String, String> fixtureParams() => Uri.base.queryParameters;
|
|
|
|
/// Installs the DevTools-facing probes the capture kit evaluates.
|
|
void installHostProbes(Map<String, String> params) {
|
|
installBackdropCensus();
|
|
installFrameLog(params);
|
|
installChatScrollProbe();
|
|
installDesignProbe(params);
|
|
}
|
|
|
|
/// Moves the browser to [route] before the app reads its location.
|
|
void openFixtureRoute(String route) {
|
|
web.window.history.replaceState(null, '', route);
|
|
}
|
|
|
|
/// The browser build's endpoint is its own page origin.
|
|
ServerEndpoint fixtureServer(Map<String, String> params) =>
|
|
ServerEndpoint.resolve(base: Uri.base, web: true);
|
|
|
|
/// The browser's location is the route; no provider is needed.
|
|
RouteInformationProvider? fixtureRouteProvider(String? route) => null;
|
|
|
|
/// Runs [app], under an Android phone's system insets (and a fold) when
|
|
/// `?inset=<top>,<bottom>` (and `&fold=1`) ask for them; see [InsetView].
|
|
void runFixtureApp(Widget app, Map<String, String> params) {
|
|
final inset = params['inset'];
|
|
if (inset == null && params['fold'] != '1') {
|
|
runApp(app);
|
|
return;
|
|
}
|
|
final parts = (inset ?? '').split(',');
|
|
final binding = WidgetsFlutterBinding.ensureInitialized();
|
|
final view = binding.platformDispatcher.implicitView!;
|
|
runWidget(
|
|
View(
|
|
view: InsetView(
|
|
view,
|
|
top: double.tryParse(parts.first) ?? 0,
|
|
bottom: parts.length > 1 ? double.tryParse(parts[1]) ?? 0 : 0,
|
|
fold: params['fold'] == '1',
|
|
),
|
|
child: app,
|
|
),
|
|
);
|
|
}
|