xref: /openbmc/phosphor-power/phosphor-power-sequencer/test/mock_device.hpp (revision fdaa950b078e162b99dd1358f66b942a26b3bd19)
1 /**
2  * Copyright © 2024 IBM Corporation
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 #pragma once
17 
18 #include "gpio.hpp"
19 #include "power_sequencer_device.hpp"
20 
21 #include <cstdint>
22 
23 #include <gmock/gmock.h>
24 
25 namespace phosphor::power::sequencer
26 {
27 
28 /**
29  * @class MockDevice
30  *
31  * Mock implementation of the PowerSequencerDevice interface.
32  */
33 class MockDevice : public PowerSequencerDevice
34 {
35   public:
36     // Specify which compiler-generated methods we want
37     MockDevice() = default;
38     MockDevice(const MockDevice&) = delete;
39     MockDevice(MockDevice&&) = delete;
40     MockDevice& operator=(const MockDevice&) = delete;
41     MockDevice& operator=(MockDevice&&) = delete;
42     virtual ~MockDevice() = default;
43 
44     MOCK_METHOD(const std::string&, getName, (), (const, override));
45     MOCK_METHOD(uint8_t, getBus, (), (const, override));
46     MOCK_METHOD(uint16_t, getAddress, (), (const, override));
47     MOCK_METHOD(const std::string&, getPowerControlGPIOName, (),
48                 (const, override));
49     MOCK_METHOD(const std::string&, getPowerGoodGPIOName, (),
50                 (const, override));
51     MOCK_METHOD(const std::vector<std::unique_ptr<Rail>>&, getRails, (),
52                 (const, override));
53     MOCK_METHOD(GPIO&, getPowerControlGPIO, (), (override));
54     MOCK_METHOD(GPIO&, getPowerGoodGPIO, (), (override));
55     MOCK_METHOD(void, powerOn, (), (override));
56     MOCK_METHOD(void, powerOff, (), (override));
57     MOCK_METHOD(bool, getPowerGood, (), (override));
58     MOCK_METHOD(std::vector<int>, getGPIOValues, (Services & services),
59                 (override));
60     MOCK_METHOD(uint16_t, getStatusWord, (uint8_t page), (override));
61     MOCK_METHOD(uint8_t, getStatusVout, (uint8_t page), (override));
62     MOCK_METHOD(double, getReadVout, (uint8_t page), (override));
63     MOCK_METHOD(double, getVoutUVFaultLimit, (uint8_t page), (override));
64     MOCK_METHOD(std::string, findPgoodFault,
65                 (Services & services, const std::string& powerSupplyError,
66                  (std::map<std::string, std::string> & additionalData)),
67                 (override));
68 };
69 
70 } // namespace phosphor::power::sequencer
71