| 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 <memory> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "components/signin/core/common/signin_pref_names.h" | 35 #include "components/signin/core/common/signin_pref_names.h" |
| 36 #include "components/webdata/common/web_data_results.h" | 36 #include "components/webdata/common/web_data_results.h" |
| 37 #include "testing/gmock/include/gmock/gmock.h" | 37 #include "testing/gmock/include/gmock/gmock.h" |
| 38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 39 #include "ui/gfx/geometry/rect.h" | 39 #include "ui/gfx/geometry/rect.h" |
| 40 #include "url/gurl.h" | 40 #include "url/gurl.h" |
| 41 | 41 |
| 42 using base::ASCIIToUTF16; | 42 using base::ASCIIToUTF16; |
| 43 using base::Bucket; | 43 using base::Bucket; |
| 44 using base::TimeTicks; | 44 using base::TimeTicks; |
| 45 using rappor::TestRapporService; | 45 using rappor::TestRapporServiceImpl; |
| 46 using ::testing::ElementsAre; | 46 using ::testing::ElementsAre; |
| 47 | 47 |
| 48 namespace autofill { | 48 namespace autofill { |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 class TestPersonalDataManager : public PersonalDataManager { | 51 class TestPersonalDataManager : public PersonalDataManager { |
| 52 public: | 52 public: |
| 53 TestPersonalDataManager() | 53 TestPersonalDataManager() |
| 54 : PersonalDataManager("en-US"), | 54 : PersonalDataManager("en-US"), |
| 55 autofill_enabled_(true) { | 55 autofill_enabled_(true) { |
| (...skipping 3972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4028 field.label = ASCIIToUTF16("password"); | 4028 field.label = ASCIIToUTF16("password"); |
| 4029 field.name = ASCIIToUTF16("password"); | 4029 field.name = ASCIIToUTF16("password"); |
| 4030 field.form_control_type = "password"; | 4030 field.form_control_type = "password"; |
| 4031 form.fields.push_back(field); | 4031 form.fields.push_back(field); |
| 4032 | 4032 |
| 4033 owned_forms_.push_back(base::MakeUnique<FormStructure>(form)); | 4033 owned_forms_.push_back(base::MakeUnique<FormStructure>(form)); |
| 4034 forms_.push_back(owned_forms_.back().get()); | 4034 forms_.push_back(owned_forms_.back().get()); |
| 4035 } | 4035 } |
| 4036 | 4036 |
| 4037 protected: | 4037 protected: |
| 4038 TestRapporService rappor_service_; | 4038 TestRapporServiceImpl rappor_service_; |
| 4039 std::vector<std::unique_ptr<FormStructure>> owned_forms_; | 4039 std::vector<std::unique_ptr<FormStructure>> owned_forms_; |
| 4040 std::vector<FormStructure*> forms_; | 4040 std::vector<FormStructure*> forms_; |
| 4041 }; | 4041 }; |
| 4042 | 4042 |
| 4043 TEST_F(AutofillMetricsParseQueryResponseTest, ServerHasData) { | 4043 TEST_F(AutofillMetricsParseQueryResponseTest, ServerHasData) { |
| 4044 AutofillQueryResponseContents response; | 4044 AutofillQueryResponseContents response; |
| 4045 response.add_field()->set_autofill_type(7); | 4045 response.add_field()->set_autofill_type(7); |
| 4046 response.add_field()->set_autofill_type(30); | 4046 response.add_field()->set_autofill_type(30); |
| 4047 response.add_field()->set_autofill_type(9); | 4047 response.add_field()->set_autofill_type(9); |
| 4048 response.add_field()->set_autofill_type(0); | 4048 response.add_field()->set_autofill_type(0); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 EXPECT_THAT( | 4133 EXPECT_THAT( |
| 4134 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), | 4134 histogram_tester.GetAllSamples("Autofill.ServerResponseHasDataForForm"), |
| 4135 ElementsAre(Bucket(true, 2))); | 4135 ElementsAre(Bucket(true, 2))); |
| 4136 | 4136 |
| 4137 // No RAPPOR metrics are logged in the case there is at least some server data | 4137 // No RAPPOR metrics are logged in the case there is at least some server data |
| 4138 // available for all forms. | 4138 // available for all forms. |
| 4139 EXPECT_EQ(0, rappor_service_.GetReportsCount()); | 4139 EXPECT_EQ(0, rappor_service_.GetReportsCount()); |
| 4140 } | 4140 } |
| 4141 | 4141 |
| 4142 } // namespace autofill | 4142 } // namespace autofill |
| OLD | NEW |