| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 void SelectNextLine() { | 46 void SelectNextLine() { |
| 47 AutofillPopupView::SelectNextLine(); | 47 AutofillPopupView::SelectNextLine(); |
| 48 } | 48 } |
| 49 void SelectPreviousLine() { | 49 void SelectPreviousLine() { |
| 50 AutofillPopupView::SelectPreviousLine(); | 50 AutofillPopupView::SelectPreviousLine(); |
| 51 } | 51 } |
| 52 bool RemoveSelectedLine() { | 52 bool RemoveSelectedLine() { |
| 53 return AutofillPopupView::RemoveSelectedLine(); | 53 return AutofillPopupView::RemoveSelectedLine(); |
| 54 } | 54 } |
| 55 bool IsSeparatorIndex(int index) { | |
| 56 return AutofillPopupView::IsSeparatorIndex(index); | |
| 57 } | |
| 58 | 55 |
| 59 MOCK_METHOD1(InvalidateRow, void(size_t)); | 56 MOCK_METHOD1(InvalidateRow, void(size_t)); |
| 60 MOCK_METHOD0(HideInternal, void()); | 57 MOCK_METHOD0(HideInternal, void()); |
| 61 | 58 |
| 62 private: | 59 private: |
| 63 virtual void ShowInternal() OVERRIDE {} | 60 virtual void ShowInternal() OVERRIDE {} |
| 64 | 61 |
| 65 virtual void ResizePopup() OVERRIDE {} | 62 virtual void ResizePopup() OVERRIDE {} |
| 66 }; | 63 }; |
| 67 | 64 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 autofill_popup_view_->autofill_values().size() - 1); | 146 autofill_popup_view_->autofill_values().size() - 1); |
| 150 EXPECT_FALSE(autofill_popup_view_->RemoveSelectedLine()); | 147 EXPECT_FALSE(autofill_popup_view_->RemoveSelectedLine()); |
| 151 EXPECT_LE(0, autofill_popup_view_->selected_line()); | 148 EXPECT_LE(0, autofill_popup_view_->selected_line()); |
| 152 | 149 |
| 153 // 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 |
| 154 // there are no Autofill entries left. | 151 // there are no Autofill entries left. |
| 155 EXPECT_CALL(*autofill_popup_view_, HideInternal()); | 152 EXPECT_CALL(*autofill_popup_view_, HideInternal()); |
| 156 autofill_popup_view_->SetSelectedLine(0); | 153 autofill_popup_view_->SetSelectedLine(0); |
| 157 EXPECT_TRUE(autofill_popup_view_->RemoveSelectedLine()); | 154 EXPECT_TRUE(autofill_popup_view_->RemoveSelectedLine()); |
| 158 } | 155 } |
| 159 | |
| 160 TEST_F(AutofillPopupViewUnitTest, IsSeparatorIndex) { | |
| 161 // Set up the popup. | |
| 162 std::vector<string16> autofill_values(3, string16()); | |
| 163 std::vector<int> autofill_ids; | |
| 164 autofill_ids.push_back(3); | |
| 165 autofill_ids.push_back(WebAutofillClient::MenuItemIDClearForm); | |
| 166 autofill_ids.push_back(WebAutofillClient::MenuItemIDAutofillOptions); | |
| 167 | |
| 168 autofill_popup_view_->Show(autofill_values, autofill_values, autofill_values, | |
| 169 autofill_ids); | |
| 170 | |
| 171 EXPECT_FALSE(autofill_popup_view_->IsSeparatorIndex(0)); | |
| 172 EXPECT_TRUE(autofill_popup_view_->IsSeparatorIndex(1)); | |
| 173 EXPECT_FALSE(autofill_popup_view_->IsSeparatorIndex(2)); | |
| 174 } | |
| OLD | NEW |