summaryrefslogtreecommitdiffstats
path: root/tests/camera2
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2012-12-18 16:06:07 -0800
committerIgor Murashkin <iam@google.com>2012-12-20 16:39:44 -0800
commit599b76fec79b9ed111676bed9004c35ab8c5adea (patch)
tree2c8126ad8a76ee96a5d324886bb7fc3414e37a8b /tests/camera2
parent0a7a430a81b97b09f42b56ab85de24d0ca711520 (diff)
downloadhardware_libhardware-599b76fec79b9ed111676bed9004c35ab8c5adea.zip
hardware_libhardware-599b76fec79b9ed111676bed9004c35ab8c5adea.tar.gz
hardware_libhardware-599b76fec79b9ed111676bed9004c35ab8c5adea.tar.bz2
Camera2: Tests: Fix Camera2Test to be correct.
- Requests were missing control type (capture vs reprocess) - Not waiting for streams to be drained before disconnecting (sporadic fails) Change-Id: Iab218b89a663db6dc26d791a390d0e11667f6889
Diffstat (limited to 'tests/camera2')
-rw-r--r--tests/camera2/camera2.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/camera2/camera2.cpp b/tests/camera2/camera2.cpp
index 75ec73f..de5b8c6 100644
--- a/tests/camera2/camera2.cpp
+++ b/tests/camera2/camera2.cpp
@@ -283,6 +283,26 @@ class Camera2Test: public testing::Test {
*count = availableSizes.count;
}
+ status_t waitUntilDrained() {
+ static const uint32_t kSleepTime = 50000; // 50 ms
+ static const uint32_t kMaxSleepTime = 10000000; // 10 s
+ ALOGV("%s: Camera %d: Starting wait", __FUNCTION__, mId);
+
+ // TODO: Set up notifications from HAL, instead of sleeping here
+ uint32_t totalTime = 0;
+ while (mDevice->ops->get_in_progress_count(mDevice) > 0) {
+ usleep(kSleepTime);
+ totalTime += kSleepTime;
+ if (totalTime > kMaxSleepTime) {
+ ALOGE("%s: Waited %d us, %d requests still in flight", __FUNCTION__,
+ mDevice->ops->get_in_progress_count(mDevice), totalTime);
+ return TIMED_OUT;
+ }
+ }
+ ALOGV("%s: Camera %d: HAL is idle", __FUNCTION__, mId);
+ return OK;
+ }
+
virtual void SetUp() {
TEST_EXTENSION_FORKING_SET_UP;
@@ -408,6 +428,10 @@ TEST_F(Camera2Test, Capture1Raw) {
add_camera_metadata_entry(request,
ANDROID_SENSOR_SENSITIVITY,
(void**)&sensitivity, 1);
+ uint8_t requestType = ANDROID_REQUEST_TYPE_CAPTURE;
+ add_camera_metadata_entry(request,
+ ANDROID_REQUEST_TYPE,
+ (void**)&requestType, 1);
uint32_t hourOfDay = 12;
add_camera_metadata_entry(request,
@@ -460,6 +484,7 @@ TEST_F(Camera2Test, Capture1Raw) {
res = rawConsumer->unlockBuffer(buffer);
ASSERT_EQ(NO_ERROR, res);
+ ASSERT_EQ(OK, waitUntilDrained());
ASSERT_NO_FATAL_FAILURE(disconnectStream(streamId));
res = closeCameraDevice(mDevice);
@@ -521,6 +546,10 @@ TEST_F(Camera2Test, CaptureBurstRaw) {
add_camera_metadata_entry(request,
ANDROID_SENSOR_SENSITIVITY,
(void**)&sensitivity, 1);
+ uint8_t requestType = ANDROID_REQUEST_TYPE_CAPTURE;
+ add_camera_metadata_entry(request,
+ ANDROID_REQUEST_TYPE,
+ (void**)&requestType, 1);
uint32_t hourOfDay = 12;
add_camera_metadata_entry(request,
@@ -690,6 +719,10 @@ TEST_F(Camera2Test, Capture1Jpeg) {
add_camera_metadata_entry(request,
ANDROID_SENSOR_SENSITIVITY,
(void**)&sensitivity, 1);
+ uint8_t requestType = ANDROID_REQUEST_TYPE_CAPTURE;
+ add_camera_metadata_entry(request,
+ ANDROID_REQUEST_TYPE,
+ (void**)&requestType, 1);
uint32_t hourOfDay = 12;
add_camera_metadata_entry(request,
@@ -742,6 +775,7 @@ TEST_F(Camera2Test, Capture1Jpeg) {
res = jpegConsumer->unlockBuffer(buffer);
ASSERT_EQ(NO_ERROR, res);
+ ASSERT_EQ(OK, waitUntilDrained());
ASSERT_NO_FATAL_FAILURE(disconnectStream(streamId));
res = closeCameraDevice(mDevice);