Remove single-window assumption from scenario_app (flutter/engine#40156)

Remove single-window assumption from scenario_app
This commit is contained in:
Michael Goderbauer
2023-03-08 16:37:47 -08:00
committed by GitHub
parent 62d537ca5f
commit 9e54a5ded0
16 changed files with 236 additions and 276 deletions

View File

@@ -2,6 +2,8 @@
// Generated file. Do not edit.
//
// clang-format off
#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h

View File

@@ -2,6 +2,8 @@
// Generated file. Do not edit.
//
// clang-format off
#import "GeneratedPluginRegistrant.h"
@implementation GeneratedPluginRegistrant

View File

@@ -12,7 +12,11 @@ import 'dart:ui';
import 'src/scenarios.dart';
void main() {
window
// TODO(goderbauer): Create a window if embedder doesn't provide an implicit
// view to draw into once we have a windowing API and set the window's
// FlutterView to the _view property.
assert(PlatformDispatcher.instance.implicitView != null);
PlatformDispatcher.instance
..onPlatformMessage = _handlePlatformMessage
..onBeginFrame = _onBeginFrame
..onDrawFrame = _onDrawFrame
@@ -22,15 +26,18 @@ void main() {
final ByteData data = ByteData(1);
data.setUint8(0, 1);
window.sendPlatformMessage('waiting_for_status', data, null);
PlatformDispatcher.instance.sendPlatformMessage('waiting_for_status', data, null);
}
/// The FlutterView into which the [Scenario]s will be rendered.
FlutterView get _view => PlatformDispatcher.instance.implicitView!;
void _handleDriverMessage(Map<String, dynamic> call) {
final String? methodName = call['method'] as String?;
switch (methodName) {
case 'set_scenario':
assert(call['args'] != null);
loadScenario(call['args'] as Map<String, dynamic>);
loadScenario(call['args'] as Map<String, dynamic>, _view);
break;
default:
throw 'Unimplemented method: $methodName.';
@@ -86,7 +93,7 @@ void _onBeginFrame(Duration duration) {
if (currentScenario == null) {
final SceneBuilder builder = SceneBuilder();
final Scene scene = builder.build();
window.render(scene);
_view.render(scene);
scene.dispose();
return;
}

View File

@@ -14,21 +14,18 @@ import 'scenario.dart';
/// that are constantly changing.
class AnimatedColorSquareScenario extends Scenario {
/// Creates the AnimatedColorSquare scenario.
///
/// The [dispatcher] parameter must not be null.
AnimatedColorSquareScenario(PlatformDispatcher dispatcher)
: super(dispatcher);
AnimatedColorSquareScenario(super.view);
static const double _squareSize = 200;
/// Used to animate the red value in the color of the square.
final _NumberSwinger<int> _r = _NumberSwinger<int>(0, 255);
_NumberSwinger<double> _top = _NumberSwinger<double>(
late _NumberSwinger<double> _top = _NumberSwinger<double>(
0,
window.physicalSize.height - _squareSize,
view.physicalSize.height - _squareSize,
);
_NumberSwinger<double> _left = _NumberSwinger<double>(
late _NumberSwinger<double> _left = _NumberSwinger<double>(
0,
window.physicalSize.width - _squareSize,
view.physicalSize.width - _squareSize,
);
@override
@@ -50,26 +47,26 @@ class AnimatedColorSquareScenario extends Scenario {
willChangeHint: true,
);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
@override
void onDrawFrame() {
window.scheduleFrame();
view.platformDispatcher.scheduleFrame();
}
@override
void onMetricsChanged() {
_top = _NumberSwinger<double>(
0,
window.physicalSize.height - _squareSize,
math.min(_top.current, window.physicalSize.height - _squareSize),
view.physicalSize.height - _squareSize,
math.min(_top.current, view.physicalSize.height - _squareSize),
);
_left = _NumberSwinger<double>(
0,
window.physicalSize.width - _squareSize,
math.min(_left.current, window.physicalSize.width - _squareSize),
view.physicalSize.width - _squareSize,
math.min(_left.current, view.physicalSize.width - _squareSize),
);
}
}

View File

@@ -11,10 +11,7 @@ import 'scenario.dart';
/// system default font.
class BogusFontText extends Scenario {
/// Creates the BogusFontText scenario.
///
/// The [dispatcher] parameter must not be null.
BogusFontText(PlatformDispatcher dispatcher)
: super(dispatcher);
BogusFontText(super.view);
// Semi-arbitrary.
final double _screenWidth = 700;
@@ -43,11 +40,11 @@ class BogusFontText extends Scenario {
willChangeHint: true,
);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
sendJsonMessage(
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
channel: 'display_data',
json: <String, dynamic>{
'data': 'ready',

View File

@@ -9,26 +9,23 @@ import 'scenario.dart';
/// A scenario with red on top and blue on the bottom.
class GetBitmapScenario extends Scenario {
/// Creates the GetBitmap scenario.
///
/// The [dispatcher] parameter must not be null.
GetBitmapScenario(PlatformDispatcher dispatcher)
: super(dispatcher);
GetBitmapScenario(super.view);
@override
void onBeginFrame(Duration duration) {
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
canvas.drawRect(Rect.fromLTWH(0, 0, window.physicalSize.width, 300),
canvas.drawRect(Rect.fromLTWH(0, 0, view.physicalSize.width, 300),
Paint()..color = const Color(0xFFFF0000));
canvas.drawRect(
Rect.fromLTWH(0, window.physicalSize.height - 300,
window.physicalSize.width, 300),
Rect.fromLTWH(0, view.physicalSize.height - 300,
view.physicalSize.width, 300),
Paint()..color = const Color(0xFF0000FF));
final Picture picture = recorder.endRecording();
final SceneBuilder builder = SceneBuilder();
builder.addPicture(Offset.zero, picture);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
picture.dispose();
scene.dispose();
}

View File

@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:ui';
import 'channel_util.dart';
import 'scenario.dart';
@@ -11,17 +9,14 @@ import 'scenario.dart';
/// route is.
class InitialRouteReply extends Scenario {
/// Creates the InitialRouteReply.
///
/// The [window] parameter must not be null.
InitialRouteReply(PlatformDispatcher dispatcher)
: super(dispatcher);
InitialRouteReply(super.view);
@override
void onBeginFrame(Duration duration) {
sendJsonMethodCall(
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
channel: 'initial_route_test_channel',
method: window.defaultRouteName,
method: view.platformDispatcher.defaultRouteName,
);
}
}

View File

@@ -12,8 +12,7 @@ import 'scenario.dart';
/// Sends the received locale data back as semantics information.
class LocaleInitialization extends Scenario {
/// Constructor
LocaleInitialization(PlatformDispatcher dispatcher)
: super(dispatcher);
LocaleInitialization(super.view);
int _tapCount = 0;
@@ -26,7 +25,7 @@ class LocaleInitialization extends Scenario {
final Canvas canvas = Canvas(recorder);
canvas.drawRect(
Rect.fromLTWH(0, 0, window.physicalSize.width, window.physicalSize.height),
Rect.fromLTWH(0, 0, view.physicalSize.width, view.physicalSize.height),
Paint()..color = const Color.fromARGB(255, 255, 255, 255),
);
final Picture picture = recorder.endRecording();
@@ -36,7 +35,7 @@ class LocaleInitialization extends Scenario {
picture,
);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
// On the first frame, pretend that it drew a text field. Send the
@@ -50,7 +49,7 @@ class LocaleInitialization extends Scenario {
// SemanticsAction.tap.
actions: 1,
rect: const Rect.fromLTRB(0.0, 0.0, 414.0, 48.0),
label: window.locales.toString(),
label: view.platformDispatcher.locales.toString(),
labelAttributes: <StringAttribute>[],
textDirection: TextDirection.ltr,
textSelectionBase: -1,
@@ -82,7 +81,7 @@ class LocaleInitialization extends Scenario {
final SemanticsUpdate semanticsUpdate = semanticsUpdateBuilder.build();
dispatcher.views.first.updateSemantics(semanticsUpdate);
view.updateSemantics(semanticsUpdate);
}
/// Handle taps.
@@ -140,7 +139,7 @@ class LocaleInitialization extends Scenario {
final SemanticsUpdate semanticsUpdate = semanticsUpdateBuilder.build();
dispatcher.views.first.updateSemantics(semanticsUpdate);
view.updateSemantics(semanticsUpdate);
_tapCount++;
}

View File

@@ -16,6 +16,6 @@ mixin PlatformEchoMixin on Scenario {
ByteData? data,
PlatformMessageResponseCallback? callback,
) {
window.sendPlatformMessage(name, data, null);
view.platformDispatcher.sendPlatformMessage(name, data, null);
}
}

View File

@@ -39,12 +39,10 @@ List<int> _encodeString(String value) {
class PlatformViewScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -54,7 +52,7 @@ class PlatformViewScenario extends Scenario
final SceneBuilder builder = SceneBuilder();
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
finishBuilder(builder);
@@ -65,12 +63,10 @@ class PlatformViewScenario extends Scenario
class NonFullScreenFlutterViewPlatformViewScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
NonFullScreenFlutterViewPlatformViewScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -80,7 +76,7 @@ class NonFullScreenFlutterViewPlatformViewScenario extends Scenario
final SceneBuilder builder = SceneBuilder();
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
finishBuilder(builder);
@@ -91,12 +87,10 @@ class NonFullScreenFlutterViewPlatformViewScenario extends Scenario
class PlatformViewNoOverlayIntersectionScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewNoOverlayIntersectionScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -107,7 +101,7 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -125,12 +119,10 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario
class PlatformViewLargerThanDisplaySize extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewLargerThanDisplaySize(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -141,7 +133,7 @@ class PlatformViewLargerThanDisplaySize extends Scenario
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
width: 15000,
height: 60000,
@@ -157,12 +149,10 @@ class PlatformViewLargerThanDisplaySize extends Scenario
class PlatformViewPartialIntersectionScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewPartialIntersectionScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier .
final int id;
@@ -173,7 +163,7 @@ class PlatformViewPartialIntersectionScenario extends Scenario
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -188,12 +178,10 @@ class PlatformViewPartialIntersectionScenario extends Scenario
class PlatformViewTwoIntersectingOverlaysScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewTwoIntersectingOverlaysScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -204,7 +192,7 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
final PictureRecorder recorder = PictureRecorder();
@@ -222,7 +210,7 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario
final Picture picture = recorder.endRecording();
builder.addPicture(const Offset(300, 300), picture);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}
@@ -231,12 +219,10 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario
class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -247,7 +233,7 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -271,7 +257,7 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario
final Picture picture = recorder.endRecording();
builder.addPicture(const Offset(300, 300), picture);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}
@@ -280,13 +266,11 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario
class MultiPlatformViewWithoutOverlaysScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
MultiPlatformViewWithoutOverlaysScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.firstId,
required this.secondId,
}) : super(dispatcher);
});
/// The platform view identifier to use for the first platform view.
final int firstId;
@@ -302,7 +286,7 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario
addPlatformView(
firstId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 1',
);
@@ -311,7 +295,7 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario
addPlatformView(
secondId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 2',
);
@@ -327,7 +311,7 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario
builder.pop();
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}
@@ -336,12 +320,10 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario
class PlatformViewMaxOverlaysScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewMaxOverlaysScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -352,7 +334,7 @@ class PlatformViewMaxOverlaysScenario extends Scenario
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
final PictureRecorder recorder = PictureRecorder();
@@ -380,7 +362,7 @@ class PlatformViewMaxOverlaysScenario extends Scenario
final Picture picture = recorder.endRecording();
builder.addPicture(const Offset(300, 300), picture);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}
@@ -389,13 +371,11 @@ class PlatformViewMaxOverlaysScenario extends Scenario
class MultiPlatformViewScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
MultiPlatformViewScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.firstId,
required this.secondId,
}) : super(dispatcher);
});
/// The platform view identifier to use for the first platform view.
final int firstId;
@@ -411,7 +391,7 @@ class MultiPlatformViewScenario extends Scenario
addPlatformView(
firstId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 1',
);
@@ -420,7 +400,7 @@ class MultiPlatformViewScenario extends Scenario
addPlatformView(
secondId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 2',
);
@@ -437,13 +417,11 @@ class MultiPlatformViewScenario extends Scenario
class MultiPlatformViewBackgroundForegroundScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
MultiPlatformViewBackgroundForegroundScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.firstId,
required this.secondId,
}) : super(dispatcher) {
}) {
_nextFrame = _firstFrame;
}
@@ -467,7 +445,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
addPlatformView(
firstId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 1',
);
@@ -478,7 +456,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
addPlatformView(
secondId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 2',
);
@@ -495,7 +473,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
builder.addPicture(Offset.zero, picture);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
@@ -506,7 +484,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
addPlatformView(
firstId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 1',
);
@@ -515,13 +493,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
addPlatformView(
secondId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 2',
);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
@@ -540,7 +518,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
if (_lastLifecycleState == 'AppLifecycleState.inactive' &&
message == 'AppLifecycleState.resumed') {
_nextFrame = _secondFrame;
window.scheduleFrame();
view.platformDispatcher.scheduleFrame();
}
_lastLifecycleState = message;
@@ -551,9 +529,9 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin {
/// Constructs a platform view with clip rect scenario.
PlatformViewClipRectScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -565,7 +543,7 @@ class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenar
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -579,9 +557,9 @@ class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenar
class PlatformViewClipRectAfterMovedScenario extends Scenario with _BasePlatformViewScenarioMixin {
/// Constructs a platform view with clip rect scenario.
PlatformViewClipRectAfterMovedScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.id,
}) : super(dispatcher);
});
/// The platform view identifier.
final int id;
@@ -599,7 +577,7 @@ class PlatformViewClipRectAfterMovedScenario extends Scenario with _BasePlatform
addPlatformView(
_numberOfFrames == 10? 10000:id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -622,7 +600,7 @@ class PlatformViewClipRectAfterMovedScenario extends Scenario with _BasePlatform
if (_numberOfFrames < 10) {
_numberOfFrames ++;
_y -= 10;
window.scheduleFrame();
view.platformDispatcher.scheduleFrame();
}
super.onDrawFrame();
}
@@ -632,9 +610,9 @@ class PlatformViewClipRectAfterMovedScenario extends Scenario with _BasePlatform
class PlatformViewClipRRectScenario extends PlatformViewScenario {
/// Constructs a platform view with clip rrect scenario.
PlatformViewClipRRectScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -653,7 +631,7 @@ class PlatformViewClipRRectScenario extends PlatformViewScenario {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -667,9 +645,9 @@ class PlatformViewClipRRectScenario extends PlatformViewScenario {
class PlatformViewLargeClipRRectScenario extends PlatformViewScenario {
/// Constructs a platform view with large clip rrect scenario.
PlatformViewLargeClipRRectScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -688,7 +666,7 @@ class PlatformViewLargeClipRRectScenario extends PlatformViewScenario {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -700,9 +678,9 @@ class PlatformViewLargeClipRRectScenario extends PlatformViewScenario {
class PlatformViewClipPathScenario extends PlatformViewScenario {
/// Constructs a platform view with clip path scenario.
PlatformViewClipPathScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -716,7 +694,7 @@ class PlatformViewClipPathScenario extends PlatformViewScenario {
final SceneBuilder builder = SceneBuilder()..pushClipPath(path);
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
finishBuilder(builder);
@@ -727,9 +705,9 @@ class PlatformViewClipPathScenario extends PlatformViewScenario {
class PlatformViewClipRectWithTransformScenario extends PlatformViewScenario {
/// Constructs a platform view with clip rect with transform scenario.
PlatformViewClipRectWithTransformScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -743,7 +721,7 @@ class PlatformViewClipRectWithTransformScenario extends PlatformViewScenario {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -765,9 +743,9 @@ class PlatformViewClipRectWithTransformScenario extends PlatformViewScenario {
class PlatformViewClipRRectWithTransformScenario extends PlatformViewScenario {
/// Constructs a platform view with clip rrect with transform scenario.
PlatformViewClipRRectWithTransformScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -790,7 +768,7 @@ class PlatformViewClipRRectWithTransformScenario extends PlatformViewScenario {
);
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -813,9 +791,9 @@ class PlatformViewClipRRectWithTransformScenario extends PlatformViewScenario {
class PlatformViewLargeClipRRectWithTransformScenario extends PlatformViewScenario {
/// Constructs a platform view with large clip rrect with transform scenario.
PlatformViewLargeClipRRectWithTransformScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -838,7 +816,7 @@ class PlatformViewLargeClipRRectWithTransformScenario extends PlatformViewScenar
);
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -860,9 +838,9 @@ class PlatformViewLargeClipRRectWithTransformScenario extends PlatformViewScenar
class PlatformViewClipPathWithTransformScenario extends PlatformViewScenario {
/// Constructs a platform view with clip path with transform scenario.
PlatformViewClipPathWithTransformScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -882,7 +860,7 @@ class PlatformViewClipPathWithTransformScenario extends PlatformViewScenario {
builder.pushClipPath(path);
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -904,9 +882,9 @@ class PlatformViewClipPathWithTransformScenario extends PlatformViewScenario {
class PlatformViewTransformScenario extends PlatformViewScenario {
/// Constructs a platform view with transform scenario.
PlatformViewTransformScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -918,7 +896,7 @@ class PlatformViewTransformScenario extends PlatformViewScenario {
final SceneBuilder builder = SceneBuilder()..pushTransform(matrix4.storage);
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
finishBuilder(builder);
@@ -929,16 +907,16 @@ class PlatformViewTransformScenario extends PlatformViewScenario {
class PlatformViewOpacityScenario extends PlatformViewScenario {
/// Constructs a platform view with transform scenario.
PlatformViewOpacityScenario(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder()..pushOpacity(150);
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
finishBuilder(builder);
@@ -949,14 +927,12 @@ class PlatformViewOpacityScenario extends PlatformViewScenario {
class PlatformViewForTouchIOSScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewForTouchIOSScenario(
PlatformDispatcher dispatcher, {
super.view, {
this.id = 0,
this.rejectUntilTouchesEnded = false,
required this.accept,
}) : super(dispatcher) {
}) {
_nextFrame = _firstFrame;
}
@@ -983,7 +959,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
// See https://github.com/flutter/flutter/issues/66044
if (_nextFrame == _firstFrame) {
_nextFrame = _secondFrame;
window.scheduleFrame();
view.platformDispatcher.scheduleFrame();
}
super.onDrawFrame();
}
@@ -1008,7 +984,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
valueInt32,
..._to32(id),
]);
window.sendPlatformMessage(
view.platformDispatcher.sendPlatformMessage(
'flutter/platform_views',
message.buffer.asByteData(),
(ByteData? response) {},
@@ -1022,14 +998,14 @@ class PlatformViewForTouchIOSScenario extends Scenario
if (rejectUntilTouchesEnded) {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
viewType: 'scenarios/textPlatformView_blockPolicyUntilTouchesEnded',
);
} else {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
}
@@ -1041,14 +1017,14 @@ class PlatformViewForTouchIOSScenario extends Scenario
if (rejectUntilTouchesEnded) {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
viewType: 'scenarios/textPlatformView_blockPolicyUntilTouchesEnded',
);
} else {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
}
@@ -1067,13 +1043,11 @@ class PlatformViewForOverlappingPlatformViewsScenario extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformViewForOverlappingPlatformViewsScenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewForOverlappingPlatformViewsScenario(
PlatformDispatcher dispatcher, {
super.view, {
required this.foregroundId,
required this.backgroundId,
}) : super(dispatcher) {
}) {
_nextFrame = _firstFrame;
}
@@ -1099,14 +1073,14 @@ class PlatformViewForOverlappingPlatformViewsScenario extends Scenario
foregroundId,
width: 100,
height: 100,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'Foreground',
);
builder.pop();
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
@@ -1118,7 +1092,7 @@ class PlatformViewForOverlappingPlatformViewsScenario extends Scenario
backgroundId,
width: 300,
height: 300,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'Background',
);
@@ -1129,14 +1103,14 @@ class PlatformViewForOverlappingPlatformViewsScenario extends Scenario
foregroundId,
width: 100,
height: 100,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'Foreground',
);
builder.pop();
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
@@ -1151,7 +1125,7 @@ class PlatformViewForOverlappingPlatformViewsScenario extends Scenario
if (_nextFrame == _firstFrame && _frameCount == 60) {
_nextFrame = _secondFrame;
}
window.scheduleFrame();
view.platformDispatcher.scheduleFrame();
super.onDrawFrame();
}
@@ -1174,7 +1148,7 @@ class PlatformViewForOverlappingPlatformViewsScenario extends Scenario
valueInt32,
..._to32(foregroundId),
]);
window.sendPlatformMessage(
view.platformDispatcher.sendPlatformMessage(
'flutter/platform_views',
message.buffer.asByteData(),
(ByteData? response) {},
@@ -1188,9 +1162,9 @@ class PlatformViewForOverlappingPlatformViewsScenario extends Scenario
class PlatformViewWithContinuousTexture extends PlatformViewScenario {
/// Constructs a platform view with continuous texture layer.
PlatformViewWithContinuousTexture(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -1201,7 +1175,7 @@ class PlatformViewWithContinuousTexture extends PlatformViewScenario {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -1218,9 +1192,9 @@ class PlatformViewWithContinuousTexture extends PlatformViewScenario {
class PlatformViewWithOtherBackDropFilter extends PlatformViewScenario {
/// Constructs the scenario.
PlatformViewWithOtherBackDropFilter(
PlatformDispatcher dispatcher, {
int id = 0,
}) : super(dispatcher, id: id);
super.view, {
super.id = 0,
});
@override
void onBeginFrame(Duration duration) {
@@ -1261,7 +1235,7 @@ class PlatformViewWithOtherBackDropFilter extends PlatformViewScenario {
addPlatformView(
id,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
);
@@ -1280,7 +1254,7 @@ class PlatformViewWithOtherBackDropFilter extends PlatformViewScenario {
builder.addPicture(const Offset(100, 100), picture3);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}
@@ -1294,12 +1268,11 @@ class TwoPlatformViewsWithOtherBackDropFilter extends Scenario
with _BasePlatformViewScenarioMixin {
/// Constructs the scenario.
TwoPlatformViewsWithOtherBackDropFilter(
PlatformDispatcher dispatcher, {
super.view, {
required int firstId,
required int secondId,
}) : _firstId = firstId,
_secondId = secondId,
super(dispatcher);
_secondId = secondId;
final int _firstId;
final int _secondId;
@@ -1327,7 +1300,7 @@ class TwoPlatformViewsWithOtherBackDropFilter extends Scenario
addPlatformView(
_firstId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
width: 100,
height: 100,
@@ -1352,7 +1325,7 @@ class TwoPlatformViewsWithOtherBackDropFilter extends Scenario
addPlatformView(
_secondId,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view 2',
);
@@ -1374,7 +1347,7 @@ class TwoPlatformViewsWithOtherBackDropFilter extends Scenario
builder.addPicture(const Offset(100, 100), picture3);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}
@@ -1383,15 +1356,12 @@ class TwoPlatformViewsWithOtherBackDropFilter extends Scenario
class PlatformViewScrollingUnderWidget extends Scenario
with _BasePlatformViewScenarioMixin {
/// Creates the PlatformView scenario.
///
/// The [dispatcher] parameter must not be null.
PlatformViewScrollingUnderWidget(
PlatformDispatcher dispatcher, {
super.view, {
required int firstPlatformViewId,
required int lastPlatformViewId,
}) : _firstPlatformViewId = firstPlatformViewId,
_lastPlatformViewId = lastPlatformViewId,
super(dispatcher);
_lastPlatformViewId = lastPlatformViewId;
final int _firstPlatformViewId;
@@ -1420,7 +1390,7 @@ class PlatformViewScrollingUnderWidget extends Scenario
} else {
_offset += 100;
}
window.scheduleFrame();
view.platformDispatcher.scheduleFrame();
super.onDrawFrame();
}
@@ -1434,7 +1404,7 @@ class PlatformViewScrollingUnderWidget extends Scenario
builder.pushOffset(0, localOffset);
addPlatformView(
i,
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
sceneBuilder: builder,
text: 'platform view $i',
width: cellWidth,
@@ -1455,7 +1425,7 @@ class PlatformViewScrollingUnderWidget extends Scenario
builder.addPicture(const Offset(0, 20), picture);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}
@@ -1634,7 +1604,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
final Picture picture = recorder.endRecording();
sceneBuilder.addPicture(const Offset(300, 300), picture);
final Scene scene = sceneBuilder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
}

View File

@@ -12,10 +12,7 @@ import 'scenario.dart';
/// A blank page with a button that pops the page when tapped.
class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
/// Creates the PoppableScreenScenario.
///
/// The [dispatcher] parameter must not be null.
PoppableScreenScenario(PlatformDispatcher dispatcher)
: super(dispatcher);
PoppableScreenScenario(super.view);
// Rect for the pop button. Only defined once onMetricsChanged is called.
Rect? _buttonRect;
@@ -39,7 +36,7 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
builder.pushOffset(0, 0);
builder.addPicture(Offset.zero, picture);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
}
@@ -51,12 +48,12 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
@override
void onMetricsChanged() {
_buttonRect = Rect.fromLTRB(
window.physicalSize.width / 4,
window.physicalSize.height * 2 / 5,
window.physicalSize.width * 3 / 4,
window.physicalSize.height * 3 / 5,
view.physicalSize.width / 4,
view.physicalSize.height * 2 / 5,
view.physicalSize.width * 3 / 4,
view.physicalSize.height * 3 / 5,
);
window.scheduleFrame();
view.platformDispatcher.scheduleFrame();
}
@override
@@ -72,7 +69,7 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
void _pop() {
sendJsonMethodCall(
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
// 'flutter/platform' is the hardcoded name of the 'platform'
// `SystemChannel` from the `SystemNavigator` API.
// https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/services/system_navigator.dart.

View File

@@ -8,10 +8,10 @@ import 'dart:ui';
/// A scenario to run for testing.
abstract class Scenario {
/// Creates a new scenario using a specific FlutterView instance.
Scenario(this.dispatcher);
Scenario(this.view);
/// The window used by this scenario. May be mocked.
final PlatformDispatcher dispatcher;
/// The FlutterView used by this scenario. May be mocked.
final FlutterView view;
/// [true] if a screenshot is taken in the next frame.
bool _didScheduleScreenshot = false;
@@ -27,12 +27,12 @@ abstract class Scenario {
/// See [PlatformDispatcher.onDrawFrame] for more details.
void onDrawFrame() {
if (_didScheduleScreenshot) {
dispatcher.sendPlatformMessage('take_screenshot', null, null);
view.platformDispatcher.sendPlatformMessage('take_screenshot', null, null);
return;
}
Future<void>.delayed(const Duration(seconds: 2), () {
_didScheduleScreenshot = true;
dispatcher.scheduleFrame();
view.platformDispatcher.scheduleFrame();
});
}

View File

@@ -15,52 +15,52 @@ import 'scenario.dart';
import 'texture.dart';
import 'touches_scenario.dart';
typedef ScenarioFactory = Scenario Function(); // ignore: public_member_api_docs
typedef _ScenarioFactory = Scenario Function(FlutterView view);
int _viewId = 0;
Map<String, ScenarioFactory> _scenarios = <String, ScenarioFactory>{
'animated_color_square': () => AnimatedColorSquareScenario(PlatformDispatcher.instance),
'locale_initialization': () => LocaleInitialization(PlatformDispatcher.instance),
'platform_view': () => PlatformViewScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_no_overlay_intersection': () => PlatformViewNoOverlayIntersectionScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_larger_than_display_size': () => PlatformViewLargerThanDisplaySize(PlatformDispatcher.instance, id: _viewId++),
'platform_view_partial_intersection': () => PlatformViewPartialIntersectionScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_two_intersecting_overlays': () => PlatformViewTwoIntersectingOverlaysScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_one_overlay_two_intersecting_overlays': () => PlatformViewOneOverlayTwoIntersectingOverlaysScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_multiple_without_overlays': () => MultiPlatformViewWithoutOverlaysScenario(PlatformDispatcher.instance, firstId: _viewId++, secondId: _viewId++),
'platform_view_max_overlays': () => PlatformViewMaxOverlaysScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_cliprect': () => PlatformViewClipRectScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_cliprect_with_transform': () => PlatformViewClipRectWithTransformScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_cliprect_after_moved': () => PlatformViewClipRectAfterMovedScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_cliprrect': () => PlatformViewClipRRectScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_large_cliprrect': () => PlatformViewLargeClipRRectScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_cliprrect_with_transform': () => PlatformViewClipRRectWithTransformScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_large_cliprrect_with_transform': () => PlatformViewLargeClipRRectWithTransformScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_clippath': () => PlatformViewClipPathScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_clippath_with_transform': () => PlatformViewClipPathWithTransformScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_transform': () => PlatformViewTransformScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_opacity': () => PlatformViewOpacityScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_with_other_backdrop_filter': () => PlatformViewWithOtherBackDropFilter(PlatformDispatcher.instance, id: _viewId++),
'two_platform_views_with_other_backdrop_filter': () => TwoPlatformViewsWithOtherBackDropFilter(PlatformDispatcher.instance, firstId: _viewId++, secondId: _viewId++),
'platform_view_multiple': () => MultiPlatformViewScenario(PlatformDispatcher.instance, firstId: _viewId++, secondId: _viewId++),
'platform_view_multiple_background_foreground': () => MultiPlatformViewBackgroundForegroundScenario(PlatformDispatcher.instance, firstId: _viewId++, secondId: _viewId++),
'non_full_screen_flutter_view_platform_view': () => NonFullScreenFlutterViewPlatformViewScenario(PlatformDispatcher.instance, id: _viewId++),
'poppable_screen': () => PoppableScreenScenario(PlatformDispatcher.instance),
'platform_view_rotate': () => PlatformViewScenario(PlatformDispatcher.instance, id: _viewId++),
'platform_view_gesture_reject_eager': () => PlatformViewForTouchIOSScenario(PlatformDispatcher.instance, id: _viewId++, accept: false),
'platform_view_gesture_accept': () => PlatformViewForTouchIOSScenario(PlatformDispatcher.instance, id: _viewId++, accept: true),
'platform_view_gesture_reject_after_touches_ended': () => PlatformViewForTouchIOSScenario(PlatformDispatcher.instance, id: _viewId++, accept: false, rejectUntilTouchesEnded: true),
'platform_view_gesture_accept_with_overlapping_platform_views': () => PlatformViewForOverlappingPlatformViewsScenario(PlatformDispatcher.instance, foregroundId: _viewId++, backgroundId: _viewId++),
'platform_view_scrolling_under_widget':()=>PlatformViewScrollingUnderWidget(PlatformDispatcher.instance, firstPlatformViewId: _viewId++, lastPlatformViewId: _viewId+=16),
'tap_status_bar': () => TouchesScenario(PlatformDispatcher.instance),
'initial_route_reply': () => InitialRouteReply(PlatformDispatcher.instance),
'platform_view_with_continuous_texture': () => PlatformViewWithContinuousTexture(PlatformDispatcher.instance, id: _viewId++),
'bogus_font_text': () => BogusFontText(PlatformDispatcher.instance),
'spawn_engine_works' : () => BogusFontText(PlatformDispatcher.instance),
'pointer_events': () => TouchesScenario(PlatformDispatcher.instance),
'display_texture': () => DisplayTexture(PlatformDispatcher.instance),
'get_bitmap': () => GetBitmapScenario(PlatformDispatcher.instance),
Map<String, _ScenarioFactory> _scenarios = <String, _ScenarioFactory>{
'animated_color_square': (FlutterView view) => AnimatedColorSquareScenario(view),
'locale_initialization': (FlutterView view) => LocaleInitialization(view),
'platform_view': (FlutterView view) => PlatformViewScenario(view, id: _viewId++),
'platform_view_no_overlay_intersection': (FlutterView view) => PlatformViewNoOverlayIntersectionScenario(view, id: _viewId++),
'platform_view_larger_than_display_size': (FlutterView view) => PlatformViewLargerThanDisplaySize(view, id: _viewId++),
'platform_view_partial_intersection': (FlutterView view) => PlatformViewPartialIntersectionScenario(view, id: _viewId++),
'platform_view_two_intersecting_overlays': (FlutterView view) => PlatformViewTwoIntersectingOverlaysScenario(view, id: _viewId++),
'platform_view_one_overlay_two_intersecting_overlays': (FlutterView view) => PlatformViewOneOverlayTwoIntersectingOverlaysScenario(view, id: _viewId++),
'platform_view_multiple_without_overlays': (FlutterView view) => MultiPlatformViewWithoutOverlaysScenario(view, firstId: _viewId++, secondId: _viewId++),
'platform_view_max_overlays': (FlutterView view) => PlatformViewMaxOverlaysScenario(view, id: _viewId++),
'platform_view_cliprect': (FlutterView view) => PlatformViewClipRectScenario(view, id: _viewId++),
'platform_view_cliprect_with_transform': (FlutterView view) => PlatformViewClipRectWithTransformScenario(view, id: _viewId++),
'platform_view_cliprect_after_moved': (FlutterView view) => PlatformViewClipRectAfterMovedScenario(view, id: _viewId++),
'platform_view_cliprrect': (FlutterView view) => PlatformViewClipRRectScenario(view, id: _viewId++),
'platform_view_large_cliprrect': (FlutterView view) => PlatformViewLargeClipRRectScenario(view, id: _viewId++),
'platform_view_cliprrect_with_transform': (FlutterView view) => PlatformViewClipRRectWithTransformScenario(view, id: _viewId++),
'platform_view_large_cliprrect_with_transform': (FlutterView view) => PlatformViewLargeClipRRectWithTransformScenario(view, id: _viewId++),
'platform_view_clippath': (FlutterView view) => PlatformViewClipPathScenario(view, id: _viewId++),
'platform_view_clippath_with_transform': (FlutterView view) => PlatformViewClipPathWithTransformScenario(view, id: _viewId++),
'platform_view_transform': (FlutterView view) => PlatformViewTransformScenario(view, id: _viewId++),
'platform_view_opacity': (FlutterView view) => PlatformViewOpacityScenario(view, id: _viewId++),
'platform_view_with_other_backdrop_filter': (FlutterView view) => PlatformViewWithOtherBackDropFilter(view, id: _viewId++),
'two_platform_views_with_other_backdrop_filter': (FlutterView view) => TwoPlatformViewsWithOtherBackDropFilter(view, firstId: _viewId++, secondId: _viewId++),
'platform_view_multiple': (FlutterView view) => MultiPlatformViewScenario(view, firstId: _viewId++, secondId: _viewId++),
'platform_view_multiple_background_foreground': (FlutterView view) => MultiPlatformViewBackgroundForegroundScenario(view, firstId: _viewId++, secondId: _viewId++),
'non_full_screen_flutter_view_platform_view': (FlutterView view) => NonFullScreenFlutterViewPlatformViewScenario(view, id: _viewId++),
'poppable_screen': (FlutterView view) => PoppableScreenScenario(view),
'platform_view_rotate': (FlutterView view) => PlatformViewScenario(view, id: _viewId++),
'platform_view_gesture_reject_eager': (FlutterView view) => PlatformViewForTouchIOSScenario(view, id: _viewId++, accept: false),
'platform_view_gesture_accept': (FlutterView view) => PlatformViewForTouchIOSScenario(view, id: _viewId++, accept: true),
'platform_view_gesture_reject_after_touches_ended': (FlutterView view) => PlatformViewForTouchIOSScenario(view, id: _viewId++, accept: false, rejectUntilTouchesEnded: true),
'platform_view_gesture_accept_with_overlapping_platform_views': (FlutterView view) => PlatformViewForOverlappingPlatformViewsScenario(view, foregroundId: _viewId++, backgroundId: _viewId++),
'platform_view_scrolling_under_widget':(FlutterView view) => PlatformViewScrollingUnderWidget(view, firstPlatformViewId: _viewId++, lastPlatformViewId: _viewId+=16),
'tap_status_bar': (FlutterView view) => TouchesScenario(view),
'initial_route_reply': (FlutterView view) => InitialRouteReply(view),
'platform_view_with_continuous_texture': (FlutterView view) => PlatformViewWithContinuousTexture(view, id: _viewId++),
'bogus_font_text': (FlutterView view) => BogusFontText(view),
'spawn_engine_works' : (FlutterView view) => BogusFontText(view),
'pointer_events': (FlutterView view) => TouchesScenario(view),
'display_texture': (FlutterView view) => DisplayTexture(view),
'get_bitmap': (FlutterView view) => GetBitmapScenario(view),
};
Map<String, dynamic> _currentScenarioParams = <String, dynamic>{};
@@ -69,7 +69,7 @@ Scenario? _currentScenarioInstance;
/// Loads an scenario.
/// The map must contain a `name` entry, which equals to the name of the scenario.
void loadScenario(Map<String, dynamic> scenario) {
void loadScenario(Map<String, dynamic> scenario, FlutterView view) {
final String scenarioName = scenario['name'] as String;
assert(_scenarios[scenarioName] != null);
_currentScenarioParams = scenario;
@@ -78,8 +78,8 @@ void loadScenario(Map<String, dynamic> scenario) {
_currentScenarioInstance!.unmount();
}
_currentScenarioInstance = _scenarios[scenario['name']]!();
window.scheduleFrame();
_currentScenarioInstance = _scenarios[scenario['name']]!(view);
view.platformDispatcher.scheduleFrame();
print('Loading scenario $scenarioName');
}

View File

@@ -11,10 +11,7 @@ import 'scenarios.dart';
/// Displays a platform texture with the given width and height.
class DisplayTexture extends Scenario {
/// Creates the DisplayTexture scenario.
///
/// The [dispatcher] parameter must not be null.
DisplayTexture(PlatformDispatcher dispatcher)
: super(dispatcher);
DisplayTexture(super.view);
int get _textureId => scenarioParams['texture_id'] as int;
double get _textureWidth =>
@@ -28,18 +25,18 @@ class DisplayTexture extends Scenario {
builder.addTexture(
_textureId,
offset: Offset(
(window.physicalSize.width / 2.0) - (_textureWidth / 2.0),
(view.physicalSize.width / 2.0) - (_textureWidth / 2.0),
0.0,
),
width: _textureWidth,
height: _textureHeight,
);
final Scene scene = builder.build();
window.render(scene);
view.render(scene);
scene.dispose();
sendJsonMessage(
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
channel: 'display_data',
json: <String, dynamic>{
'data': 'ready',

View File

@@ -10,7 +10,7 @@ import 'scenario.dart';
/// A scenario that sends back messages when touches are received.
class TouchesScenario extends Scenario {
/// Constructor for `TouchesScenario`.
TouchesScenario(PlatformDispatcher dispatcher) : super(dispatcher);
TouchesScenario(super.view);
final Map<int, int> _knownDevices = <int, int>{};
int _sequenceNo = 0;
@@ -19,7 +19,7 @@ class TouchesScenario extends Scenario {
void onBeginFrame(Duration duration) {
// It is necessary to render frames for touch events to work properly on iOS
final Scene scene = SceneBuilder().build();
window.render(scene);
view.render(scene);
scene.dispose();
}
@@ -29,7 +29,7 @@ class TouchesScenario extends Scenario {
final int deviceId =
_knownDevices.putIfAbsent(datum.device, () => _knownDevices.length);
sendJsonMessage(
dispatcher: dispatcher,
dispatcher: view.platformDispatcher,
channel: 'display_data',
json: <String, dynamic>{
'data': '$_sequenceNo,${datum.change},device=$deviceId,buttons=${datum.buttons},signalKind=${datum.signalKind}',

View File

@@ -5,7 +5,7 @@
name: scenario_app
publish_to: none
environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.17.0 <3.0.0'
# Do not add any dependencies that require more than what is provided in
# //third_party/dart/pkg, //third_party/dart/third_party/pkg, or