Skip to content
Prev Previous commit
Next Next commit
reverted skipping camera integration tests
  • Loading branch information
jesswrd committed Nov 18, 2024
commit 11d164e0c31eac20661112c36e11d989fa797a3e
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ void main() {
await controller.dispose();
}
}
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
});

// This tests that the capture is no bigger than the preset, since we have
// automatic code to fall back to smaller sizes when we need to. Returns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ void main() {
await controller.dispose();
}
}
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
});

// This tests that the capture is no bigger than the preset, since we have
// automatic code to fall back to smaller sizes when we need to. Returns
Expand Down Expand Up @@ -199,9 +197,7 @@ void main() {
await videoController.dispose();

expect(duration, lessThan(recordingTime - timePaused));
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
});

testWidgets('Set description while recording', (WidgetTester tester) async {
final List<CameraDescription> cameras =
Expand Down Expand Up @@ -238,9 +234,7 @@ void main() {
// cameras switched
expect(controller.description, cameras[1]);
}
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
});

testWidgets('Set description', (WidgetTester tester) async {
final List<CameraDescription> cameras =
Expand All @@ -255,79 +249,79 @@ void main() {
await controller.setDescription(cameras[1]);

expect(controller.description, cameras[1]);
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);

testWidgets('image streaming', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
if (cameras.isEmpty) {
return;
}

final CameraController controller = CameraController(cameras[0]);

await controller.initialize();
bool isDetecting = false;
});

await controller.startImageStream((CameraImageData image) {
if (isDetecting) {
testWidgets(
'image streaming',
(WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
if (cameras.isEmpty) {
return;
}

isDetecting = true;
final CameraController controller = CameraController(cameras[0]);

expectLater(image, isNotNull).whenComplete(() => isDetecting = false);
});
await controller.initialize();
bool isDetecting = false;

expect(controller.value.isStreamingImages, true);
await controller.startImageStream((CameraImageData image) {
if (isDetecting) {
return;
}

sleep(const Duration(milliseconds: 500));
isDetecting = true;

await controller.stopImageStream();
await controller.dispose();
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
expectLater(image, isNotNull).whenComplete(() => isDetecting = false);
});

testWidgets('recording with image stream', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
if (cameras.isEmpty) {
return;
}
expect(controller.value.isStreamingImages, true);

final CameraController controller = CameraController(cameras[0]);
sleep(const Duration(milliseconds: 500));

await controller.initialize();
bool isDetecting = false;
await controller.stopImageStream();
await controller.dispose();
},
);

await controller.startVideoRecording(
streamCallback: (CameraImageData image) {
if (isDetecting) {
testWidgets(
'recording with image stream',
(WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
if (cameras.isEmpty) {
return;
}

isDetecting = true;
final CameraController controller = CameraController(cameras[0]);

expectLater(image, isNotNull);
});
await controller.initialize();
bool isDetecting = false;

await controller.startVideoRecording(
streamCallback: (CameraImageData image) {
if (isDetecting) {
return;
}

expect(controller.value.isStreamingImages, true);
isDetecting = true;

// Stopping recording before anything is recorded will throw, per
// https://developer.android.com/reference/android/media/MediaRecorder.html#stop()
// so delay long enough to ensure that some data is recorded.
await Future<void>.delayed(const Duration(seconds: 2));
expectLater(image, isNotNull);
});

await controller.stopVideoRecording();
await controller.dispose();
expect(controller.value.isStreamingImages, true);

expect(controller.value.isStreamingImages, false);
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
// Stopping recording before anything is recorded will throw, per
// https://developer.android.com/reference/android/media/MediaRecorder.html#stop()
// so delay long enough to ensure that some data is recorded.
await Future<void>.delayed(const Duration(seconds: 2));

await controller.stopVideoRecording();
await controller.dispose();

expect(controller.value.isStreamingImages, false);
},
);

group('Camera settings', () {
Future<CameraDescription> getCamera() async {
Expand Down Expand Up @@ -463,7 +457,5 @@ void main() {
expect(lengths[n], greaterThan(0));
}
});
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ void main() {
await controller.dispose();
}
}
},
// TODO(camillesimon): Re-enable test when issue is fixed https://github.com/flutter/flutter/issues/154682.
skip: true);
});

testWidgets('Preview takes expected resolution from preset',
(WidgetTester tester) async {
Expand Down