1 /* 2 * Copyright (C) 2020 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 17 #ifndef ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_UTILS_COMMON_TEST_MOCK_DEVICE_H 18 #define ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_UTILS_COMMON_TEST_MOCK_DEVICE_H 19 20 #include <gmock/gmock.h> 21 #include <gtest/gtest.h> 22 #include <nnapi/IDevice.h> 23 24 namespace android::nn { 25 26 class MockDevice final : public IDevice { 27 public: 28 MOCK_METHOD(const std::string&, getName, (), (const, override)); 29 MOCK_METHOD(const std::string&, getVersionString, (), (const, override)); 30 MOCK_METHOD(Version, getFeatureLevel, (), (const, override)); 31 MOCK_METHOD(DeviceType, getType, (), (const, override)); 32 MOCK_METHOD(const std::vector<Extension>&, getSupportedExtensions, (), (const, override)); 33 MOCK_METHOD(const Capabilities&, getCapabilities, (), (const, override)); 34 MOCK_METHOD((std::pair<uint32_t, uint32_t>), getNumberOfCacheFilesNeeded, (), 35 (const, override)); 36 MOCK_METHOD(GeneralResult<void>, wait, (), (const, override)); 37 MOCK_METHOD(GeneralResult<std::vector<bool>>, getSupportedOperations, (const Model& model), 38 (const, override)); 39 MOCK_METHOD(GeneralResult<SharedPreparedModel>, prepareModel, 40 (const Model& model, ExecutionPreference preference, Priority priority, 41 OptionalTimePoint deadline, const std::vector<SharedHandle>& modelCache, 42 const std::vector<SharedHandle>& dataCache, const CacheToken& token, 43 const std::vector<TokenValuePair>& hints, 44 const std::vector<nn::ExtensionNameAndPrefix>& extensionNameToPrefix), 45 (const, override)); 46 MOCK_METHOD(GeneralResult<SharedPreparedModel>, prepareModelFromCache, 47 (OptionalTimePoint deadline, const std::vector<SharedHandle>& modelCache, 48 const std::vector<SharedHandle>& dataCache, const CacheToken& token), 49 (const, override)); 50 MOCK_METHOD(GeneralResult<SharedBuffer>, allocate, 51 (const BufferDesc& desc, const std::vector<SharedPreparedModel>& preparedModels, 52 const std::vector<BufferRole>& inputRoles, 53 const std::vector<BufferRole>& outputRoles), 54 (const, override)); 55 }; 56 57 } // namespace android::nn 58 59 #endif // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_UTILS_COMMON_TEST_MOCK_DEVICE_H 60