| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 // AutofillManagerTestDelegateImpl -------------------------------------------- | 96 // AutofillManagerTestDelegateImpl -------------------------------------------- |
| 97 | 97 |
| 98 class AutofillManagerTestDelegateImpl | 98 class AutofillManagerTestDelegateImpl |
| 99 : public autofill::AutofillManagerTestDelegate { | 99 : public autofill::AutofillManagerTestDelegate { |
| 100 public: | 100 public: |
| 101 AutofillManagerTestDelegateImpl() {} | 101 AutofillManagerTestDelegateImpl() {} |
| 102 virtual ~AutofillManagerTestDelegateImpl() {} | 102 virtual ~AutofillManagerTestDelegateImpl() {} |
| 103 | 103 |
| 104 // autofill::AutofillManagerTestDelegate: | 104 // autofill::AutofillManagerTestDelegate: |
| 105 virtual void DidPreviewFormData() OVERRIDE { | 105 virtual void DidPreviewFormData() override { |
| 106 ASSERT_TRUE(loop_runner_->loop_running()); | 106 ASSERT_TRUE(loop_runner_->loop_running()); |
| 107 loop_runner_->Quit(); | 107 loop_runner_->Quit(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 virtual void DidFillFormData() OVERRIDE { | 110 virtual void DidFillFormData() override { |
| 111 ASSERT_TRUE(loop_runner_->loop_running()); | 111 ASSERT_TRUE(loop_runner_->loop_running()); |
| 112 loop_runner_->Quit(); | 112 loop_runner_->Quit(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 virtual void DidShowSuggestions() OVERRIDE { | 115 virtual void DidShowSuggestions() override { |
| 116 ASSERT_TRUE(loop_runner_->loop_running()); | 116 ASSERT_TRUE(loop_runner_->loop_running()); |
| 117 loop_runner_->Quit(); | 117 loop_runner_->Quit(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void Reset() { | 120 void Reset() { |
| 121 loop_runner_ = new content::MessageLoopRunner(); | 121 loop_runner_ = new content::MessageLoopRunner(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void Wait() { | 124 void Wait() { |
| 125 loop_runner_->Run(); | 125 loop_runner_->Run(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 virtual ~WindowedPersonalDataManagerObserver() { | 152 virtual ~WindowedPersonalDataManagerObserver() { |
| 153 while (infobar_service_->infobar_count() > 0) { | 153 while (infobar_service_->infobar_count() > 0) { |
| 154 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); | 154 infobar_service_->RemoveInfoBar(infobar_service_->infobar_at(0)); |
| 155 } | 155 } |
| 156 infobar_service_->RemoveObserver(this); | 156 infobar_service_->RemoveObserver(this); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // PersonalDataManagerObserver: | 159 // PersonalDataManagerObserver: |
| 160 virtual void OnPersonalDataChanged() OVERRIDE { | 160 virtual void OnPersonalDataChanged() override { |
| 161 if (has_run_message_loop_) { | 161 if (has_run_message_loop_) { |
| 162 base::MessageLoopForUI::current()->Quit(); | 162 base::MessageLoopForUI::current()->Quit(); |
| 163 has_run_message_loop_ = false; | 163 has_run_message_loop_ = false; |
| 164 } | 164 } |
| 165 alerted_ = true; | 165 alerted_ = true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 virtual void OnInsufficientFormData() OVERRIDE { | 168 virtual void OnInsufficientFormData() override { |
| 169 OnPersonalDataChanged(); | 169 OnPersonalDataChanged(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 | 172 |
| 173 void Wait() { | 173 void Wait() { |
| 174 if (!alerted_) { | 174 if (!alerted_) { |
| 175 has_run_message_loop_ = true; | 175 has_run_message_loop_ = true; |
| 176 content::RunMessageLoop(); | 176 content::RunMessageLoop(); |
| 177 } | 177 } |
| 178 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> | 178 PersonalDataManagerFactory::GetForProfile(browser_->profile())-> |
| 179 RemoveObserver(this); | 179 RemoveObserver(this); |
| 180 } | 180 } |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 // infobars::InfoBarManager::Observer: | 183 // infobars::InfoBarManager::Observer: |
| 184 virtual void OnInfoBarAdded(infobars::InfoBar* infobar) OVERRIDE { | 184 virtual void OnInfoBarAdded(infobars::InfoBar* infobar) override { |
| 185 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> | 185 infobar_service_->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate()-> |
| 186 Accept(); | 186 Accept(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 bool alerted_; | 189 bool alerted_; |
| 190 bool has_run_message_loop_; | 190 bool has_run_message_loop_; |
| 191 Browser* browser_; | 191 Browser* browser_; |
| 192 InfoBarService* infobar_service_; | 192 InfoBarService* infobar_service_; |
| 193 | 193 |
| 194 DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver); | 194 DISALLOW_COPY_AND_ASSIGN(WindowedPersonalDataManagerObserver); |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 // AutofillInteractiveTest ---------------------------------------------------- | 197 // AutofillInteractiveTest ---------------------------------------------------- |
| 198 | 198 |
| 199 class AutofillInteractiveTest : public InProcessBrowserTest { | 199 class AutofillInteractiveTest : public InProcessBrowserTest { |
| 200 protected: | 200 protected: |
| 201 AutofillInteractiveTest() : | 201 AutofillInteractiveTest() : |
| 202 key_press_event_sink_( | 202 key_press_event_sink_( |
| 203 base::Bind(&AutofillInteractiveTest::HandleKeyPressEvent, | 203 base::Bind(&AutofillInteractiveTest::HandleKeyPressEvent, |
| 204 base::Unretained(this))) {} | 204 base::Unretained(this))) {} |
| 205 virtual ~AutofillInteractiveTest() {} | 205 virtual ~AutofillInteractiveTest() {} |
| 206 | 206 |
| 207 // InProcessBrowserTest: | 207 // InProcessBrowserTest: |
| 208 virtual void SetUpOnMainThread() OVERRIDE { | 208 virtual void SetUpOnMainThread() override { |
| 209 // Don't want Keychain coming up on Mac. | 209 // Don't want Keychain coming up on Mac. |
| 210 test::DisableSystemServices(browser()->profile()->GetPrefs()); | 210 test::DisableSystemServices(browser()->profile()->GetPrefs()); |
| 211 | 211 |
| 212 // Inject the test delegate into the AutofillManager. | 212 // Inject the test delegate into the AutofillManager. |
| 213 content::WebContents* web_contents = GetWebContents(); | 213 content::WebContents* web_contents = GetWebContents(); |
| 214 ContentAutofillDriver* autofill_driver = | 214 ContentAutofillDriver* autofill_driver = |
| 215 ContentAutofillDriver::FromWebContents(web_contents); | 215 ContentAutofillDriver::FromWebContents(web_contents); |
| 216 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); | 216 AutofillManager* autofill_manager = autofill_driver->autofill_manager(); |
| 217 autofill_manager->SetTestDelegate(&test_delegate_); | 217 autofill_manager->SetTestDelegate(&test_delegate_); |
| 218 | 218 |
| 219 // If the mouse happened to be over where the suggestions are shown, then | 219 // If the mouse happened to be over where the suggestions are shown, then |
| 220 // the preview will show up and will fail the tests. We need to give it a | 220 // the preview will show up and will fail the tests. We need to give it a |
| 221 // point that's within the browser frame, or else the method hangs. | 221 // point that's within the browser frame, or else the method hangs. |
| 222 gfx::Point reset_mouse(GetWebContents()->GetContainerBounds().origin()); | 222 gfx::Point reset_mouse(GetWebContents()->GetContainerBounds().origin()); |
| 223 reset_mouse = gfx::Point(reset_mouse.x() + 5, reset_mouse.y() + 5); | 223 reset_mouse = gfx::Point(reset_mouse.x() + 5, reset_mouse.y() + 5); |
| 224 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(reset_mouse)); | 224 ASSERT_TRUE(ui_test_utils::SendMouseMoveSync(reset_mouse)); |
| 225 } | 225 } |
| 226 | 226 |
| 227 virtual void TearDownOnMainThread() OVERRIDE { | 227 virtual void TearDownOnMainThread() override { |
| 228 // Make sure to close any showing popups prior to tearing down the UI. | 228 // Make sure to close any showing popups prior to tearing down the UI. |
| 229 content::WebContents* web_contents = GetWebContents(); | 229 content::WebContents* web_contents = GetWebContents(); |
| 230 AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( | 230 AutofillManager* autofill_manager = ContentAutofillDriver::FromWebContents( |
| 231 web_contents)->autofill_manager(); | 231 web_contents)->autofill_manager(); |
| 232 autofill_manager->client()->HideAutofillPopup(); | 232 autofill_manager->client()->HideAutofillPopup(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 PersonalDataManager* GetPersonalDataManager() { | 235 PersonalDataManager* GetPersonalDataManager() { |
| 236 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); | 236 return PersonalDataManagerFactory::GetForProfile(browser()->profile()); |
| 237 } | 237 } |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1449 ASSERT_TRUE(content::ExecuteScript( | 1449 ASSERT_TRUE(content::ExecuteScript( |
| 1450 GetRenderViewHost(), | 1450 GetRenderViewHost(), |
| 1451 "document.querySelector('input').autocomplete = 'off';")); | 1451 "document.querySelector('input').autocomplete = 'off';")); |
| 1452 | 1452 |
| 1453 // Press the down arrow to select the suggestion and attempt to preview the | 1453 // Press the down arrow to select the suggestion and attempt to preview the |
| 1454 // autofilled form. | 1454 // autofilled form. |
| 1455 SendKeyToPopupAndWait(ui::VKEY_DOWN); | 1455 SendKeyToPopupAndWait(ui::VKEY_DOWN); |
| 1456 } | 1456 } |
| 1457 | 1457 |
| 1458 } // namespace autofill | 1458 } // namespace autofill |
| OLD | NEW |