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

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: Even more deletes, and Ilya review. Created 7 years, 3 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 profiles->push_back(profile); 146 profiles->push_back(profile);
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) : FormStructure(form) {}
158 : FormStructure(form, std::string()) {}
159 virtual ~TestFormStructure() {} 157 virtual ~TestFormStructure() {}
160 158
161 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, 159 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types,
162 const std::vector<ServerFieldType>& server_types) { 160 const std::vector<ServerFieldType>& server_types) {
163 ASSERT_EQ(field_count(), heuristic_types.size()); 161 ASSERT_EQ(field_count(), heuristic_types.size());
164 ASSERT_EQ(field_count(), server_types.size()); 162 ASSERT_EQ(field_count(), server_types.size());
165 163
166 for (size_t i = 0; i < field_count(); ++i) { 164 for (size_t i = 0; i < field_count(); ++i) {
167 AutofillField* form_field = field(i); 165 AutofillField* form_field = field(i);
168 ASSERT_TRUE(form_field); 166 ASSERT_TRUE(form_field);
(...skipping 20 matching lines...) Expand all
189 public: 187 public:
190 TestAutofillManager(AutofillDriver* driver, 188 TestAutofillManager(AutofillDriver* driver,
191 AutofillManagerDelegate* manager_delegate, 189 AutofillManagerDelegate* manager_delegate,
192 TestPersonalDataManager* personal_manager) 190 TestPersonalDataManager* personal_manager)
193 : AutofillManager(driver, manager_delegate, personal_manager), 191 : AutofillManager(driver, manager_delegate, personal_manager),
194 autofill_enabled_(true) { 192 autofill_enabled_(true) {
195 set_metric_logger(new testing::NiceMock<MockAutofillMetrics>); 193 set_metric_logger(new testing::NiceMock<MockAutofillMetrics>);
196 } 194 }
197 virtual ~TestAutofillManager() {} 195 virtual ~TestAutofillManager() {}
198 196
199 virtual std::string GetAutocheckoutURLPrefix() const OVERRIDE {
200 return std::string();
201 }
202
203 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; } 197 virtual bool IsAutofillEnabled() const OVERRIDE { return autofill_enabled_; }
204 198
205 void set_autofill_enabled(bool autofill_enabled) { 199 void set_autofill_enabled(bool autofill_enabled) {
206 autofill_enabled_ = autofill_enabled; 200 autofill_enabled_ = autofill_enabled;
207 } 201 }
208 202
209 MockAutofillMetrics* metric_logger() { 203 MockAutofillMetrics* metric_logger() {
210 return static_cast<MockAutofillMetrics*>(const_cast<AutofillMetrics*>( 204 return static_cast<MockAutofillMetrics*>(const_cast<AutofillMetrics*>(
211 AutofillManager::metric_logger())); 205 AutofillManager::metric_logger()));
212 } 206 }
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 // No experiment specified. 1163 // No experiment specified.
1170 EXPECT_CALL(metric_logger, 1164 EXPECT_CALL(metric_logger,
1171 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED)); 1165 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED));
1172 EXPECT_CALL(metric_logger, 1166 EXPECT_CALL(metric_logger,
1173 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED)); 1167 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED));
1174 EXPECT_CALL(metric_logger, 1168 EXPECT_CALL(metric_logger,
1175 LogServerExperimentIdForQuery(std::string())); 1169 LogServerExperimentIdForQuery(std::string()));
1176 EXPECT_CALL(metric_logger, 1170 EXPECT_CALL(metric_logger,
1177 LogServerQueryMetric( 1171 LogServerQueryMetric(
1178 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS)); 1172 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS));
1179 AutocheckoutPageMetaData page_meta_data;
1180 FormStructure::ParseQueryResponse( 1173 FormStructure::ParseQueryResponse(
1181 "<autofillqueryresponse></autofillqueryresponse>", 1174 "<autofillqueryresponse></autofillqueryresponse>",
1182 std::vector<FormStructure*>(), 1175 std::vector<FormStructure*>(),
1183 &page_meta_data,
1184 metric_logger); 1176 metric_logger);
1185 1177
1186 // Experiment "ar1" specified. 1178 // Experiment "ar1" specified.
1187 EXPECT_CALL(metric_logger, 1179 EXPECT_CALL(metric_logger,
1188 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED)); 1180 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_RECEIVED));
1189 EXPECT_CALL(metric_logger, 1181 EXPECT_CALL(metric_logger,
1190 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED)); 1182 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED));
1191 EXPECT_CALL(metric_logger, 1183 EXPECT_CALL(metric_logger,
1192 LogServerExperimentIdForQuery("ar1")); 1184 LogServerExperimentIdForQuery("ar1"));
1193 EXPECT_CALL(metric_logger, 1185 EXPECT_CALL(metric_logger,
1194 LogServerQueryMetric( 1186 LogServerQueryMetric(
1195 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS)); 1187 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS));
1196 FormStructure::ParseQueryResponse( 1188 FormStructure::ParseQueryResponse(
1197 "<autofillqueryresponse experimentid=\"ar1\"></autofillqueryresponse>", 1189 "<autofillqueryresponse experimentid=\"ar1\"></autofillqueryresponse>",
1198 std::vector<FormStructure*>(), 1190 std::vector<FormStructure*>(),
1199 &page_meta_data,
1200 metric_logger); 1191 metric_logger);
1201 } 1192 }
1202 1193
1203 // Verify that we correctly log user happiness metrics dealing with form loading 1194 // Verify that we correctly log user happiness metrics dealing with form loading
1204 // and form submission. 1195 // and form submission.
1205 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { 1196 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
1206 // Start with a form with insufficiently many fields. 1197 // Start with a form with insufficiently many fields.
1207 FormData form; 1198 FormData form;
1208 form.name = ASCIIToUTF16("TestForm"); 1199 form.name = ASCIIToUTF16("TestForm");
1209 form.method = ASCIIToUTF16("POST"); 1200 form.method = ASCIIToUTF16("POST");
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 TimeTicks::FromInternalValue(5)); 1546 TimeTicks::FromInternalValue(5));
1556 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), 1547 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(),
1557 TimeTicks::FromInternalValue(3)); 1548 TimeTicks::FromInternalValue(3));
1558 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); 1549 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17));
1559 autofill_manager_->Reset(); 1550 autofill_manager_->Reset();
1560 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 1551 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1561 } 1552 }
1562 } 1553 }
1563 1554
1564 } // namespace autofill 1555 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698