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, override));
44     MOCK_METHOD(GeneralResult<SharedPreparedModel>, prepareModelFromCache,
45                 (OptionalTimePoint deadline, const std::vector<SharedHandle>& modelCache,
46                  const std::vector<SharedHandle>& dataCache, const CacheToken& token),
47                 (const, override));
48     MOCK_METHOD(GeneralResult<SharedBuffer>, allocate,
49                 (const BufferDesc& desc, const std::vector<SharedPreparedModel>& preparedModels,
50                  const std::vector<BufferRole>& inputRoles,
51                  const std::vector<BufferRole>& outputRoles),
52                 (const, override));
53 };
54 
55 }  // namespace android::nn
56 
57 #endif  // ANDROID_HARDWARE_INTERFACES_NEURALNETWORKS_UTILS_COMMON_TEST_MOCK_DEVICE_H
58