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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/system/fake_statistics_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/system/fake_statistics_provider.h
diff --git a/chromeos/system/fake_statistics_provider.h b/chromeos/system/fake_statistics_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..7953c4042a78a4cb7f02437235ca2b246595389c
--- /dev/null
+++ b/chromeos/system/fake_statistics_provider.h
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
+#define CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
+
+#include <map>
+#include <string>
+
+#include "chromeos/system/statistics_provider.h"
+
+namespace chromeos {
+namespace system {
+
+// A fake StatisticsProvider implementation that is useful in tests.
+class FakeStatisticsProvider : public StatisticsProvider {
+ public:
+ FakeStatisticsProvider();
+ virtual ~FakeStatisticsProvider();
+
+ // StatisticsProvider implementation:
+ virtual void StartLoadingMachineStatistics(
+ const scoped_refptr<base::TaskRunner>& file_task_runner,
+ bool load_oem_manifest) override;
+ virtual bool GetMachineStatistic(const std::string& name,
+ std::string* result) override;
+ virtual bool GetMachineFlag(const std::string& name, bool* result) override;
+ virtual void Shutdown() override;
+
+ void SetMachineStatistic(const std::string& key, const std::string& value);
+ void ClearMachineStatistic(const std::string& key);
+ void SetMachineFlag(const std::string& key, bool value);
+ void ClearMachineFlag(const std::string& key);
+
+ private:
+ std::map<std::string, std::string> machine_statistics_;
+ std::map<std::string, bool> machine_flags_;
+
+ DISALLOW_COPY_AND_ASSIGN(FakeStatisticsProvider);
+};
+
+// A convenience subclass that automatically registers itself as the test
+// StatisticsProvider during construction and cleans up at destruction.
+class ScopedFakeStatisticsProvider : public FakeStatisticsProvider {
+ public:
+ ScopedFakeStatisticsProvider();
+ virtual ~ScopedFakeStatisticsProvider();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedFakeStatisticsProvider);
+};
+
+} // namespace system
+} // namespace chromeos
+
+#endif // CHROMEOS_SYSTEM_FAKE_STATISTICS_PROVIDER_H_
« 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