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

Commit 1d636af1 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge " Convert VtsHalCasV1_2TargetTest to parameterized gtest" into rvc-dev am: b74b76cc

Change-Id: I26098815770c39f9e1687c683c04496f3f2f6fb1
parents 29afdcdc b74b76cc
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ cc_test {
    shared_libs: [
        "libbinder",
    ],
    test_suites: ["general-tests"],
    test_suites: [
        "general-tests",
        "vts-core",
    ],
}
+11 −27
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

#define LOG_TAG "mediacas_hidl_hal_test"

#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/cas/1.0/IDescramblerBase.h>
#include <android/hardware/cas/1.0/types.h>
@@ -28,8 +26,11 @@
#include <android/hardware/cas/native/1.0/IDescrambler.h>
#include <android/hardware/cas/native/1.0/types.h>
#include <binder/MemoryDealer.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/HidlSupport.h>
#include <hidl/HidlTransportSupport.h>
#include <hidl/ServiceManagement.h>
#include <hidl/Status.h>
#include <hidlmemory/FrameworkUtils.h>
#include <utils/Condition.h>
@@ -293,27 +294,14 @@ void MediaCasListener::testStatusUpdate(sp<ICas>& mediaCas, std::vector<uint8_t>
    EXPECT_EQ(mEventArg, static_cast<int32_t>(mode));
}

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

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

class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase {
class MediaCasHidlTest : public testing::TestWithParam<std::string> {
  public:
    virtual void SetUp() override {
        mService = ::testing::VtsHalHidlTargetTestBase::getService<IMediaCasService>(
                CasHidlEnvironment::Instance()->getServiceName<IMediaCasService>());
        mService = IMediaCasService::getService(GetParam());
        ASSERT_NE(mService, nullptr);
    }

    sp<IMediaCasService> mService;
    sp<IMediaCasService> mService = nullptr;

  protected:
    static void description(const std::string& description) {
@@ -497,7 +485,7 @@ class MediaCasHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    return ::testing::AssertionResult(returnVoid.isOk());
}

TEST_F(MediaCasHidlTest, TestClearKeyApisWithSession) {
TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
    description("Test that valid call sequences with SessionEvent send and receive");

    ASSERT_TRUE(createCasPlugin(CLEAR_KEY_SYSTEM_ID));
@@ -609,11 +597,7 @@ TEST_F(MediaCasHidlTest, TestClearKeyApisWithSession) {

}  // anonymous namespace

int main(int argc, char** argv) {
    ::testing::AddGlobalTestEnvironment(CasHidlEnvironment::Instance());
    ::testing::InitGoogleTest(&argc, argv);
    CasHidlEnvironment::Instance()->init(&argc, argv);
    int status = RUN_ALL_TESTS();
    LOG(INFO) << "Test result = " << status;
    return status;
}
INSTANTIATE_TEST_SUITE_P(
        PerInstance, MediaCasHidlTest,
        testing::ValuesIn(android::hardware::getAllHalInstanceNames(IMediaCasService::descriptor)),
        android::hardware::PrintInstanceNameToString);