blob: 4e4ead687280b021298161a7b9285528161b037c [file] [log] [blame]
Alex Deymo2de23f52014-02-26 14:30:13 -08001// Copyright (c) 2014 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
Gilad Arnold2cbb3852014-03-07 12:40:50 -08005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_FAKE_STATE_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_FAKE_STATE_H_
Alex Deymo2de23f52014-02-26 14:30:13 -08007
Alex Deymo94c06162014-03-21 20:34:46 -07008#include "update_engine/policy_manager/fake_random_provider.h"
9#include "update_engine/policy_manager/fake_shill_provider.h"
10#include "update_engine/policy_manager/fake_system_provider.h"
11#include "update_engine/policy_manager/fake_time_provider.h"
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070012#include "update_engine/policy_manager/fake_updater_provider.h"
Alex Deymo2de23f52014-02-26 14:30:13 -080013#include "update_engine/policy_manager/state.h"
14
15namespace chromeos_policy_manager {
16
Alex Deymo94c06162014-03-21 20:34:46 -070017// A fake State class that creates fake providers for all the providers.
Alex Deymo2de23f52014-02-26 14:30:13 -080018class FakeState : public State {
19 public:
Alex Deymo94c06162014-03-21 20:34:46 -070020 // Creates and initializes the FakeState using fake providers. Returns NULL
21 // if the initialization fails.
22 static FakeState* Construct();
23
Alex Deymo2de23f52014-02-26 14:30:13 -080024 virtual ~FakeState() {}
25
Alex Deymo94c06162014-03-21 20:34:46 -070026 // Downcasted getters, to allow access to the fake instances during testing.
27 virtual FakeRandomProvider* random_provider() override {
28 return reinterpret_cast<FakeRandomProvider*>(State::random_provider());
29 }
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070030
Alex Deymo94c06162014-03-21 20:34:46 -070031 virtual FakeShillProvider* shill_provider() override {
32 return reinterpret_cast<FakeShillProvider*>(State::shill_provider());
33 }
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070034
35 virtual FakeSystemProvider* system_provider() override {
36 return reinterpret_cast<FakeSystemProvider*>(State::system_provider());
37 }
38
Alex Deymo94c06162014-03-21 20:34:46 -070039 virtual FakeTimeProvider* time_provider() override {
40 return reinterpret_cast<FakeTimeProvider*>(State::time_provider());
41 }
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070042
43 virtual FakeUpdaterProvider* updater_provider() override {
44 return reinterpret_cast<FakeUpdaterProvider*>(State::updater_provider());
Alex Deymo94c06162014-03-21 20:34:46 -070045 }
46
Alex Deymo2de23f52014-02-26 14:30:13 -080047 private:
Alex Deymo94c06162014-03-21 20:34:46 -070048 // Creates a FakeState instance using FakeProviders.
49 FakeState();
50
Alex Deymo2de23f52014-02-26 14:30:13 -080051 DISALLOW_COPY_AND_ASSIGN(FakeState);
52};
53
54} // namespace chromeos_policy_manager
55
Gilad Arnold2cbb3852014-03-07 12:40:50 -080056#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_FAKE_STATE_H_