blob: 00e9c129bc57d1548a95ccf77c4d9fa9ad4379e6 [file] [log] [blame]
Jay Srinivasan55f50c22013-01-10 19:24:35 -08001// 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#include "update_engine/mock_system_state.h"
Alex Deymo94c06162014-03-21 20:34:46 -07006#include "update_engine/policy_manager/fake_state.h"
Jay Srinivasan55f50c22013-01-10 19:24:35 -08007#include "update_engine/update_attempter_mock.h"
8
Alex Deymo94c06162014-03-21 20:34:46 -07009using chromeos_policy_manager::FakeState;
10
Jay Srinivasan55f50c22013-01-10 19:24:35 -080011namespace chromeos_update_engine {
12
13// Mock the SystemStateInterface so that we could lie that
14// OOBE is completed even when there's no such marker file, etc.
Jay Srinivasanae4697c2013-03-18 17:08:08 -070015MockSystemState::MockSystemState()
16 : default_request_params_(this),
Alex Deymo42432912013-07-12 20:21:15 -070017 clock_(&default_clock_),
18 hardware_(&default_hardware_),
Chris Sosaaa18e162013-06-20 13:20:30 -070019 prefs_(&mock_prefs_),
David Zeuthen526cb582013-08-06 12:26:18 -070020 powerwash_safe_prefs_(&mock_powerwash_safe_prefs_),
21 p2p_manager_(&mock_p2p_manager_),
Alex Deymo94c06162014-03-21 20:34:46 -070022 payload_state_(&mock_payload_state_),
23 policy_manager_(&fake_policy_manager_) {
Jay Srinivasanae4697c2013-03-18 17:08:08 -070024 request_params_ = &default_request_params_;
Jay Srinivasan19409b72013-04-12 19:23:36 -070025 mock_payload_state_.Initialize(this);
Jay Srinivasan55f50c22013-01-10 19:24:35 -080026 mock_gpio_handler_ = new testing::NiceMock<MockGpioHandler>();
27 mock_update_attempter_ = new testing::NiceMock<UpdateAttempterMock>(
28 this, &dbus_);
David Zeuthen1cac5aa2014-04-02 10:18:00 -070029 mock_connection_manager_ = new testing::NiceMock<MockConnectionManager>(this);
30 connection_manager_ = mock_connection_manager_;
Alex Deymo94c06162014-03-21 20:34:46 -070031 fake_policy_manager_.Init(FakeState::Construct());
Jay Srinivasan55f50c22013-01-10 19:24:35 -080032}
33
34MockSystemState::~MockSystemState() {
David Zeuthen1cac5aa2014-04-02 10:18:00 -070035 delete mock_connection_manager_;
Alex Deymo51e04992014-04-03 14:06:29 -070036 delete mock_update_attempter_;
37 delete mock_gpio_handler_;
Jay Srinivasan55f50c22013-01-10 19:24:35 -080038}
39
40UpdateAttempter* MockSystemState::update_attempter() {
41 return mock_update_attempter_;
42}
43
Alex Deymo94c06162014-03-21 20:34:46 -070044} // namespace chromeos_update_engine