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

Side by Side Diff: chrome/browser/password_manager/password_manager_test_base.h

Issue 2759353004: Enable CredentialManagerBrowserTest.ObsoleteHttpCredentialMovedOnMigrationToHstsSite (Closed)
Patch Set: comments Created 3 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 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 "base/run_loop.h"
11 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
12 #include "components/password_manager/core/browser/password_store_consumer.h" 13 #include "components/password_manager/core/browser/password_store_consumer.h"
13 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/test/test_utils.h"
15 #include "net/cert/mock_cert_verifier.h" 15 #include "net/cert/mock_cert_verifier.h"
16 #include "net/test/embedded_test_server/embedded_test_server.h" 16 #include "net/test/embedded_test_server/embedded_test_server.h"
17 17
18 namespace autofill { 18 namespace autofill {
19 struct PasswordForm; 19 struct PasswordForm;
20 } 20 }
21 21
22 class ManagePasswordsUIController; 22 class ManagePasswordsUIController;
23 23
24 class NavigationObserver : public content::WebContentsObserver { 24 class NavigationObserver : public content::WebContentsObserver {
(...skipping 21 matching lines...) Expand all
46 // content::WebContentsObserver: 46 // content::WebContentsObserver:
47 void DidFinishNavigation( 47 void DidFinishNavigation(
48 content::NavigationHandle* navigation_handle) override; 48 content::NavigationHandle* navigation_handle) override;
49 void DidFinishLoad(content::RenderFrameHost* render_frame_host, 49 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
50 const GURL& validated_url) override; 50 const GURL& validated_url) override;
51 51
52 private: 52 private:
53 std::string wait_for_path_; 53 std::string wait_for_path_;
54 content::RenderFrameHost* render_frame_host_; 54 content::RenderFrameHost* render_frame_host_;
55 bool quit_on_entry_committed_; 55 bool quit_on_entry_committed_;
56 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; 56 base::RunLoop run_loop_;
57 57
58 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); 58 DISALLOW_COPY_AND_ASSIGN(NavigationObserver);
59 }; 59 };
60 60
61 // Observes the save password prompt for a specified WebContents, keeps track of 61 // Observes the save password prompt for a specified WebContents, keeps track of
62 // whether or not it is currently shown, and allows accepting saving passwords 62 // whether or not it is currently shown, and allows accepting saving passwords
63 // through it. 63 // through it.
64 class BubbleObserver { 64 class BubbleObserver {
65 public: 65 public:
66 explicit BubbleObserver(content::WebContents* web_contents); 66 explicit BubbleObserver(content::WebContents* web_contents);
67 67
68 // Checks if the save prompt is being currently shown. 68 // Checks if the save prompt is being currently shown.
69 bool IsShowingSavePrompt() const; 69 bool IsShowingSavePrompt() const;
70 70
71 // Checks if the update prompt is being currently shown. 71 // Checks if the update prompt is being currently shown.
72 bool IsShowingUpdatePrompt() const; 72 bool IsShowingUpdatePrompt() const;
73 73
74 // Dismisses the prompt currently open and moves the controller to the 74 // Dismisses the prompt currently open and moves the controller to the
75 // inactive state. 75 // inactive state.
76 void Dismiss() const; 76 void Dismiss() const;
77 77
78 // Expecting that the prompt is shown, saves the password. Checks that the 78 // Expecting that the prompt is shown, saves the password. Checks that the
79 // prompt is no longer visible afterwards. 79 // prompt is no longer visible afterwards.
80 void AcceptSavePrompt() const; 80 void AcceptSavePrompt() const;
81 81
82 // Expecting that the prompt is shown, update |form| with the password from 82 // Expecting that the prompt is shown, update |form| with the password from
83 // observed form. Checks that the prompt is no longer visible afterwards. 83 // observed form. Checks that the prompt is no longer visible afterwards.
84 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; 84 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const;
85 85
86 // Returns once the account chooser pops up or it's already shown.
87 // |web_contents| must be the custom one returned by
88 // PasswordManagerBrowserTestBase.
89 void WaitForAccountChooser() const;
90
86 private: 91 private:
87 ManagePasswordsUIController* const passwords_ui_controller_; 92 ManagePasswordsUIController* const passwords_ui_controller_;
88 93
89 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); 94 DISALLOW_COPY_AND_ASSIGN(BubbleObserver);
90 }; 95 };
91 96
92 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { 97 class PasswordManagerBrowserTestBase : public InProcessBrowserTest {
93 public: 98 public:
94 PasswordManagerBrowserTestBase(); 99 PasswordManagerBrowserTestBase();
95 ~PasswordManagerBrowserTestBase() override; 100 ~PasswordManagerBrowserTestBase() override;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const std::string& expected_value); 141 const std::string& expected_value);
137 // Same as above except the element |element_id| is in iframe |iframe_id| 142 // Same as above except the element |element_id| is in iframe |iframe_id|
138 void CheckElementValue(const std::string& iframe_id, 143 void CheckElementValue(const std::string& iframe_id,
139 const std::string& element_id, 144 const std::string& element_id,
140 const std::string& expected_value); 145 const std::string& expected_value);
141 146
142 // Synchronoulsy adds the given host to the list of valid HSTS hosts. 147 // Synchronoulsy adds the given host to the list of valid HSTS hosts.
143 void AddHSTSHost(const std::string& host); 148 void AddHSTSHost(const std::string& host);
144 149
145 // Accessors 150 // Accessors
151 // Return the first created tab with a custom ManagePasswordsUIController.
146 content::WebContents* WebContents(); 152 content::WebContents* WebContents();
147 content::RenderViewHost* RenderViewHost(); 153 content::RenderViewHost* RenderViewHost();
148 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } 154 net::EmbeddedTestServer& https_test_server() { return https_test_server_; }
149 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } 155 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; }
150 156
151 private: 157 private:
152 net::EmbeddedTestServer https_test_server_; 158 net::EmbeddedTestServer https_test_server_;
153 net::MockCertVerifier mock_cert_verifier_; 159 net::MockCertVerifier mock_cert_verifier_;
160 // A tab with some hooks injected.
161 content::WebContents* web_contents_;
154 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); 162 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase);
155 }; 163 };
156 164
157 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ 165 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698