| Index: chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc
|
| diff --git a/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc b/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc
|
| index 40a2b82e912e82d639e254fc0c448b745c1b22b1..7f987d216dfbb70f0f46cd608426a349a607cd24 100644
|
| --- a/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc
|
| +++ b/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc
|
| @@ -21,11 +21,6 @@ const char* kSampleCandidate[] = {
|
| "Sample Candidate 2",
|
| "Sample Candidate 3"
|
| };
|
| -const char* kSampleLabel[] = {
|
| - "Sample Label 1",
|
| - "Sample Label 2",
|
| - "Sample Label 3"
|
| -};
|
| const char* kSampleAnnotation[] = {
|
| "Sample Annotation 1",
|
| "Sample Annotation 2",
|
| @@ -42,15 +37,12 @@ const char* kSampleDescriptionBody[] = {
|
| "Sample Description Body 3",
|
| };
|
|
|
| -void ClearInputMethodLookupTable(size_t page_size,
|
| - InputMethodLookupTable* table) {
|
| - table->visible = false;
|
| - table->cursor_absolute_index = 0;
|
| - table->page_size = page_size;
|
| - table->candidates.clear();
|
| - table->orientation = InputMethodLookupTable::kVertical;
|
| - table->labels.clear();
|
| - table->annotations.clear();
|
| +void InitIBusLookupTable(size_t page_size,
|
| + ibus::IBusLookupTable* table) {
|
| + table->set_cursor_position(0);
|
| + table->set_page_size(page_size);
|
| + table->mutable_candidates()->clear();
|
| + table->set_orientation(ibus::IBusLookupTable::VERTICAL);
|
| }
|
|
|
| } // namespace
|
| @@ -67,148 +59,6 @@ class CandidateWindowViewTest : public views::ViewsTestBase {
|
| }
|
| };
|
|
|
| -TEST_F(CandidateWindowViewTest, ShouldUpdateCandidateViewsTest) {
|
| - // This test verifies the process of judging update lookup-table or not.
|
| - // This judgement is handled by ShouldUpdateCandidateViews, which returns true
|
| - // if update is necessary and vice versa.
|
| - InputMethodLookupTable old_table;
|
| - InputMethodLookupTable new_table;
|
| -
|
| - const size_t kPageSize = 10;
|
| -
|
| - ClearInputMethodLookupTable(kPageSize, &old_table);
|
| - ClearInputMethodLookupTable(kPageSize, &new_table);
|
| -
|
| - old_table.visible = true;
|
| - old_table.cursor_absolute_index = 0;
|
| - old_table.page_size = 1;
|
| - old_table.candidates.clear();
|
| - old_table.orientation = InputMethodLookupTable::kVertical;
|
| - old_table.labels.clear();
|
| - old_table.annotations.clear();
|
| -
|
| - new_table = old_table;
|
| -
|
| - EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - new_table.visible = false;
|
| - // Visibility would be ignored.
|
| - EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table = old_table;
|
| - new_table.candidates.push_back(kSampleCandidate[0]);
|
| - old_table.candidates.push_back(kSampleCandidate[0]);
|
| - EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.labels.push_back(kSampleLabel[0]);
|
| - old_table.labels.push_back(kSampleLabel[0]);
|
| - EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.annotations.push_back(kSampleAnnotation[0]);
|
| - old_table.annotations.push_back(kSampleAnnotation[0]);
|
| - EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - InputMethodLookupTable::Description description;
|
| - description.title = kSampleDescriptionTitle[0];
|
| - description.body = kSampleDescriptionBody[0];
|
| -
|
| - new_table.descriptions.push_back(description);
|
| - old_table.descriptions.push_back(description);
|
| - EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - new_table.cursor_absolute_index = 1;
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table = old_table;
|
| -
|
| - new_table.page_size = 2;
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table = old_table;
|
| -
|
| - new_table.orientation = InputMethodLookupTable::kHorizontal;
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - new_table = old_table;
|
| - new_table.candidates.push_back(kSampleCandidate[1]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - old_table.candidates.push_back(kSampleCandidate[2]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.candidates.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.candidates.push_back(kSampleCandidate[1]);
|
| - old_table.candidates.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - new_table = old_table;
|
| - new_table.labels.push_back(kSampleLabel[1]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - old_table.labels.push_back(kSampleLabel[2]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.labels.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.labels.push_back(kSampleLabel[1]);
|
| - old_table.labels.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - new_table = old_table;
|
| - new_table.annotations.push_back(kSampleAnnotation[1]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - old_table.annotations.push_back(kSampleAnnotation[2]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.annotations.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.annotations.push_back(kSampleAnnotation[1]);
|
| - old_table.annotations.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - new_table = old_table;
|
| - new_table.annotations.push_back(kSampleDescriptionTitle[1]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - old_table.annotations.push_back(kSampleDescriptionTitle[2]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.annotations.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.annotations.push_back(kSampleDescriptionTitle[1]);
|
| - old_table.annotations.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -
|
| - new_table = old_table;
|
| - new_table.annotations.push_back(kSampleDescriptionBody[1]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - old_table.annotations.push_back(kSampleDescriptionBody[2]);
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.annotations.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| - new_table.annotations.push_back(kSampleDescriptionBody[1]);
|
| - old_table.annotations.clear();
|
| - EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
|
| - new_table));
|
| -}
|
| -
|
| TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
|
| const char* kEmptyLabel = "";
|
| const char* kCustomizedLabel[] = { "a", "s", "d" };
|
| @@ -226,8 +76,8 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
|
| SCOPED_TRACE("candidate_views allocation test");
|
| const size_t kMaxPageSize = 16;
|
| for (size_t i = 1; i < kMaxPageSize; ++i) {
|
| - InputMethodLookupTable table;
|
| - ClearInputMethodLookupTable(i, &table);
|
| + ibus::IBusLookupTable table;
|
| + InitIBusLookupTable(i, &table);
|
| candidate_window_view.UpdateCandidates(table);
|
| EXPECT_EQ(i, candidate_window_view.candidate_views_.size());
|
| }
|
| @@ -235,18 +85,18 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
|
| {
|
| SCOPED_TRACE("Empty string for each labels expects empty labels(vertical)");
|
| const size_t kPageSize = 3;
|
| - InputMethodLookupTable table;
|
| - ClearInputMethodLookupTable(kPageSize, &table);
|
| + ibus::IBusLookupTable table;
|
| + InitIBusLookupTable(kPageSize, &table);
|
|
|
| - table.orientation = InputMethodLookupTable::kVertical;
|
| + table.set_orientation(ibus::IBusLookupTable::VERTICAL);
|
| for (size_t i = 0; i < kPageSize; ++i) {
|
| - table.candidates.push_back(kSampleCandidate[i]);
|
| - table.annotations.push_back(kSampleAnnotation[i]);
|
| - InputMethodLookupTable::Description description;
|
| - description.title = kSampleDescriptionTitle[i];
|
| - description.body = kSampleDescriptionBody[i];
|
| - table.descriptions.push_back(description);
|
| - table.labels.push_back(kEmptyLabel);
|
| + ibus::IBusLookupTable::Entry entry;
|
| + entry.value = kSampleCandidate[i];
|
| + entry.annotation = kSampleAnnotation[i];
|
| + entry.description_title = kSampleDescriptionTitle[i];
|
| + entry.description_body = kSampleDescriptionBody[i];
|
| + entry.label = kEmptyLabel;
|
| + table.mutable_candidates()->push_back(entry);
|
| }
|
|
|
| candidate_window_view.UpdateCandidates(table);
|
| @@ -261,18 +111,18 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
|
| SCOPED_TRACE(
|
| "Empty string for each labels expect empty labels(horizontal)");
|
| const size_t kPageSize = 3;
|
| - InputMethodLookupTable table;
|
| - ClearInputMethodLookupTable(kPageSize, &table);
|
| + ibus::IBusLookupTable table;
|
| + InitIBusLookupTable(kPageSize, &table);
|
|
|
| - table.orientation = InputMethodLookupTable::kHorizontal;
|
| + table.set_orientation(ibus::IBusLookupTable::HORIZONTAL);
|
| for (size_t i = 0; i < kPageSize; ++i) {
|
| - table.candidates.push_back(kSampleCandidate[i]);
|
| - table.annotations.push_back(kSampleAnnotation[i]);
|
| - InputMethodLookupTable::Description description;
|
| - description.title = kSampleDescriptionTitle[i];
|
| - description.body = kSampleDescriptionBody[i];
|
| - table.descriptions.push_back(description);
|
| - table.labels.push_back(kEmptyLabel);
|
| + ibus::IBusLookupTable::Entry entry;
|
| + entry.value = kSampleCandidate[i];
|
| + entry.annotation = kSampleAnnotation[i];
|
| + entry.description_title = kSampleDescriptionTitle[i];
|
| + entry.description_body = kSampleDescriptionBody[i];
|
| + entry.label = kEmptyLabel;
|
| + table.mutable_candidates()->push_back(entry);
|
| }
|
|
|
| candidate_window_view.UpdateCandidates(table);
|
| @@ -287,18 +137,18 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
|
| {
|
| SCOPED_TRACE("Vertical customized label case");
|
| const size_t kPageSize = 3;
|
| - InputMethodLookupTable table;
|
| - ClearInputMethodLookupTable(kPageSize, &table);
|
| + ibus::IBusLookupTable table;
|
| + InitIBusLookupTable(kPageSize, &table);
|
|
|
| - table.orientation = InputMethodLookupTable::kVertical;
|
| + table.set_orientation(ibus::IBusLookupTable::VERTICAL);
|
| for (size_t i = 0; i < kPageSize; ++i) {
|
| - table.candidates.push_back(kSampleCandidate[i]);
|
| - table.annotations.push_back(kSampleAnnotation[i]);
|
| - InputMethodLookupTable::Description description;
|
| - description.title = kSampleDescriptionTitle[i];
|
| - description.body = kSampleDescriptionBody[i];
|
| - table.descriptions.push_back(description);
|
| - table.labels.push_back(kCustomizedLabel[i]);
|
| + ibus::IBusLookupTable::Entry entry;
|
| + entry.value = kSampleCandidate[i];
|
| + entry.annotation = kSampleAnnotation[i];
|
| + entry.description_title = kSampleDescriptionTitle[i];
|
| + entry.description_body = kSampleDescriptionBody[i];
|
| + entry.label = kCustomizedLabel[i];
|
| + table.mutable_candidates()->push_back(entry);
|
| }
|
|
|
| candidate_window_view.UpdateCandidates(table);
|
| @@ -315,18 +165,18 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
|
| {
|
| SCOPED_TRACE("Horizontal customized label case");
|
| const size_t kPageSize = 3;
|
| - InputMethodLookupTable table;
|
| - ClearInputMethodLookupTable(kPageSize, &table);
|
| + ibus::IBusLookupTable table;
|
| + InitIBusLookupTable(kPageSize, &table);
|
|
|
| - table.orientation = InputMethodLookupTable::kHorizontal;
|
| + table.set_orientation(ibus::IBusLookupTable::HORIZONTAL);
|
| for (size_t i = 0; i < kPageSize; ++i) {
|
| - table.candidates.push_back(kSampleCandidate[i]);
|
| - table.annotations.push_back(kSampleAnnotation[i]);
|
| - InputMethodLookupTable::Description description;
|
| - description.title = kSampleDescriptionTitle[i];
|
| - description.body = kSampleDescriptionBody[i];
|
| - table.descriptions.push_back(description);
|
| - table.labels.push_back(kCustomizedLabel[i]);
|
| + ibus::IBusLookupTable::Entry entry;
|
| + entry.value = kSampleCandidate[i];
|
| + entry.annotation = kSampleAnnotation[i];
|
| + entry.description_title = kSampleDescriptionTitle[i];
|
| + entry.description_body = kSampleDescriptionBody[i];
|
| + entry.label = kCustomizedLabel[i];
|
| + table.mutable_candidates()->push_back(entry);
|
| }
|
|
|
| candidate_window_view.UpdateCandidates(table);
|
| @@ -347,8 +197,8 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) {
|
|
|
| TEST_F(CandidateWindowViewTest, DoNotChangeRowHeightWithLabelSwitchTest) {
|
| const size_t kPageSize = 10;
|
| - InputMethodLookupTable table;
|
| - InputMethodLookupTable no_shortcut_table;
|
| + ibus::IBusLookupTable table;
|
| + ibus::IBusLookupTable no_shortcut_table;
|
|
|
| const char kSampleCandidate1[] = "Sample String 1";
|
| const char kSampleCandidate2[] = "\xE3\x81\x82"; // multi byte string.
|
| @@ -374,29 +224,32 @@ TEST_F(CandidateWindowViewTest, DoNotChangeRowHeightWithLabelSwitchTest) {
|
| candidate_window_view.Init();
|
|
|
| // Create LookupTable object.
|
| - ClearInputMethodLookupTable(kPageSize, &table);
|
| - table.visible = true;
|
| - table.cursor_absolute_index = 0;
|
| - table.page_size = 3;
|
| - table.candidates.clear();
|
| - table.orientation = InputMethodLookupTable::kVertical;
|
| - table.labels.clear();
|
| - table.annotations.clear();
|
| -
|
| - table.candidates.push_back(kSampleCandidate1);
|
| - table.candidates.push_back(kSampleCandidate2);
|
| - table.candidates.push_back(kSampleCandidate3);
|
| -
|
| - table.labels.push_back(kSampleShortcut1);
|
| - table.labels.push_back(kSampleShortcut2);
|
| - table.labels.push_back(kSampleShortcut3);
|
| -
|
| - table.annotations.push_back(kSampleAnnotation1);
|
| - table.annotations.push_back(kSampleAnnotation2);
|
| - table.annotations.push_back(kSampleAnnotation3);
|
| -
|
| - no_shortcut_table = table;
|
| - no_shortcut_table.labels.clear();
|
| + InitIBusLookupTable(kPageSize, &table);
|
| +
|
| + table.set_cursor_position(0);
|
| + table.set_page_size(3);
|
| + table.mutable_candidates()->clear();
|
| + table.set_orientation(ibus::IBusLookupTable::VERTICAL);
|
| + no_shortcut_table.CopyFrom(table);
|
| +
|
| + ibus::IBusLookupTable::Entry entry;
|
| + entry.value = kSampleCandidate1;
|
| + entry.annotation = kSampleAnnotation1;
|
| + table.mutable_candidates()->push_back(entry);
|
| + entry.label = kSampleShortcut1;
|
| + no_shortcut_table.mutable_candidates()->push_back(entry);
|
| +
|
| + entry.value = kSampleCandidate2;
|
| + entry.annotation = kSampleAnnotation2;
|
| + table.mutable_candidates()->push_back(entry);
|
| + entry.label = kSampleShortcut2;
|
| + no_shortcut_table.mutable_candidates()->push_back(entry);
|
| +
|
| + entry.value = kSampleCandidate3;
|
| + entry.annotation = kSampleAnnotation3;
|
| + table.mutable_candidates()->push_back(entry);
|
| + entry.label = kSampleShortcut3;
|
| + no_shortcut_table.mutable_candidates()->push_back(entry);
|
|
|
| int before_height = 0;
|
|
|
|
|