| OLD | NEW |
| 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" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool autofill_enabled_; | 136 bool autofill_enabled_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); | 138 DISALLOW_COPY_AND_ASSIGN(TestPersonalDataManager); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 class TestFormStructure : public FormStructure { | 141 class TestFormStructure : public FormStructure { |
| 142 public: | 142 public: |
| 143 explicit TestFormStructure(const FormData& form) : FormStructure(form) {} | 143 explicit TestFormStructure(const FormData& form) : FormStructure(form) {} |
| 144 virtual ~TestFormStructure() {} | 144 ~TestFormStructure() override {} |
| 145 | 145 |
| 146 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, | 146 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, |
| 147 const std::vector<ServerFieldType>& server_types) { | 147 const std::vector<ServerFieldType>& server_types) { |
| 148 ASSERT_EQ(field_count(), heuristic_types.size()); | 148 ASSERT_EQ(field_count(), heuristic_types.size()); |
| 149 ASSERT_EQ(field_count(), server_types.size()); | 149 ASSERT_EQ(field_count(), server_types.size()); |
| 150 | 150 |
| 151 for (size_t i = 0; i < field_count(); ++i) { | 151 for (size_t i = 0; i < field_count(); ++i) { |
| 152 AutofillField* form_field = field(i); | 152 AutofillField* form_field = field(i); |
| 153 ASSERT_TRUE(form_field); | 153 ASSERT_TRUE(form_field); |
| 154 form_field->set_heuristic_type(heuristic_types[i]); | 154 form_field->set_heuristic_type(heuristic_types[i]); |
| 155 form_field->set_server_type(server_types[i]); | 155 form_field->set_server_type(server_types[i]); |
| 156 } | 156 } |
| 157 | 157 |
| 158 UpdateAutofillCount(); | 158 UpdateAutofillCount(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 private: | 161 private: |
| 162 DISALLOW_COPY_AND_ASSIGN(TestFormStructure); | 162 DISALLOW_COPY_AND_ASSIGN(TestFormStructure); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 class TestAutofillManager : public AutofillManager { | 165 class TestAutofillManager : public AutofillManager { |
| 166 public: | 166 public: |
| 167 TestAutofillManager(AutofillDriver* driver, | 167 TestAutofillManager(AutofillDriver* driver, |
| 168 AutofillClient* autofill_client, | 168 AutofillClient* autofill_client, |
| 169 TestPersonalDataManager* personal_manager) | 169 TestPersonalDataManager* personal_manager) |
| 170 : AutofillManager(driver, autofill_client, personal_manager), | 170 : AutofillManager(driver, autofill_client, personal_manager), |
| 171 autofill_enabled_(true) { | 171 autofill_enabled_(true) { |
| 172 set_metric_logger(new testing::NiceMock<MockAutofillMetrics>); | 172 set_metric_logger(new testing::NiceMock<MockAutofillMetrics>); |
| 173 } | 173 } |
| 174 virtual ~TestAutofillManager() {} | 174 ~TestAutofillManager() override {} |
| 175 | 175 |
| 176 virtual bool IsAutofillEnabled() const override { return autofill_enabled_; } | 176 bool IsAutofillEnabled() const override { return autofill_enabled_; } |
| 177 | 177 |
| 178 void set_autofill_enabled(bool autofill_enabled) { | 178 void set_autofill_enabled(bool autofill_enabled) { |
| 179 autofill_enabled_ = autofill_enabled; | 179 autofill_enabled_ = autofill_enabled; |
| 180 } | 180 } |
| 181 | 181 |
| 182 MockAutofillMetrics* metric_logger() { | 182 MockAutofillMetrics* metric_logger() { |
| 183 return static_cast<MockAutofillMetrics*>(const_cast<AutofillMetrics*>( | 183 return static_cast<MockAutofillMetrics*>(const_cast<AutofillMetrics*>( |
| 184 AutofillManager::metric_logger())); | 184 AutofillManager::metric_logger())); |
| 185 } | 185 } |
| 186 | 186 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 200 | 200 |
| 201 void FormSubmitted(const FormData& form, const TimeTicks& timestamp) { | 201 void FormSubmitted(const FormData& form, const TimeTicks& timestamp) { |
| 202 run_loop_.reset(new base::RunLoop()); | 202 run_loop_.reset(new base::RunLoop()); |
| 203 if (!OnFormSubmitted(form, timestamp)) | 203 if (!OnFormSubmitted(form, timestamp)) |
| 204 return; | 204 return; |
| 205 | 205 |
| 206 // Wait for the asynchronous FormSubmitted() call to complete. | 206 // Wait for the asynchronous FormSubmitted() call to complete. |
| 207 run_loop_->Run(); | 207 run_loop_->Run(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 virtual void UploadFormDataAsyncCallback( | 210 void UploadFormDataAsyncCallback( |
| 211 const FormStructure* submitted_form, | 211 const FormStructure* submitted_form, |
| 212 const base::TimeTicks& load_time, | 212 const base::TimeTicks& load_time, |
| 213 const base::TimeTicks& interaction_time, | 213 const base::TimeTicks& interaction_time, |
| 214 const base::TimeTicks& submission_time) override { | 214 const base::TimeTicks& submission_time) override { |
| 215 run_loop_->Quit(); | 215 run_loop_->Quit(); |
| 216 | 216 |
| 217 AutofillManager::UploadFormDataAsyncCallback(submitted_form, | 217 AutofillManager::UploadFormDataAsyncCallback(submitted_form, |
| 218 load_time, | 218 load_time, |
| 219 interaction_time, | 219 interaction_time, |
| 220 submission_time); | 220 submission_time); |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 autofill_manager_->OnFormsSeen(second_forms, | 1082 autofill_manager_->OnFormsSeen(second_forms, |
| 1083 TimeTicks::FromInternalValue(5)); | 1083 TimeTicks::FromInternalValue(5)); |
| 1084 autofill_manager_->FormSubmitted(second_form, | 1084 autofill_manager_->FormSubmitted(second_form, |
| 1085 TimeTicks::FromInternalValue(17)); | 1085 TimeTicks::FromInternalValue(17)); |
| 1086 autofill_manager_->Reset(); | 1086 autofill_manager_->Reset(); |
| 1087 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1087 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
| 1088 } | 1088 } |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 } // namespace autofill | 1091 } // namespace autofill |
| OLD | NEW |