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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
| 9 #include <memory> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/test/histogram_tester.h" | 16 #include "base/test/histogram_tester.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "components/autofill/core/browser/autofill_external_delegate.h" | 18 #include "components/autofill/core/browser/autofill_external_delegate.h" |
19 #include "components/autofill/core/browser/autofill_manager.h" | 19 #include "components/autofill/core/browser/autofill_manager.h" |
20 #include "components/autofill/core/browser/autofill_test_utils.h" | 20 #include "components/autofill/core/browser/autofill_test_utils.h" |
21 #include "components/autofill/core/browser/payments/payments_client.h" | 21 #include "components/autofill/core/browser/payments/payments_client.h" |
22 #include "components/autofill/core/browser/personal_data_manager.h" | 22 #include "components/autofill/core/browser/personal_data_manager.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 bool observed_submission) override { | 281 bool observed_submission) override { |
282 run_loop_->Quit(); | 282 run_loop_->Quit(); |
283 | 283 |
284 AutofillManager::UploadFormDataAsyncCallback( | 284 AutofillManager::UploadFormDataAsyncCallback( |
285 submitted_form, load_time, interaction_time, submission_time, | 285 submitted_form, load_time, interaction_time, submission_time, |
286 observed_submission); | 286 observed_submission); |
287 } | 287 } |
288 | 288 |
289 private: | 289 private: |
290 bool autofill_enabled_; | 290 bool autofill_enabled_; |
291 scoped_ptr<base::RunLoop> run_loop_; | 291 std::unique_ptr<base::RunLoop> run_loop_; |
292 | 292 |
293 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); | 293 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); |
294 }; | 294 }; |
295 | 295 |
296 } // namespace | 296 } // namespace |
297 | 297 |
298 // This is defined in the autofill_metrics.cc implementation file. | 298 // This is defined in the autofill_metrics.cc implementation file. |
299 int GetFieldTypeGroupMetric(ServerFieldType field_type, | 299 int GetFieldTypeGroupMetric(ServerFieldType field_type, |
300 AutofillMetrics::FieldTypeQualityMetric metric); | 300 AutofillMetrics::FieldTypeQualityMetric metric); |
301 | 301 |
302 class AutofillMetricsTest : public testing::Test { | 302 class AutofillMetricsTest : public testing::Test { |
303 public: | 303 public: |
304 ~AutofillMetricsTest() override; | 304 ~AutofillMetricsTest() override; |
305 | 305 |
306 void SetUp() override; | 306 void SetUp() override; |
307 void TearDown() override; | 307 void TearDown() override; |
308 | 308 |
309 protected: | 309 protected: |
310 void EnableWalletSync(); | 310 void EnableWalletSync(); |
311 | 311 |
312 base::MessageLoop message_loop_; | 312 base::MessageLoop message_loop_; |
313 TestAutofillClient autofill_client_; | 313 TestAutofillClient autofill_client_; |
314 scoped_ptr<AccountTrackerService> account_tracker_; | 314 std::unique_ptr<AccountTrackerService> account_tracker_; |
315 scoped_ptr<FakeSigninManagerBase> signin_manager_; | 315 std::unique_ptr<FakeSigninManagerBase> signin_manager_; |
316 scoped_ptr<TestSigninClient> signin_client_; | 316 std::unique_ptr<TestSigninClient> signin_client_; |
317 scoped_ptr<TestAutofillDriver> autofill_driver_; | 317 std::unique_ptr<TestAutofillDriver> autofill_driver_; |
318 scoped_ptr<TestAutofillManager> autofill_manager_; | 318 std::unique_ptr<TestAutofillManager> autofill_manager_; |
319 scoped_ptr<TestPersonalDataManager> personal_data_; | 319 std::unique_ptr<TestPersonalDataManager> personal_data_; |
320 scoped_ptr<AutofillExternalDelegate> external_delegate_; | 320 std::unique_ptr<AutofillExternalDelegate> external_delegate_; |
321 }; | 321 }; |
322 | 322 |
323 AutofillMetricsTest::~AutofillMetricsTest() { | 323 AutofillMetricsTest::~AutofillMetricsTest() { |
324 // Order of destruction is important as AutofillManager relies on | 324 // Order of destruction is important as AutofillManager relies on |
325 // PersonalDataManager to be around when it gets destroyed. | 325 // PersonalDataManager to be around when it gets destroyed. |
326 autofill_manager_.reset(); | 326 autofill_manager_.reset(); |
327 } | 327 } |
328 | 328 |
329 void AutofillMetricsTest::SetUp() { | 329 void AutofillMetricsTest::SetUp() { |
330 autofill_client_.SetPrefs(test::PrefServiceForTesting()); | 330 autofill_client_.SetPrefs(test::PrefServiceForTesting()); |
(...skipping 3278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3609 EXPECT_THAT( | 3609 EXPECT_THAT( |
3610 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), | 3610 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), |
3611 ElementsAre(Bucket(true, 2))); | 3611 ElementsAre(Bucket(true, 2))); |
3612 | 3612 |
3613 // No RAPPOR metrics are logged in the case there is at least some server data | 3613 // No RAPPOR metrics are logged in the case there is at least some server data |
3614 // available for all forms. | 3614 // available for all forms. |
3615 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 3615 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
3616 } | 3616 } |
3617 | 3617 |
3618 } // namespace autofill | 3618 } // namespace autofill |
OLD | NEW |