| 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/password_generation_manager.h" | 6 #include "chrome/browser/password_manager/password_generation_manager.h" |
| 7 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" |
| 7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" | 9 #include "chrome/browser/ui/autofill/password_generation_popup_observer.h" |
| 9 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "components/autofill/core/browser/autofill_test_utils.h" | 14 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 14 #include "components/autofill/core/common/autofill_switches.h" | 15 #include "components/autofill/core/common/autofill_switches.h" |
| 15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration); | 55 autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration); |
| 55 } | 56 } |
| 56 | 57 |
| 57 virtual void SetUpOnMainThread() OVERRIDE { | 58 virtual void SetUpOnMainThread() OVERRIDE { |
| 58 // Disable Autofill requesting access to AddressBook data. This will cause | 59 // Disable Autofill requesting access to AddressBook data. This will cause |
| 59 // test tests to hang on Mac. | 60 // test tests to hang on Mac. |
| 60 autofill::test::DisableSystemServices(browser()->profile()); | 61 autofill::test::DisableSystemServices(browser()->profile()); |
| 61 | 62 |
| 62 // Set observer for popup. | 63 // Set observer for popup. |
| 63 PasswordGenerationManager* generation_manager = | 64 PasswordGenerationManager* generation_manager = |
| 64 PasswordGenerationManager::FromWebContents(GetWebContents()); | 65 PasswordManagerDelegateImpl::GetGenerationManagerFromWebContents( |
| 66 GetWebContents()); |
| 65 generation_manager->SetTestObserver(&observer_); | 67 generation_manager->SetTestObserver(&observer_); |
| 66 | 68 |
| 67 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 69 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 68 GURL url = embedded_test_server()->GetURL("/password/signup_form.html"); | 70 GURL url = embedded_test_server()->GetURL("/password/signup_form.html"); |
| 69 ui_test_utils::NavigateToURL(browser(), url); | 71 ui_test_utils::NavigateToURL(browser(), url); |
| 70 } | 72 } |
| 71 | 73 |
| 72 virtual void CleanUpOnMainThread() OVERRIDE { | 74 virtual void CleanUpOnMainThread() OVERRIDE { |
| 73 // Cleanup UI. | 75 // Cleanup UI. |
| 74 PasswordGenerationManager* generation_manager = | 76 PasswordGenerationManager* generation_manager = |
| 75 PasswordGenerationManager::FromWebContents(GetWebContents()); | 77 PasswordManagerDelegateImpl::GetGenerationManagerFromWebContents( |
| 78 GetWebContents()); |
| 76 generation_manager->HidePopup(); | 79 generation_manager->HidePopup(); |
| 77 } | 80 } |
| 78 | 81 |
| 79 content::WebContents* GetWebContents() { | 82 content::WebContents* GetWebContents() { |
| 80 return browser()->tab_strip_model()->GetActiveWebContents(); | 83 return browser()->tab_strip_model()->GetActiveWebContents(); |
| 81 } | 84 } |
| 82 | 85 |
| 83 content::RenderViewHost* GetRenderViewHost() { | 86 content::RenderViewHost* GetRenderViewHost() { |
| 84 return GetWebContents()->GetRenderViewHost(); | 87 return GetWebContents()->GetRenderViewHost(); |
| 85 } | 88 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest, | 141 IN_PROC_BROWSER_TEST_F(PasswordGenerationInteractiveTest, |
| 139 MAYBE_PopupShownAndDismissed) { | 142 MAYBE_PopupShownAndDismissed) { |
| 140 FocusPasswordField(); | 143 FocusPasswordField(); |
| 141 EXPECT_TRUE(popup_showing()); | 144 EXPECT_TRUE(popup_showing()); |
| 142 | 145 |
| 143 SendKeyToPopup(ui::VKEY_ESCAPE); | 146 SendKeyToPopup(ui::VKEY_ESCAPE); |
| 144 | 147 |
| 145 // Popup is dismissed. | 148 // Popup is dismissed. |
| 146 EXPECT_FALSE(popup_showing()); | 149 EXPECT_FALSE(popup_showing()); |
| 147 } | 150 } |
| OLD | NEW |