This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Test cover 'toImage'. #35791
Merged
Merged
Test cover 'toImage'. #35791
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
099f100
-
polina-c 6f01a1d
Update image_test.dart
polina-c c32f62d
Merge branch 'master' of github.com:flutter/engine into tests
polina-c 06d4378
-
polina-c f1dbbdb
Update image_test.dart
polina-c f330db4
Update image_test.dart
polina-c d022932
Merge branch 'master' of github.com:flutter/engine into tests
polina-c ed128d0
-
polina-c b59d016
Update image_test.dart
polina-c b70542e
Update image_test.dart
polina-c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 || isSafari); | ||
| } | ||
|
|
||
| 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(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // 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 { | ||
| // 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')); | ||
| // image.dispose(); | ||
| // }); | ||
polina-c marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // 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(); | ||
| // } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.