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

Commit 53d2ebb0 authored by Yu Shan's avatar Yu Shan Committed by Android Build Cherrypicker Worker
Browse files

Fix Vts VUR test case.

It is not guaranteed that VHAL will send the initial value event
if VUR is on. In fact, car property service explicitly calls getValue
to generate the initial value event. Hence, if VUR is on, our test
case should allow situation where no event is generated.

Test: atest VtsHalAutomotiveVehicle_TargetTest
Bug: 334803613
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:bb7e7ae36c82dbdd6e4188ce01e2748e002d1377)
Merged-In: Id924fdd2a407b1a076102c4dd57efc6043cde359
Change-Id: Id924fdd2a407b1a076102c4dd57efc6043cde359
parent ab18a3b5
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -603,6 +603,7 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribe_enableVurIfSupported) {
                     << "skip testing";
                     << "skip testing";
    }
    }


    // Subscribe to PERF_VEHICLE_SPEED using the max sample rate.
    auto client = mVhalClient->getSubscriptionClient(mCallback);
    auto client = mVhalClient->getSubscriptionClient(mCallback);
    ASSERT_NE(client, nullptr) << "Failed to get subscription client";
    ASSERT_NE(client, nullptr) << "Failed to get subscription client";
    SubscribeOptionsBuilder builder(propId);
    SubscribeOptionsBuilder builder(propId);
@@ -616,18 +617,17 @@ TEST_P(VtsHalAutomotiveVehicleTargetTest, subscribe_enableVurIfSupported) {
                                             ", error: %s",
                                             ", error: %s",
                                             propId, result.error().message().c_str());
                                             propId, result.error().message().c_str());


    ASSERT_TRUE(mCallback->waitForExpectedEvents(propId, 1, std::chrono::seconds(2)))
            << "Must get at least 1 events within 2 seconds after subscription for rate: "
            << maxSampleRate;

    // Sleep for 1 seconds to wait for more possible events to arrive.
    // Sleep for 1 seconds to wait for more possible events to arrive.
    std::this_thread::sleep_for(std::chrono::seconds(1));
    std::this_thread::sleep_for(std::chrono::seconds(1));


    client->unsubscribe({propId});
    client->unsubscribe({propId});


    auto events = mCallback->getEvents(propId);
    auto events = mCallback->getEvents(propId);
    if (events.size() == 1) {
    if (events.size() <= 1) {
        // We only received one event, the value is not changing so nothing to check here.
        // We received 0 or 1 event, the value is not changing so nothing to check here.
        // If all VHAL clients are subscribing to PERF_VEHICLE_SPEED with VUR on, then we
        // will receive 0 event. If there are other VHAL clients subscribing to PERF_VEHICLE_SPEED
        // with VUR off, then we will receive 1 event which is the initial value.
        return;
        return;
    }
    }