| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "chrome/browser/autofill/autofill_manager.h" | 6 #include "chrome/browser/autofill/autofill_manager.h" |
| 7 #include "chrome/browser/autofill/test_autofill_external_delegate.h" | 7 #include "chrome/browser/autofill/test_autofill_external_delegate.h" |
| 8 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 8 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 9 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 9 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 virtual void SetUpOnMainThread() OVERRIDE { | 78 virtual void SetUpOnMainThread() OVERRIDE { |
| 79 web_contents_ = browser()->tab_strip_model()->GetActiveWebContents(); | 79 web_contents_ = browser()->tab_strip_model()->GetActiveWebContents(); |
| 80 ASSERT_TRUE(web_contents_ != NULL); | 80 ASSERT_TRUE(web_contents_ != NULL); |
| 81 Observe(web_contents_); | 81 Observe(web_contents_); |
| 82 | 82 |
| 83 autofill_external_delegate_.reset( | 83 autofill_external_delegate_.reset( |
| 84 new MockAutofillExternalDelegate(web_contents_)); | 84 new MockAutofillExternalDelegate(web_contents_)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Normally the WebContents will automatically delete the delegate, but here | |
| 88 // the delegate is owned by this test, so we have to manually destroy. | |
| 89 virtual void WebContentsDestroyed(content::WebContents* web_contents) | |
| 90 OVERRIDE { | |
| 91 DCHECK_EQ(web_contents_, web_contents); | |
| 92 autofill_external_delegate_.reset(); | |
| 93 } | |
| 94 | |
| 95 protected: | 87 protected: |
| 96 content::WebContents* web_contents_; | 88 content::WebContents* web_contents_; |
| 97 scoped_ptr<MockAutofillExternalDelegate> autofill_external_delegate_; | 89 scoped_ptr<MockAutofillExternalDelegate> autofill_external_delegate_; |
| 98 }; | 90 }; |
| 99 | 91 |
| 100 IN_PROC_BROWSER_TEST_F(AutofillExternalDelegateBrowserTest, | 92 IN_PROC_BROWSER_TEST_F(AutofillExternalDelegateBrowserTest, |
| 101 SwitchTabAndHideAutofillPopup) { | 93 SwitchTabAndHideAutofillPopup) { |
| 102 autofill::GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 94 autofill::GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
| 103 | 95 |
| 104 content::WindowedNotificationObserver observer( | 96 content::WindowedNotificationObserver observer( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 135 // Tests that closing the widget does not leak any resources. This test is | 127 // Tests that closing the widget does not leak any resources. This test is |
| 136 // only really meaningful when run on the memory bots. | 128 // only really meaningful when run on the memory bots. |
| 137 IN_PROC_BROWSER_TEST_F(AutofillExternalDelegateBrowserTest, | 129 IN_PROC_BROWSER_TEST_F(AutofillExternalDelegateBrowserTest, |
| 138 CloseWidgetAndNoLeaking) { | 130 CloseWidgetAndNoLeaking) { |
| 139 autofill::GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 131 autofill::GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
| 140 | 132 |
| 141 // Delete the view from under the delegate to ensure that the | 133 // Delete the view from under the delegate to ensure that the |
| 142 // delegate and the controller can handle the popup getting deleted elsewhere. | 134 // delegate and the controller can handle the popup getting deleted elsewhere. |
| 143 autofill_external_delegate_->GetController()->view()->Hide(); | 135 autofill_external_delegate_->GetController()->view()->Hide(); |
| 144 } | 136 } |
| OLD | NEW |