Test cover 'toImage'. (flutter/engine#35791)
This commit is contained in:
committed by
GitHub
parent
2251f36799
commit
5b0de4ffe9
37
engine/src/flutter/lib/web_ui/test/canvaskit/image_test.dart
Normal file
37
engine/src/flutter/lib/web_ui/test/canvaskit/image_test.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/src/engine.dart';
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
void main() {
|
||||
internalBootstrapBrowserTest(() => testMain);
|
||||
}
|
||||
|
||||
void testMain() {
|
||||
setUpCanvasKitTest();
|
||||
|
||||
test('toImage succeeds', () async {
|
||||
final ui.Image image = await _createImage();
|
||||
expect(image.runtimeType.toString(), equals('CkImage'));
|
||||
image.dispose();
|
||||
// TODO(hterkelsen): https://github.com/flutter/flutter/issues/109265
|
||||
}, skip: isFirefox);
|
||||
}
|
||||
|
||||
Future<ui.Image> _createImage() => _createPicture().toImage(10, 10);
|
||||
|
||||
ui.Picture _createPicture() {
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
final ui.Canvas canvas = ui.Canvas(recorder);
|
||||
const ui.Rect rect = ui.Rect.fromLTWH(0.0, 0.0, 100.0, 100.0);
|
||||
canvas.clipRect(rect);
|
||||
return recorder.endRecording();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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.
|
||||
|
||||
import 'package:test/bootstrap/browser.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:ui/ui.dart' as ui;
|
||||
|
||||
void main() {
|
||||
internalBootstrapBrowserTest(() => testMain);
|
||||
}
|
||||
|
||||
Future<void> testMain() async {
|
||||
|
||||
test('toImage succeeds', () async {
|
||||
final ui.Image image = await _createImage();
|
||||
expect(image.runtimeType.toString(), equals('HtmlImage'));
|
||||
image.dispose();
|
||||
// TODO(polina-c): unskip the test when bug is fixed:
|
||||
// https://github.com/flutter/engine/pull/35791
|
||||
}, skip: true);
|
||||
}
|
||||
|
||||
Future<ui.Image> _createImage() => _createPicture().toImage(10, 10);
|
||||
|
||||
ui.Picture _createPicture() {
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
final ui.Canvas canvas = ui.Canvas(recorder);
|
||||
const ui.Rect rect = ui.Rect.fromLTWH(0.0, 0.0, 100.0, 100.0);
|
||||
canvas.clipRect(rect);
|
||||
return recorder.endRecording();
|
||||
}
|
||||
@@ -25,6 +25,7 @@ tests = [
|
||||
"image_filter_test.dart",
|
||||
"image_resize_test.dart",
|
||||
"image_shader_test.dart",
|
||||
"image_test.dart",
|
||||
"isolate_name_server_test.dart",
|
||||
"isolate_test.dart",
|
||||
"lerp_test.dart",
|
||||
|
||||
26
engine/src/flutter/testing/dart/image_test.dart
Normal file
26
engine/src/flutter/testing/dart/image_test.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
// 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.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:litetest/litetest.dart';
|
||||
|
||||
void main() {
|
||||
test('toImage succeeds', () async {
|
||||
final Image image = await _createImage();
|
||||
expect(image.runtimeType.toString(), equals('Image'));
|
||||
image.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
Future<Image> _createImage() => _createPicture().toImage(10, 10);
|
||||
|
||||
Picture _createPicture() {
|
||||
final PictureRecorder recorder = PictureRecorder();
|
||||
final Canvas canvas = Canvas(recorder);
|
||||
const Rect rect = Rect.fromLTWH(0.0, 0.0, 100.0, 100.0);
|
||||
canvas.clipRect(rect);
|
||||
return recorder.endRecording();
|
||||
}
|
||||
Reference in New Issue
Block a user