mirror of
https://github.com/mii443/mozc.git
synced 2025-12-03 03:08:18 +00:00
Rename the class of GoogleJapaneseInputController to MozcImkInputController.
We need to keep GoogleJapaneseInputController as an alias of MozcImkInputController for backward compatibility. This will be removed in the future when all clients are migrated to the new name and performed relogin at least once. #codehealth PiperOrigin-RevId: 683091904
This commit is contained in:
@@ -26,7 +26,7 @@ IMKInputServer handles all of the connection between applications, and invokes
|
||||
IMKInputController.
|
||||
|
||||
The IMKit.framework configurations are in Info.plist of the client application.
|
||||
You'll see the GoogleJapaneseInputController class name in mac/Info.plist.
|
||||
You'll see the MozcImkInputController class name in mac/Info.plist.
|
||||
|
||||
## Communication with converter
|
||||
|
||||
|
||||
@@ -180,11 +180,11 @@
|
||||
<key>InputMethodConnectionName</key>
|
||||
<string>${PRODUCT_NAME}_1_Connection</string>
|
||||
<key>InputMethodServerControllerClass</key>
|
||||
<string>GoogleJapaneseInputController</string>
|
||||
<string>MozcImkInputController</string>
|
||||
<key>InputMethodServerDelegateClass</key>
|
||||
<string>GoogleJapaneseInputController</string>
|
||||
<string>MozcImkInputController</string>
|
||||
<key>InputMethodServerDataSourceClass</key>
|
||||
<string>GoogleJapaneseInputController</string>
|
||||
<string>MozcImkInputController</string>
|
||||
<key>LSBackgroundOnly</key>
|
||||
<string>1</string>
|
||||
<key>LSUIElement</key>
|
||||
|
||||
@@ -72,7 +72,7 @@ int main(int argc, char *argv[]) {
|
||||
NSString *rendererConnectionName = @kProductPrefix "_Renderer_Connection";
|
||||
RendererReceiver *rendererReceiver =
|
||||
[[RendererReceiver alloc] initWithName:rendererConnectionName];
|
||||
[GoogleJapaneseInputController setGlobalRendererReceiver:rendererReceiver];
|
||||
[MozcImkInputController setGlobalRendererReceiver:rendererReceiver];
|
||||
|
||||
// Start the converter server at this time explicitly to prevent the
|
||||
// slow-down of the response for initial key event.
|
||||
|
||||
@@ -45,13 +45,13 @@
|
||||
#include "protocol/renderer_command.pb.h"
|
||||
#include "renderer/renderer_interface.h"
|
||||
|
||||
/** GoogleJapaneseInputController is a subclass of |IMKInputController|, which holds a connection
|
||||
/** MozcImkInputController is a subclass of |IMKInputController|, which holds a connection
|
||||
* from a client application to the mozc server (Japanese IME server) on the machine.
|
||||
*
|
||||
* For the detail of IMKInputController itself, see the ADC document
|
||||
* http://developer.apple.com/documentation/Cocoa/Reference/IMKInputController_Class/
|
||||
*/
|
||||
@interface GoogleJapaneseInputController : IMKInputController <ControllerCallback> {
|
||||
@interface MozcImkInputController : IMKInputController <ControllerCallback> {
|
||||
@private
|
||||
/** Instance variables are all strong references. */
|
||||
|
||||
@@ -268,3 +268,10 @@
|
||||
- (BOOL)fillSurroundingContext:(mozc::commands::Context *)context client:(id<IMKTextInput>)client;
|
||||
|
||||
@end
|
||||
|
||||
/** GoogleJapaneseInputController is an alias of MozcImkInputController for backward compatibility.
|
||||
* This will be removed in the future when all clients are migrated to the new name and performed
|
||||
* relogin at least once.
|
||||
*/
|
||||
@interface GoogleJapaneseInputController : MozcImkInputController {}
|
||||
@end
|
||||
|
||||
@@ -178,7 +178,7 @@ bool CanSurroundingText(absl::string_view bundle_id) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@implementation GoogleJapaneseInputController
|
||||
@implementation MozcImkInputController
|
||||
#pragma mark accessors for testing
|
||||
@synthesize keyCodeMap = keyCodeMap_;
|
||||
@synthesize yenSignCharacter = yenSignCharacter_;
|
||||
@@ -621,10 +621,10 @@ bool CanSurroundingText(absl::string_view bundle_id) {
|
||||
#pragma mark Mozc Server methods
|
||||
|
||||
#pragma mark IMKServerInput Protocol
|
||||
// Currently GoogleJapaneseInputController uses handleEvent:client:
|
||||
// Currently MozcImkInputController uses handleEvent:client:
|
||||
// method to handle key events. It does not support inputText:client:
|
||||
// nor inputText:key:modifiers:client:.
|
||||
// Because GoogleJapaneseInputController does not use IMKCandidates,
|
||||
// Because MozcImkInputController does not use IMKCandidates,
|
||||
// the following methods are not needed to implement:
|
||||
// candidates
|
||||
//
|
||||
@@ -967,3 +967,7 @@ bool CanSurroundingText(absl::string_view bundle_id) {
|
||||
gRendererReceiver = rendererReceiver;
|
||||
}
|
||||
@end
|
||||
|
||||
// An alias of MozcImkInputController for backward compatibility.
|
||||
@implementation GoogleJapaneseInputController
|
||||
@end
|
||||
|
||||
@@ -237,7 +237,7 @@ class MockRenderer : public renderer::RendererInterface {
|
||||
commands::RendererCommand called_command_;
|
||||
};
|
||||
|
||||
class GoogleJapaneseInputControllerTest : public testing::Test {
|
||||
class MozcImkInputControllerTest : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
mock_server_ = [[MockIMKServer alloc] init];
|
||||
@@ -261,7 +261,7 @@ class GoogleJapaneseInputControllerTest : public testing::Test {
|
||||
}
|
||||
|
||||
void SetUpController() {
|
||||
controller_ = [[GoogleJapaneseInputController alloc] initWithServer:mock_server_
|
||||
controller_ = [[MozcImkInputController alloc] initWithServer:mock_server_
|
||||
delegate:nil
|
||||
client:mock_client_];
|
||||
controller_.imkClientForTest = mock_client_;
|
||||
@@ -284,7 +284,7 @@ class GoogleJapaneseInputControllerTest : public testing::Test {
|
||||
MockClient *mock_client_;
|
||||
const MockRenderer *mock_renderer_;
|
||||
|
||||
GoogleJapaneseInputController *controller_;
|
||||
MozcImkInputController *controller_;
|
||||
|
||||
private:
|
||||
MockIMKServer *mock_server_;
|
||||
@@ -368,7 +368,7 @@ NSTimeInterval GetDoubleTapInterval() {
|
||||
return kDoubleTapInterval;
|
||||
}
|
||||
|
||||
BOOL SendKeyEvent(unsigned short keyCode, GoogleJapaneseInputController *controller,
|
||||
BOOL SendKeyEvent(unsigned short keyCode, MozcImkInputController *controller,
|
||||
MockClient *client) {
|
||||
// tap Kana-key
|
||||
NSEvent *kanaKeyEvent = [NSEvent keyEventWithType:NSEventTypeKeyDown
|
||||
@@ -384,7 +384,7 @@ BOOL SendKeyEvent(unsigned short keyCode, GoogleJapaneseInputController *control
|
||||
return [controller handleEvent:kanaKeyEvent client:client];
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, UpdateComposedString) {
|
||||
TEST_F(MozcImkInputControllerTest, UpdateComposedString) {
|
||||
// If preedit is nullptr, it still calls setMarkedText, with an empty string.
|
||||
NSMutableAttributedString *expected = [[NSMutableAttributedString alloc] initWithString:@""];
|
||||
[controller_ updateComposedString:nullptr];
|
||||
@@ -423,14 +423,14 @@ TEST_F(GoogleJapaneseInputControllerTest, UpdateComposedString) {
|
||||
<< [[NSString stringWithFormat:@"expected:%@ actual:%@", expected, actual] UTF8String];
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, ClearCandidates) {
|
||||
TEST_F(MozcImkInputControllerTest, ClearCandidates) {
|
||||
[controller_ clearCandidates];
|
||||
EXPECT_EQ(mock_renderer_->counter_ExecCommand(), 1);
|
||||
// After clearing candidates, the candidate window has to be invisible.
|
||||
EXPECT_FALSE(mock_renderer_->CalledCommand().visible());
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, UpdateCandidates) {
|
||||
TEST_F(MozcImkInputControllerTest, UpdateCandidates) {
|
||||
// When output is null, same as ClearCandidate
|
||||
[controller_ updateCandidates:nullptr];
|
||||
// Run the runloop so "delayedUpdateCandidates" can be called
|
||||
@@ -490,7 +490,7 @@ TEST_F(GoogleJapaneseInputControllerTest, UpdateCandidates) {
|
||||
EXPECT_FALSE(rendererCommand.visible());
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, OpenLink) {
|
||||
TEST_F(MozcImkInputControllerTest, OpenLink) {
|
||||
EXPECT_EQ(gOpenURLCount, 0);
|
||||
[controller_ openLink:[NSURL URLWithString:@"http://www.example.com/"]];
|
||||
// openURL is invoked
|
||||
@@ -504,7 +504,7 @@ TEST_F(GoogleJapaneseInputControllerTest, OpenLink) {
|
||||
EXPECT_EQ(gOpenURLCount, 1);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, SwitchModeToDirect) {
|
||||
TEST_F(MozcImkInputControllerTest, SwitchModeToDirect) {
|
||||
// setup the IME status
|
||||
controller_.mode = commands::HIRAGANA;
|
||||
commands::Preedit preedit;
|
||||
@@ -528,7 +528,7 @@ TEST_F(GoogleJapaneseInputControllerTest, SwitchModeToDirect) {
|
||||
EXPECT_FALSE(controller_.rendererCommand.visible());
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, SwitchMode) {
|
||||
TEST_F(MozcImkInputControllerTest, SwitchMode) {
|
||||
// When a mode changes from DIRECT, it should invoke "ON" command beforehand.
|
||||
EXPECT_CALL(*mock_mozc_client_,
|
||||
SendKeyWithContext(HasSpecialKey(commands::KeyEvent::ON), _, NotNull()))
|
||||
@@ -557,7 +557,7 @@ TEST_F(GoogleJapaneseInputControllerTest, SwitchMode) {
|
||||
EXPECT_EQ(controller_.mode, commands::HALF_KATAKANA);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, SwitchDisplayMode) {
|
||||
TEST_F(MozcImkInputControllerTest, SwitchDisplayMode) {
|
||||
EXPECT_TRUE(mock_client_.selectedMode.empty());
|
||||
EXPECT_EQ(controller_.mode, commands::DIRECT);
|
||||
[controller_ switchDisplayMode];
|
||||
@@ -565,7 +565,7 @@ TEST_F(GoogleJapaneseInputControllerTest, SwitchDisplayMode) {
|
||||
EXPECT_EQ(mock_client_.selectedMode, "com.apple.inputmethod.Roman");
|
||||
|
||||
// Does not change the display mode for MS Word. See
|
||||
// GoogleJapaneseInputController.mm for the detailed information.
|
||||
// MozcImkInputController.mm for the detailed information.
|
||||
ResetClientBundleIdentifier(@"com.microsoft.Word");
|
||||
[controller_ switchMode:commands::HIRAGANA client:mock_client_];
|
||||
EXPECT_EQ(controller_.mode, commands::HIRAGANA);
|
||||
@@ -575,7 +575,7 @@ TEST_F(GoogleJapaneseInputControllerTest, SwitchDisplayMode) {
|
||||
EXPECT_EQ(mock_client_.selectedMode, "com.apple.inputmethod.Roman");
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, commitText) {
|
||||
TEST_F(MozcImkInputControllerTest, commitText) {
|
||||
controller_.replacementRange = NSMakeRange(0, 1);
|
||||
[controller_ commitText:"foo" client:mock_client_];
|
||||
|
||||
@@ -585,7 +585,7 @@ TEST_F(GoogleJapaneseInputControllerTest, commitText) {
|
||||
EXPECT_EQ([controller_ replacementRange].location, NSNotFound);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, handleConfig) {
|
||||
TEST_F(MozcImkInputControllerTest, handleConfig) {
|
||||
// Does not support multiple-calculation
|
||||
config::Config config;
|
||||
config.set_preedit_method(config::Config::KANA);
|
||||
@@ -602,7 +602,7 @@ TEST_F(GoogleJapaneseInputControllerTest, handleConfig) {
|
||||
<< [mock_client_.overriddenLayout UTF8String];
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, DoubleTapKanaReconvert) {
|
||||
TEST_F(MozcImkInputControllerTest, DoubleTapKanaReconvert) {
|
||||
// tap (short) tap -> emit undo command
|
||||
controller_.mode = commands::HIRAGANA;
|
||||
|
||||
@@ -629,7 +629,7 @@ TEST_F(GoogleJapaneseInputControllerTest, DoubleTapKanaReconvert) {
|
||||
EXPECT_THAT(actual_command, Text("bcd"));
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, DoubleTapKanaUndo) {
|
||||
TEST_F(MozcImkInputControllerTest, DoubleTapKanaUndo) {
|
||||
// tap (short) tap -> emit undo command
|
||||
controller_.mode = commands::HIRAGANA;
|
||||
|
||||
@@ -652,7 +652,7 @@ TEST_F(GoogleJapaneseInputControllerTest, DoubleTapKanaUndo) {
|
||||
EXPECT_EQ(SendKeyEvent(kVK_JIS_Kana, controller_, mock_client_), YES);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, DoubleTapKanaUndoTimeOver) {
|
||||
TEST_F(MozcImkInputControllerTest, DoubleTapKanaUndoTimeOver) {
|
||||
// tap (long) tap -> don't emit undo command
|
||||
controller_.mode = commands::HIRAGANA;
|
||||
|
||||
@@ -670,7 +670,7 @@ TEST_F(GoogleJapaneseInputControllerTest, DoubleTapKanaUndoTimeOver) {
|
||||
EXPECT_EQ(SendKeyEvent(kVK_JIS_Kana, controller_, mock_client_), YES);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, SingleAndDoubleTapKanaUndo) {
|
||||
TEST_F(MozcImkInputControllerTest, SingleAndDoubleTapKanaUndo) {
|
||||
// tap (long) tap (short) tap -> emit once
|
||||
controller_.mode = commands::HIRAGANA;
|
||||
|
||||
@@ -699,7 +699,7 @@ TEST_F(GoogleJapaneseInputControllerTest, SingleAndDoubleTapKanaUndo) {
|
||||
EXPECT_EQ(SendKeyEvent(kVK_JIS_Kana, controller_, mock_client_), YES);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, TripleTapKanaUndo) {
|
||||
TEST_F(MozcImkInputControllerTest, TripleTapKanaUndo) {
|
||||
// tap (short) tap (short) tap -> emit twice
|
||||
controller_.mode = commands::HIRAGANA;
|
||||
|
||||
@@ -729,7 +729,7 @@ TEST_F(GoogleJapaneseInputControllerTest, TripleTapKanaUndo) {
|
||||
EXPECT_EQ(SendKeyEvent(kVK_JIS_Kana, controller_, mock_client_), YES);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, QuadrupleTapKanaUndo) {
|
||||
TEST_F(MozcImkInputControllerTest, QuadrupleTapKanaUndo) {
|
||||
// tap (short) tap (short) tap (short) tap -> emit thrice
|
||||
controller_.mode = commands::HIRAGANA;
|
||||
|
||||
@@ -764,7 +764,7 @@ TEST_F(GoogleJapaneseInputControllerTest, QuadrupleTapKanaUndo) {
|
||||
EXPECT_EQ(SendKeyEvent(kVK_JIS_Kana, controller_, mock_client_), YES);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, DoubleTapEisuCommitRawText) {
|
||||
TEST_F(MozcImkInputControllerTest, DoubleTapEisuCommitRawText) {
|
||||
// Send Eisu-key.
|
||||
// Because of special hack for Eisu/Kana keys, it returns YES.
|
||||
EXPECT_EQ(SendKeyEvent(kVK_JIS_Eisu, controller_, mock_client_), YES);
|
||||
@@ -780,7 +780,7 @@ TEST_F(GoogleJapaneseInputControllerTest, DoubleTapEisuCommitRawText) {
|
||||
EXPECT_EQ(SendKeyEvent(kVK_JIS_Eisu, controller_, mock_client_), YES);
|
||||
}
|
||||
|
||||
TEST_F(GoogleJapaneseInputControllerTest, fillSurroundingContext) {
|
||||
TEST_F(MozcImkInputControllerTest, fillSurroundingContext) {
|
||||
[mock_client_ setAttributedString:[[NSAttributedString alloc] initWithString:@"abcde"]];
|
||||
mock_client_.expectedRange = NSMakeRange(2, 1);
|
||||
commands::Context context;
|
||||
|
||||
@@ -202,7 +202,7 @@ void CandidateController::AlignWindows() {
|
||||
command_.preedit_rectangle().right() - command_.preedit_rectangle().left(),
|
||||
command_.preedit_rectangle().bottom() - command_.preedit_rectangle().top());
|
||||
// The origin point of command_.preedit_rectangle() is the left-top of the
|
||||
// base screen which is set in GoogleJapaneseInputController. It is
|
||||
// base screen which is set in MozcImkInputController. It is
|
||||
// unnecessary calculation but to support older version of GoogleJapaneseInput
|
||||
// process we should not change it. So we minus the height of the screen here.
|
||||
mozc::Rect preedit_rect(mozc::Point(command_.preedit_rectangle().left(),
|
||||
@@ -211,7 +211,7 @@ void CandidateController::AlignWindows() {
|
||||
|
||||
// This is a hacky way to check vertical writing.
|
||||
// TODO(komatsu): We should use the return value of attributesForCharacterIndex
|
||||
// in GoogleJapaneseInputController.mm as a proper way.
|
||||
// in MozcImkInputController as a proper way.
|
||||
const bool is_vertical = (preedit_size.height < preedit_size.width);
|
||||
|
||||
// Expand the rect size to make a margin to the candidate window.
|
||||
|
||||
@@ -73,7 +73,7 @@ enum COLUMN_TYPE {
|
||||
// setCandidates: sets the candidates to be rendered.
|
||||
- (void)setCandidates:(const mozc::commands::Candidates *)candidates;
|
||||
|
||||
// setController: sets the reference of GoogleJapaneseInputController.
|
||||
// setController: sets the reference of MozcImkInputController.
|
||||
// It will be used when mouse clicks. It doesn't take ownerships of
|
||||
// |controller|.
|
||||
- (void)setSendCommandInterface:(mozc::client::SendCommandInterface *)command_sender;
|
||||
|
||||
Reference in New Issue
Block a user