Skip to content

Commit

Permalink
Merge branch 'google:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shitamo authored Feb 28, 2024
2 parents 135334e + dbadebf commit d6af481
Show file tree
Hide file tree
Showing 38 changed files with 790 additions and 725 deletions.
3 changes: 3 additions & 0 deletions src/android/jni/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ load("//:build_defs.bzl", "MOZC_TAGS", "mozc_cc_library", "mozc_py_binary", "moz
mozc_cc_library(
name = "mozcjni",
srcs = ["mozcjni.cc"],
linkopts = mozc_select(
android = ["-llog"],
),
tags = MOZC_TAGS.ANDROID_ONLY,
# Scheuklappen: keep
visibility = [
Expand Down
2 changes: 0 additions & 2 deletions src/composer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ mozc_cc_test(
"//base:util",
"//config:character_form_manager",
"//config:config_handler",
"//data_manager/testing:mock_data_manager",
"//engine:spellchecker_interface",
"//protocol:commands_cc_proto",
"//protocol:config_cc_proto",
"//testing:gunit_main",
Expand Down
42 changes: 10 additions & 32 deletions src/composer/composer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,19 @@
#include "composer/table.h"
#include "config/character_form_manager.h"
#include "config/config_handler.h"
#include "data_manager/testing/mock_data_manager.h"
#include "engine/spellchecker_interface.h"
#include "protocol/commands.pb.h"
#include "protocol/config.pb.h"
#include "testing/gmock.h"
#include "testing/gunit.h"
#include "transliteration/transliteration.h"

namespace mozc {
namespace composer {
namespace {

using ProbableKeyEvent = commands::KeyEvent_ProbableKeyEvent;
using ProbableKeyEvents = mozc::protobuf::RepeatedPtrField<ProbableKeyEvent>;

using ::mozc::commands::CheckSpellingResponse;
using ::mozc::commands::KeyEvent;
using ::mozc::commands::Request;
using ::mozc::config::CharacterFormManager;
using ::mozc::config::Config;
using ::testing::_;
using ::testing::Return;

// ProbableKeyEvent is the inner-class member so needs to define as alias.
using ProbableKeyEvent = ::mozc::commands::KeyEvent::ProbableKeyEvent;

bool InsertKey(const absl::string_view key_string, Composer *composer) {
commands::KeyEvent key;
Expand Down Expand Up @@ -134,7 +122,6 @@ class ComposerTest : public ::testing::Test {
table_.reset();
}

const testing::MockDataManager mock_data_manager_;
std::unique_ptr<Composer> composer_;
std::unique_ptr<Table> table_;
std::unique_ptr<Request> request_;
Expand Down Expand Up @@ -1222,8 +1209,7 @@ TEST_F(ComposerTest, ShiftKeyOperation) {

TEST_F(ComposerTest, ShiftKeyOperationForKatakana) {
config_->set_shift_key_mode_switch(Config::KATAKANA_INPUT_MODE);
table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);
composer_->Reset();
composer_->SetInputMode(transliteration::HIRAGANA);
InsertKey("K", composer_.get());
Expand Down Expand Up @@ -1259,8 +1245,7 @@ TEST_F(ComposerTest, AutoIMETurnOffEnabled) {
config_->set_preedit_method(Config::ROMAN);
config_->set_use_auto_ime_turn_off(true);

table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

commands::KeyEvent key;

Expand Down Expand Up @@ -1371,8 +1356,7 @@ TEST_F(ComposerTest, AutoIMETurnOffDisabled) {
config_->set_preedit_method(Config::ROMAN);
config_->set_use_auto_ime_turn_off(false);

table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

commands::KeyEvent key;

Expand Down Expand Up @@ -1405,8 +1389,7 @@ TEST_F(ComposerTest, AutoIMETurnOffKana) {
config_->set_preedit_method(Config::KANA);
config_->set_use_auto_ime_turn_off(true);

table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

commands::KeyEvent key;

Expand Down Expand Up @@ -2126,8 +2109,7 @@ TEST_F(ComposerTest, Issue2797991Case4) {
TEST_F(ComposerTest, CaseSensitiveByConfiguration) {
{
config_->set_shift_key_mode_switch(Config::OFF);
table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

table_->AddRule("i", "", "");
table_->AddRule("I", "", "");
Expand All @@ -2141,8 +2123,7 @@ TEST_F(ComposerTest, CaseSensitiveByConfiguration) {
composer_->Reset();
{
config_->set_shift_key_mode_switch(Config::ASCII_INPUT_MODE);
table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

table_->AddRule("i", "", "");
table_->AddRule("I", "", "");
Expand All @@ -2159,8 +2140,7 @@ TEST_F(ComposerTest,
InputUppercaseInAlphanumericModeWithShiftKeyModeSwitchIsKatakana) {
{
config_->set_shift_key_mode_switch(Config::KATAKANA_INPUT_MODE);
table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

table_->AddRule("i", "", "");
table_->AddRule("I", "", "");
Expand Down Expand Up @@ -2208,8 +2188,7 @@ TEST_F(ComposerTest, DeletingAlphanumericPartShouldQuitToggleAlphanumericMode) {
// 2. Type Back-space 6 times ("い")
// 3. Type "i" (should be "いい")

table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

table_->AddRule("i", "", "");

Expand Down Expand Up @@ -2240,8 +2219,7 @@ TEST_F(ComposerTest, DeletingAlphanumericPartShouldQuitToggleAlphanumericMode) {
TEST_F(ComposerTest, InputModesChangeWhenCursorMoves) {
// The expectation of this test is the same as MS-IME's

table_->InitializeWithRequestAndConfig(*request_, *config_,
mock_data_manager_);
table_->InitializeWithRequestAndConfig(*request_, *config_);

table_->AddRule("i", "", "");
table_->AddRule("gi", "", "");
Expand Down Expand Up @@ -2520,7 +2498,7 @@ TEST_F(ComposerTest, 12KeysAsciiGetQueryForPrediction) {
commands::Request::TWELVE_KEYS_TO_HALFWIDTHASCII);
composer_->SetRequest(&request);
table_->InitializeWithRequestAndConfig(
request, config::ConfigHandler::DefaultConfig(), mock_data_manager_);
request, config::ConfigHandler::DefaultConfig());
composer_->InsertCharacter("2");
EXPECT_EQ(composer_->GetStringForPreedit(), "a");
EXPECT_EQ(composer_->GetQueryForConversion(), "a");
Expand Down
10 changes: 4 additions & 6 deletions src/composer/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ constexpr absl::string_view kSquareClose = "]";
constexpr absl::string_view kMiddleDot = "";

bool Table::InitializeWithRequestAndConfig(
const commands::Request &request, const config::Config &config,
const DataManagerInterface &data_manager) {
const commands::Request &request, const config::Config &config) {
case_sensitive_ = false;
bool result = false;
if (request.special_romanji_table() !=
Expand Down Expand Up @@ -566,9 +565,8 @@ const Table &Table::GetDefaultTable() {
TableManager::TableManager()
: custom_roman_table_fingerprint_(Fingerprint32("")) {}

const Table *TableManager::GetTable(
const mozc::commands::Request &request, const mozc::config::Config &config,
const mozc::DataManagerInterface &data_manager) {
const Table *TableManager::GetTable(const mozc::commands::Request &request,
const mozc::config::Config &config) {
// calculate the hash depending on the request and the config
uint32_t hash = request.special_romanji_table();
hash = hash * (mozc::config::Config_PreeditMethod_PreeditMethod_MAX + 1) +
Expand Down Expand Up @@ -602,7 +600,7 @@ const Table *TableManager::GetTable(
}

auto table = std::make_unique<Table>();
if (!table->InitializeWithRequestAndConfig(request, config, data_manager)) {
if (!table->InitializeWithRequestAndConfig(request, config)) {
return nullptr;
}

Expand Down
8 changes: 2 additions & 6 deletions src/composer/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@
#include <istream>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/strings/string_view.h"
#include "base/container/trie.h"
#include "composer/internal/special_key.h"
#include "data_manager/data_manager_interface.h"
#include "protocol/commands.pb.h"
#include "protocol/config.pb.h"

Expand Down Expand Up @@ -94,8 +92,7 @@ class Table final {
Table &operator=(const Table &) = delete;

bool InitializeWithRequestAndConfig(const commands::Request &request,
const config::Config &config,
const DataManagerInterface &data_manager);
const config::Config &config);

// Return true if adding the input-pending pair makes a loop of
// conversion rules.
Expand Down Expand Up @@ -161,8 +158,7 @@ class TableManager {
// Return Table for the request and the config
// TableManager has ownership of the return value;
const Table *GetTable(const commands::Request &request,
const config::Config &config,
const DataManagerInterface &data_manager);
const config::Config &config);

void ClearCaches();

Expand Down
Loading

0 comments on commit d6af481

Please sign in to comment.