mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This roll includes the following engine commits: * flutter/engine@0c09bf03: In the service protocol, if no view is specified to flush tasks on, pick the first one. (#5028) * flutter/engine@ecaefd7a: Roll src/third_party/skia/ 276886160..1cd6098d5 (50 commits) (#5026) * flutter/engine@e6545573: Enable 'Speak Screen' and 'Switch Control' for iOS (#5016) * flutter/engine@3393c179: Fix Android platform channels (#5025) * flutter/engine@1bc0e1bb: On windows, refer to Dart snapshot directly executable. (#5024) * flutter/engine@cf6ca32d: Revert "Roll Dart to fe606f890b0a311da802c78b0af414a3c2087a79" (#5023) * flutter/engine@4b45a53e: Only make ERROR and FATAL log levels visible by default. (#5022) * flutter/engine@98f6c2d5: Fix shell launcher test (dart2 compliant and stop polling) (#5009) * flutter/engine@75851f08: Roll Dart to fe606f890b0a311da802c78b0af414a3c2087a79 (#5020) * flutter/engine@9495a52d: On iOS, try to use ES3, then fall back to ES2. (#5006) * flutter/engine@d6d4eec2: Fix broken Linux build (#5019) * flutter/engine@d15dc76e: Fix broken Chromebot build (#5018) * flutter/engine@c17a6290: Breadcrumbs to the wiki (#5017) * flutter/engine@4eaf2c2f: Return raw (unencoded) bytes in Image.toByteData() (#5008) * flutter/engine@d812a617: Roll src/third_party/skia/ e669bdfad..276886160 (9 commits) (#5014) * flutter/engine@62aeab72: Call SkSurface::flush instead of getting a backend handle in vulkan_swapchain. (#5012) * flutter/engine@f4ebb180: Roll src/third_party/skia/ 3462eb034..e669bdfad (54 commits) (#5007) * flutter/engine@0b7d6be9: Re-land "do not pause rendering when android view loses focus" (#5004) * flutter/engine@91dee598: If the rasterizer has a valid surface context, use that to create a snapshotting render target. (#4979) * flutter/engine@570231b7: Specify the packages file path when running engine dart tests. (#5005) * flutter/engine@0b9cef5a: Minor update to README (#5003) * flutter/engine@c386418f: Promote line height in text style created from paragraph style (#4995) * flutter/engine@4e0fbb6f: If the test specifies a .dill file, dont make the engine interpret is as source. (#5002) * flutter/engine@58e84c8b: Re-land "Support multiple shells in a single process. (#4932)" (#4998) * flutter/engine@37e5df05: Remove only use of SkPaint::kGenA8FromLCD (#4994) * flutter/engine@b7358b33: libtxt: cache font families that are remapped to the default font family (#4990) * flutter/engine@a530035b: libtxt: fix leaks in Skia object reference counting (#4988) * flutter/engine@0c74fc93: [fuchsia] Fix use-after-free (#4987) * flutter/engine@b6d2dde9: [fuchsia] Fix build (#4986) * flutter/engine@1dd12649: [async] Adapt to libasync API changes. (#4980)
230 lines
6.3 KiB
Dart
230 lines
6.3 KiB
Dart
// Copyright 2015 The Chromium 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 'dart:async';
|
||
import 'dart:typed_data';
|
||
import 'dart:ui' as ui show Image;
|
||
|
||
import 'package:flutter/rendering.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
|
||
import 'rendering_tester.dart';
|
||
|
||
class SquareImage implements ui.Image {
|
||
@override
|
||
int get width => 10;
|
||
|
||
@override
|
||
int get height => 10;
|
||
|
||
@override
|
||
Future<ByteData> toByteData() async {
|
||
throw new UnsupportedError('Cannot encode test image');
|
||
}
|
||
|
||
@override
|
||
String toString() => '[$width\u00D7$height]';
|
||
|
||
@override
|
||
void dispose() { }
|
||
}
|
||
|
||
class WideImage implements ui.Image {
|
||
@override
|
||
int get width => 20;
|
||
|
||
@override
|
||
int get height => 10;
|
||
|
||
@override
|
||
Future<ByteData> toByteData() async {
|
||
throw new UnsupportedError('Cannot encode test image');
|
||
}
|
||
|
||
@override
|
||
String toString() => '[$width\u00D7$height]';
|
||
|
||
@override
|
||
void dispose() { }
|
||
}
|
||
|
||
class TallImage implements ui.Image {
|
||
@override
|
||
int get width => 10;
|
||
|
||
@override
|
||
int get height => 20;
|
||
|
||
@override
|
||
Future<ByteData> toByteData() async {
|
||
throw new UnsupportedError('Cannot encode test image');
|
||
}
|
||
|
||
@override
|
||
String toString() => '[$width\u00D7$height]';
|
||
|
||
@override
|
||
void dispose() { }
|
||
}
|
||
|
||
void main() {
|
||
test('Image sizing', () {
|
||
RenderImage image;
|
||
|
||
image = new RenderImage(image: new SquareImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 25.0,
|
||
minHeight: 25.0,
|
||
maxWidth: 100.0,
|
||
maxHeight: 100.0));
|
||
expect(image.size.width, equals(25.0));
|
||
expect(image.size.height, equals(25.0));
|
||
|
||
expect(image, hasAGoodToStringDeep);
|
||
expect(
|
||
image.toStringDeep(minLevel: DiagnosticLevel.info),
|
||
equalsIgnoringHashCodes(
|
||
'RenderImage#00000 relayoutBoundary=up2 NEEDS-PAINT\n'
|
||
' parentData: <none> (can use size)\n'
|
||
' constraints: BoxConstraints(25.0<=w<=100.0, 25.0<=h<=100.0)\n'
|
||
' size: Size(25.0, 25.0)\n'
|
||
' image: [10×10]\n'
|
||
' alignment: center\n'
|
||
),
|
||
);
|
||
|
||
image = new RenderImage(image: new WideImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 5.0,
|
||
minHeight: 30.0,
|
||
maxWidth: 100.0,
|
||
maxHeight: 100.0));
|
||
expect(image.size.width, equals(60.0));
|
||
expect(image.size.height, equals(30.0));
|
||
|
||
image = new RenderImage(image: new TallImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 50.0,
|
||
minHeight: 5.0,
|
||
maxWidth: 75.0,
|
||
maxHeight: 75.0));
|
||
expect(image.size.width, equals(50.0));
|
||
expect(image.size.height, equals(75.0));
|
||
|
||
image = new RenderImage(image: new WideImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 5.0,
|
||
minHeight: 5.0,
|
||
maxWidth: 100.0,
|
||
maxHeight: 100.0));
|
||
expect(image.size.width, equals(20.0));
|
||
expect(image.size.height, equals(10.0));
|
||
|
||
image = new RenderImage(image: new WideImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 5.0,
|
||
minHeight: 5.0,
|
||
maxWidth: 16.0,
|
||
maxHeight: 16.0));
|
||
expect(image.size.width, equals(16.0));
|
||
expect(image.size.height, equals(8.0));
|
||
|
||
image = new RenderImage(image: new TallImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 5.0,
|
||
minHeight: 5.0,
|
||
maxWidth: 16.0,
|
||
maxHeight: 16.0));
|
||
expect(image.size.width, equals(8.0));
|
||
expect(image.size.height, equals(16.0));
|
||
|
||
image = new RenderImage(image: new SquareImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 4.0,
|
||
minHeight: 4.0,
|
||
maxWidth: 8.0,
|
||
maxHeight: 8.0));
|
||
expect(image.size.width, equals(8.0));
|
||
expect(image.size.height, equals(8.0));
|
||
|
||
image = new RenderImage(image: new WideImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 20.0,
|
||
minHeight: 20.0,
|
||
maxWidth: 30.0,
|
||
maxHeight: 30.0));
|
||
expect(image.size.width, equals(30.0));
|
||
expect(image.size.height, equals(20.0));
|
||
|
||
image = new RenderImage(image: new TallImage());
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 20.0,
|
||
minHeight: 20.0,
|
||
maxWidth: 30.0,
|
||
maxHeight: 30.0));
|
||
expect(image.size.width, equals(20.0));
|
||
expect(image.size.height, equals(30.0));
|
||
});
|
||
|
||
test('Null image sizing', () {
|
||
RenderImage image;
|
||
|
||
image = new RenderImage();
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 25.0,
|
||
minHeight: 25.0,
|
||
maxWidth: 100.0,
|
||
maxHeight: 100.0));
|
||
expect(image.size.width, equals(25.0));
|
||
expect(image.size.height, equals(25.0));
|
||
|
||
image = new RenderImage(width: 50.0);
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 25.0,
|
||
minHeight: 25.0,
|
||
maxWidth: 100.0,
|
||
maxHeight: 100.0));
|
||
expect(image.size.width, equals(50.0));
|
||
expect(image.size.height, equals(25.0));
|
||
|
||
image = new RenderImage(height: 50.0);
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 25.0,
|
||
minHeight: 25.0,
|
||
maxWidth: 100.0,
|
||
maxHeight: 100.0));
|
||
expect(image.size.width, equals(25.0));
|
||
expect(image.size.height, equals(50.0));
|
||
|
||
image = new RenderImage(width: 100.0, height: 100.0);
|
||
layout(image,
|
||
constraints: const BoxConstraints(
|
||
minWidth: 25.0,
|
||
minHeight: 25.0,
|
||
maxWidth: 75.0,
|
||
maxHeight: 75.0));
|
||
expect(image.size.width, equals(75.0));
|
||
expect(image.size.height, equals(75.0));
|
||
});
|
||
|
||
test('update image colorBlendMode', () {
|
||
final RenderImage image = new RenderImage();
|
||
expect(image.colorBlendMode, isNull);
|
||
image.colorBlendMode = BlendMode.color;
|
||
expect(image.colorBlendMode, BlendMode.color);
|
||
});
|
||
}
|