Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: services/ui/ime/ime_unittest.cc

Issue 2412593002: IME for Mus: Send ack for key events after IME driver processes the event. (Closed)
Patch Set: Addressed feedback. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | services/ui/ime/test_ime_driver/test_ime_driver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ime/ime_unittest.cc
diff --git a/services/ui/ime/ime_unittest.cc b/services/ui/ime/ime_unittest.cc
index 9c235494c5db9799f26e696cf273a3b04fede61a..da199c05a2b1c1cdcb9b81b1d6bf929ab14bd61f 100644
--- a/services/ui/ime/ime_unittest.cc
+++ b/services/ui/ime/ime_unittest.cc
@@ -19,35 +19,25 @@ class TestTextInputClient : public ui::mojom::TextInputClient {
: binding_(this, std::move(request)) {}
ui::mojom::CompositionEventPtr WaitUntilCompositionEvent() {
- run_loop_.reset(new base::RunLoop);
- run_loop_->Run();
- run_loop_.reset();
+ if (!receieved_composition_event_) {
+ run_loop_.reset(new base::RunLoop);
+ run_loop_->Run();
+ run_loop_.reset();
+ }
return std::move(receieved_composition_event_);
}
- ui::Event* WaitUntilUnhandledEvent() {
- run_loop_.reset(new base::RunLoop);
- run_loop_->Run();
- run_loop_.reset();
-
- return unhandled_event_.get();
- }
-
private:
void OnCompositionEvent(ui::mojom::CompositionEventPtr event) override {
receieved_composition_event_ = std::move(event);
- run_loop_->Quit();
- }
- void OnUnhandledEvent(std::unique_ptr<ui::Event> char_event) override {
- unhandled_event_ = std::move(char_event);
- run_loop_->Quit();
+ if (run_loop_)
+ run_loop_->Quit();
}
mojo::Binding<ui::mojom::TextInputClient> binding_;
std::unique_ptr<base::RunLoop> run_loop_;
ui::mojom::CompositionEventPtr receieved_composition_event_;
- std::unique_ptr<ui::Event> unhandled_event_;
DISALLOW_COPY_AND_ASSIGN(TestTextInputClient);
};
@@ -65,9 +55,29 @@ class IMEAppTest : public service_manager::test::ServiceTest {
connector()->ConnectToInterface("service:ui", &ime_server_);
}
+ bool ProcessKeyEvent(ui::mojom::InputMethodPtr* input_method,
+ std::unique_ptr<ui::Event> event) {
+ (*input_method)
+ ->ProcessKeyEvent(std::move(event),
+ base::Bind(&IMEAppTest::ProcessKeyEventCallback,
+ base::Unretained(this)));
+
+ run_loop_.reset(new base::RunLoop);
+ run_loop_->Run();
+ run_loop_.reset();
+
+ return handled_;
+ }
+
protected:
+ void ProcessKeyEventCallback(bool handled) {
+ handled_ = handled;
+ run_loop_->Quit();
+ }
+
ui::mojom::IMEServerPtr ime_server_;
std::unique_ptr<base::RunLoop> run_loop_;
+ bool handled_;
DISALLOW_COPY_AND_ASSIGN(IMEAppTest);
};
@@ -82,7 +92,7 @@ TEST_F(IMEAppTest, ProcessKeyEvent) {
// Send character key event.
ui::KeyEvent char_event('A', ui::VKEY_A, 0);
- input_method->ProcessKeyEvent(ui::Event::Clone(char_event));
+ EXPECT_TRUE(ProcessKeyEvent(&input_method, ui::Event::Clone(char_event)));
ui::mojom::CompositionEventPtr composition_event =
client.WaitUntilCompositionEvent();
@@ -99,13 +109,5 @@ TEST_F(IMEAppTest, ProcessKeyEvent) {
// Send non-character key event.
ui::KeyEvent nonchar_event(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, 0);
- input_method->ProcessKeyEvent(ui::Event::Clone(nonchar_event));
-
- ui::Event* unhandled_event = client.WaitUntilUnhandledEvent();
- EXPECT_TRUE(unhandled_event);
- EXPECT_TRUE(unhandled_event->IsKeyEvent());
- EXPECT_FALSE(unhandled_event->AsKeyEvent()->is_char());
- EXPECT_EQ(ui::ET_KEY_PRESSED, unhandled_event->type());
- EXPECT_EQ(nonchar_event.key_code(),
- unhandled_event->AsKeyEvent()->key_code());
+ EXPECT_FALSE(ProcessKeyEvent(&input_method, ui::Event::Clone(nonchar_event)));
}
« no previous file with comments | « no previous file | services/ui/ime/test_ime_driver/test_ime_driver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698