Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "components/password_manager/core/browser/password_store_consumer.h" | |
| 12 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 13 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 14 | 15 |
| 15 namespace autofill { | 16 namespace autofill { |
| 16 struct PasswordForm; | 17 struct PasswordForm; |
| 17 } | 18 } |
| 18 | 19 |
| 19 class ManagePasswordsUIController; | 20 class ManagePasswordsUIController; |
| 20 | 21 |
| 21 class NavigationObserver : public content::WebContentsObserver { | 22 class NavigationObserver : public content::WebContentsObserver { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 // Expecting that the prompt is shown, update |form| with the password from | 80 // Expecting that the prompt is shown, update |form| with the password from |
| 80 // observed form. Checks that the prompt is no longer visible afterwards. | 81 // observed form. Checks that the prompt is no longer visible afterwards. |
| 81 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; | 82 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; |
| 82 | 83 |
| 83 private: | 84 private: |
| 84 ManagePasswordsUIController* const passwords_ui_controller_; | 85 ManagePasswordsUIController* const passwords_ui_controller_; |
| 85 | 86 |
| 86 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); | 87 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); |
| 87 }; | 88 }; |
| 88 | 89 |
| 90 // A helper class that synchronously waits until the password store handles a | |
| 91 // GetLogins() request. | |
| 92 class PasswordStoreResultsObserver | |
|
vasilii
2017/01/12 14:59:21
Is it needed in the header?
jdoerrie
2017/01/12 17:40:58
Nope. Moved it into an anonymous namespace in the
| |
| 93 : public password_manager::PasswordStoreConsumer { | |
| 94 public: | |
| 95 PasswordStoreResultsObserver() = default; | |
| 96 | |
| 97 void OnGetPasswordStoreResults( | |
| 98 std::vector<std::unique_ptr<autofill::PasswordForm>> results) override; | |
| 99 | |
| 100 void Wait(); | |
| 101 | |
| 102 private: | |
| 103 base::RunLoop run_loop_; | |
| 104 | |
| 105 DISALLOW_COPY_AND_ASSIGN(PasswordStoreResultsObserver); | |
| 106 }; | |
| 107 | |
| 89 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { | 108 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { |
| 90 public: | 109 public: |
| 91 PasswordManagerBrowserTestBase(); | 110 PasswordManagerBrowserTestBase(); |
| 92 ~PasswordManagerBrowserTestBase() override; | 111 ~PasswordManagerBrowserTestBase() override; |
| 93 | 112 |
| 94 // InProcessBrowserTest: | 113 // InProcessBrowserTest: |
| 95 void SetUpOnMainThread() override; | 114 void SetUpOnMainThread() override; |
| 96 void TearDownOnMainThread() override; | 115 void TearDownOnMainThread() override; |
| 97 | 116 |
| 98 protected: | 117 protected: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 115 // equal to |expected_value|. If the current value is not as expected, this | 134 // equal to |expected_value|. If the current value is not as expected, this |
| 116 // waits until the "change" event is fired for the element. This also | 135 // waits until the "change" event is fired for the element. This also |
| 117 // guarantees that once the real value matches the expected, the JavaScript | 136 // guarantees that once the real value matches the expected, the JavaScript |
| 118 // event loop is spun to allow all other possible events to take place. | 137 // event loop is spun to allow all other possible events to take place. |
| 119 void WaitForElementValue(const std::string& element_id, | 138 void WaitForElementValue(const std::string& element_id, |
| 120 const std::string& expected_value); | 139 const std::string& expected_value); |
| 121 // Same as above except the element |element_id| is in iframe |iframe_id| | 140 // Same as above except the element |element_id| is in iframe |iframe_id| |
| 122 void WaitForElementValue(const std::string& iframe_id, | 141 void WaitForElementValue(const std::string& iframe_id, |
| 123 const std::string& element_id, | 142 const std::string& element_id, |
| 124 const std::string& expected_value); | 143 const std::string& expected_value); |
| 144 // Make sure that the password store processed all the previous calls which | |
| 145 // are executed on another thread. | |
| 146 void WaitForPasswordStore(); | |
| 125 // Checks that the current "value" attribute of the HTML element with | 147 // Checks that the current "value" attribute of the HTML element with |
| 126 // |element_id| is equal to |expected_value|. | 148 // |element_id| is equal to |expected_value|. |
| 127 void CheckElementValue(const std::string& element_id, | 149 void CheckElementValue(const std::string& element_id, |
| 128 const std::string& expected_value); | 150 const std::string& expected_value); |
| 129 // Same as above except the element |element_id| is in iframe |iframe_id| | 151 // Same as above except the element |element_id| is in iframe |iframe_id| |
| 130 void CheckElementValue(const std::string& iframe_id, | 152 void CheckElementValue(const std::string& iframe_id, |
| 131 const std::string& element_id, | 153 const std::string& element_id, |
| 132 const std::string& expected_value); | 154 const std::string& expected_value); |
| 133 | 155 |
| 134 // Accessors | 156 // Accessors |
| 135 content::WebContents* WebContents(); | 157 content::WebContents* WebContents(); |
| 136 content::RenderViewHost* RenderViewHost(); | 158 content::RenderViewHost* RenderViewHost(); |
| 137 | 159 |
| 138 private: | 160 private: |
| 139 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); | 161 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); |
| 140 }; | 162 }; |
| 141 | 163 |
| 142 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 164 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
| OLD | NEW |