| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 ~AutofillInteractiveTest() override {} | 228 ~AutofillInteractiveTest() override {} |
| 229 | 229 |
| 230 // InProcessBrowserTest: | 230 // InProcessBrowserTest: |
| 231 void SetUpOnMainThread() override { | 231 void SetUpOnMainThread() override { |
| 232 // Don't want Keychain coming up on Mac. | 232 // Don't want Keychain coming up on Mac. |
| 233 test::DisableSystemServices(browser()->profile()->GetPrefs()); | 233 test::DisableSystemServices(browser()->profile()->GetPrefs()); |
| 234 | 234 |
| 235 // Inject the test delegate into the AutofillManager. | 235 // Inject the test delegate into the AutofillManager. |
| 236 content::WebContents* web_contents = GetWebContents(); | 236 content::WebContents* web_contents = GetWebContents(); |
| 237 ContentAutofillDriver* autofill_driver = | 237 ContentAutofillDriver* autofill_driver = |
| 238 ContentAutofillDriverFactory::FromWebContents(web_contents) | 238 static_cast<ContentAutofillDriver*>( |
| 239 ->DriverForFrame(web_contents->GetMainFrame()); | 239 ContentAutofillDriverFactory::FromWebContents(web_contents) |
| 240 ->DriverForFrame(web_contents->GetMainFrame())); |
| 240 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); | 241 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); |
| 241 autofill_manager->SetTestDelegate(&test_delegate_); | 242 autofill_manager->SetTestDelegate(&test_delegate_); |
| 242 | 243 |
| 243 // If the mouse happened to be over where the suggestions are shown, then | 244 // If the mouse happened to be over where the suggestions are shown, then |
| 244 // the preview will show up and will fail the tests. We need to give it a | 245 // the preview will show up and will fail the tests. We need to give it a |
| 245 // point that's within the browser frame, or else the method hangs. | 246 // point that's within the browser frame, or else the method hangs. |
| 246 gfx::Point reset_mouse(GetWebContents()->GetContainerBounds().origin()); | 247 gfx::Point reset_mouse(GetWebContents()->GetContainerBounds().origin()); |
| 247 reset_mouse = gfx::Point(reset_mouse.x() + 5, reset_mouse.y() + 5); | 248 reset_mouse = gfx::Point(reset_mouse.x() + 5, reset_mouse.y() + 5); |
| 248 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(reset_mouse)); | 249 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(reset_mouse)); |
| 249 | 250 |
| 250 ASSERT_TRUE(embedded_test_server()->Start()); | 251 ASSERT_TRUE(embedded_test_server()->Start()); |
| 251 InProcessBrowserTest::SetUpOnMainThread(); | 252 InProcessBrowserTest::SetUpOnMainThread(); |
| 252 } | 253 } |
| 253 | 254 |
| 254 void TearDownOnMainThread() override { | 255 void TearDownOnMainThread() override { |
| 255 // Make sure to close any showing popups prior to tearing down the UI. | 256 // Make sure to close any showing popups prior to tearing down the UI. |
| 256 content::WebContents* web_contents = GetWebContents(); | 257 content::WebContents* web_contents = GetWebContents(); |
| 257 AutofillManager* autofill_manager = | 258 AutofillManager* autofill_manager = |
| 258 ContentAutofillDriverFactory::FromWebContents(web_contents) | 259 static_cast<ContentAutofillDriver*>( |
| 259 ->DriverForFrame(web_contents->GetMainFrame()) | 260 ContentAutofillDriverFactory::FromWebContents(web_contents) |
| 261 ->DriverForFrame(web_contents->GetMainFrame())) |
| 260 ->autofill_manager(); | 262 ->autofill_manager(); |
| 261 autofill_manager->client()->HideAutofillPopup(); | 263 autofill_manager->client()->HideAutofillPopup(); |
| 262 test::ReenableSystemServices(); | 264 test::ReenableSystemServices(); |
| 263 } | 265 } |
| 264 | 266 |
| 265 content::WebContents* GetWebContents() { | 267 content::WebContents* GetWebContents() { |
| 266 return browser()->tab_strip_model()->GetActiveWebContents(); | 268 return browser()->tab_strip_model()->GetActiveWebContents(); |
| 267 } | 269 } |
| 268 | 270 |
| 269 content::RenderViewHost* GetRenderViewHost() { | 271 content::RenderViewHost* GetRenderViewHost() { |
| (...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), | 1729 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), |
| 1728 GURL(std::string(kDataURIPrefix) + kTestPasswordFormString))); | 1730 GURL(std::string(kDataURIPrefix) + kTestPasswordFormString))); |
| 1729 ASSERT_TRUE(content::ExecuteScript( | 1731 ASSERT_TRUE(content::ExecuteScript( |
| 1730 GetRenderViewHost(), | 1732 GetRenderViewHost(), |
| 1731 "document.getElementById('user').value = 'user';")); | 1733 "document.getElementById('user').value = 'user';")); |
| 1732 FocusFieldByName("password"); | 1734 FocusFieldByName("password"); |
| 1733 PasteStringAndWait("foobar"); | 1735 PasteStringAndWait("foobar"); |
| 1734 } | 1736 } |
| 1735 | 1737 |
| 1736 } // namespace autofill | 1738 } // namespace autofill |
| OLD | NEW |