| 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 "components/password_manager/core/browser/password_store_consumer.h" |
| 13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 15 #include "net/cert/mock_cert_verifier.h" |
| 15 #include "net/test/embedded_test_server/embedded_test_server.h" | 16 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 16 | 17 |
| 17 namespace autofill { | 18 namespace autofill { |
| 18 struct PasswordForm; | 19 struct PasswordForm; |
| 19 } | 20 } |
| 20 | 21 |
| 21 class ManagePasswordsUIController; | 22 class ManagePasswordsUIController; |
| 22 | 23 |
| 23 class NavigationObserver : public content::WebContentsObserver { | 24 class NavigationObserver : public content::WebContentsObserver { |
| 24 public: | 25 public: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { | 92 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { |
| 92 public: | 93 public: |
| 93 PasswordManagerBrowserTestBase(); | 94 PasswordManagerBrowserTestBase(); |
| 94 ~PasswordManagerBrowserTestBase() override; | 95 ~PasswordManagerBrowserTestBase() override; |
| 95 | 96 |
| 96 // InProcessBrowserTest: | 97 // InProcessBrowserTest: |
| 97 void SetUpOnMainThread() override; | 98 void SetUpOnMainThread() override; |
| 98 void TearDownOnMainThread() override; | 99 void TearDownOnMainThread() override; |
| 100 void SetUpInProcessBrowserTestFixture() override; |
| 101 void TearDownInProcessBrowserTestFixture() override; |
| 99 | 102 |
| 100 protected: | 103 protected: |
| 101 // Wrapper around ui_test_utils::NavigateToURL that waits until | 104 // Wrapper around ui_test_utils::NavigateToURL that waits until |
| 102 // DidFinishLoad() fires. Normally this function returns after | 105 // DidFinishLoad() fires. Normally this function returns after |
| 103 // DidStopLoading(), which caused flakiness as the NavigationObserver | 106 // DidStopLoading(), which caused flakiness as the NavigationObserver |
| 104 // would sometimes see the DidFinishLoad event from a previous navigation and | 107 // would sometimes see the DidFinishLoad event from a previous navigation and |
| 105 // return immediately. | 108 // return immediately. |
| 106 void NavigateToFile(const std::string& path); | 109 void NavigateToFile(const std::string& path); |
| 107 | 110 |
| 108 // Navigates to |filename| and runs |submission_script| to submit. Navigates | 111 // Navigates to |filename| and runs |submission_script| to submit. Navigates |
| (...skipping 20 matching lines...) Expand all Loading... |
| 129 void WaitForPasswordStore(); | 132 void WaitForPasswordStore(); |
| 130 // Checks that the current "value" attribute of the HTML element with | 133 // Checks that the current "value" attribute of the HTML element with |
| 131 // |element_id| is equal to |expected_value|. | 134 // |element_id| is equal to |expected_value|. |
| 132 void CheckElementValue(const std::string& element_id, | 135 void CheckElementValue(const std::string& element_id, |
| 133 const std::string& expected_value); | 136 const std::string& expected_value); |
| 134 // Same as above except the element |element_id| is in iframe |iframe_id| | 137 // Same as above except the element |element_id| is in iframe |iframe_id| |
| 135 void CheckElementValue(const std::string& iframe_id, | 138 void CheckElementValue(const std::string& iframe_id, |
| 136 const std::string& element_id, | 139 const std::string& element_id, |
| 137 const std::string& expected_value); | 140 const std::string& expected_value); |
| 138 | 141 |
| 142 // Synchronoulsy adds the given host to the list of valid HSTS hosts. |
| 143 void AddHSTSHost(const std::string& host); |
| 144 |
| 139 // Accessors | 145 // Accessors |
| 140 content::WebContents* WebContents(); | 146 content::WebContents* WebContents(); |
| 141 content::RenderViewHost* RenderViewHost(); | 147 content::RenderViewHost* RenderViewHost(); |
| 142 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } | 148 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } |
| 149 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } |
| 143 | 150 |
| 144 private: | 151 private: |
| 145 net::EmbeddedTestServer https_test_server_; | 152 net::EmbeddedTestServer https_test_server_; |
| 153 net::MockCertVerifier mock_cert_verifier_; |
| 146 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); | 154 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); |
| 147 }; | 155 }; |
| 148 | 156 |
| 149 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 157 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
| OLD | NEW |