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

Commit 6905b343 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Parameterize VtsHalEvsV1_0TargetTest"

parents 90a34e51 b46adc94
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -25,8 +25,10 @@ cc_test {
    shared_libs: [
        "libui",
    ],
    static_libs: ["android.hardware.automotive.evs@1.0"],
    test_suites: ["general-tests"],
    static_libs: [
        "android.hardware.automotive.evs@1.0",
    ],
    test_suites: ["vts-core"],
    cflags: [
        "-O0",
        "-g",
+23 −47
Original line number Diff line number Diff line
@@ -17,15 +17,6 @@
#define LOG_TAG "VtsHalEvsTest"


// Note:  We have't got a great way to indicate which target
// should be tested, so we'll leave the interface served by the
// default (mock) EVS driver here for easy reference.  All
// actual EVS drivers should serve on the EvsEnumeratorHw name,
// however, so the code is checked in that way.
//const static char kEnumeratorName[]  = "EvsEnumeratorHw-Mock";
const static char kEnumeratorName[]  = "EvsEnumeratorHw";


// These values are called out in the EVS design doc (as of Mar 8, 2017)
static const int kMaxStreamStartMilliseconds = 500;
static const int kMinimumFramesPerSecond = 10;
@@ -53,8 +44,9 @@ static const float kNanoToSeconds = 0.000000001f;
#include <android/hardware/automotive/evs/1.0/IEvsCameraStream.h>
#include <android/hardware/automotive/evs/1.0/IEvsDisplay.h>

#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>

using namespace ::android::hardware::automotive::evs::V1_0;
using ::android::hardware::Return;
@@ -64,32 +56,19 @@ using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_string;
using ::android::sp;

// Test environment for Evs HIDL HAL.
class EvsHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
   public:
    // get the test environment singleton
    static EvsHidlEnvironment* Instance() {
        static EvsHidlEnvironment* instance = new EvsHidlEnvironment;
        return instance;
    }

    virtual void registerTestServices() override { registerTestService<IEvsEnumerator>(); }

   private:
    EvsHidlEnvironment() {}
};

// The main test class for EVS
class EvsHidlTest : public ::testing::VtsHalHidlTargetTestBase {
class EvsHidlTest : public ::testing::TestWithParam<std::string> {
public:
    virtual void SetUp() override {
        // Make sure we can connect to the enumerator
        string service_name =
            EvsHidlEnvironment::Instance()->getServiceName<IEvsEnumerator>(kEnumeratorName);
        pEnumerator = getService<IEvsEnumerator>(service_name);
        std::string service_name = GetParam();
        pEnumerator = IEvsEnumerator::getService(service_name);

        ASSERT_NE(pEnumerator.get(), nullptr);

        mIsHwModule = !service_name.compare(kEnumeratorName);
        // "default" is reserved for EVS manager.
        constexpr static char kEvsManagerName[] = "default";
        mIsHwModule = service_name.compare(kEvsManagerName);
    }

    virtual void TearDown() override {}
@@ -130,7 +109,7 @@ protected:
 * Opens each camera reported by the enumerator and then explicitly closes it via a
 * call to closeCamera.  Then repeats the test to ensure all cameras can be reopened.
 */
TEST_F(EvsHidlTest, CameraOpenClean) {
TEST_P(EvsHidlTest, CameraOpenClean) {
    ALOGI("Starting CameraOpenClean test");

    // Get the camera list
@@ -162,7 +141,7 @@ TEST_F(EvsHidlTest, CameraOpenClean) {
 * call.  This ensures that the intended "aggressive open" behavior works.  This is necessary for
 * the system to be tolerant of shutdown/restart race conditions.
 */
TEST_F(EvsHidlTest, CameraOpenAggressive) {
TEST_P(EvsHidlTest, CameraOpenAggressive) {
    ALOGI("Starting CameraOpenAggressive test");

    // Get the camera list
@@ -216,7 +195,7 @@ TEST_F(EvsHidlTest, CameraOpenAggressive) {
 * DisplayOpen:
 * Test both clean shut down and "aggressive open" device stealing behavior.
 */
TEST_F(EvsHidlTest, DisplayOpen) {
TEST_P(EvsHidlTest, DisplayOpen) {
    ALOGI("Starting DisplayOpen test");

    // Request exclusive access to the EVS display, then let it go
@@ -264,7 +243,7 @@ TEST_F(EvsHidlTest, DisplayOpen) {
 * Validate that display states transition as expected and can be queried from either the display
 * object itself or the owning enumerator.
 */
TEST_F(EvsHidlTest, DisplayStates) {
TEST_P(EvsHidlTest, DisplayStates) {
    ALOGI("Starting DisplayStates test");

    // Ensure the display starts in the expected state
@@ -324,7 +303,7 @@ TEST_F(EvsHidlTest, DisplayStates) {
 * CameraStreamPerformance:
 * Measure and qualify the stream start up time and streaming frame rate of each reported camera
 */
TEST_F(EvsHidlTest, CameraStreamPerformance) {
TEST_P(EvsHidlTest, CameraStreamPerformance) {
    ALOGI("Starting CameraStreamPerformance test");

    // Get the camera list
@@ -387,7 +366,7 @@ TEST_F(EvsHidlTest, CameraStreamPerformance) {
 * Ensure the camera implementation behaves properly when the client holds onto buffers for more
 * than one frame time.  The camera must cleanly skip frames until the client is ready again.
 */
TEST_F(EvsHidlTest, CameraStreamBuffering) {
TEST_P(EvsHidlTest, CameraStreamBuffering) {
    ALOGI("Starting CameraStreamBuffering test");

    // Arbitrary constant (should be > 1 and less than crazy)
@@ -456,7 +435,7 @@ TEST_F(EvsHidlTest, CameraStreamBuffering) {
 * imagery is simply copied to the display buffer and presented on screen.  This is the one test
 * which a human could observe to see the operation of the system on the physical display.
 */
TEST_F(EvsHidlTest, CameraToDisplayRoundTrip) {
TEST_P(EvsHidlTest, CameraToDisplayRoundTrip) {
    ALOGI("Starting CameraToDisplayRoundTrip test");

    // Get the camera list
@@ -517,7 +496,7 @@ TEST_F(EvsHidlTest, CameraToDisplayRoundTrip) {
 * Verify that each client can start and stop video streams on the same
 * underlying camera.
 */
TEST_F(EvsHidlTest, MultiCameraStream) {
TEST_P(EvsHidlTest, MultiCameraStream) {
    ALOGI("Starting MultiCameraStream test");

    if (mIsHwModule) {
@@ -601,11 +580,8 @@ TEST_F(EvsHidlTest, MultiCameraStream) {
}


int main(int argc, char** argv) {
    ::testing::AddGlobalTestEnvironment(EvsHidlEnvironment::Instance());
    ::testing::InitGoogleTest(&argc, argv);
    EvsHidlEnvironment::Instance()->init(&argc, argv);
    int status = RUN_ALL_TESTS();
    ALOGI("Test result = %d", status);
    return status;
}
INSTANTIATE_TEST_SUITE_P(
    PerInstance,
    EvsHidlTest,
    testing::ValuesIn(android::hardware::getAllHalInstanceNames(IEvsEnumerator::descriptor)),
    android::hardware::PrintInstanceNameToString);