|
| 1 | +// Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +import 'dart:typed_data'; |
| 6 | +import 'dart:ui'; |
| 7 | + |
| 8 | +import 'package:litetest/litetest.dart'; |
| 9 | + |
| 10 | +final Uint8List imageData = Uint8List.fromList(<int>[ // Small WebP file |
| 11 | + 0x52, 0x49, 0x46, 0x46, 0x12, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x4c, // |RIFF....WEBPVP8L| |
| 12 | + 0x06, 0x00, 0x00, 0x00, 0x2f, 0x41, 0x6c, 0x6f, 0x00, 0x6b, // |..../Alo.k| |
| 13 | +]); |
| 14 | + |
| 15 | +void main() { |
| 16 | + test('Stringification of native objects exposed in Dart', () async { |
| 17 | + expect(SemanticsUpdateBuilder().toString(), 'SemanticsUpdateBuilder'); |
| 18 | + expect(SemanticsUpdateBuilder().build().toString(), 'SemanticsUpdate'); |
| 19 | + expect(ParagraphBuilder(ParagraphStyle()).toString(), 'ParagraphBuilder'); |
| 20 | + expect(ParagraphBuilder(ParagraphStyle()).build().toString(), 'Paragraph(dirty)'); |
| 21 | + expect((await instantiateImageCodec(imageData)).toString(), 'Codec()'); |
| 22 | + expect(Path().toString(), 'Path'); |
| 23 | + final PictureRecorder recorder = PictureRecorder(); |
| 24 | + expect(recorder.toString(), 'PictureRecorder(recording: false)'); |
| 25 | + final Canvas canvas = Canvas(recorder); |
| 26 | + expect(recorder.toString(), 'PictureRecorder(recording: true)'); |
| 27 | + expect(canvas.toString(), 'Canvas(recording: true)'); |
| 28 | + final Picture picture = recorder.endRecording(); |
| 29 | + expect(recorder.toString(), 'PictureRecorder(recording: false)'); |
| 30 | + expect(canvas.toString(), 'Canvas(recording: false)'); |
| 31 | + expect(picture.toString(), 'Picture'); |
| 32 | + expect( |
| 33 | + ImageDescriptor.raw( |
| 34 | + await ImmutableBuffer.fromUint8List(Uint8List.fromList(<int>[0, 0, 0, 0])), |
| 35 | + width: 1, |
| 36 | + height: 1, |
| 37 | + pixelFormat: PixelFormat.rgba8888, |
| 38 | + ).toString(), 'ImageDescriptor(width: 1, height: 1, bytes per pixel: 4)', |
| 39 | + ); |
| 40 | + expect(SceneBuilder().toString(), 'SceneBuilder'); |
| 41 | + expect(SceneBuilder().build().toString(), 'Scene'); |
| 42 | + }); |
| 43 | +} |
0 commit comments