summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--metricsd/include/metrics/metrics_library.h1
-rw-r--r--metricsd/uploader/upload_service.h1
-rw-r--r--metricsd/uploader/upload_service_test.cc18
3 files changed, 19 insertions, 1 deletions
diff --git a/metricsd/include/metrics/metrics_library.h b/metricsd/include/metrics/metrics_library.h
index eaae6ca08..26df2f473 100644
--- a/metricsd/include/metrics/metrics_library.h
+++ b/metricsd/include/metrics/metrics_library.h
@@ -123,6 +123,7 @@ class MetricsLibrary : public MetricsLibraryInterface {
private:
friend class CMetricsLibraryTest;
friend class MetricsLibraryTest;
+ friend class UploadServiceTest;
FRIEND_TEST(MetricsLibraryTest, AreMetricsEnabled);
FRIEND_TEST(MetricsLibraryTest, FormatChromeMessage);
FRIEND_TEST(MetricsLibraryTest, FormatChromeMessageTooLong);
diff --git a/metricsd/uploader/upload_service.h b/metricsd/uploader/upload_service.h
index ea93d21a3..a4d0a1e9f 100644
--- a/metricsd/uploader/upload_service.h
+++ b/metricsd/uploader/upload_service.h
@@ -107,6 +107,7 @@ class UploadService : public base::HistogramFlattener {
FRIEND_TEST(UploadServiceTest, LogContainsAggregatedValues);
FRIEND_TEST(UploadServiceTest, LogEmptyAfterUpload);
FRIEND_TEST(UploadServiceTest, LogEmptyByDefault);
+ FRIEND_TEST(UploadServiceTest, LogFromTheMetricsLibrary);
FRIEND_TEST(UploadServiceTest, LogKernelCrash);
FRIEND_TEST(UploadServiceTest, LogUncleanShutdown);
FRIEND_TEST(UploadServiceTest, LogUserCrash);
diff --git a/metricsd/uploader/upload_service_test.cc b/metricsd/uploader/upload_service_test.cc
index fd8248ae7..873953ef8 100644
--- a/metricsd/uploader/upload_service_test.cc
+++ b/metricsd/uploader/upload_service_test.cc
@@ -41,6 +41,7 @@ class UploadServiceTest : public testing::Test {
CHECK(dir_.CreateUniqueTempDir());
chromeos_metrics::PersistentInteger::SetMetricsDirectory(
dir_.path().value());
+ metrics_lib_.InitForTest(dir_.path());
upload_service_.reset(new UploadService(new MockSystemProfileSetter(),
&metrics_lib_, "", true));
@@ -62,7 +63,7 @@ class UploadServiceTest : public testing::Test {
base::ScopedTempDir dir_;
scoped_ptr<UploadService> upload_service_;
- MetricsLibraryMock metrics_lib_;
+ MetricsLibrary metrics_lib_;
scoped_ptr<base::AtExitManager> exit_manager_;
};
@@ -274,3 +275,18 @@ TEST_F(UploadServiceTest, SessionIdIncrementedAtInitialization) {
cache.Initialize();
EXPECT_EQ(cache.profile_.session_id, session_id + 1);
}
+
+// Test that we can log metrics from the metrics library and have the uploader
+// upload them.
+TEST_F(UploadServiceTest, LogFromTheMetricsLibrary) {
+ SenderMock* sender = new SenderMock();
+ upload_service_->sender_.reset(sender);
+
+ upload_service_->UploadEvent();
+ EXPECT_EQ(0, sender->send_call_count());
+
+ metrics_lib_.SendEnumToUMA("testname", 2, 10);
+ upload_service_->UploadEvent();
+
+ EXPECT_EQ(1, sender->send_call_count());
+}