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

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 23033016: Remove autocheckout code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/autofill_metrics.h" 5 #include "components/autofill/core/browser/autofill_metrics.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" 14 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
15 #include "chrome/browser/autofill/personal_data_manager_factory.h" 15 #include "chrome/browser/autofill/personal_data_manager_factory.h"
16 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" 16 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "components/autofill/content/browser/autocheckout_page_meta_data.h"
20 #include "components/autofill/core/browser/autofill_common_test.h" 19 #include "components/autofill/core/browser/autofill_common_test.h"
21 #include "components/autofill/core/browser/autofill_external_delegate.h" 20 #include "components/autofill/core/browser/autofill_external_delegate.h"
22 #include "components/autofill/core/browser/autofill_manager.h" 21 #include "components/autofill/core/browser/autofill_manager.h"
23 #include "components/autofill/core/browser/autofill_manager_delegate.h" 22 #include "components/autofill/core/browser/autofill_manager_delegate.h"
24 #include "components/autofill/core/browser/personal_data_manager.h" 23 #include "components/autofill/core/browser/personal_data_manager.h"
25 #include "components/autofill/core/browser/test_autofill_driver.h" 24 #include "components/autofill/core/browser/test_autofill_driver.h"
26 #include "components/autofill/core/common/form_data.h" 25 #include "components/autofill/core/common/form_data.h"
27 #include "components/autofill/core/common/form_field_data.h" 26 #include "components/autofill/core/common/form_field_data.h"
28 #include "components/autofill/core/common/forms_seen_state.h" 27 #include "components/autofill/core/common/forms_seen_state.h"
29 #include "components/webdata/common/web_data_results.h" 28 #include "components/webdata/common/web_data_results.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 147 }
149 148
150 bool autofill_enabled_; 149 bool autofill_enabled_;
151 150
152 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); 151 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager);
153 }; 152 };
154 153
155 class TestFormStructure : public FormStructure { 154 class TestFormStructure : public FormStructure {
156 public: 155 public:
157 explicit TestFormStructure(const FormData& form) 156 explicit TestFormStructure(const FormData& form)
158 : FormStructure(form, std::string()) {} 157 : FormStructure(form) {}
Dan Beam 2013/08/20 21:44:08 nit: if this is legal in chrome code/style: exp
159 virtual ~TestFormStructure() {} 158 virtual ~TestFormStructure() {}
160 159
161 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, 160 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types,
162 const std::vector<ServerFieldType>& server_types) { 161 const std::vector<ServerFieldType>& server_types) {
163 ASSERT_EQ(field_count(), heuristic_types.size()); 162 ASSERT_EQ(field_count(), heuristic_types.size());
164 ASSERT_EQ(field_count(), server_types.size()); 163 ASSERT_EQ(field_count(), server_types.size());
165 164
166 for (size_t i = 0; i < field_count(); ++i) { 165 for (size_t i = 0; i < field_count(); ++i) {
167 AutofillField* form_field = field(i); 166 AutofillField* form_field = field(i);
168 ASSERT_TRUE(form_field); 167 ASSERT_TRUE(form_field);
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 // No experiment specified. 1168 // No experiment specified.
1170 EXPECT_CALL(metric_logger, 1169 EXPECT_CALL(metric_logger,
1171 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED)); 1170 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED));
1172 EXPECT_CALL(metric_logger, 1171 EXPECT_CALL(metric_logger,
1173 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED)); 1172 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED));
1174 EXPECT_CALL(metric_logger, 1173 EXPECT_CALL(metric_logger,
1175 LogServerExperimentIdForQuery(std::string())); 1174 LogServerExperimentIdForQuery(std::string()));
1176 EXPECT_CALL(metric_logger, 1175 EXPECT_CALL(metric_logger,
1177 LogServerQueryMetric( 1176 LogServerQueryMetric(
1178 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS)); 1177 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS));
1179 AutocheckoutPageMetaData page_meta_data;
1180 FormStructure::ParseQueryResponse( 1178 FormStructure::ParseQueryResponse(
1181 "<autofillqueryresponse></autofillqueryresponse>", 1179 "<autofillqueryresponse></autofillqueryresponse>",
1182 std::vector<FormStructure*>(), 1180 std::vector<FormStructure*>(),
1183 &page_meta_data,
1184 metric_logger); 1181 metric_logger);
1185 1182
1186 // Experiment "ar1" specified. 1183 // Experiment "ar1" specified.
1187 EXPECT_CALL(metric_logger, 1184 EXPECT_CALL(metric_logger,
1188 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED)); 1185 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED));
1189 EXPECT_CALL(metric_logger, 1186 EXPECT_CALL(metric_logger,
1190 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED)); 1187 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED));
1191 EXPECT_CALL(metric_logger, 1188 EXPECT_CALL(metric_logger,
1192 LogServerExperimentIdForQuery("ar1")); 1189 LogServerExperimentIdForQuery("ar1"));
1193 EXPECT_CALL(metric_logger, 1190 EXPECT_CALL(metric_logger,
1194 LogServerQueryMetric( 1191 LogServerQueryMetric(
1195 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS)); 1192 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS));
1196 FormStructure::ParseQueryResponse( 1193 FormStructure::ParseQueryResponse(
1197 "<autofillqueryresponse experimentid=\"ar1\"></autofillqueryresponse>", 1194 "<autofillqueryresponse experimentid=\"ar1\"></autofillqueryresponse>",
1198 std::vector<FormStructure*>(), 1195 std::vector<FormStructure*>(),
1199 &page_meta_data,
1200 metric_logger); 1196 metric_logger);
1201 } 1197 }
1202 1198
1203 // Verify that we correctly log user happiness metrics dealing with form loading 1199 // Verify that we correctly log user happiness metrics dealing with form loading
1204 // and form submission. 1200 // and form submission.
1205 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { 1201 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
1206 // Start with a form with insufficiently many fields. 1202 // Start with a form with insufficiently many fields.
1207 FormData form; 1203 FormData form;
1208 form.name = ASCIIToUTF16("TestForm"); 1204 form.name = ASCIIToUTF16("TestForm");
1209 form.method = ASCIIToUTF16("POST"); 1205 form.method = ASCIIToUTF16("POST");
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 TimeTicks::FromInternalValue(5)); 1551 TimeTicks::FromInternalValue(5));
1556 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), 1552 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1557 TimeTicks::FromInternalValue(3)); 1553 TimeTicks::FromInternalValue(3));
1558 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); 1554 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17));
1559 autofill_manager_->Reset(); 1555 autofill_manager_->Reset();
1560 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 1556 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1561 } 1557 }
1562 } 1558 }
1563 1559
1564 } // namespace autofill 1560 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698