Lev Proleev | 900c28a | 2021-01-26 19:40:20 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Michael Butler | 8414a6e | 2021-03-10 18:41:05 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_TEST_MOCK_DEVICE_H |
| 18 | #define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_TEST_MOCK_DEVICE_H |
Lev Proleev | 900c28a | 2021-01-26 19:40:20 +0000 | [diff] [blame] | 19 | |
| 20 | #include <aidl/android/hardware/neuralnetworks/BnDevice.h> |
| 21 | #include <android/binder_auto_utils.h> |
| 22 | #include <android/binder_interface_utils.h> |
| 23 | #include <gmock/gmock.h> |
| 24 | #include <gtest/gtest.h> |
| 25 | |
| 26 | namespace aidl::android::hardware::neuralnetworks::utils { |
| 27 | |
| 28 | class MockDevice final : public BnDevice { |
| 29 | public: |
| 30 | static std::shared_ptr<MockDevice> create(); |
| 31 | |
| 32 | MOCK_METHOD(ndk::ScopedAStatus, allocate, |
| 33 | (const BufferDesc& desc, const std::vector<IPreparedModelParcel>& preparedModels, |
| 34 | const std::vector<BufferRole>& inputRoles, |
| 35 | const std::vector<BufferRole>& outputRoles, DeviceBuffer* deviceBuffer), |
| 36 | (override)); |
| 37 | MOCK_METHOD(ndk::ScopedAStatus, getCapabilities, (Capabilities * capabilities), (override)); |
| 38 | MOCK_METHOD(ndk::ScopedAStatus, getNumberOfCacheFilesNeeded, |
| 39 | (NumberOfCacheFiles * numberOfCacheFiles), (override)); |
| 40 | MOCK_METHOD(ndk::ScopedAStatus, getSupportedExtensions, (std::vector<Extension> * extensions), |
| 41 | (override)); |
| 42 | MOCK_METHOD(ndk::ScopedAStatus, getSupportedOperations, |
| 43 | (const Model& model, std::vector<bool>* supportedOperations), (override)); |
| 44 | MOCK_METHOD(ndk::ScopedAStatus, getType, (DeviceType * deviceType), (override)); |
| 45 | MOCK_METHOD(ndk::ScopedAStatus, getVersionString, (std::string * version), (override)); |
| 46 | MOCK_METHOD(ndk::ScopedAStatus, prepareModel, |
| 47 | (const Model& model, ExecutionPreference preference, Priority priority, |
| 48 | int64_t deadline, const std::vector<ndk::ScopedFileDescriptor>& modelCache, |
| 49 | const std::vector<ndk::ScopedFileDescriptor>& dataCache, |
| 50 | const std::vector<uint8_t>& token, |
| 51 | const std::shared_ptr<IPreparedModelCallback>& callback), |
| 52 | (override)); |
Miao Wang | b5c8a82 | 2021-10-26 20:03:05 +0000 | [diff] [blame] | 53 | MOCK_METHOD(ndk::ScopedAStatus, prepareModelWithConfig, |
| 54 | (const Model& model, const PrepareModelConfig& config, |
| 55 | const std::shared_ptr<IPreparedModelCallback>& callback), |
| 56 | (override)); |
Lev Proleev | 900c28a | 2021-01-26 19:40:20 +0000 | [diff] [blame] | 57 | MOCK_METHOD(ndk::ScopedAStatus, prepareModelFromCache, |
| 58 | (int64_t deadline, const std::vector<ndk::ScopedFileDescriptor>& modelCache, |
| 59 | const std::vector<ndk::ScopedFileDescriptor>& dataCache, |
| 60 | const std::vector<uint8_t>& token, |
| 61 | const std::shared_ptr<IPreparedModelCallback>& callback), |
| 62 | (override)); |
| 63 | }; |
| 64 | |
| 65 | inline std::shared_ptr<MockDevice> MockDevice::create() { |
| 66 | return ndk::SharedRefBase::make<MockDevice>(); |
| 67 | } |
| 68 | |
| 69 | } // namespace aidl::android::hardware::neuralnetworks::utils |
| 70 | |
Michael Butler | 8414a6e | 2021-03-10 18:41:05 -0800 | [diff] [blame] | 71 | #endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_AIDL_UTILS_TEST_MOCK_DEVICE_H |