1 // Copyright 2014 The Chromium 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.
5 #ifndef CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
6 #define CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
11 #include "chromeos/system/statistics_provider.h"
16 // A fake StatisticsProvider implementation that is useful in tests.
17 class FakeStatisticsProvider
: public StatisticsProvider
{
19 FakeStatisticsProvider();
20 ~FakeStatisticsProvider() override
;
22 // StatisticsProvider implementation:
23 void StartLoadingMachineStatistics(
24 const scoped_refptr
<base::TaskRunner
>& file_task_runner
,
25 bool load_oem_manifest
) override
;
26 bool GetMachineStatistic(const std::string
& name
,
27 std::string
* result
) override
;
28 bool HasMachineStatistic(const std::string
& name
) override
;
29 bool GetMachineFlag(const std::string
& name
, bool* result
) override
;
30 bool HasMachineFlag(const std::string
& name
) override
;
31 void Shutdown() override
;
33 void SetMachineStatistic(const std::string
& key
, const std::string
& value
);
34 void ClearMachineStatistic(const std::string
& key
);
35 void SetMachineFlag(const std::string
& key
, bool value
);
36 void ClearMachineFlag(const std::string
& key
);
39 std::map
<std::string
, std::string
> machine_statistics_
;
40 std::map
<std::string
, bool> machine_flags_
;
42 DISALLOW_COPY_AND_ASSIGN(FakeStatisticsProvider
);
45 // A convenience subclass that automatically registers itself as the test
46 // StatisticsProvider during construction and cleans up at destruction.
47 class ScopedFakeStatisticsProvider
: public FakeStatisticsProvider
{
49 ScopedFakeStatisticsProvider();
50 ~ScopedFakeStatisticsProvider() override
;
53 DISALLOW_COPY_AND_ASSIGN(ScopedFakeStatisticsProvider
);
57 } // namespace chromeos
59 #endif // CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_