| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } // namespace | 146 } // namespace |
| 147 | 147 |
| 148 class PasswordFormManagerTest : public testing::Test { | 148 class PasswordFormManagerTest : public testing::Test { |
| 149 public: | 149 public: |
| 150 PasswordFormManagerTest() {} | 150 PasswordFormManagerTest() {} |
| 151 | 151 |
| 152 // Types of possible outcomes of simulated matching, see | 152 // Types of possible outcomes of simulated matching, see |
| 153 // SimulateMatchingPhase. | 153 // SimulateMatchingPhase. |
| 154 enum ResultOfSimulatedMatching { RESULT_MATCH_FOUND, RESULT_NO_MATCH }; | 154 enum ResultOfSimulatedMatching { RESULT_MATCH_FOUND, RESULT_NO_MATCH }; |
| 155 | 155 |
| 156 virtual void SetUp() { | 156 void SetUp() override { |
| 157 observed_form_.origin = GURL("http://accounts.google.com/a/LoginAuth"); | 157 observed_form_.origin = GURL("http://accounts.google.com/a/LoginAuth"); |
| 158 observed_form_.action = GURL("http://accounts.google.com/a/Login"); | 158 observed_form_.action = GURL("http://accounts.google.com/a/Login"); |
| 159 observed_form_.username_element = ASCIIToUTF16("Email"); | 159 observed_form_.username_element = ASCIIToUTF16("Email"); |
| 160 observed_form_.password_element = ASCIIToUTF16("Passwd"); | 160 observed_form_.password_element = ASCIIToUTF16("Passwd"); |
| 161 observed_form_.submit_element = ASCIIToUTF16("signIn"); | 161 observed_form_.submit_element = ASCIIToUTF16("signIn"); |
| 162 observed_form_.signon_realm = "http://accounts.google.com"; | 162 observed_form_.signon_realm = "http://accounts.google.com"; |
| 163 | 163 |
| 164 saved_match_ = observed_form_; | 164 saved_match_ = observed_form_; |
| 165 saved_match_.origin = GURL("http://accounts.google.com/a/ServiceLoginAuth"); | 165 saved_match_.origin = GURL("http://accounts.google.com/a/ServiceLoginAuth"); |
| 166 saved_match_.action = GURL("http://accounts.google.com/a/ServiceLogin"); | 166 saved_match_.action = GURL("http://accounts.google.com/a/ServiceLogin"); |
| 167 saved_match_.preferred = true; | 167 saved_match_.preferred = true; |
| 168 saved_match_.username_value = ASCIIToUTF16("test@gmail.com"); | 168 saved_match_.username_value = ASCIIToUTF16("test@gmail.com"); |
| 169 saved_match_.password_value = ASCIIToUTF16("test1"); | 169 saved_match_.password_value = ASCIIToUTF16("test1"); |
| 170 saved_match_.other_possible_usernames.push_back( | 170 saved_match_.other_possible_usernames.push_back( |
| 171 ASCIIToUTF16("test2@gmail.com")); | 171 ASCIIToUTF16("test2@gmail.com")); |
| 172 | 172 |
| 173 mock_store_ = new NiceMock<MockPasswordStore>(); | 173 mock_store_ = new NiceMock<MockPasswordStore>(); |
| 174 client_.reset(new TestPasswordManagerClient(mock_store_.get())); | 174 client_.reset(new TestPasswordManagerClient(mock_store_.get())); |
| 175 } | 175 } |
| 176 | 176 |
| 177 virtual void TearDown() { | 177 void TearDown() override { |
| 178 if (mock_store_.get()) | 178 if (mock_store_.get()) |
| 179 mock_store_->Shutdown(); | 179 mock_store_->Shutdown(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 MockPasswordStore* mock_store() const { return mock_store_.get(); } | 182 MockPasswordStore* mock_store() const { return mock_store_.get(); } |
| 183 | 183 |
| 184 PasswordForm* GetPendingCredentials(PasswordFormManager* p) { | 184 PasswordForm* GetPendingCredentials(PasswordFormManager* p) { |
| 185 return &p->pending_credentials_; | 185 return &p->pending_credentials_; |
| 186 } | 186 } |
| 187 | 187 |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 PasswordStore::ALLOW_PROMPT); | 1286 PasswordStore::ALLOW_PROMPT); |
| 1287 RunAllPendingTasks(); | 1287 RunAllPendingTasks(); |
| 1288 | 1288 |
| 1289 // Make sure that the preferred match is updated appropriately. | 1289 // Make sure that the preferred match is updated appropriately. |
| 1290 EXPECT_EQ(ASCIIToUTF16("password"), | 1290 EXPECT_EQ(ASCIIToUTF16("password"), |
| 1291 retrieving_manager.preferred_match()->password_value); | 1291 retrieving_manager.preferred_match()->password_value); |
| 1292 password_store->Shutdown(); | 1292 password_store->Shutdown(); |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 } // namespace password_manager | 1295 } // namespace password_manager |
| OLD | NEW |