diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 03:35:51 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-20 03:35:51 +0000 |
commit | 61f6cee64ce4c4271e7a4652a908490f48e028fb (patch) | |
tree | dba77d19e08901c8d7bb10e38602f4acd13320d4 /chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc | |
parent | ac7cc2b66e7d5668a4b97d4c2726c5c88cc94583 (diff) | |
download | chromium_src-61f6cee64ce4c4271e7a4652a908490f48e028fb.zip chromium_src-61f6cee64ce4c4271e7a4652a908490f48e028fb.tar.gz chromium_src-61f6cee64ce4c4271e7a4652a908490f48e028fb.tar.bz2 |
AutofillDialogControllerImpl refinements
1) merge Hide() and DelegateDestroyed()
2) remove possible hide/show race condition
BUG=none
Review URL: https://chromiumcodereview.appspot.com/11570057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc')
-rw-r--r-- | chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc index f90fd19..efc5e4d 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc @@ -57,9 +57,13 @@ class TestAutofillPopupController : public AutofillPopupControllerImpl { bool RemoveSelectedLine() { return AutofillPopupControllerImpl::RemoveSelectedLine(); } + void DoHide() { + AutofillPopupControllerImpl::Hide(); + } MOCK_METHOD1(InvalidateRow, void(size_t)); MOCK_METHOD0(UpdateBoundsAndRedrawPopup, void()); + MOCK_METHOD0(Hide, void()); private: virtual void ShowView() OVERRIDE {} @@ -77,7 +81,7 @@ class AutofillPopupControllerUnitTest : public ::testing::Test { // This will make sure the controller and the view (if any) are both // cleaned up. if (autofill_popup_controller_) - autofill_popup_controller_->Hide(); + autofill_popup_controller_->DoHide(); } AutofillPopupController* popup_controller() { @@ -209,3 +213,54 @@ TEST_F(AutofillPopupControllerUnitTest, SkipSeparator) { autofill_popup_controller_->SelectPreviousLine(); EXPECT_EQ(0, autofill_popup_controller_->selected_line()); } + +TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) { + MockAutofillExternalDelegate delegate; + + AutofillPopupControllerImpl* controller = + AutofillPopupControllerImpl::GetOrCreate( + NULL, + &delegate, + NULL, + gfx::Rect()); + EXPECT_TRUE(controller); + + // This should not inform |delegate| of its destruction. + EXPECT_CALL(delegate, ControllerDestroyed()).Times(0); + controller->Hide(); + + controller = + AutofillPopupControllerImpl::GetOrCreate( + NULL, + &delegate, + NULL, + gfx::Rect()); + EXPECT_TRUE(controller); + AutofillPopupControllerImpl* controller2 = + AutofillPopupControllerImpl::GetOrCreate( + controller, + &delegate, + NULL, + gfx::Rect()); + EXPECT_EQ(controller, controller2); + controller->Hide(); + + TestAutofillPopupController* test_controller = + new TestAutofillPopupController(&delegate); + EXPECT_CALL(*test_controller, Hide()); + + gfx::Rect bounds(0, 0, 1, 2); + AutofillPopupControllerImpl* controller3 = + AutofillPopupControllerImpl::GetOrCreate( + test_controller, + &delegate, + NULL, + bounds); + EXPECT_EQ( + bounds, + static_cast<AutofillPopupController*>(controller3)->element_bounds()); + controller3->Hide(); + + EXPECT_CALL(delegate, ControllerDestroyed()); + delete test_controller; +} |