| 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 19 matching lines...) Expand all Loading... |
| 124 browser()->OpenURL(content::OpenURLParams( | 116 browser()->OpenURL(content::OpenURLParams( |
| 125 GURL(chrome::kChromeUIBookmarksURL), content::Referrer(), | 117 GURL(chrome::kChromeUIBookmarksURL), content::Referrer(), |
| 126 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 118 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); |
| 127 browser()->OpenURL(content::OpenURLParams( | 119 browser()->OpenURL(content::OpenURLParams( |
| 128 GURL(chrome::kChromeUIAboutURL), content::Referrer(), | 120 GURL(chrome::kChromeUIAboutURL), content::Referrer(), |
| 129 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 121 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); |
| 130 observer.Wait(); | 122 observer.Wait(); |
| 131 | 123 |
| 132 EXPECT_TRUE(autofill_external_delegate_->popup_hidden()); | 124 EXPECT_TRUE(autofill_external_delegate_->popup_hidden()); |
| 133 } | 125 } |
| 134 | |
| 135 // Tests that closing the widget does not leak any resources. This test is | |
| 136 // only really meaningful when run on the memory bots. | |
| 137 IN_PROC_BROWSER_TEST_F(AutofillExternalDelegateBrowserTest, | |
| 138 CloseWidgetAndNoLeaking) { | |
| 139 autofill::GenerateTestAutofillPopup(autofill_external_delegate_.get()); | |
| 140 | |
| 141 // Delete the view from under the delegate to ensure that the | |
| 142 // delegate and the controller can handle the popup getting deleted elsewhere. | |
| 143 autofill_external_delegate_->GetController()->view()->Hide(); | |
| 144 } | |
| OLD | NEW |