Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f415f561 authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera VTS: Improve test for torch callback

Test below sequence:
- ICameraProvider::setCallback
- setTorchMode(on)
- verify torch mode on callback is received
- ICameraProvider::setCallback
- verify torch mode on callback is received again

This makes sure if torch is on, a new callback registration will trigger
a flash-on callback.

Test: atest VtsAidlHalCameraProvider_TargetTest
Bug: 247038031
Change-Id: I6cea64fcd08fd68fda78b3c0efb7763b7de6edbc
parent a461a198
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -386,6 +386,22 @@ TEST_P(CameraAidlTest, setTorchMode) {
                mTorchStatus = TorchModeStatus::NOT_AVAILABLE;
            }

            // register a new callback; make sure it receives the
            // flash-on callback.
            std::shared_ptr<TorchProviderCb> cb2 = ndk::SharedRefBase::make<TorchProviderCb>(this);
            ret = mProvider->setCallback(cb2);
            ASSERT_TRUE(ret.isOk());
            ASSERT_NE(cb2, nullptr);
            {
                std::unique_lock<std::mutex> l(mTorchLock);
                while (TorchModeStatus::NOT_AVAILABLE == mTorchStatus) {
                    auto timeout = std::chrono::system_clock::now() +
                                   std::chrono::seconds(kTorchTimeoutSec);
                    ASSERT_NE(std::cv_status::timeout, mTorchCond.wait_until(l, timeout));
                }
                ASSERT_EQ(TorchModeStatus::AVAILABLE_ON, mTorchStatus);
            }

            ret = device->setTorchMode(false);
            ASSERT_TRUE(ret.isOk());
            {