Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Unified Diff: chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc

Issue 2766263007: Verify that previous_selected_line is within bounds before passing to (Closed)
Patch Set: Removes extra newline. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/autofill/autofill_popup_controller_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc
diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc
index a8557401c3ec20622449c9675cb7a2512787ecd7..7f77edc661e5909647840a5457721a7ce6c7399c 100644
--- a/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc
+++ b/chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc
@@ -32,6 +32,7 @@
using ::testing::_;
using ::testing::AtLeast;
+using ::testing::Mock;
using ::testing::NiceMock;
using base::ASCIIToUTF16;
using base::WeakPtr;
@@ -246,16 +247,30 @@ TEST_F(AutofillPopupControllerUnitTest, RemoveLine) {
// No line is selected so the removal should fail.
EXPECT_FALSE(autofill_popup_controller_->RemoveSelectedLine());
+ // Select the first entry.
+ base::Optional<int> selected_line(0);
+ EXPECT_CALL(*autofill_popup_view_,
+ OnSelectedRowChanged(kNoSelection, selected_line));
+ autofill_popup_controller_->SetSelectedLine(selected_line);
+ Mock::VerifyAndClearExpectations(autofill_popup_view());
+
// Remove the first entry. The popup should be redrawn since its size has
// changed.
+ EXPECT_CALL(*autofill_popup_view_, OnSelectedRowChanged(_, _)).Times(0);
EXPECT_CALL(*autofill_popup_controller_, OnSuggestionsChanged());
- autofill_popup_controller_->SetSelectedLine(0);
EXPECT_TRUE(autofill_popup_controller_->RemoveSelectedLine());
+ Mock::VerifyAndClearExpectations(autofill_popup_view());
+
+ // Select the last entry.
+ EXPECT_CALL(*autofill_popup_view_,
+ OnSelectedRowChanged(kNoSelection, selected_line));
+ autofill_popup_controller_->SetSelectedLine(selected_line);
+ Mock::VerifyAndClearExpectations(autofill_popup_view());
// Remove the last entry. The popup should then be hidden since there are
// no Autofill entries left.
+ EXPECT_CALL(*autofill_popup_view_, OnSelectedRowChanged(_, _)).Times(0);
EXPECT_CALL(*autofill_popup_controller_, Hide());
- autofill_popup_controller_->SetSelectedLine(0);
EXPECT_TRUE(autofill_popup_controller_->RemoveSelectedLine());
}
@@ -268,18 +283,20 @@ TEST_F(AutofillPopupControllerUnitTest, RemoveOnlyLine) {
// Generate a popup.
autofill::GenerateTestAutofillPopup(external_delegate_.get());
+ // No selection immediately after drawing popup.
+ EXPECT_FALSE(autofill_popup_controller_->selected_line());
+
// Select the only line.
base::Optional<int> selected_line(0);
- autofill_popup_controller_->SetSelectedLine(selected_line);
EXPECT_CALL(*autofill_popup_view_,
- OnSelectedRowChanged(kNoSelection, selected_line))
- .Times(0);
+ OnSelectedRowChanged(kNoSelection, selected_line));
+ autofill_popup_controller_->SetSelectedLine(selected_line);
+ Mock::VerifyAndClearExpectations(autofill_popup_view());
// Remove the only line. The popup should then be hidden since there are no
// Autofill entries left.
EXPECT_CALL(*autofill_popup_controller_, Hide());
- EXPECT_CALL(*autofill_popup_view_,
- OnSelectedRowChanged(selected_line, kNoSelection));
+ EXPECT_CALL(*autofill_popup_view_, OnSelectedRowChanged(_, _)).Times(0);
EXPECT_TRUE(autofill_popup_controller_->RemoveSelectedLine());
}
« no previous file with comments | « chrome/browser/ui/autofill/autofill_popup_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698