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

Commit cc6ec7c4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10233678 from d6976527 to udc-release

Change-Id: I154bcae76b972f58d668c41dc7856c67ec10e98a
parents 2c4e51ff d6976527
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -134,6 +134,19 @@ int32_t TvInputAidlTest::getNumNotIn(vector<int32_t>& nums) {
    return result;
}

bool TvInputAidlTest::isValidHandle(NativeHandle& handle) {
    if (handle.fds.empty()) {
        return false;
    }
    for (size_t i = 0; i < handle.fds.size(); i++) {
        int fd = handle.fds[i].get();
        if (fcntl(fd, F_GETFL) < 0) {
            return false;
        }
    }
    return true;
}

/*
 * GetStreamConfigTest:
 * Calls updateStreamConfigurations() for each existing device
@@ -168,6 +181,8 @@ TEST_P(TvInputAidlTest, OpenAndCloseStreamTest) {
            ALOGD("OpenAndCloseStreamTest: open stream, device_id=%d, stream_id=%d", device_id,
                  stream_id);
            ASSERT_TRUE(tv_input_->openStream(device_id, stream_id, &handle).isOk());
            ASSERT_TRUE(isValidHandle(handle));

            ALOGD("OpenAndCloseStreamTest: close stream, device_id=%d, stream_id=%d", device_id,
                  stream_id);
            ASSERT_TRUE(tv_input_->closeStream(device_id, stream_id).isOk());
@@ -268,6 +283,7 @@ TEST_P(TvInputAidlTest, OpenAnOpenedStreamsTest) {

    ALOGD("OpenAnOpenedStreamsTest: open stream, device_id=%d, stream_id=%d", device_id, stream_id);
    ASSERT_TRUE(tv_input_->openStream(device_id, stream_id, &handle).isOk());
    ASSERT_TRUE(isValidHandle(handle));

    ALOGD("OpenAnOpenedStreamsTest: open stream, device_id=%d, stream_id=%d", device_id, stream_id);
    ASSERT_TRUE(tv_input_->openStream(device_id, stream_id, &handle).getServiceSpecificError() ==
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

#include <android/binder_manager.h>
#include <fcntl.h>

#include <aidl/Gtest.h>
#include <aidl/Vintf.h>
@@ -84,6 +85,9 @@ class TvInputAidlTest : public testing::TestWithParam<string> {
     */
    int32_t getNumNotIn(vector<int32_t>& nums);

    /* Checks if a native handle contains valid file descriptor(s). */
    bool isValidHandle(NativeHandle& handle);

  protected:
    shared_ptr<ITvInput> tv_input_;
    shared_ptr<TvInputCallback> tv_input_callback_;