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

Unified Diff: components/component_updater/component_updater_service_unittest.cc

Issue 1777793002: Define a few simple UMA metrics for the component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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: components/component_updater/component_updater_service_unittest.cc
diff --git a/components/component_updater/component_updater_service_unittest.cc b/components/component_updater/component_updater_service_unittest.cc
index 15b62bb853b087008a9839e768f104ac969ce3d9..83d5874ed16a9d11fd286b2d315018fc27d8983a 100644
--- a/components/component_updater/component_updater_service_unittest.cc
+++ b/components/component_updater/component_updater_service_unittest.cc
@@ -15,6 +15,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/test/histogram_tester.h"
#include "base/test/sequenced_worker_pool_owner.h"
#include "base/thread_task_runner_handle.h"
#include "base/values.h"
@@ -215,6 +216,7 @@ TEST_F(ComponentUpdaterTest, RegisterComponent) {
void OnUpdate(const std::vector<std::string>& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
+ completion_callback.Run(0);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)
@@ -226,6 +228,8 @@ TEST_F(ComponentUpdaterTest, RegisterComponent) {
base::Closure quit_closure_;
};
+ base::HistogramTester ht;
+
scoped_refptr<MockInstaller> installer(new MockInstaller());
EXPECT_CALL(*installer, Uninstall()).WillOnce(Return(true));
@@ -260,8 +264,11 @@ TEST_F(ComponentUpdaterTest, RegisterComponent) {
EXPECT_TRUE(component_updater().RegisterComponent(crx_component2));
RunThreads();
-
EXPECT_TRUE(component_updater().UnregisterComponent(id1));
+
+ ht.ExpectUniqueSample("ComponentUpdater.Calls", 1, 2);
+ ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 2);
+ ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 2);
}
// Tests that on-demand updates invoke UpdateClient::Install.
@@ -275,6 +282,7 @@ TEST_F(ComponentUpdaterTest, OnDemandUpdate) {
const std::string& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
+ completion_callback.Run(0);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)
@@ -286,6 +294,8 @@ TEST_F(ComponentUpdaterTest, OnDemandUpdate) {
base::Closure quit_closure_;
};
+ base::HistogramTester ht;
+
auto config = configurator();
config->SetInitialDelay(3600);
@@ -312,6 +322,10 @@ TEST_F(ComponentUpdaterTest, OnDemandUpdate) {
EXPECT_TRUE(OnDemandTester::OnDemand(&cus, id));
RunThreads();
+
+ ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1);
+ ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1);
+ ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1);
}
// Tests that throttling an update invokes UpdateClient::Install.
@@ -325,6 +339,7 @@ TEST_F(ComponentUpdaterTest, MaybeThrottle) {
const std::string& ids,
const UpdateClient::CrxDataCallback& crx_data_callback,
const UpdateClient::CompletionCallback& completion_callback) {
+ completion_callback.Run(0);
static int cnt = 0;
++cnt;
if (cnt >= max_cnt_)
@@ -336,6 +351,8 @@ TEST_F(ComponentUpdaterTest, MaybeThrottle) {
base::Closure quit_closure_;
};
+ base::HistogramTester ht;
+
auto config = configurator();
config->SetInitialDelay(3600);
@@ -359,6 +376,10 @@ TEST_F(ComponentUpdaterTest, MaybeThrottle) {
base::Bind(&ComponentUpdaterTest::ReadyCallback));
RunThreads();
+
+ ht.ExpectUniqueSample("ComponentUpdater.Calls", 0, 1);
+ ht.ExpectUniqueSample("ComponentUpdater.UpdateCompleteResult", 0, 1);
+ ht.ExpectTotalCount("ComponentUpdater.UpdateCompleteTime", 1);
}
} // namespace component_updater
« no previous file with comments | « components/component_updater/component_updater_service_internal.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698