-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare for investigating #15 issue
- Loading branch information
Showing
6 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_custom_target(copy-addon DEPENDS anthy-addon.conf.in-fmt) | ||
add_custom_command(TARGET copy-addon COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/src/anthy-addon.conf ${CMAKE_CURRENT_BINARY_DIR}/anthy.conf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_custom_target(copy-im DEPENDS anthy.conf.in-fmt) | ||
add_custom_command(TARGET copy-im COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/src/anthy.conf ${CMAKE_CURRENT_BINARY_DIR}/anthy.conf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2021-2021 CSSlayer <wengxt@gmail.com> | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* | ||
*/ | ||
#include "testdir.h" | ||
#include "testfrontend_public.h" | ||
#include <fcitx-utils/eventdispatcher.h> | ||
#include <fcitx-utils/log.h> | ||
#include <fcitx-utils/standardpath.h> | ||
#include <fcitx-utils/testing.h> | ||
#include <fcitx/addonmanager.h> | ||
#include <fcitx/inputmethodmanager.h> | ||
#include <fcitx/instance.h> | ||
#include <iostream> | ||
|
||
using namespace fcitx; | ||
|
||
void scheduleEvent(EventDispatcher *dispatcher, Instance *instance) { | ||
dispatcher->schedule([dispatcher, instance]() { | ||
auto *anthy = instance->addonManager().addon("anthy", true); | ||
FCITX_ASSERT(anthy); | ||
|
||
auto defaultGroup = instance->inputMethodManager().currentGroup(); | ||
defaultGroup.inputMethodList().clear(); | ||
defaultGroup.inputMethodList().push_back(InputMethodGroupItem("anthy")); | ||
defaultGroup.setDefaultInputMethod(""); | ||
instance->inputMethodManager().setGroup(defaultGroup); | ||
auto *testfrontend = instance->addonManager().addon("testfrontend"); | ||
auto uuid = | ||
testfrontend->call<ITestFrontend::createInputContext>("testapp"); | ||
auto ic = instance->inputContextManager().findByUUID(uuid); | ||
|
||
RawConfig config; | ||
config.setValueByPath("General/TypingMethod", "Nicola"); | ||
anthy->setConfig(config); | ||
|
||
testfrontend->call<ITestFrontend::keyEvent>(uuid, Key("Muhenkan"), | ||
false); | ||
testfrontend->call<ITestFrontend::keyEvent>(uuid, Key("a"), false); | ||
testfrontend->call<ITestFrontend::keyEvent>(uuid, Key("a"), true); | ||
testfrontend->call<ITestFrontend::keyEvent>(uuid, Key("Muhenkan"), | ||
true); | ||
|
||
instance->exit(); | ||
}); | ||
} | ||
|
||
int main() { | ||
setupTestingEnvironment(TESTING_BINARY_DIR, {TESTING_BINARY_DIR "/src"}, | ||
{TESTING_BINARY_DIR "/test"}); | ||
// fcitx::Log::setLogRule("default=5,table=5,libime-table=5"); | ||
char arg0[] = "testanthy"; | ||
char arg1[] = "--disable=all"; | ||
char arg2[] = "--enable=testim,testfrontend,anthy,testui"; | ||
char *argv[] = {arg0, arg1, arg2}; | ||
fcitx::Log::setLogRule("default=5,anthy=5"); | ||
Instance instance(FCITX_ARRAY_SIZE(argv), argv); | ||
instance.addonManager().registerDefaultLoader(nullptr); | ||
EventDispatcher dispatcher; | ||
dispatcher.attach(&instance.eventLoop()); | ||
scheduleEvent(&dispatcher, &instance); | ||
instance.exec(); | ||
|
||
return 0; | ||
} |