blob: 5cdccb945feb79b94b3c994201e30347c25dd4b4 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2013 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//
Don Garrett83692e42013-11-08 10:11:30 -080016
Gilad Arnoldcf175a02014-07-10 16:48:47 -070017#ifndef UPDATE_ENGINE_MOCK_HARDWARE_H_
18#define UPDATE_ENGINE_MOCK_HARDWARE_H_
Don Garrett83692e42013-11-08 10:11:30 -080019
Alex Deymodf632d12014-04-29 20:04:36 -070020#include <string>
21#include <vector>
22
Alex Deymo04f2b382014-03-21 15:45:17 -070023#include "update_engine/fake_hardware.h"
Don Garrett83692e42013-11-08 10:11:30 -080024
25#include <gmock/gmock.h>
26
27namespace chromeos_update_engine {
28
29// A mocked, fake implementation of HardwareInterface.
30class MockHardware : public HardwareInterface {
Alex Deymodf632d12014-04-29 20:04:36 -070031 public:
Don Garrett83692e42013-11-08 10:11:30 -080032 MockHardware() {
33 // Delegate all calls to the fake instance
Don Garrett83692e42013-11-08 10:11:30 -080034 ON_CALL(*this, IsOfficialBuild())
35 .WillByDefault(testing::Invoke(&fake_,
36 &FakeHardware::IsOfficialBuild));
37 ON_CALL(*this, IsNormalBootMode())
38 .WillByDefault(testing::Invoke(&fake_,
39 &FakeHardware::IsNormalBootMode));
Alex Deymobccbc382014-04-03 13:38:55 -070040 ON_CALL(*this, IsOOBEComplete(testing::_))
41 .WillByDefault(testing::Invoke(&fake_,
42 &FakeHardware::IsOOBEComplete));
Don Garrett83692e42013-11-08 10:11:30 -080043 ON_CALL(*this, GetHardwareClass())
44 .WillByDefault(testing::Invoke(&fake_,
45 &FakeHardware::GetHardwareClass));
46 ON_CALL(*this, GetFirmwareVersion())
47 .WillByDefault(testing::Invoke(&fake_,
48 &FakeHardware::GetFirmwareVersion));
49 ON_CALL(*this, GetECVersion())
50 .WillByDefault(testing::Invoke(&fake_,
51 &FakeHardware::GetECVersion));
Alex Deymoebbe7ef2014-10-30 13:02:49 -070052 ON_CALL(*this, GetPowerwashCount())
53 .WillByDefault(testing::Invoke(&fake_,
54 &FakeHardware::GetPowerwashCount));
Don Garrett83692e42013-11-08 10:11:30 -080055 }
56
Alex Deymo763e7db2015-08-27 21:08:08 -070057 ~MockHardware() override = default;
Don Garrett83692e42013-11-08 10:11:30 -080058
59 // Hardware overrides.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080060 MOCK_CONST_METHOD0(IsOfficialBuild, bool());
61 MOCK_CONST_METHOD0(IsNormalBootMode, bool());
Alex Deymobccbc382014-04-03 13:38:55 -070062 MOCK_CONST_METHOD1(IsOOBEComplete, bool(base::Time* out_time_of_oobe));
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080063 MOCK_CONST_METHOD0(GetHardwareClass, std::string());
64 MOCK_CONST_METHOD0(GetFirmwareVersion, std::string());
65 MOCK_CONST_METHOD0(GetECVersion, std::string());
Alex Deymoebbe7ef2014-10-30 13:02:49 -070066 MOCK_CONST_METHOD0(GetPowerwashCount, int());
Don Garrett83692e42013-11-08 10:11:30 -080067
68 // Returns a reference to the underlying FakeHardware.
69 FakeHardware& fake() {
70 return fake_;
71 }
72
Alex Deymodf632d12014-04-29 20:04:36 -070073 private:
Don Garrett83692e42013-11-08 10:11:30 -080074 // The underlying FakeHardware.
75 FakeHardware fake_;
76
77 DISALLOW_COPY_AND_ASSIGN(MockHardware);
78};
79
80
81} // namespace chromeos_update_engine
82
Gilad Arnoldcf175a02014-07-10 16:48:47 -070083#endif // UPDATE_ENGINE_MOCK_HARDWARE_H_