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 fixtureParams() => Uri.base.queryParameters; /// Installs the DevTools-facing probes the capture kit evaluates. void installHostProbes(Map 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 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=,` (and `&fold=1`) ask for them; see [InsetView]. void runFixtureApp(Widget app, Map 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, ), ); }