未验证 提交 0e82628c 编写于 作者: E Emmanuel Garcia 提交者: GitHub

Update scenario UI screenshoots (#19421)

上级 52c23455
......@@ -244,12 +244,11 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
@Override
public void onTouch(@NonNull PlatformViewsChannel.PlatformViewTouch touch) {
float density = context.getResources().getDisplayMetrics().density;
PointerProperties[] pointerProperties =
parsePointerPropertiesList(touch.rawPointerPropertiesList)
.toArray(new PointerProperties[touch.pointerCount]);
PointerCoords[] pointerCoords =
parsePointerCoordsList(touch.rawPointerCoords, density)
parsePointerCoordsList(touch.rawPointerCoords, getDisplayDensity())
.toArray(new PointerCoords[touch.pointerCount]);
if (!vdControllers.containsKey(touch.viewId)) {
......@@ -569,9 +568,12 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
}
}
private float getDisplayDensity() {
return context.getResources().getDisplayMetrics().density;
}
private int toPhysicalPixels(double logicalPixels) {
float density = context.getResources().getDisplayMetrics().density;
return (int) Math.round(logicalPixels * density);
return (int) Math.round(logicalPixels * getDisplayDensity());
}
private void flushAllViews() {
......@@ -621,8 +623,18 @@ public class PlatformViewsController implements PlatformViewsAccessibilityDelega
PlatformView platformView = factory.create(context, viewId, createParams);
View view = platformView.getView();
platformViews.put(viewId, view);
// Reverse scale the view based on the screen density.
//
// Flow pixels are based on the physical resolution. For example, 1000 pixels in flow equals
// 500 points in Android if the display density is 2.0.
float density = getDisplayDensity();
view.setPivotX(0);
view.setPivotY(0);
view.setScaleX(1 / density);
view.setScaleY(1 / density);
platformViews.put(viewId, view);
((FlutterView) flutterView).addView(view);
}
......
......@@ -111,7 +111,7 @@ class VirtualDisplayController {
DisplayManager displayManager =
(DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
virtualDisplay =
displayManager.createVirtualDisplay("flutter-vd", width, height, densityDpi, surface, 0);
displayManager.createVirtualDisplay("flutter-vd", width, height, 1, surface, 0);
final View embeddedView = getView();
// There's a bug in Android version older than O where view tree observer onDrawListeners don't
......
......@@ -41,8 +41,7 @@ public class EngineLaunchE2ETest {
// TODO: Fix race condition between sending this over the channel and starting the entrypoint.
// https://github.com/flutter/flutter/issues/55999
UiThreadStatement.runOnUiThread(
() ->
engine.get().getLocalizationChannel().sendLocales(Arrays.asList(Locale.US), Locale.US));
() -> engine.get().getLocalizationChannel().sendLocales(Arrays.asList(Locale.US)));
// The default Dart main entrypoint sends back a platform message on the "waiting_for_status"
// channel. That will be our launch success assertion condition.
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.flutter.scenarios">
<application
android:name=".ScenarioApplication"
android:name="io.flutter.app.FlutterApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
......@@ -18,9 +17,7 @@
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="com.google.intent.action.TEST_LOOP" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/javascript" />
</intent-filter>
<intent-filter>
......@@ -28,11 +25,19 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".StrictModeFlutterActivity"
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true">
<intent-filter>
<!-- TODO: https://github.com/flutter/flutter/issues/60635 -->
<action android:name="dev.flutter.scenarios.STRICT_MODE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.flutter.embedded_views_preview"
android:value="true" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
\ No newline at end of file
</manifest>
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package dev.flutter.scenarios;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class BlankActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package dev.flutter.scenarios;
import android.os.Bundle;
import android.os.StrictMode;
import io.flutter.app.FlutterApplication;
import io.flutter.embedding.android.FlutterActivity;
public class ScenarioApplication extends FlutterApplication {
// TODO: Trigger this activity.
// https://github.com/flutter/flutter/issues/60635
public class StrictModeFlutterActivity extends FlutterActivity {
@Override
public void onCreate() {
protected void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.penaltyDeath()
.build());
super.onCreate();
super.onCreate(savedInstanceState);
}
}
......@@ -192,28 +192,28 @@
app.launchArguments = @[ @"--platform-view-multiple-background-foreground" ];
[app launch];
XCUIElement* platform_view1 = app.textViews[@"platform_view[8]"];
XCUIElement* platform_view1 = app.textViews[@"platform_view[0]"];
XCTAssertTrue(platform_view1.exists);
XCTAssertEqual(platform_view1.frame.origin.x, 25);
XCTAssertEqual(platform_view1.frame.origin.y, 325);
XCTAssertEqual(platform_view1.frame.size.width, 250);
XCTAssertEqual(platform_view1.frame.size.height, 250);
XCUIElement* platform_view2 = app.textViews[@"platform_view[9]"];
XCUIElement* platform_view2 = app.textViews[@"platform_view[1]"];
XCTAssertTrue(platform_view2.exists);
XCTAssertEqual(platform_view2.frame.origin.x, 25);
XCTAssertEqual(platform_view2.frame.origin.y, 25);
XCTAssertEqual(platform_view2.frame.size.width, 250);
XCTAssertEqual(platform_view2.frame.size.height, 250);
XCUIElement* overlay1 = app.otherElements[@"platform_view[8].overlay[0]"];
XCUIElement* overlay1 = app.otherElements[@"platform_view[0].overlay[0]"];
XCTAssertTrue(overlay1.exists);
XCTAssertEqual(overlay1.frame.origin.x, 25);
XCTAssertEqual(overlay1.frame.origin.y, 325);
XCTAssertEqual(overlay1.frame.size.width, 225);
XCTAssertEqual(overlay1.frame.size.height, 175);
XCUIElement* overlay2 = app.otherElements[@"platform_view[9].overlay[0]"];
XCUIElement* overlay2 = app.otherElements[@"platform_view[1].overlay[0]"];
XCTAssertTrue(overlay2.exists);
XCTAssertEqual(overlay2.frame.origin.x, 25);
XCTAssertEqual(overlay2.frame.origin.y, 25);
......
......@@ -33,19 +33,22 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
PlatformViewScenario(Window window, String text, {int id = 0})
PlatformViewScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
/// The platform view identifier.
final int id;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
finishBuilderByAddingPlatformViewAndPicture(builder, 0);
finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
......@@ -54,12 +57,15 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
PlatformViewNoOverlayIntersectionScenario(Window window, String text, {int id = 0})
PlatformViewNoOverlayIntersectionScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
/// The platform view identifier.
final int id;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
......@@ -68,7 +74,7 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario with _BasePlatf
finishBuilderByAddingPlatformViewAndPicture(
builder,
0,
id,
overlayOffset: const Offset(150, 350),
);
}
......@@ -79,12 +85,15 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
PlatformViewPartialIntersectionScenario(Window window, String text, {int id = 0})
PlatformViewPartialIntersectionScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
/// The platform view identifier .
final int id;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
......@@ -93,7 +102,7 @@ class PlatformViewPartialIntersectionScenario extends Scenario with _BasePlatfor
finishBuilderByAddingPlatformViewAndPicture(
builder,
0,
id,
overlayOffset: const Offset(150, 250),
);
}
......@@ -104,19 +113,22 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario with _BasePla
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
PlatformViewTwoIntersectingOverlaysScenario(Window window, String text, {int id = 0})
PlatformViewTwoIntersectingOverlaysScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
/// The platform view identifier.
final int id;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
_addPlatformViewtoScene(builder, 0, 500, 500);
_addPlatformViewtoScene(builder, id, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
canvas.drawCircle(
......@@ -142,19 +154,22 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario wit
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(Window window, String text, {int id = 0})
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
/// The platform view identifier.
final int id;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
_addPlatformViewtoScene(builder, 0, 500, 500);
_addPlatformViewtoScene(builder, id, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
canvas.drawCircle(
......@@ -185,12 +200,19 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
MultiPlatformViewWithoutOverlaysScenario(Window window, String text, {int id = 0})
MultiPlatformViewWithoutOverlaysScenario(Window window, String text, { this.firstId, this.secondId })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
createPlatformView(window, text, firstId);
createPlatformView(window, text, secondId);
}
/// The platform view identifier to use for the first platform view.
final int firstId;
/// The platform view identifier to use for the second platform view.
final int secondId;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
......@@ -198,10 +220,10 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario with _BasePlatfo
builder.pushOffset(0, 0);
builder.pushOffset(0, 600);
_addPlatformViewtoScene(builder, 0, 500, 500);
_addPlatformViewtoScene(builder, firstId, 500, 500);
builder.pop();
_addPlatformViewtoScene(builder, 1, 500, 500);
_addPlatformViewtoScene(builder, secondId, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
......@@ -224,19 +246,22 @@ class PlatformViewMaxOverlaysScenario extends Scenario with _BasePlatformViewSce
/// Creates the PlatformView scenario.
///
/// The [window] parameter must not be null.
PlatformViewMaxOverlaysScenario(Window window, String text, {int id = 0})
PlatformViewMaxOverlaysScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
/// The platform view identifier.
final int id;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
_addPlatformViewtoScene(builder, 0, 500, 500);
_addPlatformViewtoScene(builder, id, 500, 500);
final PictureRecorder recorder = PictureRecorder();
final Canvas canvas = Canvas(recorder);
canvas.drawCircle(
......@@ -394,25 +419,28 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario with _BaseP
/// Platform view with clip rect.
class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin {
/// Constructs a platform view with clip rect scenario.
PlatformViewClipRectScenario(Window window, String text, {int id = 0})
PlatformViewClipRectScenario(Window window, String text, { this.id })
: assert(window != null),
super(window) {
createPlatformView(window, text, id);
}
/// The platform view identifier.
final int id;
@override
void onBeginFrame(Duration duration) {
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
builder.pushClipRect(const Rect.fromLTRB(100, 100, 400, 400));
finishBuilderByAddingPlatformViewAndPicture(builder, 1);
finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with clip rrect.
class PlatformViewClipRRectScenario extends PlatformViewScenario {
/// Constructs a platform view with clip rrect scenario.
PlatformViewClipRRectScenario(Window window, String text, {int id = 0})
PlatformViewClipRRectScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
......@@ -431,14 +459,14 @@ class PlatformViewClipRRectScenario extends PlatformViewScenario {
bottomLeft: const Radius.circular(50),
),
);
finishBuilderByAddingPlatformViewAndPicture(builder, 2);
finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with clip path.
class PlatformViewClipPathScenario extends PlatformViewScenario {
/// Constructs a platform view with clip rrect scenario.
PlatformViewClipPathScenario(Window window, String text, {int id = 0})
PlatformViewClipPathScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
......@@ -455,14 +483,14 @@ class PlatformViewClipPathScenario extends PlatformViewScenario {
..close();
builder.pushClipPath(path);
finishBuilderByAddingPlatformViewAndPicture(builder, 3);
finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with transform.
class PlatformViewTransformScenario extends PlatformViewScenario {
/// Constructs a platform view with transform scenario.
PlatformViewTransformScenario(Window window, String text, {int id = 0})
PlatformViewTransformScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
......@@ -477,14 +505,14 @@ class PlatformViewTransformScenario extends PlatformViewScenario {
builder.pushTransform(matrix4.storage);
finishBuilderByAddingPlatformViewAndPicture(builder, 4);
finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
/// Platform view with opacity.
class PlatformViewOpacityScenario extends PlatformViewScenario {
/// Constructs a platform view with transform scenario.
PlatformViewOpacityScenario(Window window, String text, {int id = 0})
PlatformViewOpacityScenario(Window window, String text, { int id = 0 })
: super(window, text, id: id);
@override
......@@ -494,7 +522,7 @@ class PlatformViewOpacityScenario extends PlatformViewScenario {
builder.pushOffset(0, 0);
builder.pushOpacity(150);
finishBuilderByAddingPlatformViewAndPicture(builder, 5);
finishBuilderByAddingPlatformViewAndPicture(builder, id);
}
}
......@@ -524,7 +552,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
final SceneBuilder builder = SceneBuilder();
builder.pushOffset(0, 0);
finishBuilderByAddingPlatformViewAndPicture(builder, 11);
finishBuilderByAddingPlatformViewAndPicture(builder, _viewId);
}
@override
......@@ -562,17 +590,23 @@ class PlatformViewForTouchIOSScenario extends Scenario
mixin _BasePlatformViewScenarioMixin on Scenario {
int _textureId;
bool get usesAndroidHybridComposition {
return (scenarioParams['use_android_view'] as bool) == true;
}
/// Construct the platform view related scenario
///
/// It prepare a TextPlatformView so it can be added to the SceneBuilder in `onBeginFrame`.
/// Call this method in the constructor of the platform view related scenarios
/// to perform necessary set up.
void createPlatformView(Window window, String text, int id, {String viewType = 'scenarios/textPlatformView'}) {
const int _valueTrue = 1;
const int _valueInt32 = 3;
const int _valueFloat64 = 6;
const int _valueString = 7;
const int _valueUint8List = 8;
const int _valueMap = 13;
final Uint8List message = Uint8List.fromList(<int>[
_valueString,
'create'.length, // this won't work if we use multi-byte characters.
......@@ -580,8 +614,10 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
_valueMap,
if (Platform.isIOS)
3, // 3 entries in map for iOS.
if (Platform.isAndroid)
6, // 6 entries in map for Android.
if (Platform.isAndroid && !usesAndroidHybridComposition)
6, // 6 entries in map for virtual displays on Android.
if (Platform.isAndroid && usesAndroidHybridComposition)
5, // 5 entries in map for Android views.
_valueString,
'id'.length,
...utf8.encode('id'),
......@@ -593,7 +629,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
_valueString,
viewType.length,
...utf8.encode(viewType),
if (Platform.isAndroid) ...<int>[
if (Platform.isAndroid && !usesAndroidHybridComposition) ...<int>[
_valueString,
'width'.length,
...utf8.encode('width'),
......@@ -610,6 +646,17 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
_valueInt32,
..._to32(0), // LTR
],
if (Platform.isAndroid && usesAndroidHybridComposition) ...<int>[
_valueString,
'hybrid'.length,
...utf8.encode('hybrid'),
_valueTrue,
_valueString,
'direction'.length,
...utf8.encode('direction'),
_valueInt32,
..._to32(0), // LTR
],
_valueString,
'params'.length,
...utf8.encode('params'),
......@@ -622,7 +669,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
'flutter/platform_views',
message.buffer.asByteData(),
(ByteData response) {
if (response != null && Platform.isAndroid) {
if (response != null && Platform.isAndroid && !usesAndroidHybridComposition) {
// Envelope.
_textureId = response.getUint8(0);
}
......@@ -641,9 +688,12 @@ mixin _BasePlatformViewScenarioMixin on Scenario {
if (Platform.isIOS) {
sceneBuilder.addPlatformView(viewId, offset: overlayOffset, width: width, height: height);
} else if (Platform.isAndroid) {
if (scenarioParams['use_android_view'] as bool) {
// Hybrid composition.
sceneBuilder.addPlatformView(viewId, offset: overlayOffset, width: width, height: height);
if (usesAndroidHybridComposition) {
// Hybrid composition does not support `offset`.
// https://github.com/flutter/flutter/issues/60630
sceneBuilder.pushOffset(overlayOffset.dx, overlayOffset.dy);
sceneBuilder.addPlatformView(viewId, width: width, height: height);
sceneBuilder.pop();
} else if (_textureId != null) {
sceneBuilder.addTexture(_textureId, offset: overlayOffset, width: width, height: height);
}
......
......@@ -13,52 +13,59 @@ import 'scenario.dart';
import 'send_text_focus_semantics.dart';
import 'touches_scenario.dart';
Map<String, Scenario> _scenarios = <String, Scenario>{
'animated_color_square': AnimatedColorSquareScenario(window),
'locale_initialization': LocaleInitialization(window),
'platform_view': PlatformViewScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
'platform_view_no_overlay_intersection': PlatformViewNoOverlayIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
'platform_view_partial_intersection': PlatformViewPartialIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
'platform_view_two_intersecting_overlays': PlatformViewTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
'platform_view_one_overlay_two_intersecting_overlays': PlatformViewOneOverlayTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
'platform_view_multiple_without_overlays': MultiPlatformViewWithoutOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
'platform_view_max_overlays': PlatformViewMaxOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: 0),
'platform_view_cliprect': PlatformViewClipRectScenario(window, 'PlatformViewClipRect', id: 1),
'platform_view_cliprrect': PlatformViewClipRRectScenario(window, 'PlatformViewClipRRect', id: 2),
'platform_view_clippath': PlatformViewClipPathScenario(window, 'PlatformViewClipPath', id: 3),
'platform_view_transform': PlatformViewTransformScenario(window, 'PlatformViewTransform', id: 4),
'platform_view_opacity': PlatformViewOpacityScenario(window, 'PlatformViewOpacity', id: 5),
'platform_view_multiple': MultiPlatformViewScenario(window, firstId: 6, secondId: 7),
'platform_view_multiple_background_foreground': MultiPlatformViewBackgroundForegroundScenario(window, firstId: 8, secondId: 9),
'poppable_screen': PoppableScreenScenario(window),
'platform_view_rotate': PlatformViewScenario(window, 'Rotate Platform View', id: 10),
'platform_view_gesture_reject_eager': PlatformViewForTouchIOSScenario(window, 'platform view touch', id: 11, accept: false),
'platform_view_gesture_accept': PlatformViewForTouchIOSScenario(window, 'platform view touch', id: 11, accept: true),
'platform_view_gesture_reject_after_touches_ended': PlatformViewForTouchIOSScenario(window, 'platform view touch', id: 11, accept: false, rejectUntilTouchesEnded: true),
'tap_status_bar': TouchesScenario(window),
'text_semantics_focus': SendTextFocusScemantics(window),
typedef ScenarioFactory = Scenario Function();
int _viewId = 0;
Map<String, ScenarioFactory> _scenarios = <String, ScenarioFactory>{
'animated_color_square': () => AnimatedColorSquareScenario(window),
'locale_initialization': () => LocaleInitialization(window),
'platform_view': () => PlatformViewScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
'platform_view_no_overlay_intersection': () => PlatformViewNoOverlayIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
'platform_view_partial_intersection': () => PlatformViewPartialIntersectionScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
'platform_view_two_intersecting_overlays': () => PlatformViewTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
'platform_view_one_overlay_two_intersecting_overlays': () => PlatformViewOneOverlayTwoIntersectingOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
'platform_view_multiple_without_overlays': () => MultiPlatformViewWithoutOverlaysScenario(window, 'Hello from Scenarios (Platform View)', firstId: _viewId++, secondId: _viewId++),
'platform_view_max_overlays': () => PlatformViewMaxOverlaysScenario(window, 'Hello from Scenarios (Platform View)', id: _viewId++),
'platform_view_cliprect': () => PlatformViewClipRectScenario(window, 'PlatformViewClipRect', id: _viewId++),
'platform_view_cliprrect': () => PlatformViewClipRRectScenario(window, 'PlatformViewClipRRect', id: _viewId++),
'platform_view_clippath': () => PlatformViewClipPathScenario(window, 'PlatformViewClipPath', id: _viewId++),
'platform_view_transform': () => PlatformViewTransformScenario(window, 'PlatformViewTransform', id: _viewId++),
'platform_view_opacity': () => PlatformViewOpacityScenario(window, 'PlatformViewOpacity', id: _viewId++),
'platform_view_multiple': () => MultiPlatformViewScenario(window, firstId: 6, secondId: _viewId++),
'platform_view_multiple_background_foreground': () => MultiPlatformViewBackgroundForegroundScenario(window, firstId: _viewId++, secondId: _viewId++),
'poppable_screen': () => PoppableScreenScenario(window),
'platform_view_rotate': () => PlatformViewScenario(window, 'Rotate Platform View', id: _viewId++),
'platform_view_gesture_reject_eager': () => PlatformViewForTouchIOSScenario(window, 'platform view touch', id: _viewId++, accept: false),
'platform_view_gesture_accept': () => PlatformViewForTouchIOSScenario(window, 'platform view touch', id: _viewId++, accept: true),
'platform_view_gesture_reject_after_touches_ended': () => PlatformViewForTouchIOSScenario(window, 'platform view touch', id: _viewId++, accept: false, rejectUntilTouchesEnded: true),
'tap_status_bar': () => TouchesScenario(window),
'text_semantics_focus': () => SendTextFocusScemantics(window),
};
Map<String, dynamic> _currentScenario = <String, dynamic>{
Map<String, dynamic> _currentScenarioParams = <String, dynamic>{
'name': 'animated_color_square',
};
Scenario _currentScenarioInstance = _scenarios[_currentScenarioParams['name']]();
/// Loads an scenario.
/// The map must contain a `name` entry, which equals to the name of the scenario.
void loadScenario(Map<String, dynamic> scenario) {
final String scenarioName = scenario['name'] as String;
assert(_scenarios[scenarioName] != null);
_currentScenario = scenario;
_currentScenarioParams = scenario;
_currentScenarioInstance = _scenarios[scenario['name']]();
window.scheduleFrame();
print('Loading scenario $scenarioName');
}
/// Gets the loaded [Scenario].
Scenario get currentScenario {
return _currentScenario != null ? _scenarios[_currentScenario['name']] : null;
return _currentScenarioInstance;
}
/// Gets the parameters passed to the app over the channel.
Map<String, dynamic> get scenarioParams {
return Map<String, dynamic>.from(_currentScenario);
return Map<String, dynamic>.from(_currentScenarioParams);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册