From 099f1005818e045f748f8f5ba9e609095a2071df Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Mon, 29 Aug 2022 16:11:49 -0700 Subject: [PATCH 1/8] - --- lib/web_ui/test/canvaskit/image_test.dart | 28 ++++++++++++++++++++ lib/web_ui/test/engine/image/image_test.dart | 28 ++++++++++++++++++++ testing/dart/BUILD.gn | 1 + testing/dart/image_test.dart | 25 +++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 lib/web_ui/test/canvaskit/image_test.dart create mode 100644 lib/web_ui/test/engine/image/image_test.dart create mode 100644 testing/dart/image_test.dart diff --git a/lib/web_ui/test/canvaskit/image_test.dart b/lib/web_ui/test/canvaskit/image_test.dart new file mode 100644 index 0000000000000..3c9f577bf7c05 --- /dev/null +++ b/lib/web_ui/test/canvaskit/image_test.dart @@ -0,0 +1,28 @@ +// 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 testMain() async { + test('toImage succeeds', () async { + final ui.Image image = await _createImage(); + expect(image.runtimeType, equals('EngineImage')); + }); +} + +Future _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(); +} diff --git a/lib/web_ui/test/engine/image/image_test.dart b/lib/web_ui/test/engine/image/image_test.dart new file mode 100644 index 0000000000000..952292801fba3 --- /dev/null +++ b/lib/web_ui/test/engine/image/image_test.dart @@ -0,0 +1,28 @@ +// 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 testMain() async { + test('toImage succeeds', () async { + final ui.Image image = await _createImage(); + expect(image.runtimeType, equals('HtmlImage')); + }); +} + +Future _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(); +} diff --git a/testing/dart/BUILD.gn b/testing/dart/BUILD.gn index 4321cd37f55ae..712bae0f1d56d 100644 --- a/testing/dart/BUILD.gn +++ b/testing/dart/BUILD.gn @@ -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", diff --git a/testing/dart/image_test.dart b/testing/dart/image_test.dart new file mode 100644 index 0000000000000..fc392e9209729 --- /dev/null +++ b/testing/dart/image_test.dart @@ -0,0 +1,25 @@ +// 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, equals('?')); + }); +} + +Future _createImage() async => _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(); +} From 6f01a1de6bc8f36272a6200d7e72fb4b24a9d00d Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Mon, 29 Aug 2022 16:20:15 -0700 Subject: [PATCH 2/8] Update image_test.dart --- testing/dart/image_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/dart/image_test.dart b/testing/dart/image_test.dart index fc392e9209729..6e14ab01a3fb0 100644 --- a/testing/dart/image_test.dart +++ b/testing/dart/image_test.dart @@ -10,7 +10,7 @@ import 'package:litetest/litetest.dart'; void main() { test('toImage succeeds', () async { final Image image = await _createImage(); - expect(image.runtimeType, equals('?')); + expect(image.runtimeType, equals('Image')); }); } From 06d4378de731b9b8f5374950c9db5a964c8a26f7 Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Mon, 29 Aug 2022 17:07:47 -0700 Subject: [PATCH 3/8] - --- lib/web_ui/test/canvaskit/image_test.dart | 2 +- lib/web_ui/test/engine/image/image_test.dart | 2 +- testing/dart/image_test.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/web_ui/test/canvaskit/image_test.dart b/lib/web_ui/test/canvaskit/image_test.dart index 3c9f577bf7c05..3d627999102e1 100644 --- a/lib/web_ui/test/canvaskit/image_test.dart +++ b/lib/web_ui/test/canvaskit/image_test.dart @@ -13,7 +13,7 @@ void main() { Future testMain() async { test('toImage succeeds', () async { final ui.Image image = await _createImage(); - expect(image.runtimeType, equals('EngineImage')); + expect(image.runtimeType.toString(), equals('EngineImage')); }); } diff --git a/lib/web_ui/test/engine/image/image_test.dart b/lib/web_ui/test/engine/image/image_test.dart index 952292801fba3..3b8159a75f6c7 100644 --- a/lib/web_ui/test/engine/image/image_test.dart +++ b/lib/web_ui/test/engine/image/image_test.dart @@ -13,7 +13,7 @@ void main() { Future testMain() async { test('toImage succeeds', () async { final ui.Image image = await _createImage(); - expect(image.runtimeType, equals('HtmlImage')); + expect(image.runtimeType.toString(), equals('HtmlImage')); }); } diff --git a/testing/dart/image_test.dart b/testing/dart/image_test.dart index 6e14ab01a3fb0..f350859b17810 100644 --- a/testing/dart/image_test.dart +++ b/testing/dart/image_test.dart @@ -10,7 +10,7 @@ import 'package:litetest/litetest.dart'; void main() { test('toImage succeeds', () async { final Image image = await _createImage(); - expect(image.runtimeType, equals('Image')); + expect(image.runtimeType.toString(), equals('Image')); }); } From f1dbbdb375c3dca2974bf00b55586910e1bfc7f6 Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 30 Aug 2022 10:33:42 -0700 Subject: [PATCH 4/8] Update image_test.dart --- lib/web_ui/test/canvaskit/image_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web_ui/test/canvaskit/image_test.dart b/lib/web_ui/test/canvaskit/image_test.dart index 3d627999102e1..82cbcfe09fd4a 100644 --- a/lib/web_ui/test/canvaskit/image_test.dart +++ b/lib/web_ui/test/canvaskit/image_test.dart @@ -13,7 +13,7 @@ void main() { Future testMain() async { test('toImage succeeds', () async { final ui.Image image = await _createImage(); - expect(image.runtimeType.toString(), equals('EngineImage')); + expect(image.runtimeType.toString(), equals('CkImage')); }); } From f330db4335751199dec5daa811e3347f8be7a05c Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 30 Aug 2022 10:51:10 -0700 Subject: [PATCH 5/8] Update image_test.dart --- lib/web_ui/test/engine/image/image_test.dart | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/web_ui/test/engine/image/image_test.dart b/lib/web_ui/test/engine/image/image_test.dart index 3b8159a75f6c7..e998fcbebca66 100644 --- a/lib/web_ui/test/engine/image/image_test.dart +++ b/lib/web_ui/test/engine/image/image_test.dart @@ -3,26 +3,28 @@ // found in the LICENSE file. import 'package:test/bootstrap/browser.dart'; -import 'package:test/test.dart'; -import 'package:ui/ui.dart' as ui; +// import 'package:test/test.dart'; +// import 'package:ui/ui.dart' as ui; void main() { internalBootstrapBrowserTest(() => testMain); } Future testMain() async { - test('toImage succeeds', () async { - final ui.Image image = await _createImage(); - expect(image.runtimeType.toString(), equals('HtmlImage')); - }); + // TODO(polina-c): uncomment the test when bug is fixed: + // https://github.com/flutter/engine/pull/35791 + // test('toImage succeeds', () async { + // final ui.Image image = await _createImage(); + // expect(image.runtimeType.toString(), equals('HtmlImage')); + // }); } -Future _createImage() => _createPicture().toImage(10, 10); +// Future _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(); -} +// 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(); +// } From ed128d0e36d2c1c927f2de9b1ca8bb3b65b8de3a Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 30 Aug 2022 11:56:09 -0700 Subject: [PATCH 6/8] - --- lib/web_ui/test/canvaskit/image_test.dart | 13 +++++++++++-- lib/web_ui/test/engine/image/image_test.dart | 1 + testing/dart/image_test.dart | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/web_ui/test/canvaskit/image_test.dart b/lib/web_ui/test/canvaskit/image_test.dart index 82cbcfe09fd4a..a77abae58b32e 100644 --- a/lib/web_ui/test/canvaskit/image_test.dart +++ b/lib/web_ui/test/canvaskit/image_test.dart @@ -2,19 +2,28 @@ // 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); } -Future testMain() async { +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 || isSafari); } Future _createImage() => _createPicture().toImage(10, 10); diff --git a/lib/web_ui/test/engine/image/image_test.dart b/lib/web_ui/test/engine/image/image_test.dart index e998fcbebca66..9f8419216a137 100644 --- a/lib/web_ui/test/engine/image/image_test.dart +++ b/lib/web_ui/test/engine/image/image_test.dart @@ -16,6 +16,7 @@ Future testMain() async { // test('toImage succeeds', () async { // final ui.Image image = await _createImage(); // expect(image.runtimeType.toString(), equals('HtmlImage')); + // image.dispose(); // }); } diff --git a/testing/dart/image_test.dart b/testing/dart/image_test.dart index f350859b17810..4cb44267b6f25 100644 --- a/testing/dart/image_test.dart +++ b/testing/dart/image_test.dart @@ -11,10 +11,11 @@ void main() { test('toImage succeeds', () async { final Image image = await _createImage(); expect(image.runtimeType.toString(), equals('Image')); + image.dispose(); }); } -Future _createImage() async => _createPicture().toImage(10, 10); +Future _createImage() => _createPicture().toImage(10, 10); Picture _createPicture() { final PictureRecorder recorder = PictureRecorder(); From b59d0169fa17cffa7ccadcfc8c2729c268d59872 Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 30 Aug 2022 14:02:15 -0700 Subject: [PATCH 7/8] Update image_test.dart --- lib/web_ui/test/engine/image/image_test.dart | 33 ++++++++++---------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/web_ui/test/engine/image/image_test.dart b/lib/web_ui/test/engine/image/image_test.dart index 9f8419216a137..8d690483a7ea6 100644 --- a/lib/web_ui/test/engine/image/image_test.dart +++ b/lib/web_ui/test/engine/image/image_test.dart @@ -3,29 +3,30 @@ // found in the LICENSE file. import 'package:test/bootstrap/browser.dart'; -// import 'package:test/test.dart'; -// import 'package:ui/ui.dart' as ui; +import 'package:test/test.dart'; +import 'package:ui/ui.dart' as ui; void main() { internalBootstrapBrowserTest(() => testMain); } Future testMain() async { - // TODO(polina-c): uncomment the test when bug is fixed: + + 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 - // test('toImage succeeds', () async { - // final ui.Image image = await _createImage(); - // expect(image.runtimeType.toString(), equals('HtmlImage')); - // image.dispose(); - // }); + }, skip: true); } -// Future _createImage() => _createPicture().toImage(10, 10); +Future _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(); -// } +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(); +} From b70542ee50dd0336b7c3957861b6669dc198e96b Mon Sep 17 00:00:00 2001 From: Polina Cherkasova Date: Tue, 30 Aug 2022 14:20:05 -0700 Subject: [PATCH 8/8] Update image_test.dart --- lib/web_ui/test/canvaskit/image_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web_ui/test/canvaskit/image_test.dart b/lib/web_ui/test/canvaskit/image_test.dart index a77abae58b32e..f6ba8031cf1a4 100644 --- a/lib/web_ui/test/canvaskit/image_test.dart +++ b/lib/web_ui/test/canvaskit/image_test.dart @@ -23,7 +23,7 @@ void testMain() { expect(image.runtimeType.toString(), equals('CkImage')); image.dispose(); // TODO(hterkelsen): https://github.com/flutter/flutter/issues/109265 - }, skip: isFirefox || isSafari); + }, skip: isFirefox); } Future _createImage() => _createPicture().toImage(10, 10);