Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chromeos/system/fake_statistics_provider.h

Issue 644413003: Replace MockStatisticsProvider with FakeStatisticsProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add clarifying comments. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/system/fake_statistics_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
6 #define CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "chromeos/system/statistics_provider.h"
12
13 namespace chromeos {
14 namespace system {
15
16 // A fake StatisticsProvider implementation that is useful in tests.
17 class FakeStatisticsProvider : public StatisticsProvider {
18 public:
19 FakeStatisticsProvider();
20 virtual ~FakeStatisticsProvider();
21
22 // StatisticsProvider implementation:
23 virtual void StartLoadingMachineStatistics(
24 const scoped_refptr<base::TaskRunner>& file_task_runner,
25 bool load_oem_manifest) override;
26 virtual bool GetMachineStatistic(const std::string& name,
27 std::string* result) override;
28 virtual bool GetMachineFlag(const std::string& name, bool* result) override;
29 virtual void Shutdown() override;
30
31 void SetMachineStatistic(const std::string& key, const std::string& value);
32 void ClearMachineStatistic(const std::string& key);
33 void SetMachineFlag(const std::string& key, bool value);
34 void ClearMachineFlag(const std::string& key);
35
36 private:
37 std::map<std::string, std::string> machine_statistics_;
38 std::map<std::string, bool> machine_flags_;
39
40 DISALLOW_COPY_AND_ASSIGN(FakeStatisticsProvider);
41 };
42
43 // A convenience subclass that automatically registers itself as the test
44 // StatisticsProvider during construction and cleans up at destruction.
45 class ScopedFakeStatisticsProvider : public FakeStatisticsProvider {
46 public:
47 ScopedFakeStatisticsProvider();
48 virtual ~ScopedFakeStatisticsProvider();
49
50 private:
51 DISALLOW_COPY_AND_ASSIGN(ScopedFakeStatisticsProvider);
52 };
53
54 } // namespace system
55 } // namespace chromeos
56
57 #endif // CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
OLDNEW
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/system/fake_statistics_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698