summaryrefslogtreecommitdiff
path: root/neuralnetworks/1.3/utils/test/DeviceTest.cpp
diff options
context:
space:
mode:
authorLev Proleev <levp@google.com>2021-03-08 10:46:33 +0000
committerXusong Wang <xusongw@google.com>2021-03-16 11:56:47 -0700
commit7b0b54697cf9d9f9afbf4d4c97bd5292057c732e (patch)
treee40f13f61d094dffa2afcb6c5b5472ac5001241c /neuralnetworks/1.3/utils/test/DeviceTest.cpp
parent5cfbacbb7c0f5232710e901046d60a50662fac4e (diff)
Add missing NNAPI HIDL interface mock tests
prepareModelFromCache* was tested for handling of errors happening during the preparation launch but not during the actual preparation. Bug: 163801800 Test: mma Test: atest neuralnetworks_utils_hal_common_test Test: atest neuralnetworks_utils_hal_1_[0-3]_test Change-Id: I2c4b235fd4877238d7a18be8b0ea051434c1df6b Merged-In: I2c4b235fd4877238d7a18be8b0ea051434c1df6b (cherry picked from commit c6cf50ad425d60796da6a326f5d5515fb3b28fc0)
Diffstat (limited to 'neuralnetworks/1.3/utils/test/DeviceTest.cpp')
-rw-r--r--neuralnetworks/1.3/utils/test/DeviceTest.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/neuralnetworks/1.3/utils/test/DeviceTest.cpp b/neuralnetworks/1.3/utils/test/DeviceTest.cpp
index f260990471..2d1b2f295a 100644
--- a/neuralnetworks/1.3/utils/test/DeviceTest.cpp
+++ b/neuralnetworks/1.3/utils/test/DeviceTest.cpp
@@ -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();