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

Unified Diff: src/platform/metrics/metrics_daemon.h

Issue 1919005: Add some basic tests for metrics_daemon. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Address review comments. Created 10 years, 8 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
Index: src/platform/metrics/metrics_daemon.h
diff --git a/src/platform/metrics/metrics_daemon.h b/src/platform/metrics/metrics_daemon.h
index 99f76d087198f3e653893d8f42d72fb4ac83db80..028525a3d8c8e50a74022239dad71da2d24817f0 100644
--- a/src/platform/metrics/metrics_daemon.h
+++ b/src/platform/metrics/metrics_daemon.h
@@ -9,11 +9,14 @@
#include <glib.h>
#include <time.h>
+#include <gtest/gtest_prod.h> // for FRIEND_TEST
+
class MetricsDaemon {
public:
MetricsDaemon()
- : network_state_(kUnknownNetworkState),
+ : daily_use_record_file_(NULL),
+ network_state_(kUnknownNetworkState),
network_state_last_(0),
power_state_(kUnknownPowerState),
screensaver_state_(kUnknownScreenSaverState),
@@ -26,11 +29,23 @@ class MetricsDaemon {
~MetricsDaemon() {}
// Does all the work. If |run_as_daemon| is true, daemonizes by
- // forking. If |testing| is true, logs the stats instead of sending
- // them to Chrome.
- void Run(bool run_as_daemon, bool testing);
+ // forking.
+ void Run(bool run_as_daemon);
private:
+ friend class MetricsDaemonTest;
+ FRIEND_TEST(MetricsDaemonTest, LogDailyUseRecord);
+ FRIEND_TEST(MetricsDaemonTest, LookupNetworkState);
+ FRIEND_TEST(MetricsDaemonTest, LookupPowerState);
+ FRIEND_TEST(MetricsDaemonTest, LookupScreenSaverState);
+ FRIEND_TEST(MetricsDaemonTest, LookupSessionState);
+ FRIEND_TEST(MetricsDaemonTest, NetStateChanged);
+ FRIEND_TEST(MetricsDaemonTest, PowerStateChanged);
+ FRIEND_TEST(MetricsDaemonTest, PublishMetric);
+ FRIEND_TEST(MetricsDaemonTest, ScreenSaverStateChanged);
+ FRIEND_TEST(MetricsDaemonTest, SessionStateChanged);
+ FRIEND_TEST(MetricsDaemonTest, SetUserActiveState);
+
// The network states (see network_states.h).
enum NetworkState {
kUnknownNetworkState = -1, // Initial/unknown network state.
@@ -71,6 +86,16 @@ class MetricsDaemon {
int seconds_;
};
+ // Metric parameters.
+ static const char kMetricDailyUseTimeName[];
+ static const int kMetricDailyUseTimeMin;
+ static const int kMetricDailyUseTimeMax;
+ static const int kMetricDailyUseTimeBuckets;
+ static const char kMetricTimeToNetworkDropName[];
+ static const int kMetricTimeToNetworkDropMin;
+ static const int kMetricTimeToNetworkDropMax;
+ static const int kMetricTimeToNetworkDropBuckets;
+
// D-Bus message match strings.
static const char* kDBusMatches_[];
@@ -161,9 +186,11 @@ class MetricsDaemon {
void PublishMetric(const char* name, int sample,
int min, int max, int nbuckets);
- // Testing mode.
+ // Test mode.
bool testing_;
+ const char* daily_use_record_file_;
+
// Current network state.
NetworkState network_state_;

Powered by Google App Engine
This is Rietveld 408576698