blob: a2e5cd2f34487951785a27c8c845153638fd0783 [file] [log] [blame]
Jay Srinivasan08fce042012-06-07 16:31:01 -07001// Copyright (c) 2012 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_SYSTEM_STATE_H__
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_SYSTEM_STATE_H__
7
8#include <gmock/gmock.h>
9
Jay Srinivasanf0572052012-10-23 18:12:56 -070010#include <metrics/metrics_library_mock.h>
Jay Srinivasan43488792012-06-19 00:25:31 -070011#include <policy/mock_device_policy.h>
Jay Srinivasanf0572052012-10-23 18:12:56 -070012
Jay Srinivasan43488792012-06-19 00:25:31 -070013#include "update_engine/system_state.h"
Jay Srinivasan08fce042012-06-07 16:31:01 -070014
15namespace chromeos_update_engine {
16
17// Mock the SystemStateInterface so that we could lie that
18// OOBE is completed even when there's no such marker file, etc.
19class MockSystemState : public SystemState {
Jay Srinivasan43488792012-06-19 00:25:31 -070020 public:
Jay Srinivasanf0572052012-10-23 18:12:56 -070021 MockSystemState() {
22 // By default, provide a mock metrics library. If the caller wants,
23 // they can override this by using set_metrics_lib() method.
24 metrics_lib_ = &mock_metrics_lib_;
25 }
Jay Srinivasan43488792012-06-19 00:25:31 -070026 virtual ~MockSystemState() {}
27
28 MOCK_METHOD0(IsOOBEComplete, bool());
29 MOCK_METHOD1(SetDevicePolicy, void(const policy::DevicePolicy*));
30 MOCK_CONST_METHOD0(GetDevicePolicy, const policy::DevicePolicy*());
31
32 void SetConnectionManager(ConnectionManager* connection_manager) {
33 connection_manager_ = connection_manager;
34 }
35
36 virtual ConnectionManager* GetConnectionManager() {
37 return connection_manager_;
38 }
39
Jay Srinivasanf0572052012-10-23 18:12:56 -070040 void set_metrics_lib(MetricsLibraryInterface* metrics_lib) {
41 metrics_lib_ = metrics_lib;
42 }
43 virtual MetricsLibraryInterface* metrics_lib() {
44 return metrics_lib_;
45 }
46
47
Jay Srinivasan43488792012-06-19 00:25:31 -070048 private:
49 ConnectionManager* connection_manager_;
Jay Srinivasanf0572052012-10-23 18:12:56 -070050 MetricsLibraryMock mock_metrics_lib_;
51 MetricsLibraryInterface* metrics_lib_;
Jay Srinivasan08fce042012-06-07 16:31:01 -070052};
53
54} // namespeace chromeos_update_engine
55
56#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_MOCK_SYSTEM_STATE_H__