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

Side by Side Diff: ui/views/mus/input_method_mus_unittest.cc

Issue 2611773002: Removes code using mus client lib (Closed)
Patch Set: dont run on linux Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « ui/views/mus/input_method_mus.cc ('k') | ui/views/mus/interactive_ui_tests_mus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/mus/input_method_mus.h"
6
7 #include <memory>
8
9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/base/ime/dummy_text_input_client.h"
14 #include "ui/base/ime/input_method_delegate.h"
15 #include "ui/events/event.h"
16 #include "ui/views/mus/window_manager_connection.h"
17 #include "ui/views/test/scoped_views_test_helper.h"
18
19 namespace views {
20 namespace {
21
22 class TestInputMethodDelegate : public ui::internal::InputMethodDelegate {
23 public:
24 TestInputMethodDelegate() {}
25 ~TestInputMethodDelegate() override {}
26
27 // ui::internal::InputMethodDelegate:
28 ui::EventDispatchDetails DispatchKeyEventPostIME(
29 ui::KeyEvent* key_event) override {
30 return ui::EventDispatchDetails();
31 }
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(TestInputMethodDelegate);
35 };
36
37 class TestTextInputClient : public ui::DummyTextInputClient {
38 public:
39 TestTextInputClient() {}
40 ~TestTextInputClient() override {}
41
42 ui::KeyEvent* WaitUntilInputReceieved() {
43 run_loop_ = base::MakeUnique<base::RunLoop>();
44 run_loop_->Run();
45 run_loop_.reset();
46
47 return received_event_->AsKeyEvent();
48 }
49
50 // ui::DummyTextInputClient:
51 void InsertChar(const ui::KeyEvent& event) override {
52 received_event_ = ui::Event::Clone(event);
53 run_loop_->Quit();
54 }
55
56 private:
57 std::unique_ptr<base::RunLoop> run_loop_;
58 std::unique_ptr<ui::Event> received_event_;
59
60 DISALLOW_COPY_AND_ASSIGN(TestTextInputClient);
61 };
62
63 } // namespace
64
65 class InputMethodMusTest : public testing::Test {
66 public:
67 InputMethodMusTest() : message_loop_(base::MessageLoop::TYPE_UI) {}
68 ~InputMethodMusTest() override {}
69
70 service_manager::Connector* connector() {
71 return WindowManagerConnection::Get()->connector();
72 }
73
74 private:
75 base::MessageLoop message_loop_;
76 ScopedViewsTestHelper helper_;
77
78 DISALLOW_COPY_AND_ASSIGN(InputMethodMusTest);
79 };
80
81 TEST_F(InputMethodMusTest, DispatchKeyEvent) {
82 TestInputMethodDelegate input_method_delegate;
83 InputMethodMus input_method(&input_method_delegate, nullptr);
84 input_method.Init(connector());
85
86 TestTextInputClient text_input_client;
87 input_method.SetFocusedTextInputClient(&text_input_client);
88
89 ui::KeyEvent key_event('A', ui::VKEY_A, 0);
90 input_method.DispatchKeyEvent(&key_event);
91
92 ui::KeyEvent* received_event = text_input_client.WaitUntilInputReceieved();
93 EXPECT_EQ(ui::ET_KEY_PRESSED, received_event->type());
94 EXPECT_TRUE(received_event->is_char());
95 EXPECT_EQ(key_event.GetCharacter(), received_event->GetCharacter());
96 }
97
98 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/input_method_mus.cc ('k') | ui/views/mus/interactive_ui_tests_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698