OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 6 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" | 8 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 class TestPopupObserver : public autofill::PasswordGenerationPopupObserver { | 25 class TestPopupObserver : public autofill::PasswordGenerationPopupObserver { |
26 public: | 26 public: |
27 TestPopupObserver() | 27 TestPopupObserver() |
28 : popup_showing_(false), | 28 : popup_showing_(false), |
29 password_visible_(false) {} | 29 password_visible_(false) {} |
30 virtual ~TestPopupObserver() {} | 30 virtual ~TestPopupObserver() {} |
31 | 31 |
32 virtual void OnPopupShown(bool password_visible) OVERRIDE { | 32 virtual void OnPopupShown(bool password_visible) override { |
33 popup_showing_ = true; | 33 popup_showing_ = true; |
34 password_visible_ = password_visible; | 34 password_visible_ = password_visible; |
35 } | 35 } |
36 | 36 |
37 virtual void OnPopupHidden() OVERRIDE { | 37 virtual void OnPopupHidden() override { |
38 popup_showing_ = false; | 38 popup_showing_ = false; |
39 } | 39 } |
40 | 40 |
41 bool popup_showing() { return popup_showing_; } | 41 bool popup_showing() { return popup_showing_; } |
42 bool password_visible() { return password_visible_; } | 42 bool password_visible() { return password_visible_; } |
43 | 43 |
44 private: | 44 private: |
45 bool popup_showing_; | 45 bool popup_showing_; |
46 bool password_visible_; | 46 bool password_visible_; |
47 }; | 47 }; |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 class PasswordGenerationInteractiveTest : public InProcessBrowserTest { | 51 class PasswordGenerationInteractiveTest : public InProcessBrowserTest { |
52 public: | 52 public: |
53 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 53 virtual void SetUpCommandLine(CommandLine* command_line) override { |
54 // Make sure the feature is enabled. | 54 // Make sure the feature is enabled. |
55 command_line->AppendSwitch(autofill::switches::kEnablePasswordGeneration); | 55 command_line->AppendSwitch(autofill::switches::kEnablePasswordGeneration); |
56 | 56 |
57 // Don't require ping from autofill or blacklist checking. | 57 // Don't require ping from autofill or blacklist checking. |
58 command_line->AppendSwitch( | 58 command_line->AppendSwitch( |
59 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration); | 59 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration); |
60 } | 60 } |
61 | 61 |
62 virtual void SetUpOnMainThread() OVERRIDE { | 62 virtual void SetUpOnMainThread() override { |
63 // Disable Autofill requesting access to AddressBook data. This will cause | 63 // Disable Autofill requesting access to AddressBook data. This will cause |
64 // the tests to hang on Mac. | 64 // the tests to hang on Mac. |
65 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); | 65 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); |
66 | 66 |
67 // Set observer for popup. | 67 // Set observer for popup. |
68 ChromePasswordManagerClient* client = | 68 ChromePasswordManagerClient* client = |
69 ChromePasswordManagerClient::FromWebContents(GetWebContents()); | 69 ChromePasswordManagerClient::FromWebContents(GetWebContents()); |
70 client->SetTestObserver(&observer_); | 70 client->SetTestObserver(&observer_); |
71 | 71 |
72 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 72 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
73 GURL url = embedded_test_server()->GetURL("/password/signup_form.html"); | 73 GURL url = embedded_test_server()->GetURL("/password/signup_form.html"); |
74 ui_test_utils::NavigateToURL(browser(), url); | 74 ui_test_utils::NavigateToURL(browser(), url); |
75 } | 75 } |
76 | 76 |
77 virtual void TearDownOnMainThread() OVERRIDE { | 77 virtual void TearDownOnMainThread() override { |
78 // Clean up UI. | 78 // Clean up UI. |
79 ChromePasswordManagerClient* client = | 79 ChromePasswordManagerClient* client = |
80 ChromePasswordManagerClient::FromWebContents(GetWebContents()); | 80 ChromePasswordManagerClient::FromWebContents(GetWebContents()); |
81 client->HidePasswordGenerationPopup(); | 81 client->HidePasswordGenerationPopup(); |
82 } | 82 } |
83 | 83 |
84 content::WebContents* GetWebContents() { | 84 content::WebContents* GetWebContents() { |
85 return browser()->tab_strip_model()->GetActiveWebContents(); | 85 return browser()->tab_strip_model()->GetActiveWebContents(); |
86 } | 86 } |
87 | 87 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest, | 184 IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest, |
185 MAYBE_PopupShownAndDismissedByScrolling) { | 185 MAYBE_PopupShownAndDismissedByScrolling) { |
186 FocusPasswordField(); | 186 FocusPasswordField(); |
187 EXPECT_TRUE(GenerationPopupShowing()); | 187 EXPECT_TRUE(GenerationPopupShowing()); |
188 | 188 |
189 ASSERT_TRUE(content::ExecuteScript(GetRenderViewHost(), | 189 ASSERT_TRUE(content::ExecuteScript(GetRenderViewHost(), |
190 "window.scrollTo(100, 0);")); | 190 "window.scrollTo(100, 0);")); |
191 | 191 |
192 EXPECT_FALSE(GenerationPopupShowing()); | 192 EXPECT_FALSE(GenerationPopupShowing()); |
193 } | 193 } |
OLD | NEW |