From a36381479c5c546a01188390f1e0d2e280a3dbd8 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Wed, 20 Mar 2013 15:56:31 -0700 Subject: Camera: Add hotplug support (for fixed # of cameras) * Minor: also change addListener to fire the current status upon subscription * Minor: STATUS_AVAILABLE is now an alias for STATUS_PRESENT and deprecated Change-Id: I254608a7332095e3ef201ffea64cff156cfc1b3e --- camera/tests/ProCameraTests.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'camera') diff --git a/camera/tests/ProCameraTests.cpp b/camera/tests/ProCameraTests.cpp index ecc0854..5f8f772 100644 --- a/camera/tests/ProCameraTests.cpp +++ b/camera/tests/ProCameraTests.cpp @@ -587,14 +587,19 @@ TEST_F(ProCameraTest, DISABLED_StreamingImageSingle) { sp listener = new ServiceListener(); EXPECT_OK(ProCamera::addServiceListener(listener)); - ServiceListener::Status currentStatus = ServiceListener::STATUS_AVAILABLE; + ServiceListener::Status currentStatus; + + // when subscribing a new listener, + // we immediately get a callback to the current status + while (listener->waitForStatusChange(/*out*/currentStatus) != OK); + EXPECT_EQ(ServiceListener::STATUS_PRESENT, currentStatus); dout << "Will now stream and resume infinitely..." << std::endl; while (true) { - if (currentStatus == ServiceListener::STATUS_AVAILABLE) { + if (currentStatus == ServiceListener::STATUS_PRESENT) { - EXPECT_OK(mCamera->createStream(mDisplayW, mDisplayH, mDisplayFmt, + ASSERT_OK(mCamera->createStream(mDisplayW, mDisplayH, mDisplayFmt, surface, &depthStreamId)); EXPECT_NE(-1, depthStreamId); @@ -613,12 +618,15 @@ TEST_F(ProCameraTest, DISABLED_StreamingImageSingle) { while (listener->waitForStatusChange(/*out*/stat) != OK); if (currentStatus != stat) { - if (stat == ServiceListener::STATUS_AVAILABLE) { + if (stat == ServiceListener::STATUS_PRESENT) { dout << "Reconnecting to camera" << std::endl; mCamera = ProCamera::connect(CAMERA_ID); } else if (stat == ServiceListener::STATUS_NOT_AVAILABLE) { dout << "Disconnecting from camera" << std::endl; mCamera->disconnect(); + } else if (stat == ServiceListener::STATUS_NOT_PRESENT) { + dout << "Camera unplugged" << std::endl; + mCamera = NULL; } else { dout << "Unknown status change " << std::hex << stat << std::endl; @@ -1216,7 +1224,7 @@ TEST_F(ProCameraTest, ServiceListenersFunctional) { } EXPECT_OK(listener->waitForStatusChange(/*out*/stat)); - EXPECT_EQ(ServiceListener::STATUS_AVAILABLE, stat); + EXPECT_EQ(ServiceListener::STATUS_PRESENT, stat); EXPECT_OK(ProCamera::removeServiceListener(listener)); } -- cgit v1.1