raster_test.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import 'dart:typed_data';
  17. import 'dart:ui' as ui;
  18. import 'package:fis_lib_print/printing.dart';
  19. import 'package:flutter/widgets.dart';
  20. import 'package:flutter_test/flutter_test.dart';
  21. void main() {
  22. setUp(() {
  23. TestWidgetsFlutterBinding.ensureInitialized();
  24. });
  25. test('PdfRaster', () async {
  26. final raster =
  27. PdfRaster(10, 10, Uint8List.fromList(List<int>.filled(10 * 10 * 4, 0)));
  28. expect(raster.toString(), 'Image 10x10 400 bytes');
  29. expect(await raster.toImage(), isA<ui.Image>());
  30. expect(await raster.toPng(), isA<Uint8List>());
  31. });
  32. testWidgets('PdfRasterImage', (WidgetTester tester) async {
  33. final raster =
  34. PdfRaster(10, 10, Uint8List.fromList(List<int>.filled(10 * 10 * 4, 0)));
  35. await tester.pumpWidget(Image(image: PdfRasterImage(raster)));
  36. await tester.pumpAndSettle();
  37. });
  38. }