Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2019-11-27 19:11:22 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9da967e9cec5bff5bf9f8fd0d9cba492ea1a3c30
9da967e9
1 parent
54dcd599
Add printing tests
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
Makefile
printing/test/printing_test.dart
Makefile
View file @
9da967e
...
...
@@ -76,6 +76,7 @@ test-pdf: $(FONTS) get-pdf .coverage
test
/compare-pdf.sh pdf
test
/golden
test-printing
:
$(FONTS) get-printing .coverage
cd
printing; flutter
test
--coverage --coverage-path lcov.info
cd
printing/example; flutter
test
--coverage --coverage-path ../lcov.info
test-readme
:
$(FONTS) get-readme
...
...
printing/test/printing_test.dart
0 → 100644
View file @
9da967e
import
'dart:io'
;
import
'dart:typed_data'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:pdf/pdf.dart'
;
import
'package:pdf/widgets.dart'
as
pdf
;
import
'package:printing/printing.dart'
;
pdf
.
Document
doc
;
pdf
.
Font
ttf
;
void
main
(
)
{
final
String
path
=
Directory
.
current
.
path
.
split
(
'/'
).
last
==
'test'
?
'..'
:
'.'
;
const
MethodChannel
channel
=
MethodChannel
(
'net.nfet.printing'
);
TestWidgetsFlutterBinding
.
ensureInitialized
();
setUp
(()
{
channel
.
setMockMethodCallHandler
((
MethodCall
methodCall
)
async
{
print
(
methodCall
);
return
'1'
;
});
});
tearDown
(()
{
channel
.
setMockMethodCallHandler
(
null
);
});
test
(
'convertHtml'
,
()
async
{
// expect(await Printing.platformVersion, '42');
});
test
(
'pdfImageFromImageProvider(FileImage)'
,
()
async
{
final
PdfImage
image
=
await
pdfImageFromImageProvider
(
pdf:
doc
.
document
,
image:
FileImage
(
File
(
'
$path
/example.png'
)));
doc
.
addPage
(
pdf
.
Page
(
build:
(
pdf
.
Context
context
)
=>
pdf
.
Center
(
child:
pdf
.
Container
(
child:
pdf
.
Image
(
image
),
),
),
),
);
});
setUpAll
(()
{
pdf
.
Document
.
debug
=
true
;
pdf
.
RichText
.
debug
=
true
;
final
Uint8List
fontData
=
File
(
'
$path
/../pdf/open-sans.ttf'
).
readAsBytesSync
();
ttf
=
pdf
.
Font
.
ttf
(
fontData
.
buffer
.
asByteData
());
doc
=
pdf
.
Document
();
});
tearDownAll
(()
{
final
File
file
=
File
(
'printing.pdf'
);
file
.
writeAsBytesSync
(
doc
.
save
());
});
}
...
...
Please
register
or
login
to post a comment