OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 7 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 // Normally the WebContents will automatically delete the delegate, but here | 91 // Normally the WebContents will automatically delete the delegate, but here |
92 // the delegate is owned by this test, so we have to manually destroy. | 92 // the delegate is owned by this test, so we have to manually destroy. |
93 void WebContentsDestroyed() override { autofill_external_delegate_.reset(); } | 93 void WebContentsDestroyed() override { autofill_external_delegate_.reset(); } |
94 | 94 |
95 protected: | 95 protected: |
96 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; | 96 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; |
97 }; | 97 }; |
98 | 98 |
99 // Autofill UI isn't currently hidden on window move on Mac. | |
100 // http://crbug.com/180566 | |
101 #if !defined(OS_MACOSX) | |
102 IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, | 99 IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, |
103 HidePopupOnWindowConfiguration) { | 100 DoNotHidePopupOnWindowMove) { |
| 101 GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
| 102 |
| 103 EXPECT_FALSE(autofill_external_delegate_->popup_hidden()); |
| 104 |
| 105 // Move the window, which should not cause the popup to hide. |
| 106 gfx::Rect new_bounds = browser()->window()->GetBounds() - gfx::Vector2d(1, 1); |
| 107 browser()->window()->SetBounds(new_bounds); |
| 108 |
| 109 EXPECT_FALSE(autofill_external_delegate_->popup_hidden()); |
| 110 } |
| 111 |
| 112 IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, |
| 113 HidePopupOnWindowResize) { |
104 GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 114 GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
105 | 115 |
106 EXPECT_FALSE(autofill_external_delegate_->popup_hidden()); | 116 EXPECT_FALSE(autofill_external_delegate_->popup_hidden()); |
107 | 117 |
108 // Resize the window, which should cause the popup to hide. | 118 // Resize the window, which should cause the popup to hide. |
109 gfx::Rect new_bounds = browser()->window()->GetBounds() - gfx::Vector2d(1, 1); | 119 gfx::Rect new_bounds = browser()->window()->GetBounds(); |
| 120 new_bounds.Inset(1, 1); |
110 browser()->window()->SetBounds(new_bounds); | 121 browser()->window()->SetBounds(new_bounds); |
111 | 122 |
112 autofill_external_delegate_->WaitForPopupHidden(); | 123 autofill_external_delegate_->WaitForPopupHidden(); |
113 EXPECT_TRUE(autofill_external_delegate_->popup_hidden()); | 124 EXPECT_TRUE(autofill_external_delegate_->popup_hidden()); |
114 } | 125 } |
115 #endif // !defined(OS_MACOSX) | |
116 | 126 |
117 // This test checks that the browser doesn't crash if the delegate is deleted | 127 // This test checks that the browser doesn't crash if the delegate is deleted |
118 // before the popup is hidden. | 128 // before the popup is hidden. |
119 IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, | 129 IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, |
120 DeleteDelegateBeforePopupHidden){ | 130 DeleteDelegateBeforePopupHidden){ |
121 GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 131 GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
122 | 132 |
123 // Delete the external delegate here so that is gets deleted before popup is | 133 // Delete the external delegate here so that is gets deleted before popup is |
124 // hidden. This can happen if the web_contents are destroyed before the popup | 134 // hidden. This can happen if the web_contents are destroyed before the popup |
125 // is hidden. See http://crbug.com/232475 | 135 // is hidden. See http://crbug.com/232475 |
126 autofill_external_delegate_.reset(); | 136 autofill_external_delegate_.reset(); |
127 } | 137 } |
128 | 138 |
129 } // namespace autofill | 139 } // namespace autofill |
OLD | NEW |