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

Commit 85a2aefa authored by Jan Sebechlebsky's avatar Jan Sebechlebsky
Browse files

Explicitly define default actions for mocks in VirtualCameraSessionTest.

GMock will by default use the ScopedAStatus constructor, which will
construct ScopedAStatus wrapping nullptr status and crash when
someone attempts to print it using << operator (which gunit does).

Bug: 25482184
Test: atest virtual_camera_tests
Change-Id: I34013792941f90fcab9680bafec9c3b5f95c7880
parent 596327a6
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -113,10 +113,25 @@ class VirtualCameraSessionTest : public ::testing::Test {
        *mVirtualCameraDevice, mMockCameraDeviceCallback,
        mMockVirtualCameraClientCallback);

    // Explicitly defining default actions below to prevent gmock from
    // default-constructing ndk::ScopedAStatus, because default-constructed
    // status wraps nullptr AStatus and causes crash when attempting to print
    // it in gtest report.
    ON_CALL(*mMockCameraDeviceCallback, notify)
        .WillByDefault(ndk::ScopedAStatus::ok);
    ON_CALL(*mMockCameraDeviceCallback, processCaptureResult)
        .WillByDefault(ndk::ScopedAStatus::ok);
    ON_CALL(*mMockCameraDeviceCallback, requestStreamBuffers)
        .WillByDefault(ndk::ScopedAStatus::ok);
    ON_CALL(*mMockCameraDeviceCallback, returnStreamBuffers)
        .WillByDefault(ndk::ScopedAStatus::ok);

    ON_CALL(*mMockVirtualCameraClientCallback, onStreamConfigured)
        .WillByDefault(ndk::ScopedAStatus::ok);
    ON_CALL(*mMockVirtualCameraClientCallback, onProcessCaptureRequest)
        .WillByDefault(ndk::ScopedAStatus::ok);
    ON_CALL(*mMockVirtualCameraClientCallback, onStreamClosed)
        .WillByDefault(ndk::ScopedAStatus::ok);
  }

 protected: