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

Unified Diff: chrome/browser/autofill/autofill_download_unittest.cc

Issue 5703002: Add some basic success/failure UMA logging for autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Hopefully compile on Windows Created 10 years 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: chrome/browser/autofill/autofill_download_unittest.cc
diff --git a/chrome/browser/autofill/autofill_download_unittest.cc b/chrome/browser/autofill/autofill_download_unittest.cc
index 68173c6c05393106ad388467fefaa0e5b83ecc11..17e2282a9edeedd7a90fc2faf48a3b4b98ca60b0 100644
--- a/chrome/browser/autofill/autofill_download_unittest.cc
+++ b/chrome/browser/autofill/autofill_download_unittest.cc
@@ -8,6 +8,7 @@
#include "base/test/test_timeouts.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autofill/autofill_download.h"
+#include "chrome/browser/autofill/autofill_metrics.h"
#include "chrome/common/net/test_url_fetcher_factory.h"
#include "chrome/test/testing_profile.h"
#include "net/url_request/url_request_status.h"
@@ -18,6 +19,18 @@
using webkit_glue::FormData;
using WebKit::WebInputElement;
+namespace {
+
+class MockAutoFillServerQueryMetricLogger :
+ public AutoFillServerQueryMetricLogger {
+ public:
+ // TODO(isherman): Use gmock instead and test that metrics are logged as we'd
dhollowa 2010/12/12 07:07:51 Let's use gmock now.
Ilya Sherman 2010/12/13 22:13:51 Done.
+ // expect.
+ virtual void Log(Metric metric) const OVERRIDE {}
+};
+
+} // namespace
+
// This tests AutoFillDownloadManager. AutoFillDownloadTestHelper implements
// AutoFillDownloadManager::Observer and creates an instance of
// AutoFillDownloadManager. Then it records responses to different initiated
@@ -86,8 +99,6 @@ class AutoFillDownloadTestHelper : public AutoFillDownloadManager::Observer {
AutoFillDownloadManager download_manager;
};
-namespace {
-
TEST(AutoFillDownloadTest, QueryAndUploadTest) {
MessageLoopForUI message_loop;
// Create and register factory.
@@ -173,7 +184,9 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
form_structures.push_back(form_structure);
// Request with id 0.
- EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures));
+ EXPECT_TRUE(helper.download_manager.StartQueryRequest(
+ form_structures,
+ MockAutoFillServerQueryMetricLogger()));
// Set upload to 100% so requests happen.
helper.download_manager.SetPositiveUploadRate(1.0);
helper.download_manager.SetNegativeUploadRate(1.0);
@@ -258,7 +271,9 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
EXPECT_EQ(NULL, fetcher);
// Request with id 3.
- EXPECT_TRUE(helper.download_manager.StartQueryRequest(form_structures));
+ EXPECT_TRUE(helper.download_manager.StartQueryRequest(
+ form_structures,
+ MockAutoFillServerQueryMetricLogger()));
fetcher = factory.GetFetcherByID(3);
ASSERT_TRUE(fetcher);
fetcher->set_backoff_delay(
@@ -274,7 +289,9 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
helper.responses_.pop_front();
// Query requests should be ignored for the next 10 seconds.
- EXPECT_FALSE(helper.download_manager.StartQueryRequest(form_structures));
+ EXPECT_FALSE(helper.download_manager.StartQueryRequest(
+ form_structures,
+ MockAutoFillServerQueryMetricLogger()));
fetcher = factory.GetFetcherByID(4);
EXPECT_EQ(NULL, fetcher);
@@ -304,5 +321,3 @@ TEST(AutoFillDownloadTest, QueryAndUploadTest) {
// Make sure consumer of URLFetcher does the right thing.
URLFetcher::set_factory(NULL);
}
-
-} // namespace

Powered by Google App Engine
This is Rietveld 408576698