blob: 574f1f70ee8d8a28391ad97a79789627ea7f0255 [file] [log] [blame]
Don Garrett83692e42013-11-08 10:11:30 -08001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Deymo759c2752014-03-17 21:09:36 -07005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HARDWARE_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HARDWARE_H_
Don Garrett83692e42013-11-08 10:11:30 -08007
Alex Deymo04f2b382014-03-21 15:45:17 -07008#include "update_engine/fake_hardware.h"
Don Garrett83692e42013-11-08 10:11:30 -08009
10#include <gmock/gmock.h>
11
12namespace chromeos_update_engine {
13
14// A mocked, fake implementation of HardwareInterface.
15class MockHardware : public HardwareInterface {
16public:
17 MockHardware() {
18 // Delegate all calls to the fake instance
19 ON_CALL(*this, BootKernelDevice())
20 .WillByDefault(testing::Invoke(&fake_,
21 &FakeHardware::BootKernelDevice));
22 ON_CALL(*this, BootDevice())
23 .WillByDefault(testing::Invoke(&fake_,
24 &FakeHardware::BootDevice));
Alex Deymo5708ecd2014-04-29 19:44:50 -070025 ON_CALL(*this, IsBootDeviceRemovable())
26 .WillByDefault(testing::Invoke(&fake_,
27 &FakeHardware::IsBootDeviceRemovable));
Alex Vakulenko59e253e2014-02-24 10:40:21 -080028 ON_CALL(*this, GetKernelDevices())
29 .WillByDefault(testing::Invoke(&fake_,
30 &FakeHardware::GetKernelDevices));
Don Garrett83692e42013-11-08 10:11:30 -080031 ON_CALL(*this, IsKernelBootable(testing::_, testing::_))
32 .WillByDefault(testing::Invoke(&fake_,
33 &FakeHardware::IsKernelBootable));
34 ON_CALL(*this, MarkKernelUnbootable(testing::_))
35 .WillByDefault(testing::Invoke(&fake_,
36 &FakeHardware::MarkKernelUnbootable));
37 ON_CALL(*this, IsOfficialBuild())
38 .WillByDefault(testing::Invoke(&fake_,
39 &FakeHardware::IsOfficialBuild));
40 ON_CALL(*this, IsNormalBootMode())
41 .WillByDefault(testing::Invoke(&fake_,
42 &FakeHardware::IsNormalBootMode));
Alex Deymobccbc382014-04-03 13:38:55 -070043 ON_CALL(*this, IsOOBEComplete(testing::_))
44 .WillByDefault(testing::Invoke(&fake_,
45 &FakeHardware::IsOOBEComplete));
Don Garrett83692e42013-11-08 10:11:30 -080046 ON_CALL(*this, GetHardwareClass())
47 .WillByDefault(testing::Invoke(&fake_,
48 &FakeHardware::GetHardwareClass));
49 ON_CALL(*this, GetFirmwareVersion())
50 .WillByDefault(testing::Invoke(&fake_,
51 &FakeHardware::GetFirmwareVersion));
52 ON_CALL(*this, GetECVersion())
53 .WillByDefault(testing::Invoke(&fake_,
54 &FakeHardware::GetECVersion));
55 }
56
57 virtual ~MockHardware() {}
58
59 // Hardware overrides.
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080060 MOCK_CONST_METHOD0(BootKernelDevice, std::string());
61 MOCK_CONST_METHOD0(BootDevice, std::string());
Alex Deymo5708ecd2014-04-29 19:44:50 -070062 MOCK_CONST_METHOD0(IsBootDeviceRemovable, bool());
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080063 MOCK_CONST_METHOD0(GetKernelDevices, std::vector<std::string>());
64 MOCK_CONST_METHOD2(IsKernelBootable,
Don Garrett83692e42013-11-08 10:11:30 -080065 bool(const std::string& kernel_device, bool* bootable));
66 MOCK_METHOD1(MarkKernelUnbootable,
67 bool(const std::string& kernel_device));
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080068 MOCK_CONST_METHOD0(IsOfficialBuild, bool());
69 MOCK_CONST_METHOD0(IsNormalBootMode, bool());
Alex Deymobccbc382014-04-03 13:38:55 -070070 MOCK_CONST_METHOD1(IsOOBEComplete, bool(base::Time* out_time_of_oobe));
Alex Vakulenkod0fdfb32014-02-21 15:26:26 -080071 MOCK_CONST_METHOD0(GetHardwareClass, std::string());
72 MOCK_CONST_METHOD0(GetFirmwareVersion, std::string());
73 MOCK_CONST_METHOD0(GetECVersion, std::string());
Don Garrett83692e42013-11-08 10:11:30 -080074
75 // Returns a reference to the underlying FakeHardware.
76 FakeHardware& fake() {
77 return fake_;
78 }
79
80private:
81 // The underlying FakeHardware.
82 FakeHardware fake_;
83
84 DISALLOW_COPY_AND_ASSIGN(MockHardware);
85};
86
87
88} // namespace chromeos_update_engine
89
Alex Deymo759c2752014-03-17 21:09:36 -070090#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HARDWARE_H_