| // 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(); |
| } |