| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/password_manager/password_manager_test_base.h" | 8 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 9 #include "chrome/browser/password_manager/password_store_factory.h" | 9 #include "chrome/browser/password_manager/password_store_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_io_data.h" | 11 #include "chrome/browser/profiles/profile_io_data.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" | 13 #include "chrome/browser/ui/passwords/passwords_model_delegate.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 15 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
| 16 #include "components/password_manager/core/browser/password_store_consumer.h" | |
| 17 #include "components/password_manager/core/browser/test_password_store.h" | 16 #include "components/password_manager/core/browser/test_password_store.h" |
| 18 #include "content/public/test/browser_test.h" | 17 #include "content/public/test/browser_test.h" |
| 19 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
| 20 #include "net/cert/cert_verify_result.h" | 19 #include "net/cert/cert_verify_result.h" |
| 21 #include "net/cert/mock_cert_verifier.h" | 20 #include "net/cert/mock_cert_verifier.h" |
| 22 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 // A helper class that synchronously waits until the password store handles a | |
| 27 // GetLogins() request. | |
| 28 class PasswordStoreResultsObserver | |
| 29 : public password_manager::PasswordStoreConsumer { | |
| 30 public: | |
| 31 PasswordStoreResultsObserver() = default; | |
| 32 | |
| 33 void OnGetPasswordStoreResults( | |
| 34 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override { | |
| 35 run_loop_.Quit(); | |
| 36 } | |
| 37 | |
| 38 void Wait() { | |
| 39 run_loop_.Run(); | |
| 40 } | |
| 41 | |
| 42 private: | |
| 43 base::RunLoop run_loop_; | |
| 44 | |
| 45 DISALLOW_COPY_AND_ASSIGN(PasswordStoreResultsObserver); | |
| 46 }; | |
| 47 | |
| 48 class CredentialManagerBrowserTest : public PasswordManagerBrowserTestBase { | 25 class CredentialManagerBrowserTest : public PasswordManagerBrowserTestBase { |
| 49 public: | 26 public: |
| 50 CredentialManagerBrowserTest() = default; | 27 CredentialManagerBrowserTest() = default; |
| 51 | 28 |
| 52 bool IsShowingAccountChooser() { | 29 bool IsShowingAccountChooser() { |
| 53 return PasswordsModelDelegateFromWebContents(WebContents())-> | 30 return PasswordsModelDelegateFromWebContents(WebContents())-> |
| 54 GetState() == password_manager::ui::CREDENTIAL_REQUEST_STATE; | 31 GetState() == password_manager::ui::CREDENTIAL_REQUEST_STATE; |
| 55 } | 32 } |
| 56 | 33 |
| 57 // Make sure that the password store processed all the previous calls which | 34 // Make sure that the password store processed all the previous calls which |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 signin_form.skip_zero_click = false; | 330 signin_form.skip_zero_click = false; |
| 354 signin_form.times_used = 1; | 331 signin_form.times_used = 1; |
| 355 signin_form.password_value = base::ASCIIToUTF16("API"); | 332 signin_form.password_value = base::ASCIIToUTF16("API"); |
| 356 password_manager::TestPasswordStore::PasswordMap stored = | 333 password_manager::TestPasswordStore::PasswordMap stored = |
| 357 password_store->stored_passwords(); | 334 password_store->stored_passwords(); |
| 358 ASSERT_EQ(1u, stored.size()); | 335 ASSERT_EQ(1u, stored.size()); |
| 359 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); | 336 EXPECT_EQ(signin_form, stored[signin_form.signon_realm][0]); |
| 360 } | 337 } |
| 361 | 338 |
| 362 } // namespace | 339 } // namespace |
| OLD | NEW |