| 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 "chrome/browser/chromeos/input_method/candidate_window_controller_impl.
h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl.
h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace chromeos { | 9 namespace chromeos { |
| 10 namespace input_method { | 10 namespace input_method { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 virtual ~CandidateWindowControllerImplTest() { | 52 virtual ~CandidateWindowControllerImplTest() { |
| 53 } | 53 } |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 const gfx::Rect kScreenRect; | 56 const gfx::Rect kScreenRect; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 TEST_F(CandidateWindowControllerImplTest, | 59 TEST_F(CandidateWindowControllerImplTest, |
| 60 ConvertLookupTableToInfolistEntryTest_DenseCase) { | 60 ConvertLookupTableToInfolistEntryTest_DenseCase) { |
| 61 CandidateWindow candidate_window; | 61 ui::CandidateWindow candidate_window; |
| 62 candidate_window.set_page_size(10); | 62 candidate_window.set_page_size(10); |
| 63 for (size_t i = 0; i < kSampleCandidateSize; ++i) { | 63 for (size_t i = 0; i < kSampleCandidateSize; ++i) { |
| 64 CandidateWindow::Entry entry; | 64 ui::CandidateWindow::Entry entry; |
| 65 entry.value = kSampleCandidate[i]; | 65 entry.value = kSampleCandidate[i]; |
| 66 entry.description_title = kSampleDescriptionTitle[i]; | 66 entry.description_title = kSampleDescriptionTitle[i]; |
| 67 entry.description_body = kSampleDescriptionBody[i]; | 67 entry.description_body = kSampleDescriptionBody[i]; |
| 68 candidate_window.mutable_candidates()->push_back(entry); | 68 candidate_window.mutable_candidates()->push_back(entry); |
| 69 } | 69 } |
| 70 candidate_window.set_cursor_position(1); | 70 candidate_window.set_cursor_position(1); |
| 71 | 71 |
| 72 std::vector<InfolistEntry> infolist_entries; | 72 std::vector<InfolistEntry> infolist_entries; |
| 73 bool has_highlighted = false; | 73 bool has_highlighted = false; |
| 74 | 74 |
| 75 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( | 75 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( |
| 76 candidate_window, | 76 candidate_window, |
| 77 &infolist_entries, | 77 &infolist_entries, |
| 78 &has_highlighted); | 78 &has_highlighted); |
| 79 | 79 |
| 80 EXPECT_EQ(kSampleCandidateSize, infolist_entries.size()); | 80 EXPECT_EQ(kSampleCandidateSize, infolist_entries.size()); |
| 81 EXPECT_TRUE(has_highlighted); | 81 EXPECT_TRUE(has_highlighted); |
| 82 EXPECT_TRUE(infolist_entries[1].highlighted); | 82 EXPECT_TRUE(infolist_entries[1].highlighted); |
| 83 } | 83 } |
| 84 | 84 |
| 85 TEST_F(CandidateWindowControllerImplTest, | 85 TEST_F(CandidateWindowControllerImplTest, |
| 86 ConvertLookupTableToInfolistEntryTest_SparseCase) { | 86 ConvertLookupTableToInfolistEntryTest_SparseCase) { |
| 87 CandidateWindow candidate_window; | 87 ui::CandidateWindow candidate_window; |
| 88 candidate_window.set_page_size(10); | 88 candidate_window.set_page_size(10); |
| 89 for (size_t i = 0; i < kSampleCandidateSize; ++i) { | 89 for (size_t i = 0; i < kSampleCandidateSize; ++i) { |
| 90 CandidateWindow::Entry entry; | 90 ui::CandidateWindow::Entry entry; |
| 91 entry.value = kSampleCandidate[i]; | 91 entry.value = kSampleCandidate[i]; |
| 92 candidate_window.mutable_candidates()->push_back(entry); | 92 candidate_window.mutable_candidates()->push_back(entry); |
| 93 } | 93 } |
| 94 | 94 |
| 95 std::vector<CandidateWindow::Entry>* candidates = | 95 std::vector<ui::CandidateWindow::Entry>* candidates = |
| 96 candidate_window.mutable_candidates(); | 96 candidate_window.mutable_candidates(); |
| 97 (*candidates)[2].description_title = kSampleDescriptionTitle[2]; | 97 (*candidates)[2].description_title = kSampleDescriptionTitle[2]; |
| 98 (*candidates)[2].description_body = kSampleDescriptionBody[2]; | 98 (*candidates)[2].description_body = kSampleDescriptionBody[2]; |
| 99 | 99 |
| 100 candidate_window.set_cursor_position(2); | 100 candidate_window.set_cursor_position(2); |
| 101 | 101 |
| 102 std::vector<InfolistEntry> infolist_entries; | 102 std::vector<InfolistEntry> infolist_entries; |
| 103 bool has_highlighted = false; | 103 bool has_highlighted = false; |
| 104 | 104 |
| 105 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( | 105 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( |
| 106 candidate_window, | 106 candidate_window, |
| 107 &infolist_entries, | 107 &infolist_entries, |
| 108 &has_highlighted); | 108 &has_highlighted); |
| 109 | 109 |
| 110 // Infolist entries skips empty descriptions, so expected entry size is 1. | 110 // Infolist entries skips empty descriptions, so expected entry size is 1. |
| 111 EXPECT_EQ(1UL, infolist_entries.size()); | 111 EXPECT_EQ(1UL, infolist_entries.size()); |
| 112 EXPECT_TRUE(has_highlighted); | 112 EXPECT_TRUE(has_highlighted); |
| 113 EXPECT_TRUE(infolist_entries[0].highlighted); | 113 EXPECT_TRUE(infolist_entries[0].highlighted); |
| 114 } | 114 } |
| 115 | 115 |
| 116 TEST_F(CandidateWindowControllerImplTest, | 116 TEST_F(CandidateWindowControllerImplTest, |
| 117 ConvertLookupTableToInfolistEntryTest_SparseNoSelectionCase) { | 117 ConvertLookupTableToInfolistEntryTest_SparseNoSelectionCase) { |
| 118 CandidateWindow candidate_window; | 118 ui::CandidateWindow candidate_window; |
| 119 candidate_window.set_page_size(10); | 119 candidate_window.set_page_size(10); |
| 120 | 120 |
| 121 for (size_t i = 0; i < kSampleCandidateSize; ++i) { | 121 for (size_t i = 0; i < kSampleCandidateSize; ++i) { |
| 122 CandidateWindow::Entry entry; | 122 ui::CandidateWindow::Entry entry; |
| 123 entry.value = kSampleCandidate[i]; | 123 entry.value = kSampleCandidate[i]; |
| 124 candidate_window.mutable_candidates()->push_back(entry); | 124 candidate_window.mutable_candidates()->push_back(entry); |
| 125 } | 125 } |
| 126 | 126 |
| 127 std::vector<CandidateWindow::Entry>* candidates = | 127 std::vector<ui::CandidateWindow::Entry>* candidates = |
| 128 candidate_window.mutable_candidates(); | 128 candidate_window.mutable_candidates(); |
| 129 (*candidates)[2].description_title = kSampleDescriptionTitle[2]; | 129 (*candidates)[2].description_title = kSampleDescriptionTitle[2]; |
| 130 (*candidates)[2].description_body = kSampleDescriptionBody[2]; | 130 (*candidates)[2].description_body = kSampleDescriptionBody[2]; |
| 131 | 131 |
| 132 candidate_window.set_cursor_position(0); | 132 candidate_window.set_cursor_position(0); |
| 133 | 133 |
| 134 std::vector<InfolistEntry> infolist_entries; | 134 std::vector<InfolistEntry> infolist_entries; |
| 135 bool has_highlighted; | 135 bool has_highlighted; |
| 136 | 136 |
| 137 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( | 137 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( |
| 138 candidate_window, | 138 candidate_window, |
| 139 &infolist_entries, | 139 &infolist_entries, |
| 140 &has_highlighted); | 140 &has_highlighted); |
| 141 | 141 |
| 142 // Infolist entries skips empty descriptions, so expected entry size is 1 and | 142 // Infolist entries skips empty descriptions, so expected entry size is 1 and |
| 143 // no highlighted entries. | 143 // no highlighted entries. |
| 144 EXPECT_EQ(1UL, infolist_entries.size()); | 144 EXPECT_EQ(1UL, infolist_entries.size()); |
| 145 EXPECT_FALSE(has_highlighted); | 145 EXPECT_FALSE(has_highlighted); |
| 146 EXPECT_FALSE(infolist_entries[0].highlighted); | 146 EXPECT_FALSE(infolist_entries[0].highlighted); |
| 147 } | 147 } |
| 148 | 148 |
| 149 TEST_F(CandidateWindowControllerImplTest, | 149 TEST_F(CandidateWindowControllerImplTest, |
| 150 ConvertLookupTableToInfolistEntryTest_NoInfolistCase) { | 150 ConvertLookupTableToInfolistEntryTest_NoInfolistCase) { |
| 151 CandidateWindow candidate_window; | 151 ui::CandidateWindow candidate_window; |
| 152 candidate_window.set_page_size(10); | 152 candidate_window.set_page_size(10); |
| 153 | 153 |
| 154 for (size_t i = 0; i < kSampleCandidateSize; ++i) { | 154 for (size_t i = 0; i < kSampleCandidateSize; ++i) { |
| 155 CandidateWindow::Entry entry; | 155 ui::CandidateWindow::Entry entry; |
| 156 entry.value = kSampleCandidate[i]; | 156 entry.value = kSampleCandidate[i]; |
| 157 candidate_window.mutable_candidates()->push_back(entry); | 157 candidate_window.mutable_candidates()->push_back(entry); |
| 158 } | 158 } |
| 159 candidate_window.set_cursor_position(1); | 159 candidate_window.set_cursor_position(1); |
| 160 | 160 |
| 161 std::vector<InfolistEntry> infolist_entries; | 161 std::vector<InfolistEntry> infolist_entries; |
| 162 bool has_highlighted = false; | 162 bool has_highlighted = false; |
| 163 | 163 |
| 164 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( | 164 TestableCandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( |
| 165 candidate_window, | 165 candidate_window, |
| 166 &infolist_entries, | 166 &infolist_entries, |
| 167 &has_highlighted); | 167 &has_highlighted); |
| 168 | 168 |
| 169 EXPECT_TRUE(infolist_entries.empty()); | 169 EXPECT_TRUE(infolist_entries.empty()); |
| 170 EXPECT_FALSE(has_highlighted); | 170 EXPECT_FALSE(has_highlighted); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace input_method | 173 } // namespace input_method |
| 174 } // namespace chromeos | 174 } // namespace chromeos |
| OLD | NEW |