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

Commit 4bf91c7e authored by Avichal Rakesh's avatar Avichal Rakesh
Browse files

Camera VTS: Fix incorrect return value check

The AIDL interface specificies that ICameraProvider::setCallback should
return Status::ILLEGAL_ARGUMENT if the provided callback is null. The
setCallback test incorrectly checked for the return value to be OK
instead.

This CL fixes the test to check for ILLEGAL_ARGUMENT and removes setting
callback to null from setTorchMode test. In addition it fixes
`setCallback` test to use Bn* variant of ICameraProviderCallback to
ensure that the object makes it through the binder.

Bug: 233221359
Test: atest VtsAidlHalCameraProvider_TargetTest
Change-Id: Ia33226b15efd9628bf8e1b53ec2a3012b08eaaac
parent 412f907b
Loading
Loading
Loading
Loading
+4 −7
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ using ::aidl::android::hardware::camera::device::ICameraDevice;
using ::aidl::android::hardware::camera::metadata::RequestAvailableDynamicRangeProfilesMap;
using ::aidl::android::hardware::camera::metadata::RequestAvailableDynamicRangeProfilesMap;
using ::aidl::android::hardware::camera::metadata::SensorPixelMode;
using ::aidl::android::hardware::camera::metadata::SensorPixelMode;
using ::aidl::android::hardware::camera::provider::CameraIdAndStreamCombination;
using ::aidl::android::hardware::camera::provider::CameraIdAndStreamCombination;
using ::aidl::android::hardware::camera::provider::ICameraProviderCallbackDefault;
using ::aidl::android::hardware::camera::provider::BnCameraProviderCallback;


using ::ndk::ScopedAStatus;
using ::ndk::ScopedAStatus;


@@ -86,7 +86,7 @@ TEST_P(CameraAidlTest, getVendorTags) {


// Test if ICameraProvider::setCallback returns Status::OK
// Test if ICameraProvider::setCallback returns Status::OK
TEST_P(CameraAidlTest, setCallback) {
TEST_P(CameraAidlTest, setCallback) {
    struct ProviderCb : public ICameraProviderCallbackDefault {
    struct ProviderCb : public BnCameraProviderCallback {
        ScopedAStatus cameraDeviceStatusChange(const std::string& cameraDeviceName,
        ScopedAStatus cameraDeviceStatusChange(const std::string& cameraDeviceName,
                                               CameraDeviceStatus newStatus) override {
                                               CameraDeviceStatus newStatus) override {
            ALOGI("camera device status callback name %s, status %d", cameraDeviceName.c_str(),
            ALOGI("camera device status callback name %s, status %d", cameraDeviceName.c_str(),
@@ -109,11 +109,11 @@ TEST_P(CameraAidlTest, setCallback) {
        }
        }
    };
    };


    std::shared_ptr<ProviderCb> cb = ProviderCb::make<ProviderCb>();
    std::shared_ptr<ProviderCb> cb = ndk::SharedRefBase::make<ProviderCb>();
    ScopedAStatus ret = mProvider->setCallback(cb);
    ScopedAStatus ret = mProvider->setCallback(cb);
    ASSERT_TRUE(ret.isOk());
    ASSERT_TRUE(ret.isOk());
    ret = mProvider->setCallback(nullptr);
    ret = mProvider->setCallback(nullptr);
    ASSERT_TRUE(ret.isOk());
    ASSERT_EQ(static_cast<int32_t>(Status::ILLEGAL_ARGUMENT), ret.getServiceSpecificError());
}
}


// Test if ICameraProvider::getCameraDeviceInterface returns Status::OK and non-null device
// Test if ICameraProvider::getCameraDeviceInterface returns Status::OK and non-null device
@@ -399,9 +399,6 @@ TEST_P(CameraAidlTest, setTorchMode) {
            }
            }
        }
        }
    }
    }

    ret = mProvider->setCallback(nullptr);
    ASSERT_TRUE(ret.isOk());
}
}


// Check dump functionality.
// Check dump functionality.