Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
InputMethodEngine's cached composition text should be cleared when re…
Browse files Browse the repository at this point in the history
…set & CommitText.

BUG=522782
TEST=Verified the bug not repro on local sandbox.

Review URL: https://codereview.chromium.org/1307783003

Cr-Commit-Position: refs/heads/master@{#345554}
(cherry picked from commit 952eb74)

Review URL: https://codereview.chromium.org/1320573004 .

Cr-Commit-Position: refs/branch-heads/2490@{#196}
Cr-Branched-From: 7790a35-refs/heads/master@{#344925}
  • Loading branch information
shuchen-google committed Sep 9, 2015
1 parent ccd2db1 commit 66f3e7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions chrome/browser/chromeos/input_method/input_method_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ bool InputMethodEngine::CommitText(int context_id, const char* text,
size_t len = GetUtf8StringLength(text);
UMA_HISTOGRAM_CUSTOM_COUNTS("InputMethod.CommitLength",
len, 1, 25, 25);
composition_text_.reset(new CompositionText());
}
return true;
}
Expand Down Expand Up @@ -613,6 +614,7 @@ void InputMethodEngine::PropertyActivate(const std::string& property_name) {
void InputMethodEngine::Reset() {
if (!CheckProfile())
return;
composition_text_.reset(new CompositionText());
observer_->OnReset(active_component_id_);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,17 @@ TEST_F(InputMethodEngineTest, TestHistograms) {
FocusIn(ui::TEXT_INPUT_TYPE_TEXT);
engine_->Enable(kTestImeComponentId);
std::vector<InputMethodEngineInterface::SegmentInfo> segments;
engine_->SetComposition(
engine_->GetCotextIdForTesting(), "test", 0, 0, 0, segments, NULL);
int context = engine_->GetCotextIdForTesting();
std::string error;
base::HistogramTester histograms;
engine_->CommitText(1, "input", &error);
engine_->CommitText(1,
engine_->SetComposition(context, "test", 0, 0, 0, segments, NULL);
engine_->CommitText(context, "input", &error);
engine_->SetComposition(context, "test", 0, 0, 0, segments, NULL);
engine_->CommitText(context,
"\xE5\x85\xA5\xE5\x8A\x9B", // 2 UTF-8 characters
&error);
engine_->CommitText(1, "input\xE5\x85\xA5\xE5\x8A\x9B", &error);
engine_->SetComposition(context, "test", 0, 0, 0, segments, NULL);
engine_->CommitText(context, "input\xE5\x85\xA5\xE5\x8A\x9B", &error);
histograms.ExpectTotalCount("InputMethod.CommitLength", 3);
histograms.ExpectBucketCount("InputMethod.CommitLength", 5, 1);
histograms.ExpectBucketCount("InputMethod.CommitLength", 2, 1);
Expand Down

0 comments on commit 66f3e7e

Please sign in to comment.