Add missing NNAPI HIDL interface mock tests am: 7b0b54697c am: faa3ea2821

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1640841

Change-Id: Ie788e56dd6783834732acd98e320d5ea6397e1f2
This commit is contained in:
Lev Proleev 2021-03-16 22:17:25 +00:00 committed by Automerger Merge Worker
commit 7e21641013
2 changed files with 36 additions and 2 deletions

View file

@ -772,7 +772,7 @@ TEST(DeviceTest, prepareModelFromCache) {
EXPECT_NE(result.value(), nullptr);
}
TEST(DeviceTest, prepareModelFromCacheError) {
TEST(DeviceTest, prepareModelFromCacheLaunchError) {
// setup call
const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice).value();
@ -790,6 +790,23 @@ TEST(DeviceTest, prepareModelFromCacheError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
}
TEST(DeviceTest, prepareModelFromCacheReturnError) {
// setup call
const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModelFromCache(_, _, _, _))
.Times(1)
.WillOnce(Invoke(makePreparedModelFromCacheReturn(
V1_0::ErrorStatus::NONE, V1_0::ErrorStatus::GENERAL_FAILURE, nullptr)));
// run test
const auto result = device->prepareModelFromCache({}, {}, {}, {});
// verify result
ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
}
TEST(DeviceTest, prepareModelFromCacheNullptrError) {
// setup call
const auto mockDevice = createMockDevice();

View file

@ -794,7 +794,7 @@ TEST(DeviceTest, prepareModelFromCache) {
EXPECT_NE(result.value(), nullptr);
}
TEST(DeviceTest, prepareModelFromCacheError) {
TEST(DeviceTest, prepareModelFromCacheLaunchError) {
// setup call
const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice).value();
@ -812,6 +812,23 @@ TEST(DeviceTest, prepareModelFromCacheError) {
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
}
TEST(DeviceTest, prepareModelFromCacheReturnError) {
// setup call
const auto mockDevice = createMockDevice();
const auto device = Device::create(kName, mockDevice).value();
EXPECT_CALL(*mockDevice, prepareModelFromCache_1_3(_, _, _, _, _))
.Times(1)
.WillOnce(Invoke(makePreparedModelFromCacheReturn(
V1_3::ErrorStatus::NONE, V1_3::ErrorStatus::GENERAL_FAILURE, nullptr)));
// run test
const auto result = device->prepareModelFromCache({}, {}, {}, {});
// verify result
ASSERT_FALSE(result.has_value());
EXPECT_EQ(result.error().code, nn::ErrorStatus::GENERAL_FAILURE);
}
TEST(DeviceTest, prepareModelFromCacheNullptrError) {
// setup call
const auto mockDevice = createMockDevice();