|
7 | 7 | #include "gtest/gtest.h" |
8 | 8 |
|
9 | 9 | using testing::_; |
| 10 | +using testing::InSequence; |
10 | 11 | using testing::Invoke; |
11 | 12 | using testing::Return; |
12 | 13 |
|
@@ -87,24 +88,34 @@ TEST(MockWin32Window, OnImeCompositionResult) { |
87 | 88 | window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_RESULTSTR); |
88 | 89 | } |
89 | 90 |
|
90 | | -TEST(MockWin32Window, OnImeCompositionComposeAndResult) { |
| 91 | +TEST(MockWin32Window, OnImeCompositionResultAndCompose) { |
91 | 92 | MockTextInputManagerWin32* text_input_manager = |
92 | 93 | new MockTextInputManagerWin32(); |
93 | 94 | std::unique_ptr<TextInputManagerWin32> text_input_manager_ptr( |
94 | 95 | text_input_manager); |
95 | 96 | MockWin32Window window(std::move(text_input_manager_ptr)); |
96 | | - EXPECT_CALL(*text_input_manager, GetComposingString()) |
97 | | - .WillRepeatedly( |
98 | | - Return(std::optional<std::u16string>(std::u16string(u"nihao")))); |
99 | | - EXPECT_CALL(*text_input_manager, GetResultString()) |
100 | | - .WillRepeatedly( |
101 | | - Return(std::optional<std::u16string>(std::u16string(u"`}")))); |
| 97 | + |
| 98 | + // This situation is that Google Japanese Input finished composing "今日" in |
| 99 | + // "今日は" but is still composing "は". |
| 100 | + { |
| 101 | + InSequence dummy; |
| 102 | + EXPECT_CALL(*text_input_manager, GetResultString()) |
| 103 | + .WillRepeatedly( |
| 104 | + Return(std::optional<std::u16string>(std::u16string(u"今日")))); |
| 105 | + EXPECT_CALL(*text_input_manager, GetComposingString()) |
| 106 | + .WillRepeatedly( |
| 107 | + Return(std::optional<std::u16string>(std::u16string(u"は")))); |
| 108 | + } |
| 109 | + { |
| 110 | + InSequence dummy; |
| 111 | + EXPECT_CALL(window, OnComposeChange(std::u16string(u"今日"), 0)).Times(1); |
| 112 | + EXPECT_CALL(window, OnComposeCommit()).Times(1); |
| 113 | + EXPECT_CALL(window, OnComposeChange(std::u16string(u"は"), 0)).Times(1); |
| 114 | + } |
| 115 | + |
102 | 116 | EXPECT_CALL(*text_input_manager, GetComposingCursorPosition()) |
103 | 117 | .WillRepeatedly(Return((int)0)); |
104 | 118 |
|
105 | | - EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 0)).Times(1); |
106 | | - EXPECT_CALL(window, OnComposeChange(std::u16string(u"`}"), 0)).Times(1); |
107 | | - EXPECT_CALL(window, OnComposeCommit()).Times(1); |
108 | 119 | ON_CALL(window, OnImeComposition) |
109 | 120 | .WillByDefault(Invoke(&window, &MockWin32Window::CallOnImeComposition)); |
110 | 121 | EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1); |
|
0 commit comments