blob: 6a27488c1b7d11e1f315340f3e461c24aad51975 [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
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HARDWARE_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HARDWARE_H__
7
8#include "fake_hardware.h"
9
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));
25 ON_CALL(*this, IsKernelBootable(testing::_, testing::_))
26 .WillByDefault(testing::Invoke(&fake_,
27 &FakeHardware::IsKernelBootable));
28 ON_CALL(*this, MarkKernelUnbootable(testing::_))
29 .WillByDefault(testing::Invoke(&fake_,
30 &FakeHardware::MarkKernelUnbootable));
31 ON_CALL(*this, IsOfficialBuild())
32 .WillByDefault(testing::Invoke(&fake_,
33 &FakeHardware::IsOfficialBuild));
34 ON_CALL(*this, IsNormalBootMode())
35 .WillByDefault(testing::Invoke(&fake_,
36 &FakeHardware::IsNormalBootMode));
37 ON_CALL(*this, GetHardwareClass())
38 .WillByDefault(testing::Invoke(&fake_,
39 &FakeHardware::GetHardwareClass));
40 ON_CALL(*this, GetFirmwareVersion())
41 .WillByDefault(testing::Invoke(&fake_,
42 &FakeHardware::GetFirmwareVersion));
43 ON_CALL(*this, GetECVersion())
44 .WillByDefault(testing::Invoke(&fake_,
45 &FakeHardware::GetECVersion));
46 }
47
48 virtual ~MockHardware() {}
49
50 // Hardware overrides.
51 MOCK_METHOD0(BootKernelDevice, const std::string());
52 MOCK_METHOD0(BootDevice, const std::string());
53 MOCK_METHOD2(IsKernelBootable,
54 bool(const std::string& kernel_device, bool* bootable));
55 MOCK_METHOD1(MarkKernelUnbootable,
56 bool(const std::string& kernel_device));
57 MOCK_METHOD0(IsOfficialBuild, bool());
58 MOCK_METHOD0(IsNormalBootMode, bool());
59 MOCK_METHOD0(GetHardwareClass, std::string());
60 MOCK_METHOD0(GetFirmwareVersion, std::string());
61 MOCK_METHOD0(GetECVersion, std::string());
62
63 // Returns a reference to the underlying FakeHardware.
64 FakeHardware& fake() {
65 return fake_;
66 }
67
68private:
69 // The underlying FakeHardware.
70 FakeHardware fake_;
71
72 DISALLOW_COPY_AND_ASSIGN(MockHardware);
73};
74
75
76} // namespace chromeos_update_engine
77
78#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_HARDWARE_H__