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/weak_ptr.h" | 5 #include "base/memory/weak_ptr.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.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 "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 // Remove the first entry. The popup should be redrawn since its size has | 217 // Remove the first entry. The popup should be redrawn since its size has |
218 // changed. | 218 // changed. |
219 EXPECT_CALL(*autofill_popup_controller_, UpdateBoundsAndRedrawPopup()); | 219 EXPECT_CALL(*autofill_popup_controller_, UpdateBoundsAndRedrawPopup()); |
220 autofill_popup_controller_->SetSelectedLine(0); | 220 autofill_popup_controller_->SetSelectedLine(0); |
221 EXPECT_TRUE(autofill_popup_controller_->RemoveSelectedLine()); | 221 EXPECT_TRUE(autofill_popup_controller_->RemoveSelectedLine()); |
222 | 222 |
223 // Remove the last entry. The popup should then be hidden since there are | 223 // Remove the last entry. The popup should then be hidden since there are |
224 // no Autofill entries left. | 224 // no Autofill entries left. |
225 autofill_popup_controller_->SetSelectedLine(0); | 225 autofill_popup_controller_->SetSelectedLine(0); |
226 // The controller self-deletes here, don't double delete. | |
227 EXPECT_TRUE(autofill_popup_controller_->RemoveSelectedLine()); | 226 EXPECT_TRUE(autofill_popup_controller_->RemoveSelectedLine()); |
228 autofill_popup_controller_ = NULL; | |
229 } | 227 } |
230 | 228 |
231 TEST_F(AutofillPopupControllerUnitTest, SkipSeparator) { | 229 TEST_F(AutofillPopupControllerUnitTest, SkipSeparator) { |
232 // Set up the popup. | 230 // Set up the popup. |
233 std::vector<string16> names(3, string16()); | 231 std::vector<string16> names(3, string16()); |
234 std::vector<int> autofill_ids; | 232 std::vector<int> autofill_ids; |
235 autofill_ids.push_back(1); | 233 autofill_ids.push_back(1); |
236 autofill_ids.push_back(WebAutofillClient::MenuItemIDSeparator); | 234 autofill_ids.push_back(WebAutofillClient::MenuItemIDSeparator); |
237 autofill_ids.push_back(WebAutofillClient::MenuItemIDAutofillOptions); | 235 autofill_ids.push_back(WebAutofillClient::MenuItemIDAutofillOptions); |
238 autofill_popup_controller_->Show(names, names, names, autofill_ids); | 236 autofill_popup_controller_->Show(names, names, names, autofill_ids); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 TestAutofillPopupController autofill_popup_controller(&external_delegate_, | 379 TestAutofillPopupController autofill_popup_controller(&external_delegate_, |
382 element_bounds[i]); | 380 element_bounds[i]); |
383 autofill_popup_controller.set_display(display); | 381 autofill_popup_controller.set_display(display); |
384 autofill_popup_controller.Show(names, names, names, autofill_ids); | 382 autofill_popup_controller.Show(names, names, names, autofill_ids); |
385 | 383 |
386 EXPECT_EQ(expected_popup_bounds[i].ToString(), | 384 EXPECT_EQ(expected_popup_bounds[i].ToString(), |
387 autofill_popup_controller.popup_bounds().ToString()) << | 385 autofill_popup_controller.popup_bounds().ToString()) << |
388 "Popup bounds failed to match for test " << i; | 386 "Popup bounds failed to match for test " << i; |
389 } | 387 } |
390 } | 388 } |
OLD | NEW |