forked from firebase/flutterfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[firebase_ml_vision] Fix crash when passing contact info from barcode (…
- Loading branch information
1 parent
66f1174
commit 60d6f7c
Showing
8 changed files
with
74 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 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 |
---|---|---|
|
@@ -34,6 +34,51 @@ void main() { | |
|
||
expect(barcodes.length, 1); | ||
}); | ||
|
||
test('detectInImage contactInfo', () async { | ||
final String tmpFilename = await _loadImage( | ||
'assets/test_contact_barcode.png', | ||
); | ||
|
||
final FirebaseVisionImage visionImage = | ||
FirebaseVisionImage.fromFilePath( | ||
tmpFilename, | ||
); | ||
|
||
final BarcodeDetector detector = vision.barcodeDetector(); | ||
final List<Barcode> barcodes = await detector.detectInImage( | ||
visionImage, | ||
); | ||
|
||
expect(barcodes, hasLength(1)); | ||
final BarcodeContactInfo info = barcodes[0].contactInfo; | ||
|
||
final BarcodePersonName name = info.name; | ||
expect(name.first, 'John'); | ||
expect(name.last, 'Doe'); | ||
expect(name.formattedName, 'John Doe'); | ||
expect(name.middle, anyOf(isNull, isEmpty)); | ||
expect(name.prefix, anyOf(isNull, isEmpty)); | ||
expect(name.pronunciation, anyOf(isNull, isEmpty)); | ||
expect(name.suffix, anyOf(isNull, isEmpty)); | ||
|
||
expect(info.jobTitle, anyOf(isNull, isEmpty)); | ||
expect(info.organization, anyOf(isNull, isEmpty)); | ||
expect(info.urls, <String>['http://www.example.com']); | ||
expect(info.addresses, anyOf(isNull, isEmpty)); | ||
|
||
expect(info.emails, hasLength(1)); | ||
final BarcodeEmail email = info.emails[0]; | ||
expect(email.address, '[email protected]'); | ||
expect(email.body, anyOf(isNull, isEmpty)); | ||
expect(email.subject, anyOf(isNull, isEmpty)); | ||
expect(email.type, BarcodeEmailType.unknown); | ||
|
||
expect(info.phones, hasLength(1)); | ||
final BarcodePhone phone = info.phones[0]; | ||
expect(phone.number, '555-555-5555'); | ||
expect(phone.type, BarcodePhoneType.unknown); | ||
}); | ||
}); | ||
|
||
group('$FaceDetector', () { | ||
|
This file contains 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 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 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ name: firebase_ml_vision | |
description: Flutter plugin for Firebase machine learning vision services. | ||
author: Flutter Team <[email protected]> | ||
homepage: https://github.com/flutter/plugins/tree/master/packages/firebase_ml_vision | ||
version: 0.8.0+1 | ||
version: 0.8.0+2 | ||
|
||
dependencies: | ||
flutter: | ||
|