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

Side by Side Diff: components/password_manager/core/browser/password_manager_test_utils.cc

Issue 1668523002: [Password Manager] Switch password manager code to use the Feature framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to fieldtrial_testing_config_*.json Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/password_manager/core/browser/password_manager_test_utils.h " 5 #include "components/password_manager/core/browser/password_manager_test_utils.h "
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 #include <string> 9 #include <string>
10 10
11 #include "base/feature_list.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 14
14 using autofill::PasswordForm; 15 using autofill::PasswordForm;
15 16
16 namespace password_manager { 17 namespace password_manager {
17 18
19 namespace {
20
21 void GetFeatureOverridesAsCSV(const std::vector<const base::Feature*>& features,
22 std::string* overrides) {
23 for (const base::Feature* feature : features) {
24 overrides->append(feature->name);
25 overrides->push_back(',');
26 }
27 }
28
29 } // namespace
30
18 const char kTestingIconUrlSpec[] = "https://accounts.google.com/Icon"; 31 const char kTestingIconUrlSpec[] = "https://accounts.google.com/Icon";
19 const char kTestingFederationUrlSpec[] = "https://accounts.google.com/login"; 32 const char kTestingFederationUrlSpec[] = "https://accounts.google.com/login";
20 const int kTestingDaysAfterPasswordsAreSynced = 1; 33 const int kTestingDaysAfterPasswordsAreSynced = 1;
21 const wchar_t kTestingFederatedLoginMarker[] = L"__federated__"; 34 const wchar_t kTestingFederatedLoginMarker[] = L"__federated__";
22 35
23 scoped_ptr<PasswordForm> CreatePasswordFormFromDataForTesting( 36 scoped_ptr<PasswordForm> CreatePasswordFormFromDataForTesting(
24 const PasswordFormData& form_data) { 37 const PasswordFormData& form_data) {
25 scoped_ptr<PasswordForm> form(new PasswordForm()); 38 scoped_ptr<PasswordForm> form(new PasswordForm());
26 form->scheme = form_data.scheme; 39 form->scheme = form_data.scheme;
27 form->preferred = form_data.preferred; 40 form->preferred = form_data.preferred;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 for (const PasswordForm* remaining_expected_form : remaining_expectations) { 101 for (const PasswordForm* remaining_expected_form : remaining_expectations) {
89 *mismatch_output << std::endl 102 *mismatch_output << std::endl
90 << "Unmatched expected form:" << std::endl 103 << "Unmatched expected form:" << std::endl
91 << *remaining_expected_form; 104 << *remaining_expected_form;
92 } 105 }
93 } 106 }
94 107
95 return !had_mismatched_actual_form && remaining_expectations.empty(); 108 return !had_mismatched_actual_form && remaining_expectations.empty();
96 } 109 }
97 110
111 void SetFeatures(const std::vector<const base::Feature*>& enable_features,
112 const std::vector<const base::Feature*>& disable_features,
113 scoped_ptr<base::FeatureList> feature_list) {
114 std::string enable_overrides;
115 std::string disable_overrides;
116
117 GetFeatureOverridesAsCSV(enable_features, &enable_overrides);
118 GetFeatureOverridesAsCSV(disable_features, &disable_overrides);
119
120 base::FeatureList::ClearInstanceForTesting();
121 feature_list->InitializeFromCommandLine(enable_overrides, disable_overrides);
122 base::FeatureList::SetInstance(std::move(feature_list));
123 }
124
98 MockPasswordStoreObserver::MockPasswordStoreObserver() {} 125 MockPasswordStoreObserver::MockPasswordStoreObserver() {}
99 126
100 MockPasswordStoreObserver::~MockPasswordStoreObserver() {} 127 MockPasswordStoreObserver::~MockPasswordStoreObserver() {}
101 128
102 } // namespace password_manager 129 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698