am c6a66bf1: am 3ef7f0af: Merge "metricsd: Add test case for the upload service."
* commit 'c6a66bf1cfdfd35e3289fbfd3fb16be795def9f9': metricsd: Add test case for the upload service.
This commit is contained in:
commit
2f146a5a60
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue