-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[camerax] Implement video capture for CameraX android camera re-write #3467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f876e73
ca2a353
22eea7a
77dfba1
daf385b
167f9c2
23ec03e
034a508
d5affdd
9797067
c76d1a4
3141b02
92a51b8
5e776a5
0ba0dfc
89d7936
9eecbed
f8eee31
fb4770b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -561,6 +561,48 @@ void main() { | |
| verify(recording.close()); | ||
| verifyNoMoreInteractions(recording); | ||
| }); | ||
|
|
||
| test('stopVideoRecording throws a camera exception if ' | ||
| 'no recording is in progress', () async { | ||
| final AndroidCameraCameraX camera = AndroidCameraCameraX(); | ||
| const String videoOutputPath = '/test/output/path'; | ||
|
|
||
| camera.recording = null; | ||
| camera.videoOutputPath = videoOutputPath; | ||
|
|
||
| expect(() => camera.stopVideoRecording(0), throwsA(isA<CameraException>())); | ||
| }); | ||
|
|
||
| test('stopVideoRecording throws a camera exception if ' | ||
| 'videoOutputPath is null', () async { | ||
| final AndroidCameraCameraX camera = AndroidCameraCameraX(); | ||
| final MockRecording recording = MockRecording(); | ||
|
|
||
| camera.recording = recording; | ||
| camera.videoOutputPath = null; | ||
|
|
||
| expect(() => camera.stopVideoRecording(0), throwsA(isA<CameraException>())); | ||
| }); | ||
|
|
||
| test('calling stopVideoRecording twice stops the recording ' | ||
| 'and then throws a CameraException', () async { | ||
| final AndroidCameraCameraX camera = AndroidCameraCameraX(); | ||
| final MockRecording recording = MockRecording(); | ||
| final MockProcessCameraProvider processCameraProvider = | ||
| MockProcessCameraProvider(); | ||
| final MockVideoCapture videoCapture = MockVideoCapture(); | ||
| const String videoOutputPath = '/test/output/path'; | ||
|
|
||
| camera.processCameraProvider = processCameraProvider; | ||
| camera.recording = recording; | ||
| camera.videoCapture = videoCapture; | ||
| camera.videoOutputPath = videoOutputPath; | ||
|
|
||
| final XFile file = await camera.stopVideoRecording(0); | ||
| assert(file.path == videoOutputPath); | ||
|
||
|
|
||
| expect(() => camera.stopVideoRecording(0), throwsA(isA<CameraException>())); | ||
| }); | ||
| }); | ||
|
|
||
camsim99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| test( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there error cases around recording that should be tested. For example calling stop twice in a row?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sort of testing is good, and likely the sort we should use for several other methods tested here. Not sure this should block this PR, though, so if you don't get to it, please add it here: flutter/flutter#125928
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocking: I do think that some error testing should be required before merging even if the test is that we we swallow the error and don't crash (or that we crash and the crash is part of the documented behavior)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This action currently throws a CameraException. I'll add a test for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added a logic and a test for calling recording twice (we silently do nothing in this case, based on a check of if the class variable
recordingis null or not).