mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Rebase ios-experimental branch onto main. This will make the PRs experimenting with newer versions of Xcode (like https://github.com/flutter/flutter/pull/173123) smaller and easier to reason about. Rebases #168860 and #170274 ``` $ git rebase main -Xtheirs ``` --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Co-authored-by: Siva <a-siva@users.noreply.github.com> Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org> Co-authored-by: Jamil Saadeh <jssaadeh@outlook.com> Co-authored-by: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com> Co-authored-by: Greg Price <gnprice@gmail.com> Co-authored-by: Ben Konyi <bkonyi@google.com> Co-authored-by: Ricardo Dalarme <ricardodalarme@outlook.com> Co-authored-by: Flutter GitHub Bot <fluttergithubbot@gmail.com> Co-authored-by: Justin McCandless <jmccandless@google.com> Co-authored-by: Alex Talebi <31685655+SalehTZ@users.noreply.github.com> Co-authored-by: Qun Cheng <36861262+QuncCccccc@users.noreply.github.com> Co-authored-by: Mouad Debbar <mdebbar@google.com> Co-authored-by: Zuckjet <1083941774@qq.com> Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com> Co-authored-by: auto-submit[bot] <98614782+auto-submit[bot]@users.noreply.github.com> Co-authored-by: auto-submit[bot] <flutter-engprod-team@google.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: yim <ybz975218925@gmail.com> Co-authored-by: bufffun <chenmingding.cmd@alibaba-inc.com> Co-authored-by: Chinmay Garde <chinmaygarde@google.com> Co-authored-by: Hannah Jin <jhy03261997@gmail.com> Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: Valentin Vignal <32538273+ValentinVignal@users.noreply.github.com> Co-authored-by: Derek Xu <derekx@google.com> Co-authored-by: Yash Dhrangdhariya <72062416+Yash-Dhrangdhariya@users.noreply.github.com> Co-authored-by: bungeman <bungeman@chromium.org> Co-authored-by: Ahmed Mohamed Sameh <ahmedsameha1@gmail.com> Co-authored-by: John "codefu" McDole <codefu@google.com> Co-authored-by: Dmitry Grand <dmgr@google.com> Co-authored-by: Kostia Sokolovskyi <sokolovskyi.konstantin@gmail.com> Co-authored-by: Reid Baker <1063596+reidbaker@users.noreply.github.com> Co-authored-by: Matthew Kosarek <matt.kosarek@canonical.com> Co-authored-by: Jason Simmons <jason-simmons@users.noreply.github.com> Co-authored-by: Jim Graham <flar@google.com> Co-authored-by: Michael Goderbauer <goderbauer@google.com> Co-authored-by: Gray Mackall <34871572+gmackall@users.noreply.github.com> Co-authored-by: Gray Mackall <mackall@google.com> Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com> Co-authored-by: Jon Ihlas <jon.i@hotmail.fr> Co-authored-by: Micael Cid <micaelcid10@gmail.com> Co-authored-by: Alexander Aprelev <aam@google.com> Co-authored-by: hellohuanlin <41930132+hellohuanlin@users.noreply.github.com> Co-authored-by: Luke Memet <1598289+lukemmtt@users.noreply.github.com> Co-authored-by: Victoria Ashworth <15619084+vashworth@users.noreply.github.com> Co-authored-by: Mairramer <50643541+Mairramer@users.noreply.github.com> Co-authored-by: Florin Malita <fmalita@gmail.com> Co-authored-by: chunhtai <47866232+chunhtai@users.noreply.github.com> Co-authored-by: Salem Iranloye <127918074+salemiranloye@users.noreply.github.com> Co-authored-by: Kevin Moore <kevmoo@google.com> Co-authored-by: Sydney Bao <sydneybao@google.com> Co-authored-by: Wdestroier <Wdestroier@gmail.com> Co-authored-by: Matt Boetger <matt.boetger@gmail.com> Co-authored-by: Reid Baker <reidbaker@google.com> Co-authored-by: Victor Sanni <victorsanniay@gmail.com> Co-authored-by: Jessy Yameogo <jessy.yameogo@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: romain.gyh <11901536+romaingyh@users.noreply.github.com> Co-authored-by: Robert Ancell <robert.ancell@canonical.com> Co-authored-by: TheLastFlame <131446187+TheLastFlame@users.noreply.github.com> Co-authored-by: masato <returnymgstokh@icloud.com> Co-authored-by: Albin PK <56157868+albinpk@users.noreply.github.com> Co-authored-by: Huy <huy@nevercode.io> Co-authored-by: Matan Lurey <matanlurey@users.noreply.github.com> Co-authored-by: Azat Chorekliyev <azat24680@gmail.com> Co-authored-by: EdwynZN <edwinzn9@gmail.com> Co-authored-by: Bruno Leroux <bruno.leroux@gmail.com> Co-authored-by: Dev TtangKong <ttankkeo112@gmail.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Co-authored-by: Houssem Eddine Fadhli <houssemeddinefadhli81@gmail.com>
268 lines
8.8 KiB
Dart
268 lines
8.8 KiB
Dart
// Copyright 2014 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.
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:vector_math/vector_math_64.dart';
|
|
|
|
import 'rendering_tester.dart';
|
|
|
|
void main() {
|
|
TestRenderingFlutterBinding.ensureInitialized();
|
|
|
|
test('Describe transform control test', () {
|
|
final Matrix4 identity = Matrix4.identity();
|
|
final List<String> description = debugDescribeTransform(identity);
|
|
expect(description, <String>[
|
|
'[0] 1.0,0.0,0.0,0.0',
|
|
'[1] 0.0,1.0,0.0,0.0',
|
|
'[2] 0.0,0.0,1.0,0.0',
|
|
'[3] 0.0,0.0,0.0,1.0',
|
|
]);
|
|
});
|
|
|
|
test('transform property test', () {
|
|
final Matrix4 transform = Matrix4.diagonal3(Vector3.all(2.0));
|
|
final TransformProperty simple = TransformProperty('transform', transform);
|
|
expect(simple.name, equals('transform'));
|
|
expect(simple.value, same(transform));
|
|
expect(
|
|
simple.toString(parentConfiguration: sparseTextConfiguration),
|
|
equals(
|
|
'transform:\n'
|
|
' [0] 2.0,0.0,0.0,0.0\n'
|
|
' [1] 0.0,2.0,0.0,0.0\n'
|
|
' [2] 0.0,0.0,2.0,0.0\n'
|
|
' [3] 0.0,0.0,0.0,1.0',
|
|
),
|
|
);
|
|
expect(
|
|
simple.toString(parentConfiguration: singleLineTextConfiguration),
|
|
equals('transform: [2.0,0.0,0.0,0.0; 0.0,2.0,0.0,0.0; 0.0,0.0,2.0,0.0; 0.0,0.0,0.0,1.0]'),
|
|
);
|
|
|
|
final TransformProperty nullProperty = TransformProperty('transform', null);
|
|
expect(nullProperty.name, equals('transform'));
|
|
expect(nullProperty.value, isNull);
|
|
expect(nullProperty.toString(), equals('transform: null'));
|
|
|
|
final TransformProperty hideNull = TransformProperty('transform', null, defaultValue: null);
|
|
expect(hideNull.value, isNull);
|
|
expect(hideNull.toString(), equals('transform: null'));
|
|
});
|
|
|
|
test('debugPaintPadding', () {
|
|
expect((Canvas canvas) {
|
|
debugPaintPadding(canvas, const Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), null);
|
|
}, paints..rect(color: const Color(0x90909090)));
|
|
expect(
|
|
(Canvas canvas) {
|
|
debugPaintPadding(
|
|
canvas,
|
|
const Rect.fromLTRB(10.0, 10.0, 20.0, 20.0),
|
|
const Rect.fromLTRB(11.0, 11.0, 19.0, 19.0),
|
|
);
|
|
},
|
|
paints
|
|
..path(color: const Color(0x900090FF))
|
|
..path(color: const Color(0xFF0090FF)),
|
|
);
|
|
expect(
|
|
(Canvas canvas) {
|
|
debugPaintPadding(
|
|
canvas,
|
|
const Rect.fromLTRB(10.0, 10.0, 20.0, 20.0),
|
|
const Rect.fromLTRB(15.0, 15.0, 15.0, 15.0),
|
|
);
|
|
},
|
|
paints
|
|
..rect(rect: const Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), color: const Color(0x90909090)),
|
|
);
|
|
});
|
|
|
|
test('debugPaintPadding from render objects', () {
|
|
debugPaintSizeEnabled = true;
|
|
RenderSliver s;
|
|
RenderBox b;
|
|
final RenderViewport root = RenderViewport(
|
|
crossAxisDirection: AxisDirection.right,
|
|
offset: ViewportOffset.zero(),
|
|
children: <RenderSliver>[
|
|
s = RenderSliverPadding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: RenderSliverToBoxAdapter(
|
|
child: b = RenderPadding(padding: const EdgeInsets.all(10.0)),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
layout(root);
|
|
expect(
|
|
b.debugPaint,
|
|
paints
|
|
..rect(color: const Color(0xFF00FFFF))
|
|
..rect(color: const Color(0x90909090)),
|
|
);
|
|
expect(b.debugPaint, isNot(paints..path()));
|
|
expect(
|
|
s.debugPaint,
|
|
paints
|
|
..circle(hasMaskFilter: true)
|
|
..line(hasMaskFilter: true)
|
|
..path(hasMaskFilter: true)
|
|
..path(hasMaskFilter: true)
|
|
..path(color: const Color(0x900090FF))
|
|
..path(color: const Color(0xFF0090FF)),
|
|
);
|
|
expect(s.debugPaint, isNot(paints..rect()));
|
|
debugPaintSizeEnabled = false;
|
|
});
|
|
|
|
test('debugPaintPadding from render objects', () {
|
|
debugPaintSizeEnabled = true;
|
|
RenderSliver s;
|
|
final RenderBox b = RenderPadding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: RenderViewport(
|
|
crossAxisDirection: AxisDirection.right,
|
|
offset: ViewportOffset.zero(),
|
|
children: <RenderSliver>[s = RenderSliverPadding(padding: const EdgeInsets.all(10.0))],
|
|
),
|
|
);
|
|
layout(b);
|
|
expect(s.debugPaint, paints..rect(color: const Color(0x90909090)));
|
|
expect(
|
|
s.debugPaint,
|
|
isNot(
|
|
paints
|
|
..circle(hasMaskFilter: true)
|
|
..line(hasMaskFilter: true)
|
|
..path(hasMaskFilter: true)
|
|
..path(hasMaskFilter: true)
|
|
..path(color: const Color(0x900090FF))
|
|
..path(color: const Color(0xFF0090FF)),
|
|
),
|
|
);
|
|
expect(
|
|
b.debugPaint,
|
|
paints
|
|
..rect(color: const Color(0xFF00FFFF))
|
|
..path(color: const Color(0x900090FF))
|
|
..path(color: const Color(0xFF0090FF)),
|
|
);
|
|
expect(b.debugPaint, isNot(paints..rect(color: const Color(0x90909090))));
|
|
debugPaintSizeEnabled = false;
|
|
});
|
|
|
|
test('debugPaintPadding from render objects with inverted direction vertical', () {
|
|
debugPaintSizeEnabled = true;
|
|
RenderSliver s;
|
|
final RenderViewport root = RenderViewport(
|
|
axisDirection: AxisDirection.up,
|
|
crossAxisDirection: AxisDirection.right,
|
|
offset: ViewportOffset.zero(),
|
|
children: <RenderSliver>[
|
|
s = RenderSliverPadding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: RenderSliverToBoxAdapter(
|
|
child: RenderPadding(padding: const EdgeInsets.all(10.0)),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
layout(root);
|
|
final PaintingContext context = PaintingContext(
|
|
ContainerLayer(),
|
|
const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0),
|
|
);
|
|
s.debugPaint(context, const Offset(0.0, 500));
|
|
debugPaintSizeEnabled = false;
|
|
});
|
|
|
|
test('debugPaintPadding from render objects with inverted direction horizontal', () {
|
|
debugPaintSizeEnabled = true;
|
|
RenderSliver s;
|
|
final RenderViewport root = RenderViewport(
|
|
axisDirection: AxisDirection.left,
|
|
crossAxisDirection: AxisDirection.down,
|
|
offset: ViewportOffset.zero(),
|
|
children: <RenderSliver>[
|
|
s = RenderSliverPadding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: RenderSliverToBoxAdapter(
|
|
child: RenderPadding(padding: const EdgeInsets.all(10.0)),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
layout(root);
|
|
final PaintingContext context = PaintingContext(
|
|
ContainerLayer(),
|
|
const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0),
|
|
);
|
|
s.debugPaint(context, const Offset(0.0, 500));
|
|
debugPaintSizeEnabled = false;
|
|
});
|
|
|
|
test('debugDisableOpacity keeps things in the right spot', () {
|
|
debugDisableOpacityLayers = true;
|
|
|
|
final RenderDecoratedBox blackBox = RenderDecoratedBox(
|
|
decoration: const BoxDecoration(color: Color(0xff000000)),
|
|
child: RenderConstrainedBox(
|
|
additionalConstraints: BoxConstraints.tight(const Size.square(20.0)),
|
|
),
|
|
);
|
|
final RenderOpacity root = RenderOpacity(
|
|
opacity: .5,
|
|
child: RenderRepaintBoundary(child: blackBox),
|
|
);
|
|
layout(root, phase: EnginePhase.compositingBits);
|
|
|
|
final OffsetLayer rootLayer = OffsetLayer();
|
|
final PaintingContext context = PaintingContext(rootLayer, const Rect.fromLTWH(0, 0, 500, 500));
|
|
context.paintChild(root, const Offset(40, 40));
|
|
|
|
final OpacityLayer opacityLayer = rootLayer.firstChild! as OpacityLayer;
|
|
expect(opacityLayer.offset, const Offset(40, 40));
|
|
debugDisableOpacityLayers = false;
|
|
});
|
|
|
|
test('debugAssertAllRenderVarsUnset warns when debugProfileLayoutsEnabled set', () {
|
|
debugProfileLayoutsEnabled = true;
|
|
expect(() => debugAssertAllRenderVarsUnset('ERROR'), throwsFlutterError);
|
|
debugProfileLayoutsEnabled = false;
|
|
});
|
|
|
|
test('debugAssertAllRenderVarsUnset warns when debugDisableClipLayers set', () {
|
|
debugDisableClipLayers = true;
|
|
expect(() => debugAssertAllRenderVarsUnset('ERROR'), throwsFlutterError);
|
|
debugDisableClipLayers = false;
|
|
});
|
|
|
|
test('debugAssertAllRenderVarsUnset warns when debugDisablePhysicalShapeLayers set', () {
|
|
debugDisablePhysicalShapeLayers = true;
|
|
expect(() => debugAssertAllRenderVarsUnset('ERROR'), throwsFlutterError);
|
|
debugDisablePhysicalShapeLayers = false;
|
|
});
|
|
|
|
test('debugAssertAllRenderVarsUnset warns when debugDisableOpacityLayers set', () {
|
|
debugDisableOpacityLayers = true;
|
|
expect(() => debugAssertAllRenderVarsUnset('ERROR'), throwsFlutterError);
|
|
debugDisableOpacityLayers = false;
|
|
});
|
|
|
|
test('debugCheckHasBoundedAxis warns for vertical and horizontal axis', () {
|
|
expect(
|
|
() => debugCheckHasBoundedAxis(Axis.vertical, const BoxConstraints()),
|
|
throwsFlutterError,
|
|
);
|
|
expect(
|
|
() => debugCheckHasBoundedAxis(Axis.horizontal, const BoxConstraints()),
|
|
throwsFlutterError,
|
|
);
|
|
});
|
|
}
|