Skip to content

Commit ddc298b

Browse files
authored
[camera]delete fake bitrate/fps integration tests (flutter#13291)
## These tests are fake They are intended to verify higher fps/bit rate results in larger files. Based on the [commit history](flutter@f3ed1d3), the Android used to do the same test as iOS: ``` for (int n = 0; n < lengths.length - 1; n++) { expect(lengths[n], lessThan(lengths[n + 1]), reason: 'incrementing fps should increment file size'); } ``` But later it fails CI, so it changes to ``` for (int n = 0; n < lengths.length - 1; n++) { expect(lengths[n], greaterThan(0)); } ``` Also note that it still leaves `for (var n = 0; i < lengths.length-1; n++)` - the `-1` bound only made sense when comparing `length[n]` against `length[n+1]`. This is **NOT** the right way to fix a CI failure. The iOS tests passed the CI since we only run it on simulator, so the test is skipped. But if i run it locally, [it may pass or fail based on how I put my phone on the table](flutter/flutter#191202 (comment)) ( <-- Very funny, read it! 😃 ) ## Why remove 1. The test premise is wrong - higher FPS/bit rate setting does not necessarily mean larger file size, as explained in the link above. 2. Camera setting related tests are already deterministically covered in unit testes. Fixes flutter/flutter#194395 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 85e4d42 commit ddc298b

2 files changed

Lines changed: 0 additions & 261 deletions

File tree

‎packages/camera/camera_android/example/integration_test/camera_test.dart‎

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -265,138 +265,4 @@ void main() {
265265

266266
expect(controller.value.isStreamingImages, false);
267267
});
268-
269-
group('Camera settings', () {
270-
Future<CameraDescription> getCamera() async {
271-
final List<CameraDescription> cameras = await CameraPlatform.instance.availableCameras();
272-
expect(cameras.isNotEmpty, equals(true));
273-
274-
// Prefer back camera, as it allows more customizations.
275-
final CameraDescription cameraDescription = cameras.firstWhere(
276-
(CameraDescription description) => description.lensDirection == CameraLensDirection.back,
277-
orElse: () => cameras.first,
278-
);
279-
return cameraDescription;
280-
}
281-
282-
Future<void> startRecording(CameraController controller) async {
283-
await controller.initialize();
284-
285-
//region Lock video as much as possible to avoid video bitrate fluctuations
286-
await controller.lockCaptureOrientation();
287-
await controller.setExposureMode(ExposureMode.locked);
288-
await controller.setFocusMode(FocusMode.locked);
289-
await controller.setFlashMode(FlashMode.off);
290-
await controller.setExposureOffset(0);
291-
//endregion
292-
293-
await controller.prepareForVideoRecording();
294-
await controller.startVideoRecording();
295-
}
296-
297-
testWidgets('Control FPS', (WidgetTester tester) async {
298-
final CameraDescription cameraDescription = await getCamera();
299-
300-
final lengths = <int>[];
301-
302-
for (final fps in <int>[10, 30]) {
303-
final controller = CameraController(
304-
cameraDescription,
305-
mediaSettings: MediaSettings(resolutionPreset: ResolutionPreset.medium, fps: fps),
306-
);
307-
308-
await startRecording(controller);
309-
310-
sleep(const Duration(milliseconds: 1000));
311-
312-
final XFile file = await controller.stopVideoRecording();
313-
314-
// Load video size
315-
final videoFile = File(file.path);
316-
317-
lengths.add(await videoFile.length());
318-
319-
await controller.dispose();
320-
}
321-
322-
for (var n = 0; n < lengths.length - 1; n++) {
323-
expect(lengths[n], greaterThan(0));
324-
}
325-
});
326-
327-
testWidgets('Control video bitrate', (WidgetTester tester) async {
328-
final CameraDescription cameraDescription = await getCamera();
329-
330-
const kiloBits = 1000;
331-
final lengths = <int>[];
332-
for (final videoBitrate in <int>[200 * kiloBits, 2000 * kiloBits]) {
333-
final controller = CameraController(
334-
cameraDescription,
335-
mediaSettings: MediaSettings(
336-
resolutionPreset: ResolutionPreset.medium,
337-
videoBitrate: videoBitrate,
338-
),
339-
);
340-
341-
await startRecording(controller);
342-
343-
sleep(const Duration(milliseconds: 1000));
344-
345-
final XFile file = await controller.stopVideoRecording();
346-
347-
// Load video size
348-
final videoFile = File(file.path);
349-
350-
lengths.add(await videoFile.length());
351-
352-
await controller.dispose();
353-
}
354-
355-
for (var n = 0; n < lengths.length - 1; n++) {
356-
expect(lengths[n], greaterThan(0));
357-
}
358-
});
359-
360-
testWidgets('Control audio bitrate', (WidgetTester tester) async {
361-
final lengths = <int>[];
362-
363-
final CameraDescription cameraDescription = await getCamera();
364-
365-
const kiloBits = 1000;
366-
367-
for (final audioBitrate in <int>[32 * kiloBits, 256 * kiloBits]) {
368-
final controller = CameraController(
369-
cameraDescription,
370-
mediaSettings: MediaSettings(
371-
//region Use lowest video settings for minimize video impact on bitrate
372-
resolutionPreset: ResolutionPreset.low,
373-
fps: 10,
374-
videoBitrate: 64 * kiloBits,
375-
//endregion
376-
audioBitrate: audioBitrate,
377-
enableAudio: true,
378-
),
379-
);
380-
381-
await startRecording(controller);
382-
383-
sleep(const Duration(milliseconds: 1000));
384-
385-
final XFile file = await controller.stopVideoRecording();
386-
387-
// Load video metadata
388-
final videoFile = File(file.path);
389-
390-
final int length = await videoFile.length();
391-
392-
lengths.add(length);
393-
394-
await controller.dispose();
395-
}
396-
397-
for (var n = 0; n < lengths.length - 1; n++) {
398-
expect(lengths[n], greaterThan(0));
399-
}
400-
});
401-
});
402268
}

‎packages/camera/camera_avfoundation/example/integration_test/camera_test.dart‎

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -320,131 +320,4 @@ void main() {
320320
}
321321
}
322322
});
323-
324-
group('Camera settings', () {
325-
testWidgets('Control FPS', (WidgetTester tester) async {
326-
final List<CameraDescription> cameras = await CameraPlatform.instance.availableCameras();
327-
if (cameras.isEmpty) {
328-
return;
329-
}
330-
331-
final lengths = <int>[];
332-
for (final fps in <int>[10, 30]) {
333-
final controller = CameraController.withSettings(
334-
cameras.first,
335-
mediaSettings: MediaSettings(resolutionPreset: ResolutionPreset.medium, fps: fps),
336-
);
337-
await controller.initialize();
338-
await controller.prepareForVideoRecording();
339-
340-
// Take Video
341-
await controller.startVideoRecording();
342-
await Future<void>.delayed(const Duration(milliseconds: 500));
343-
final XFile file = await controller.stopVideoRecording();
344-
345-
// Load video size
346-
final videoFile = File(file.path);
347-
348-
lengths.add(await videoFile.length());
349-
350-
await controller.dispose();
351-
}
352-
353-
for (var n = 0; n < lengths.length - 1; n++) {
354-
expect(
355-
lengths[n],
356-
lessThan(lengths[n + 1]),
357-
reason: 'incrementing fps should increment file size',
358-
);
359-
}
360-
});
361-
362-
testWidgets('Control video bitrate', (WidgetTester tester) async {
363-
final List<CameraDescription> cameras = await CameraPlatform.instance.availableCameras();
364-
if (cameras.isEmpty) {
365-
return;
366-
}
367-
368-
const kiloBits = 1024;
369-
final lengths = <int>[];
370-
for (final videoBitrate in <int>[100 * kiloBits, 1000 * kiloBits]) {
371-
final controller = CameraController.withSettings(
372-
cameras.first,
373-
mediaSettings: MediaSettings(
374-
resolutionPreset: ResolutionPreset.medium,
375-
videoBitrate: videoBitrate,
376-
),
377-
);
378-
await controller.initialize();
379-
await controller.prepareForVideoRecording();
380-
381-
// Take Video
382-
await controller.startVideoRecording();
383-
await Future<void>.delayed(const Duration(milliseconds: 500));
384-
final XFile file = await controller.stopVideoRecording();
385-
386-
// Load video size
387-
final videoFile = File(file.path);
388-
389-
lengths.add(await videoFile.length());
390-
391-
await controller.dispose();
392-
}
393-
394-
for (var n = 0; n < lengths.length - 1; n++) {
395-
expect(
396-
lengths[n],
397-
lessThan(lengths[n + 1]),
398-
reason: 'incrementing video bitrate should increment file size',
399-
);
400-
}
401-
});
402-
403-
testWidgets('Control audio bitrate', (WidgetTester tester) async {
404-
final List<CameraDescription> cameras = await CameraPlatform.instance.availableCameras();
405-
if (cameras.isEmpty) {
406-
return;
407-
}
408-
409-
final lengths = <int>[];
410-
411-
const kiloBits = 1024;
412-
for (final audioBitrate in <int>[32 * kiloBits, 64 * kiloBits]) {
413-
final controller = CameraController.withSettings(
414-
cameras.first,
415-
mediaSettings: MediaSettings(
416-
resolutionPreset: ResolutionPreset.low,
417-
fps: 5,
418-
videoBitrate: 32000,
419-
audioBitrate: audioBitrate,
420-
enableAudio: true,
421-
),
422-
);
423-
await controller.initialize();
424-
await controller.prepareForVideoRecording();
425-
426-
// Take Video
427-
await controller.startVideoRecording();
428-
await Future<void>.delayed(const Duration(milliseconds: 1000));
429-
final XFile file = await controller.stopVideoRecording();
430-
431-
// Load video metadata
432-
final videoFile = File(file.path);
433-
434-
final int length = await videoFile.length();
435-
436-
lengths.add(length);
437-
438-
await controller.dispose();
439-
}
440-
441-
for (var n = 0; n < lengths.length - 1; n++) {
442-
expect(
443-
lengths[n],
444-
lessThan(lengths[n + 1]),
445-
reason: 'incrementing audio bitrate should increment file size',
446-
);
447-
}
448-
});
449-
});
450323
}

0 commit comments

Comments
 (0)