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

Side by Side Diff: services/ui/public/interfaces/ime/ime_struct_traits_unittest.cc

Issue 2626383002: IME for Mus: EnumTraits for TextInputMode and TextInputType. (Closed)
Patch Set: 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
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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "mojo/public/cpp/bindings/binding_set.h" 7 #include "mojo/public/cpp/bindings/binding_set.h"
8 #include "services/ui/public/interfaces/ime/ime_struct_traits_test.mojom.h" 8 #include "services/ui/public/interfaces/ime/ime_struct_traits_test.mojom.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/ime/composition_text.h" 10 #include "ui/base/ime/composition_text.h"
(...skipping 13 matching lines...) Expand all
24 return traits_test_bindings_.CreateInterfacePtrAndBind(this); 24 return traits_test_bindings_.CreateInterfacePtrAndBind(this);
25 } 25 }
26 26
27 private: 27 private:
28 // mojom::IMEStructTraitsTest: 28 // mojom::IMEStructTraitsTest:
29 void EchoCompositionText( 29 void EchoCompositionText(
30 const CompositionText& in, 30 const CompositionText& in,
31 const EchoCompositionTextCallback& callback) override { 31 const EchoCompositionTextCallback& callback) override {
32 callback.Run(in); 32 callback.Run(in);
33 } 33 }
34 void EchoTextInputMode(TextInputMode in,
35 const EchoTextInputModeCallback& callback) override {
36 callback.Run(in);
37 }
38 void EchoTextInputType(TextInputType in,
39 const EchoTextInputTypeCallback& callback) override {
40 callback.Run(in);
41 }
34 42
35 base::MessageLoop loop_; // A MessageLoop is needed for Mojo IPC to work. 43 base::MessageLoop loop_; // A MessageLoop is needed for Mojo IPC to work.
36 mojo::BindingSet<mojom::IMEStructTraitsTest> traits_test_bindings_; 44 mojo::BindingSet<mojom::IMEStructTraitsTest> traits_test_bindings_;
37 45
38 DISALLOW_COPY_AND_ASSIGN(IMEStructTraitsTest); 46 DISALLOW_COPY_AND_ASSIGN(IMEStructTraitsTest);
39 }; 47 };
40 48
41 } // namespace 49 } // namespace
42 50
43 TEST_F(IMEStructTraitsTest, CompositionText) { 51 TEST_F(IMEStructTraitsTest, CompositionText) {
44 CompositionText input; 52 CompositionText input;
45 input.text = base::UTF8ToUTF16("abcdefghij"); 53 input.text = base::UTF8ToUTF16("abcdefghij");
46 input.underlines.push_back(CompositionUnderline(0, 2, SK_ColorGRAY, false)); 54 input.underlines.push_back(CompositionUnderline(0, 2, SK_ColorGRAY, false));
47 input.underlines.push_back( 55 input.underlines.push_back(
48 CompositionUnderline(3, 6, SK_ColorRED, true, SK_ColorGREEN)); 56 CompositionUnderline(3, 6, SK_ColorRED, true, SK_ColorGREEN));
49 input.selection = gfx::Range(1, 7); 57 input.selection = gfx::Range(1, 7);
50 58
51 mojom::IMEStructTraitsTestPtr proxy = GetTraitsTestProxy(); 59 mojom::IMEStructTraitsTestPtr proxy = GetTraitsTestProxy();
52 CompositionText output; 60 CompositionText output;
53 proxy->EchoCompositionText(input, &output); 61 proxy->EchoCompositionText(input, &output);
54 62
55 EXPECT_EQ(input, output); 63 EXPECT_EQ(input, output);
56 } 64 }
57 65
66 TEST_F(IMEStructTraitsTest, TextInputMode) {
67 const TextInputMode kTextInputModes[] = {
68 TEXT_INPUT_MODE_DEFAULT, TEXT_INPUT_MODE_VERBATIM,
69 TEXT_INPUT_MODE_LATIN, TEXT_INPUT_MODE_LATIN_NAME,
70 TEXT_INPUT_MODE_LATIN_PROSE, TEXT_INPUT_MODE_FULL_WIDTH_LATIN,
71 TEXT_INPUT_MODE_KANA, TEXT_INPUT_MODE_KANA_NAME,
72 TEXT_INPUT_MODE_KATAKANA, TEXT_INPUT_MODE_NUMERIC,
73 TEXT_INPUT_MODE_TEL, TEXT_INPUT_MODE_EMAIL,
74 TEXT_INPUT_MODE_URL,
75 };
76
77 mojom::IMEStructTraitsTestPtr proxy = GetTraitsTestProxy();
78 for (size_t i = 0; i < arraysize(kTextInputModes); i++) {
79 ui::TextInputMode mode_out;
80 ASSERT_TRUE(proxy->EchoTextInputMode(kTextInputModes[i], &mode_out));
81 EXPECT_EQ(kTextInputModes[i], mode_out);
82 }
83 }
84
85 TEST_F(IMEStructTraitsTest, TextInputType) {
86 const TextInputType kTextInputTypes[] = {
87 TEXT_INPUT_TYPE_NONE,
88 TEXT_INPUT_TYPE_TEXT,
89 TEXT_INPUT_TYPE_PASSWORD,
90 TEXT_INPUT_TYPE_SEARCH,
91 TEXT_INPUT_TYPE_EMAIL,
92 TEXT_INPUT_TYPE_NUMBER,
93 TEXT_INPUT_TYPE_TELEPHONE,
94 TEXT_INPUT_TYPE_URL,
95 TEXT_INPUT_TYPE_DATE,
96 TEXT_INPUT_TYPE_DATE_TIME,
97 TEXT_INPUT_TYPE_DATE_TIME_LOCAL,
98 TEXT_INPUT_TYPE_MONTH,
99 TEXT_INPUT_TYPE_TIME,
100 TEXT_INPUT_TYPE_WEEK,
101 TEXT_INPUT_TYPE_TEXT_AREA,
102 TEXT_INPUT_TYPE_CONTENT_EDITABLE,
103 TEXT_INPUT_TYPE_DATE_TIME_FIELD,
104 };
105
106 mojom::IMEStructTraitsTestPtr proxy = GetTraitsTestProxy();
107 for (size_t i = 0; i < arraysize(kTextInputTypes); i++) {
108 ui::TextInputType type_out;
109 ASSERT_TRUE(proxy->EchoTextInputType(kTextInputTypes[i], &type_out));
110 EXPECT_EQ(kTextInputTypes[i], type_out);
111 }
112 }
113
58 } // namespace ui 114 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/interfaces/ime/ime_struct_traits_test.mojom ('k') | ui/aura/mus/input_method_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698