| 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_popup_view.h" | 6 #include "chrome/browser/autofill/autofill_popup_view.h" |
| 7 #include "chrome/browser/autofill/test_autofill_external_delegate.h" | 7 #include "chrome/browser/autofill/test_autofill_external_delegate.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 autofill_popup_view_->autofill_values().size() - 1); | 146 autofill_popup_view_->autofill_values().size() - 1); |
| 147 EXPECT_FALSE(autofill_popup_view_->RemoveSelectedLine()); | 147 EXPECT_FALSE(autofill_popup_view_->RemoveSelectedLine()); |
| 148 EXPECT_LE(0, autofill_popup_view_->selected_line()); | 148 EXPECT_LE(0, autofill_popup_view_->selected_line()); |
| 149 | 149 |
| 150 // Remove the first (and only) entry. The popup should then be hidden since | 150 // Remove the first (and only) entry. The popup should then be hidden since |
| 151 // there are no Autofill entries left. | 151 // there are no Autofill entries left. |
| 152 EXPECT_CALL(*autofill_popup_view_, HideInternal()); | 152 EXPECT_CALL(*autofill_popup_view_, HideInternal()); |
| 153 autofill_popup_view_->SetSelectedLine(0); | 153 autofill_popup_view_->SetSelectedLine(0); |
| 154 EXPECT_TRUE(autofill_popup_view_->RemoveSelectedLine()); | 154 EXPECT_TRUE(autofill_popup_view_->RemoveSelectedLine()); |
| 155 } | 155 } |
| 156 |
| 157 TEST_F(AutofillPopupViewUnitTest, SkipSeparator) { |
| 158 // Set up the popup. |
| 159 std::vector<string16> autofill_values(3, string16()); |
| 160 std::vector<int> autofill_ids; |
| 161 autofill_ids.push_back(1); |
| 162 autofill_ids.push_back(WebAutofillClient::MenuItemIDSeparator); |
| 163 autofill_ids.push_back(WebAutofillClient::MenuItemIDAutofillOptions); |
| 164 autofill_popup_view_->Show(autofill_values, autofill_values, autofill_values, |
| 165 autofill_ids); |
| 166 |
| 167 // To remove warnings. |
| 168 EXPECT_CALL(*autofill_popup_view_, InvalidateRow(_)).Times(AtLeast(0)); |
| 169 |
| 170 autofill_popup_view_->SetSelectedLine(0); |
| 171 |
| 172 // Make sure next skips the unselectable separator. |
| 173 autofill_popup_view_->SelectNextLine(); |
| 174 EXPECT_EQ(2, autofill_popup_view_->selected_line()); |
| 175 |
| 176 // Make sure previous skips the unselectable separator. |
| 177 autofill_popup_view_->SelectPreviousLine(); |
| 178 EXPECT_EQ(0, autofill_popup_view_->selected_line()); |
| 179 } |
| OLD | NEW |