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

Unified Diff: components/autofill/browser/autocheckout/whitelist_manager_unittest.cc

Issue 14060013: Add UMA stats to track whitelist download latency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename variables and update comments. Created 7 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: components/autofill/browser/autocheckout/whitelist_manager_unittest.cc
diff --git a/components/autofill/browser/autocheckout/whitelist_manager_unittest.cc b/components/autofill/browser/autocheckout/whitelist_manager_unittest.cc
index 6ff02bb940cf8892c257c6cd06d9494c2fbdb721..0aaedc8a9768efb60720ae3737c51568e7230033 100644
--- a/components/autofill/browser/autocheckout/whitelist_manager_unittest.cc
+++ b/components/autofill/browser/autocheckout/whitelist_manager_unittest.cc
@@ -7,6 +7,7 @@
#include "base/message_loop.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/browser/autocheckout/whitelist_manager.h"
+#include "components/autofill/browser/autofill_metrics.h"
#include "components/autofill/common/autofill_switches.h"
#include "content/public/test/test_browser_thread.h"
#include "googleurl/src/gurl.h"
@@ -15,6 +16,7 @@
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_status.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -32,6 +34,16 @@ namespace autocheckout {
class WhitelistManagerTest;
+class MockAutofillMetrics : public AutofillMetrics {
+ public:
+ MockAutofillMetrics() {}
+ MOCK_CONST_METHOD2(LogAutocheckoutWhitelistDownloadDuration,
+ void(const base::TimeDelta& duration,
+ AutofillMetrics::AutocheckoutWhitelistDownloadStatus));
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockAutofillMetrics);
+};
+
class TestWhitelistManager : public WhitelistManager {
public:
TestWhitelistManager()
@@ -64,9 +76,15 @@ class TestWhitelistManager : public WhitelistManager {
return WhitelistManager::url_prefixes();
}
+ virtual const AutofillMetrics& GetMetricLogger() const OVERRIDE {
+ return mock_metrics_logger_;
+ }
+
private:
bool did_start_download_timer_;
+ MockAutofillMetrics mock_metrics_logger_;
+
DISALLOW_COPY_AND_ASSIGN(TestWhitelistManager);
};
@@ -97,6 +115,16 @@ class WhitelistManagerTest : public testing::Test {
CreateWhitelistManager();
+ AutofillMetrics::AutocheckoutWhitelistDownloadStatus status;
+ if (response_code == net::HTTP_OK)
+ status = AutofillMetrics::AUTOCHECKOUT_WHITELIST_DOWNLOAD_SUCCEEDED;
+ else
+ status = AutofillMetrics::AUTOCHECKOUT_WHITELIST_DOWNLOAD_FAILED;
+ EXPECT_CALL(
+ static_cast<const MockAutofillMetrics&>(
+ whitelist_manager_->GetMetricLogger()),
+ LogAutocheckoutWhitelistDownloadDuration(testing::_, status)).Times(1);
+
whitelist_manager_->TriggerDownload();
net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
ASSERT_TRUE(fetcher);

Powered by Google App Engine
This is Rietveld 408576698