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

Side by Side Diff: services/ui/ime/ime_unittest.cc

Issue 2503063003: Add service name constant for UI service. (Closed)
Patch Set: . Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "mojo/public/cpp/bindings/interface_request.h" 10 #include "mojo/public/cpp/bindings/interface_request.h"
11 #include "services/service_manager/public/cpp/service_context.h" 11 #include "services/service_manager/public/cpp/service_context.h"
12 #include "services/service_manager/public/cpp/service_test.h" 12 #include "services/service_manager/public/cpp/service_test.h"
13 #include "services/ui/public/interfaces/constants.mojom.h"
13 #include "services/ui/public/interfaces/ime.mojom.h" 14 #include "services/ui/public/interfaces/ime.mojom.h"
14 #include "ui/events/event.h" 15 #include "ui/events/event.h"
15 16
16 class TestTextInputClient : public ui::mojom::TextInputClient { 17 class TestTextInputClient : public ui::mojom::TextInputClient {
17 public: 18 public:
18 explicit TestTextInputClient(ui::mojom::TextInputClientRequest request) 19 explicit TestTextInputClient(ui::mojom::TextInputClientRequest request)
19 : binding_(this, std::move(request)) {} 20 : binding_(this, std::move(request)) {}
20 21
21 ui::mojom::CompositionEventPtr WaitUntilCompositionEvent() { 22 ui::mojom::CompositionEventPtr WaitUntilCompositionEvent() {
22 if (!receieved_composition_event_) { 23 if (!receieved_composition_event_) {
(...skipping 22 matching lines...) Expand all
45 class IMEAppTest : public service_manager::test::ServiceTest { 46 class IMEAppTest : public service_manager::test::ServiceTest {
46 public: 47 public:
47 IMEAppTest() : ServiceTest("mus_ime_unittests") {} 48 IMEAppTest() : ServiceTest("mus_ime_unittests") {}
48 ~IMEAppTest() override {} 49 ~IMEAppTest() override {}
49 50
50 // service_manager::test::ServiceTest: 51 // service_manager::test::ServiceTest:
51 void SetUp() override { 52 void SetUp() override {
52 ServiceTest::SetUp(); 53 ServiceTest::SetUp();
53 // test_ime_driver will register itself as the current IMEDriver. 54 // test_ime_driver will register itself as the current IMEDriver.
54 connector()->Connect("test_ime_driver"); 55 connector()->Connect("test_ime_driver");
55 connector()->ConnectToInterface("ui", &ime_server_); 56 connector()->ConnectToInterface(ui::mojom::kServiceName, &ime_server_);
56 } 57 }
57 58
58 bool ProcessKeyEvent(ui::mojom::InputMethodPtr* input_method, 59 bool ProcessKeyEvent(ui::mojom::InputMethodPtr* input_method,
59 std::unique_ptr<ui::Event> event) { 60 std::unique_ptr<ui::Event> event) {
60 (*input_method) 61 (*input_method)
61 ->ProcessKeyEvent(std::move(event), 62 ->ProcessKeyEvent(std::move(event),
62 base::Bind(&IMEAppTest::ProcessKeyEventCallback, 63 base::Bind(&IMEAppTest::ProcessKeyEventCallback,
63 base::Unretained(this))); 64 base::Unretained(this)));
64 65
65 run_loop_.reset(new base::RunLoop); 66 run_loop_.reset(new base::RunLoop);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ui::KeyEvent* received_key_event = 105 ui::KeyEvent* received_key_event =
105 composition_event->key_event.value()->AsKeyEvent(); 106 composition_event->key_event.value()->AsKeyEvent();
106 EXPECT_EQ(ui::ET_KEY_PRESSED, received_key_event->type()); 107 EXPECT_EQ(ui::ET_KEY_PRESSED, received_key_event->type());
107 EXPECT_TRUE(received_key_event->is_char()); 108 EXPECT_TRUE(received_key_event->is_char());
108 EXPECT_EQ(char_event.GetCharacter(), received_key_event->GetCharacter()); 109 EXPECT_EQ(char_event.GetCharacter(), received_key_event->GetCharacter());
109 110
110 // Send non-character key event. 111 // Send non-character key event.
111 ui::KeyEvent nonchar_event(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, 0); 112 ui::KeyEvent nonchar_event(ui::ET_KEY_PRESSED, ui::VKEY_LEFT, 0);
112 EXPECT_FALSE(ProcessKeyEvent(&input_method, ui::Event::Clone(nonchar_event))); 113 EXPECT_FALSE(ProcessKeyEvent(&input_method, ui::Event::Clone(nonchar_event)));
113 } 114 }
OLDNEW
« no previous file with comments | « services/ui/demo/mus_demo_unittests.cc ('k') | services/ui/ime/test_ime_driver/test_ime_application.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698