Files
android/libwvdrmengine/include/WVTypes.h
Alex Dale 52bd76e0e2 Fixed test and log formatting for CdmResponseType.
[ Merge of http://go/wvgerrit/168397 ]

When CdmResponseType (enum) was transformed to CdmResponseType
(struct), the test printers where not updated to print the result
of failed comparisons.  In addition, several logs statements were
updated haphazardly, leaving inconsistencies and potential
compiler-specific behavior.

This CL replaces CdmResponseType std::string operator with a ToString()
method.  This is to make it consistent with Google's C++ style guide
on conversion operators vs methods.  The string conversion function is
now defined in wv_cdm_types.cpp instead of inline in the header file.

The PrintTo function has been implemented along with the other CDM
test printers in test_printers.cpp.

Bug: 273989359
Test: run_x86_64_tests
Test: MediaDrmParameterizedTests on redfin
Test: Forrest drm_compliance
Change-Id: Ibfaa17029046b75b1c8c278f7bd7e04a24379848
2023-03-27 11:21:45 -07:00

56 lines
1.6 KiB
C++

//
// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_TYPES_H_
#define WV_TYPES_H_
#include <aidl/android/hardware/drm/Status.h>
#include "wv_cdm_types.h"
namespace wvdrm {
using AidlDrmStatus = ::aidl::android::hardware::drm::Status;
#define WVDRM_DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
#define WVDRM_DISALLOW_COPY_AND_ASSIGN_AND_NEW(TypeName) \
TypeName() = delete; \
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
struct WvStatus {
public:
explicit WvStatus(AidlDrmStatus status) : mStatus(status) {}
WvStatus() : mStatus(AidlDrmStatus::OK) {}
WvStatus(AidlDrmStatus status, wvcdm::CdmResponseType cdmErr)
: mStatus(status), mCdmErr(cdmErr) {}
explicit operator AidlDrmStatus() const { return mStatus; }
explicit operator int32_t() const { return static_cast<int32_t>(mStatus); }
AidlDrmStatus get() const { return mStatus; }
bool operator==(const AidlDrmStatus other) const { return mStatus == other; }
bool operator!=(const AidlDrmStatus other) const { return mStatus != other; }
WvStatus &setCdmErr(wvcdm::CdmResponseType cdmErr) {
mCdmErr = cdmErr;
return *this;
}
const wvcdm::CdmResponseType& getCdmErr() const { return mCdmErr; }
private:
AidlDrmStatus mStatus{};
wvcdm::CdmResponseType mCdmErr{};
};
} // namespace wvdrm
#endif // WV_TYPES_H_