diff options
author | uekawa@chromium.org <uekawa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 15:51:06 +0000 |
---|---|---|
committer | uekawa@chromium.org <uekawa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-13 15:51:06 +0000 |
commit | 269305943d476666de052881029a481577f0145e (patch) | |
tree | 442291a0acb42d71431c1fb8125519a7d1a215fe /ash/ime | |
parent | 5f38661ebabcd5329cd9d36c8fd146254abc1529 (diff) | |
download | chromium_src-269305943d476666de052881029a481577f0145e.zip chromium_src-269305943d476666de052881029a481577f0145e.tar.gz chromium_src-269305943d476666de052881029a481577f0145e.tar.bz2 |
Migrate CandidateWindow::Entry to string16.
BUG=329604
Review URL: https://codereview.chromium.org/162723003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/ime')
-rw-r--r-- | ash/ime/candidate_view.cc | 10 | ||||
-rw-r--r-- | ash/ime/candidate_window_view.cc | 11 | ||||
-rw-r--r-- | ash/ime/candidate_window_view.h | 2 | ||||
-rw-r--r-- | ash/ime/candidate_window_view_unittest.cc | 74 |
4 files changed, 51 insertions, 46 deletions
diff --git a/ash/ime/candidate_view.cc b/ash/ime/candidate_view.cc index 82c90092..83c930f 100644 --- a/ash/ime/candidate_view.cc +++ b/ash/ime/candidate_view.cc @@ -174,12 +174,12 @@ void CandidateView::SetWidths(int shortcut_width, int candidate_width) { } void CandidateView::SetEntry(const ui::CandidateWindow::Entry& entry) { - std::string label = entry.label; + base::string16 label = entry.label; if (!label.empty() && orientation_ != ui::CandidateWindow::VERTICAL) - label += '.'; - shortcut_label_->SetText(base::UTF8ToUTF16(label)); - candidate_label_->SetText(base::UTF8ToUTF16(entry.value)); - annotation_label_->SetText(base::UTF8ToUTF16(entry.annotation)); + label += base::ASCIIToUTF16("."); + shortcut_label_->SetText(label); + candidate_label_->SetText(entry.value); + annotation_label_->SetText(entry.annotation); } void CandidateView::SetInfolistIcon(bool enable) { diff --git a/ash/ime/candidate_window_view.cc b/ash/ime/candidate_window_view.cc index 8865e64..ec158ac 100644 --- a/ash/ime/candidate_window_view.cc +++ b/ash/ime/candidate_window_view.cc @@ -114,8 +114,8 @@ class InformationTextArea : public views::View { } // Sets the displayed text. - void SetText(const std::string& utf8_text) { - label_->SetText(base::UTF8ToUTF16(utf8_text)); + void SetText(const base::string16& text) { + label_->SetText(text); } // Sets the border thickness for top/bottom. @@ -225,8 +225,8 @@ void CandidateWindowView::ShowPreeditText() { UpdateVisibility(); } -void CandidateWindowView::UpdatePreeditText(const std::string& utf8_text) { - preedit_->SetText(utf8_text); +void CandidateWindowView::UpdatePreeditText(const base::string16& text) { + preedit_->SetText(text); } void CandidateWindowView::ShowLookupTable() { @@ -335,7 +335,8 @@ void CandidateWindowView::UpdateCandidates( // Updates auxiliary text auxiliary_text_->SetVisible(candidate_window_.is_auxiliary_text_visible()); - auxiliary_text_->SetText(candidate_window_.auxiliary_text()); + auxiliary_text_->SetText(base::UTF8ToUTF16( + candidate_window_.auxiliary_text())); } void CandidateWindowView::SetCursorBounds(const gfx::Rect& cursor_bounds, diff --git a/ash/ime/candidate_window_view.h b/ash/ime/candidate_window_view.h index 34bdcf3..ee2c510 100644 --- a/ash/ime/candidate_window_view.h +++ b/ash/ime/candidate_window_view.h @@ -61,7 +61,7 @@ class ASH_EXPORT CandidateWindowView : public views::BubbleDelegateView, void ShowPreeditText(); // Updates the preedit text. - void UpdatePreeditText(const std::string& utf8_text); + void UpdatePreeditText(const base::string16& text); // Updates candidates of the candidate window from |candidate_window|. // Candidates are arranged per |orientation|. diff --git a/ash/ime/candidate_window_view_unittest.cc b/ash/ime/candidate_window_view_unittest.cc index 45ab518..b0295fe 100644 --- a/ash/ime/candidate_window_view_unittest.cc +++ b/ash/ime/candidate_window_view_unittest.cc @@ -52,10 +52,10 @@ void InitCandidateWindowWithCandidatesFilled( InitCandidateWindow(page_size, candidate_window); for (size_t i = 0; i < page_size; ++i) { ui::CandidateWindow::Entry entry; - entry.value = base::StringPrintf("value %lld", - static_cast<unsigned long long>(i)); - entry.label = base::StringPrintf("%lld", - static_cast<unsigned long long>(i)); + entry.value = base::UTF8ToUTF16(base::StringPrintf( + "value %lld", static_cast<unsigned long long>(i))); + entry.label = base::UTF8ToUTF16(base::StringPrintf( + "%lld", static_cast<unsigned long long>(i))); candidate_window->mutable_candidates()->push_back(entry); } } @@ -188,11 +188,11 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) { candidate_window.set_orientation(ui::CandidateWindow::VERTICAL); for (size_t i = 0; i < kPageSize; ++i) { ui::CandidateWindow::Entry entry; - entry.value = kSampleCandidate[i]; - entry.annotation = kSampleAnnotation[i]; - entry.description_title = kSampleDescriptionTitle[i]; - entry.description_body = kSampleDescriptionBody[i]; - entry.label = kEmptyLabel; + entry.value = base::UTF8ToUTF16(kSampleCandidate[i]); + entry.annotation = base::UTF8ToUTF16(kSampleAnnotation[i]); + entry.description_title = base::UTF8ToUTF16(kSampleDescriptionTitle[i]); + entry.description_body = base::UTF8ToUTF16(kSampleDescriptionBody[i]); + entry.label = base::UTF8ToUTF16(kEmptyLabel); candidate_window.mutable_candidates()->push_back(entry); } @@ -214,11 +214,11 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) { candidate_window.set_orientation(ui::CandidateWindow::HORIZONTAL); for (size_t i = 0; i < kPageSize; ++i) { ui::CandidateWindow::Entry entry; - entry.value = kSampleCandidate[i]; - entry.annotation = kSampleAnnotation[i]; - entry.description_title = kSampleDescriptionTitle[i]; - entry.description_body = kSampleDescriptionBody[i]; - entry.label = kEmptyLabel; + entry.value = base::UTF8ToUTF16(kSampleCandidate[i]); + entry.annotation = base::UTF8ToUTF16(kSampleAnnotation[i]); + entry.description_title = base::UTF8ToUTF16(kSampleDescriptionTitle[i]); + entry.description_body = base::UTF8ToUTF16(kSampleDescriptionBody[i]); + entry.label = base::UTF8ToUTF16(kEmptyLabel); candidate_window.mutable_candidates()->push_back(entry); } @@ -240,11 +240,11 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) { candidate_window.set_orientation(ui::CandidateWindow::VERTICAL); for (size_t i = 0; i < kPageSize; ++i) { ui::CandidateWindow::Entry entry; - entry.value = kSampleCandidate[i]; - entry.annotation = kSampleAnnotation[i]; - entry.description_title = kSampleDescriptionTitle[i]; - entry.description_body = kSampleDescriptionBody[i]; - entry.label = kCustomizedLabel[i]; + entry.value = base::UTF8ToUTF16(kSampleCandidate[i]); + entry.annotation = base::UTF8ToUTF16(kSampleAnnotation[i]); + entry.description_title = base::UTF8ToUTF16(kSampleDescriptionTitle[i]); + entry.description_body = base::UTF8ToUTF16(kSampleDescriptionBody[i]); + entry.label = base::UTF8ToUTF16(kCustomizedLabel[i]); candidate_window.mutable_candidates()->push_back(entry); } @@ -268,11 +268,11 @@ TEST_F(CandidateWindowViewTest, ShortcutSettingTest) { candidate_window.set_orientation(ui::CandidateWindow::HORIZONTAL); for (size_t i = 0; i < kPageSize; ++i) { ui::CandidateWindow::Entry entry; - entry.value = kSampleCandidate[i]; - entry.annotation = kSampleAnnotation[i]; - entry.description_title = kSampleDescriptionTitle[i]; - entry.description_body = kSampleDescriptionBody[i]; - entry.label = kCustomizedLabel[i]; + entry.value = base::UTF8ToUTF16(kSampleCandidate[i]); + entry.annotation = base::UTF8ToUTF16(kSampleAnnotation[i]); + entry.description_title = base::UTF8ToUTF16(kSampleDescriptionTitle[i]); + entry.description_body = base::UTF8ToUTF16(kSampleDescriptionBody[i]); + entry.label = base::UTF8ToUTF16(kCustomizedLabel[i]); candidate_window.mutable_candidates()->push_back(entry); } @@ -294,17 +294,21 @@ TEST_F(CandidateWindowViewTest, DoNotChangeRowHeightWithLabelSwitchTest) { ui::CandidateWindow candidate_window; ui::CandidateWindow no_shortcut_candidate_window; - const char kSampleCandidate1[] = "Sample String 1"; - const char kSampleCandidate2[] = "\xE3\x81\x82"; // multi byte string. - const char kSampleCandidate3[] = "....."; - - const char kSampleShortcut1[] = "1"; - const char kSampleShortcut2[] = "b"; - const char kSampleShortcut3[] = "C"; - - const char kSampleAnnotation1[] = "Sample Annotation 1"; - const char kSampleAnnotation2[] = "\xE3\x81\x82"; // multi byte string. - const char kSampleAnnotation3[] = "......"; + const base::string16 kSampleCandidate1 = base::UTF8ToUTF16( + "Sample String 1"); + const base::string16 kSampleCandidate2 = base::UTF8ToUTF16( + "\xE3\x81\x82"); // multi byte string. + const base::string16 kSampleCandidate3 = base::UTF8ToUTF16("....."); + + const base::string16 kSampleShortcut1 = base::UTF8ToUTF16("1"); + const base::string16 kSampleShortcut2 = base::UTF8ToUTF16("b"); + const base::string16 kSampleShortcut3 = base::UTF8ToUTF16("C"); + + const base::string16 kSampleAnnotation1 = base::UTF8ToUTF16( + "Sample Annotation 1"); + const base::string16 kSampleAnnotation2 = base::UTF8ToUTF16( + "\xE3\x81\x82"); // multi byte string. + const base::string16 kSampleAnnotation3 = base::UTF8ToUTF16("......"); // Create CandidateWindow object. InitCandidateWindow(kPageSize, &candidate_window); |