Commit 3c74037c authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

rule-based: Use native code for resetting engine.

<This change is hidden behind a flag>

As part of migrating PK rule-based IMEs to native code, this CL migrates
reset to native code path.

We port RuleBasedController#onCompositionCancelled in
chos/pk/rulebasedcontroller.js.

Note that we need onReset to call through to the extension, as it has
side effects that may affect the extension when it is running (e.g.
when VK is up).

Note that the JS code has already been guarded by the runtime flag.

Bug: 1009903
Change-Id: Ic1efc191fb7c963916b58cea4e8055d1d8ae6743
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1968776
Commit-Queue: Darren Shen <shend@chromium.org>
Reviewed-by: default avatarShu Chen <shuchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726145}
parent 3178100f
...@@ -118,6 +118,9 @@ void NativeInputMethodEngine::ImeObserver::OnKeyEvent( ...@@ -118,6 +118,9 @@ void NativeInputMethodEngine::ImeObserver::OnKeyEvent(
void NativeInputMethodEngine::ImeObserver::OnReset( void NativeInputMethodEngine::ImeObserver::OnReset(
const std::string& engine_id) { const std::string& engine_id) {
if (ShouldEngineUseMojo(engine_id)) {
remote_to_engine_->ResetForRulebased();
}
base_observer_->OnReset(engine_id); base_observer_->OnReset(engine_id);
} }
......
...@@ -128,12 +128,14 @@ class NativeInputMethodEngineTest : public InProcessBrowserTest, ...@@ -128,12 +128,14 @@ class NativeInputMethodEngineTest : public InProcessBrowserTest,
base::test::ScopedFeatureList feature_list_; base::test::ScopedFeatureList feature_list_;
}; };
// ID is specified in google_xkb_manifest.json.
constexpr char kEngineIdVietnameseTelex[] = "vkd_vi_telex";
} // namespace } // namespace
IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest, IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest,
VietnameseTelex_SimpleTransform) { VietnameseTelex_SimpleTransform) {
// ID is specified in google_xkb_manifest.json. engine_.Enable(kEngineIdVietnameseTelex);
engine_.Enable("vkd_vi_telex");
engine_.FlushForTesting(); engine_.FlushForTesting();
EXPECT_TRUE(engine_.IsConnectedForTesting()); EXPECT_TRUE(engine_.IsConnectedForTesting());
...@@ -157,3 +159,27 @@ IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest, ...@@ -157,3 +159,27 @@ IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest,
SetFocus(nullptr); SetFocus(nullptr);
} }
IN_PROC_BROWSER_TEST_F(NativeInputMethodEngineTest, VietnameseTelex_Reset) {
engine_.Enable(kEngineIdVietnameseTelex);
engine_.FlushForTesting();
EXPECT_TRUE(engine_.IsConnectedForTesting());
// Create a fake text field.
ui::DummyTextInputClient text_input_client(ui::TEXT_INPUT_TYPE_TEXT);
SetFocus(&text_input_client);
DispatchKeyPress(ui::VKEY_A);
engine_.Reset();
DispatchKeyPress(ui::VKEY_S);
// Expect to commit 's'.
ASSERT_EQ(text_input_client.composition_history().size(), 1U);
EXPECT_EQ(text_input_client.composition_history()[0].text,
base::ASCIIToUTF16("a"));
ASSERT_EQ(text_input_client.insert_text_history().size(), 1U);
EXPECT_EQ(text_input_client.insert_text_history()[0],
base::ASCIIToUTF16("s"));
SetFocus(nullptr);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment