diff --git a/src/base/BUILD.bazel b/src/base/BUILD.bazel index 0d2c7cd61..e2546e1fb 100644 --- a/src/base/BUILD.bazel +++ b/src/base/BUILD.bazel @@ -144,6 +144,7 @@ mozc_cc_library( deps = [ ":file_stream", "@com_google_absl//absl/base:core_headers", + "@com_google_absl//absl/log:initialize", "@com_google_absl//absl/log:log_entry", "@com_google_absl//absl/log:log_sink", "@com_google_absl//absl/log:log_sink_registry", @@ -184,7 +185,6 @@ mozc_cc_test( name = "codegen_bytearray_stream_test", size = "small", srcs = ["codegen_bytearray_stream_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], target_compatible_with = mozc_select( android = ["@platforms//:incompatible"], @@ -211,7 +211,6 @@ mozc_cc_test( name = "singleton_test", size = "small", srcs = ["singleton_test.cc"], - requires_full_emulation = False, deps = [ ":singleton", ":thread", @@ -251,7 +250,6 @@ mozc_cc_library( mozc_cc_test( name = "hash_test", srcs = ["hash_test.cc"], - requires_full_emulation = False, deps = [ ":hash", "//testing:gunit_main", @@ -271,7 +269,6 @@ mozc_cc_library( mozc_cc_test( name = "clock_test", srcs = ["clock_test.cc"], - requires_full_emulation = False, deps = [ ":clock", ":clock_mock", @@ -325,7 +322,6 @@ mozc_cc_test( srcs = [ "util_test.cc", ], - requires_full_emulation = False, deps = [ ":logging", ":util", @@ -366,7 +362,6 @@ mozc_cc_test( name = "number_util_test", size = "small", srcs = ["number_util_test.cc"], - requires_full_emulation = False, deps = [ ":number_util", "//testing:gunit_main", @@ -389,7 +384,6 @@ mozc_cc_test( name = "text_normalizer_test", size = "small", srcs = ["text_normalizer_test.cc"], - requires_full_emulation = False, deps = [ ":text_normalizer", ":util", @@ -415,7 +409,6 @@ mozc_cc_test( name = "clock_mock_test", size = "small", srcs = ["clock_mock_test.cc"], - requires_full_emulation = False, deps = [ ":clock_mock", "//testing:gunit_main", @@ -454,7 +447,6 @@ mozc_cc_test( name = "mmap_test", size = "small", srcs = ["mmap_test.cc"], - requires_full_emulation = False, deps = [ ":file_util", ":mmap", @@ -522,7 +514,6 @@ mozc_cc_test( name = "file_util_mock_test", size = "small", srcs = ["file_util_mock_test.cc"], - requires_full_emulation = False, deps = [ ":file_util_mock", "//testing:gunit_main", @@ -533,7 +524,6 @@ mozc_cc_test( name = "file_util_test", size = "small", srcs = ["file_util_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], # TODO(b/73698251): disabled due to errors deps = [ ":file_util", @@ -600,7 +590,6 @@ mozc_cc_library( mozc_cc_test( name = "system_util_test", srcs = ["system_util_test.cc"], - requires_full_emulation = False, visibility = ["//visibility:private"], deps = [ ":environ_mock", @@ -672,7 +661,6 @@ mozc_cc_test( name = "process_mutex_test", size = "small", srcs = ["process_mutex_test.cc"], - requires_full_emulation = False, deps = [ ":file_util", ":logging", @@ -748,7 +736,6 @@ mozc_cc_test( name = "config_file_stream_test", size = "small", srcs = ["config_file_stream_test.cc"], - requires_full_emulation = False, deps = [ ":config_file_stream", ":file_util", @@ -819,7 +806,6 @@ mozc_cc_test( name = "version_test", size = "small", srcs = ["version_test.cc"], - requires_full_emulation = False, deps = [ ":util", ":version", @@ -857,7 +843,6 @@ mozc_cc_test( "unverified_aes256_test.cc", "unverified_sha1_test.cc", ], - requires_full_emulation = False, visibility = ["//visibility:private"], deps = [ ":obfuscator_support", @@ -909,7 +894,6 @@ mozc_cc_test( "encryptor_test.cc", "password_manager_test.cc", ], - requires_full_emulation = False, # Skipped for Windows Presubmit as CryptProtectData doesn't work on a headless Windows VM. # Background: https://github.com/Azure/azure-cli/issues/20695#issuecomment-992086316 tags = ["nowin"], @@ -934,7 +918,6 @@ mozc_cc_test( name = "cpu_stats_test", size = "small", srcs = ["cpu_stats_test.cc"], - requires_full_emulation = False, deps = [ ":cpu_stats", "//testing:gunit_main", @@ -970,7 +953,6 @@ mozc_cc_test( name = "stopwatch_test", size = "small", srcs = ["stopwatch_test.cc"], - requires_full_emulation = False, deps = [ ":clock", ":clock_mock", @@ -1006,7 +988,6 @@ mozc_cc_test( name = "url_test", size = "small", srcs = ["url_test.cc"], - requires_full_emulation = False, deps = [ ":url", "//testing:gunit_main", @@ -1031,7 +1012,6 @@ mozc_cc_test( name = "multifile_test", size = "small", srcs = ["multifile_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], # TODO(b/73698251): disabled due to errors deps = [ ":file_stream", @@ -1086,7 +1066,6 @@ mozc_cc_test( ":gen_embedded_file_test_data", ], data = ["embedded_file.h"], - requires_full_emulation = False, tags = ["noandroid"], # TODO(b/73698251): disabled due to errors deps = [ ":embedded_file", diff --git a/src/base/container/BUILD.bazel b/src/base/container/BUILD.bazel index 0d491254c..64f40290d 100644 --- a/src/base/container/BUILD.bazel +++ b/src/base/container/BUILD.bazel @@ -46,7 +46,6 @@ mozc_cc_test( name = "bitarray_test", size = "small", srcs = ["bitarray_test.cc"], - requires_full_emulation = False, deps = [ ":bitarray", "//testing:gunit_main", @@ -88,7 +87,6 @@ mozc_cc_test( name = "serialized_string_array_test", size = "small", srcs = ["serialized_string_array_test.cc"], - requires_full_emulation = False, deps = [ ":serialized_string_array", "//testing:gunit_main", @@ -112,7 +110,6 @@ mozc_cc_test( name = "trie_test", size = "small", srcs = ["trie_test.cc"], - requires_full_emulation = False, deps = [ ":trie", "//testing:gunit_main", diff --git a/src/base/log_file.cc b/src/base/log_file.cc index 29cb38b74..997ca7a65 100644 --- a/src/base/log_file.cc +++ b/src/base/log_file.cc @@ -32,6 +32,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/initialize.h" #include "absl/log/log_entry.h" #include "absl/log/log_sink.h" #include "absl/log/log_sink_registry.h" @@ -64,6 +65,7 @@ class LogFileSink : public absl::LogSink { void RegisterLogFileSink(const std::string &path) { #if !defined(MOZC_NO_LOGGING) && !defined(__ANDROID__) + absl::InitializeLog(); absl::AddLogSink(new LogFileSink(path)); #endif // !MOZC_NO_LOGGING && !__ANDROID__ } diff --git a/src/base/strings/BUILD.bazel b/src/base/strings/BUILD.bazel index 8de72b805..8233d69f1 100644 --- a/src/base/strings/BUILD.bazel +++ b/src/base/strings/BUILD.bazel @@ -124,7 +124,6 @@ mozc_cc_test( srcs = [ "japanese_test.cc", ], - requires_full_emulation = False, deps = [ ":japanese", "//testing:gunit_main", diff --git a/src/base/strings/unicode.h b/src/base/strings/unicode.h index d61e503c9..df71f0504 100644 --- a/src/base/strings/unicode.h +++ b/src/base/strings/unicode.h @@ -144,16 +144,34 @@ absl::string_view Utf8Substring(absl::string_view sv, size_t pos, size_t count); } // namespace strings +// Represents both a UTF-8 string and its decoded result. +class UnicodeChar { + public: + UnicodeChar(const char* utf8, const uint_fast8_t bytes_seen, + char32_t codepoint) + : utf8_(utf8), + dr_(utf8_internal::DecodeResult::Continue(codepoint, bytes_seen)) {} + + char32_t char32() const { return dr_.code_point(); } + absl::string_view utf8() const { + return absl::string_view(utf8_, dr_.bytes_seen()); + } + + private: + const char* utf8_; + utf8_internal::DecodeResult dr_; +}; + // Utf8CharIterator is an iterator adapter for a string-like iterator to iterate // over each UTF-8 character. // Note that the simple dereference returns the underlying StringIterator value. // Use one of the member functions to access each character. -template +template class Utf8CharIterator { public: using difference_type = typename std::iterator_traits::difference_type; - using value_type = std::conditional_t; + using value_type = ValueType; using pointer = const value_type*; // The reference type can be non-reference for input iterators. using reference = value_type; @@ -173,10 +191,12 @@ class Utf8CharIterator { // Returns the current character. reference operator*() const { - if constexpr (AsChar32) { + if constexpr (std::is_same_v) { return char32(); - } else { + } else if constexpr (std::is_same_v) { return view(); + } else if constexpr (std::is_same_v) { + return ValueType{ptr_, dr_.bytes_seen(), dr_.code_point()}; } } @@ -218,9 +238,9 @@ class Utf8CharIterator { // another iterator last. // // REQUIRES: last points to the same string object. - template + template absl::string_view SubstringTo( - const Utf8CharIterator last) const { + const Utf8CharIterator last) const { return absl::string_view(ptr_, last.ptr_ - ptr_); } @@ -238,14 +258,14 @@ class Utf8CharIterator { }; // Comparison operators for Utf8CharIterator. -template -bool operator==(const Utf8CharIterator lhs, - const Utf8CharIterator rhs) { +template +bool operator==(const Utf8CharIterator lhs, + const Utf8CharIterator rhs) { return lhs.to_address() == rhs.to_address(); } -template -bool operator!=(const Utf8CharIterator lhs, - const Utf8CharIterator rhs) { +template +bool operator!=(const Utf8CharIterator lhs, + const Utf8CharIterator rhs) { return !(lhs == rhs); } @@ -261,16 +281,16 @@ bool operator!=(const Utf8CharIterator lhs, // size, however, this class will mostly be used to just iterate over each // character once, so it'd be inefficient to iterate over the same string twice. // Therefore, it doesn't have the size() member function. -template +template class Utf8AsCharsBase { public: using StringViewT = absl::string_view; using CharT = StringViewT::value_type; - using value_type = std::conditional_t; + using value_type = ValueType; using reference = value_type&; using const_reference = const value_type&; - using iterator = Utf8CharIterator; + using iterator = Utf8CharIterator; using const_iterator = iterator; using difference_type = StringViewT::difference_type; using size_type = StringViewT::size_type; @@ -295,9 +315,9 @@ class Utf8AsCharsBase { // can be different among first, last, and the constructed class. // // Complexity: constant - template - Utf8AsCharsBase(const Utf8CharIterator first, - const Utf8CharIterator last) + template + Utf8AsCharsBase(const Utf8CharIterator first, + const Utf8CharIterator last) : sv_(first.to_address(), last.to_address() - first.to_address()) {} // Construction from a null pointer is disallowed. @@ -339,13 +359,13 @@ class Utf8AsCharsBase { // complexity. // // Complexity: constant - template - StringViewT Substring(const Utf8CharIterator first) const { + template + StringViewT Substring(const Utf8CharIterator first) const { return first.SubstringTo(end()); } - template - StringViewT Substring(const Utf8CharIterator first, - const Utf8CharIterator last) const { + template + StringViewT Substring(const Utf8CharIterator first, + const Utf8CharIterator last) const { return first.SubstringTo(last); } @@ -364,34 +384,34 @@ class Utf8AsCharsBase { // Bitwise comparison operators that compare two Utf8AsCharBase using the // underlying string_view comparators. -template -bool operator==(const Utf8AsCharsBase lhs, - const Utf8AsCharsBase rhs) { +template +bool operator==(const Utf8AsCharsBase lhs, + const Utf8AsCharsBase rhs) { return lhs.view() == rhs.view(); } -template -bool operator!=(const Utf8AsCharsBase lhs, - const Utf8AsCharsBase rhs) { +template +bool operator!=(const Utf8AsCharsBase lhs, + const Utf8AsCharsBase rhs) { return lhs.view() != rhs.view(); } -template -bool operator<(const Utf8AsCharsBase lhs, - const Utf8AsCharsBase rhs) { +template +bool operator<(const Utf8AsCharsBase lhs, + const Utf8AsCharsBase rhs) { return lhs.view() < rhs.view(); } -template -bool operator<=(const Utf8AsCharsBase lhs, - const Utf8AsCharsBase rhs) { +template +bool operator<=(const Utf8AsCharsBase lhs, + const Utf8AsCharsBase rhs) { return lhs.view() <= rhs.view(); } -template -bool operator>=(const Utf8AsCharsBase lhs, - const Utf8AsCharsBase rhs) { +template +bool operator>=(const Utf8AsCharsBase lhs, + const Utf8AsCharsBase rhs) { return lhs.view() >= rhs.view(); } -template -bool operator>(const Utf8AsCharsBase lhs, - const Utf8AsCharsBase rhs) { +template +bool operator>(const Utf8AsCharsBase lhs, + const Utf8AsCharsBase rhs) { return lhs.view() > rhs.view(); } @@ -413,7 +433,7 @@ bool operator>(const Utf8AsCharsBase lhs, // std::vector v; // absl::c_copy(Utf8AsChars32(sv), std::back_inserter(s32)); // absl::c_copy(Utf8AsChars32(sv), std::back_inserter(v)); -using Utf8AsChars32 = Utf8AsCharsBase; +using Utf8AsChars32 = Utf8AsCharsBase; // Utf8AsChars is a wrapper to iterator a UTF-8 string over each character as // substrings. Characters with invalid encodings are returned as they are. @@ -430,7 +450,21 @@ using Utf8AsChars32 = Utf8AsCharsBase; // const absl::string_view sv = ...; // std::vector v; // absl::c_copy(Utf8AsChars(sv), std::back_inserter(v)); -using Utf8AsChars = Utf8AsCharsBase; +using Utf8AsChars = Utf8AsCharsBase; + +// Utf8AsUnicodeChar is similar to Utf8AsChars32 and Utf8AsChars above, except +// that it can provide both char32_t code points and its UTF-8 sub-strings. +// +// When both aren't needed, Utf8AsChars32 and Utf8AsChars are more efficient. +// +// Example: +// bool Func(const absl::string_view sv) { +// for (const UnicodeChar c : Utf8AsUnicodeChar(sv)) { +// std::cout << c.utf8() >> " --> " << c.char32(); +// } +// ... +// } +using Utf8AsUnicodeChar = Utf8AsCharsBase; // Implementations. namespace strings { @@ -467,16 +501,18 @@ constexpr std::pair FrontChar( } // namespace strings -template -typename Utf8AsCharsBase::value_type Utf8AsCharsBase::back() - const { +template +typename Utf8AsCharsBase::value_type +Utf8AsCharsBase::back() const { const char* const last = EndPtr(); if (sv_.back() <= 0x7f) { // ASCII - if constexpr (AsChar32) { + if constexpr (std::is_same_v) { return sv_.back(); - } else { + } else if constexpr (std::is_same_v) { return value_type(last - 1, 1); + } else if constexpr (std::is_same_v) { + return value_type{last - 1, 1, sv_.back()}; } } // Other patterns. UTF-8 characters are at most four bytes long. @@ -487,10 +523,12 @@ typename Utf8AsCharsBase::value_type Utf8AsCharsBase::back() const char* const ptr = last - size; const utf8_internal::DecodeResult dr = utf8_internal::Decode(ptr, last); if (dr.bytes_seen() == size) { - if constexpr (AsChar32) { + if constexpr (std::is_same_v) { return dr.code_point(); - } else { + } else if constexpr (std::is_same_v) { return value_type(ptr, dr.bytes_seen()); + } else if constexpr (std::is_same_v) { + return value_type{ptr, dr.bytes_seen(), dr.code_point()}; } } } diff --git a/src/base/strings/unicode_test.cc b/src/base/strings/unicode_test.cc index a53445771..49c6cabae 100644 --- a/src/base/strings/unicode_test.cc +++ b/src/base/strings/unicode_test.cc @@ -314,6 +314,24 @@ TEST_P(Utf8AsCharsTest, AsString) { EXPECT_EQ(actual, GetParam().u8_strings); } +TEST_P(Utf8AsCharsTest, AsUnicodeChar) { + const Utf8AsUnicodeChar s(GetParam().input); + std::u32string actual_u32; + std::vector actual_string_views; + for (const UnicodeChar data : s) { + actual_u32.push_back(data.char32()); + actual_string_views.push_back(data.utf8()); + } + EXPECT_EQ(actual_u32, GetParam().chars32); + EXPECT_EQ(actual_string_views, GetParam().u8_strings); + if (!s.empty()) { + EXPECT_EQ(s.front().char32(), GetParam().chars32.front()); + EXPECT_EQ(s.front().utf8(), GetParam().u8_strings.front()); + EXPECT_EQ(s.back().char32(), GetParam().chars32.back()); + EXPECT_EQ(s.back().utf8(), GetParam().u8_strings.back()); + } +} + TEST_P(Utf8AsCharsTest, Properties) { const Utf8AsChars32 s(GetParam().input); const absl::string_view input = GetParam().input; diff --git a/src/build_defs.bzl b/src/build_defs.bzl index 88b21f2bd..33ae6e427 100644 --- a/src/build_defs.bzl +++ b/src/build_defs.bzl @@ -70,7 +70,7 @@ def mozc_cc_library(deps = [], copts = [], visibility = None, **kwargs): ) register_extension_info( - extension = "mozc_cc_library", + extension = mozc_cc_library, label_regex_for_dep = "{extension_name}", ) @@ -85,7 +85,7 @@ def mozc_cc_binary(deps = [], copts = [], **kwargs): ) register_extension_info( - extension = "mozc_cc_binary", + extension = mozc_cc_binary, label_regex_for_dep = "{extension_name}", ) @@ -99,8 +99,6 @@ def mozc_cc_test(name, tags = [], deps = [], copts = [], **kwargs): copts: copts for cc_test. -funsigned-char is added. **kwargs: other args for cc_test. """ - - requires_full_emulation = kwargs.pop("requires_full_emulation", False) native.cc_test( name = name, tags = tags, @@ -110,7 +108,7 @@ def mozc_cc_test(name, tags = [], deps = [], copts = [], **kwargs): ) register_extension_info( - extension = "mozc_cc_test", + extension = mozc_cc_test, label_regex_for_dep = "{extension_name}", ) @@ -124,7 +122,7 @@ def mozc_py_library(name, srcs, srcs_version = "PY3", **kwargs): ) register_extension_info( - extension = "mozc_py_library", + extension = mozc_py_library, label_regex_for_dep = "{extension_name}", ) @@ -147,7 +145,7 @@ def mozc_py_binary(name, srcs, python_version = "PY3", srcs_version = "PY3", tes ) register_extension_info( - extension = "mozc_py_binary", + extension = mozc_py_binary, label_regex_for_dep = "{extension_name}", ) @@ -210,7 +208,7 @@ def mozc_objc_library( ) register_extension_info( - extension = "mozc_objc_library", + extension = mozc_objc_library, label_regex_for_dep = "{extension_name}", ) @@ -268,7 +266,7 @@ def mozc_objc_test( ) register_extension_info( - extension = "mozc_objc_test", + extension = mozc_objc_test, label_regex_for_dep = "{extension_name}", ) @@ -392,6 +390,11 @@ def mozc_select( oss_android: value for OSS Android build. oss_linux: value for OSS Linux build. oss_macos: value for OSS macOS build. + oss_windows: value for OSS Windows build. + prod: value for prod build. + prod_linux: value for prod Linux build. + prod_macos: value for prod macOS build. + prod_windows: value for prod Windows build. wasm: value for wasm build. windows: value for Windows build. (placeholder) diff --git a/src/client/BUILD.bazel b/src/client/BUILD.bazel index 87137a8fb..ccf9b3c81 100644 --- a/src/client/BUILD.bazel +++ b/src/client/BUILD.bazel @@ -110,7 +110,6 @@ mozc_cc_test( name = "client_test", size = "small", srcs = ["client_test.cc"], - requires_full_emulation = False, deps = [ ":client", ":client_interface", diff --git a/src/composer/BUILD.bazel b/src/composer/BUILD.bazel index 995646543..b163626fa 100644 --- a/src/composer/BUILD.bazel +++ b/src/composer/BUILD.bazel @@ -77,7 +77,6 @@ mozc_cc_test( name = "composer_test", size = "small", srcs = ["composer_test.cc"], - requires_full_emulation = False, deps = [ ":composer", ":key_parser", @@ -133,7 +132,6 @@ mozc_cc_test( name = "table_test", size = "small", srcs = ["table_test.cc"], - requires_full_emulation = False, deps = [ ":table", "//composer/internal:special_key", @@ -152,8 +150,9 @@ mozc_cc_library( srcs = ["key_event_util.cc"], hdrs = ["key_event_util.h"], deps = [ - "//base:logging", "//protocol:commands_cc_proto", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", ], ) @@ -161,7 +160,6 @@ mozc_cc_test( name = "key_event_util_test", size = "small", srcs = ["key_event_util_test.cc"], - requires_full_emulation = False, deps = [ ":key_event_util", ":key_parser", @@ -193,7 +191,6 @@ mozc_cc_test( name = "key_parser_test", size = "small", srcs = ["key_parser_test.cc"], - requires_full_emulation = False, deps = [ ":key_event_util", ":key_parser", diff --git a/src/composer/internal/BUILD.bazel b/src/composer/internal/BUILD.bazel index 283a02c09..d07105cb5 100644 --- a/src/composer/internal/BUILD.bazel +++ b/src/composer/internal/BUILD.bazel @@ -96,7 +96,6 @@ mozc_cc_test( srcs = [ "transliterators_test.cc", ], - requires_full_emulation = False, deps = [ ":transliterator_interface", ":transliterators", @@ -110,7 +109,6 @@ mozc_cc_test( srcs = [ "char_chunk_test.cc", ], - requires_full_emulation = False, deps = [ ":char_chunk", ":composition_input", @@ -144,7 +142,6 @@ mozc_cc_test( srcs = [ "composition_input_test.cc", ], - requires_full_emulation = False, deps = [ ":composition_input", "//composer:table", @@ -179,7 +176,6 @@ mozc_cc_test( srcs = [ "composition_test.cc", ], - requires_full_emulation = False, deps = [ ":char_chunk", ":composition", @@ -217,7 +213,6 @@ mozc_cc_test( name = "converter_test", size = "small", srcs = ["converter_test.cc"], - requires_full_emulation = False, deps = [ ":converter", "//composer:table", @@ -240,7 +235,6 @@ mozc_cc_test( name = "mode_switching_handler_test", size = "small", srcs = ["mode_switching_handler_test.cc"], - requires_full_emulation = False, deps = [ ":mode_switching_handler", "//testing:gunit_main", diff --git a/src/composer/key_event_util.cc b/src/composer/key_event_util.cc index e58bb61de..07adfed29 100644 --- a/src/composer/key_event_util.cc +++ b/src/composer/key_event_util.cc @@ -33,7 +33,8 @@ #include #include -#include "base/logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "protocol/commands.pb.h" namespace mozc { @@ -85,7 +86,7 @@ bool KeyEventUtil::GetKeyInformation(const KeyEvent &key_event, : KeyEvent::NO_SPECIALKEY; const uint32_t key_code = key_event.has_key_code() ? key_event.key_code() : 0; - // Make sure the translation from the obsolete spesification. + // Make sure the translation from the obsolete specification. // key_code should no longer contain control characters. if (0 < key_code && key_code <= 32) { return false; @@ -173,7 +174,7 @@ void KeyEventUtil::NormalizeNumpadKey(const KeyEvent &key_event, new_key_code = ','; break; default: - LOG(ERROR) << "Should not reach here."; + LOG(ERROR) << "Unexpected numpad key: " << numpad_key; return; } diff --git a/src/config/BUILD.bazel b/src/config/BUILD.bazel index fa68352d8..291bd30e0 100644 --- a/src/config/BUILD.bazel +++ b/src/config/BUILD.bazel @@ -65,7 +65,6 @@ mozc_cc_test( size = "small", srcs = ["config_handler_test.cc"], data = ["//data/test/config:config_test_data"], - requires_full_emulation = False, deps = [ ":config_handler", "//base:clock", @@ -107,7 +106,6 @@ mozc_cc_test( name = "stats_config_util_test", size = "small", srcs = ["stats_config_util_test.cc"], - requires_full_emulation = False, deps = [ ":config_handler", ":stats_config_util", @@ -159,7 +157,6 @@ mozc_cc_test( name = "character_form_manager_test", size = "large", srcs = ["character_form_manager_test.cc"], - requires_full_emulation = False, deps = [ ":character_form_manager", "//protocol:config_cc_proto", diff --git a/src/converter/BUILD.bazel b/src/converter/BUILD.bazel index 96a1a100d..966f7c304 100644 --- a/src/converter/BUILD.bazel +++ b/src/converter/BUILD.bazel @@ -65,7 +65,6 @@ mozc_cc_test( name = "segments_test", size = "small", srcs = ["segments_test.cc"], - requires_full_emulation = False, deps = [ ":segments", "//base:number_util", @@ -160,7 +159,6 @@ mozc_cc_test( "//data/test/dictionary:connection_single_column.txt", "//data_manager/testing:mozc_dataset_for_testing@connection", ], - requires_full_emulation = False, deps = [ ":connector", "//base:logging", @@ -201,7 +199,6 @@ mozc_cc_test( srcs = [ "nbest_generator_test.cc", ], - requires_full_emulation = False, deps = [ ":connector", ":immutable_converter_no_factory", @@ -250,7 +247,6 @@ mozc_cc_test( name = "candidate_filter_test", size = "small", srcs = ["candidate_filter_test.cc"], - requires_full_emulation = False, deps = [ ":candidate_filter", ":node", @@ -303,7 +299,6 @@ mozc_cc_test( name = "lattice_test", size = "small", srcs = ["lattice_test.cc"], - requires_full_emulation = False, deps = [ ":lattice", ":node", @@ -374,7 +369,6 @@ mozc_cc_test( srcs = [ "immutable_converter_test.cc", ], - requires_full_emulation = False, deps = [ ":immutable_converter_no_factory", ":lattice", @@ -449,7 +443,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["converter_test.cc"], - requires_full_emulation = False, deps = [ ":converter", ":converter_interface", @@ -499,7 +492,6 @@ mozc_cc_test( name = "converter_regression_test", size = "medium", srcs = ["converter_regression_test.cc"], - requires_full_emulation = False, deps = [ ":converter_interface", ":segments", @@ -533,7 +525,6 @@ mozc_cc_test( size = "small", srcs = ["pos_id_printer_test.cc"], data = ["//data/test/dictionary:id.def"], - requires_full_emulation = False, deps = [ ":pos_id_printer", "//base:file_stream", @@ -632,7 +623,6 @@ mozc_cc_test( name = "key_corrector_test", size = "small", srcs = ["key_corrector_test.cc"], - requires_full_emulation = False, deps = [ ":key_corrector", "//testing:gunit_main", diff --git a/src/converter/converter.cc b/src/converter/converter.cc index f3d43af43..53b427df7 100644 --- a/src/converter/converter.cc +++ b/src/converter/converter.cc @@ -37,6 +37,7 @@ #include #include +#include "absl/base/optimization.h" #include "absl/log/check.h" #include "absl/log/log.h" #include "absl/strings/string_view.h" @@ -292,7 +293,7 @@ bool Converter::StartConversion(const ConversionRequest &original_request, conversion_key = request.composer().GetQueryForPrediction(); break; default: - LOG(FATAL) << "Should never reach here"; + ABSL_UNREACHABLE(); } if (conversion_key.empty()) { return false; diff --git a/src/data_manager/BUILD.bazel b/src/data_manager/BUILD.bazel index c1c2bf238..0a2af6e9f 100644 --- a/src/data_manager/BUILD.bazel +++ b/src/data_manager/BUILD.bazel @@ -164,7 +164,6 @@ mozc_cc_library( mozc_cc_test( name = "dataset_writer_test", srcs = ["dataset_writer_test.cc"], - requires_full_emulation = False, deps = [ ":dataset_cc_proto", ":dataset_writer", @@ -215,7 +214,6 @@ mozc_cc_library( mozc_cc_test( name = "dataset_reader_test", srcs = ["dataset_reader_test.cc"], - requires_full_emulation = False, deps = [ ":dataset_cc_proto", ":dataset_reader", @@ -265,7 +263,6 @@ mozc_cc_library( mozc_cc_test( name = "serialized_dictionary_test", srcs = ["serialized_dictionary_test.cc"], - requires_full_emulation = False, deps = [ ":serialized_dictionary", "//base/container:serialized_string_array", diff --git a/src/data_manager/oss/BUILD.bazel b/src/data_manager/oss/BUILD.bazel index a4d43a992..f76d1413d 100644 --- a/src/data_manager/oss/BUILD.bazel +++ b/src/data_manager/oss/BUILD.bazel @@ -137,7 +137,6 @@ mozc_cc_test( "//data/dictionary_oss:connection_single_column.txt", "//data/dictionary_oss:suggestion_filter.txt", ], - requires_full_emulation = False, deps = [ ":oss_data_manager", "//data_manager:data_manager_test_base", diff --git a/src/data_manager/testing/BUILD.bazel b/src/data_manager/testing/BUILD.bazel index 83ebe3f44..141e218d3 100644 --- a/src/data_manager/testing/BUILD.bazel +++ b/src/data_manager/testing/BUILD.bazel @@ -75,7 +75,6 @@ mozc_cc_test( "//data/test/dictionary:dictionary_data", "//data/test/dictionary:suggestion_filter.txt", ], - requires_full_emulation = False, deps = [ ":mock_data_manager", "//data_manager:data_manager_test_base", diff --git a/src/dictionary/BUILD.bazel b/src/dictionary/BUILD.bazel index 3b3a4c2af..2ee410963 100644 --- a/src/dictionary/BUILD.bazel +++ b/src/dictionary/BUILD.bazel @@ -70,7 +70,6 @@ mozc_cc_test( name = "dictionary_impl_test", size = "small", srcs = ["dictionary_impl_test.cc"], - requires_full_emulation = False, deps = [ ":dictionary_impl", ":dictionary_interface", @@ -170,7 +169,6 @@ mozc_cc_test( srcs = [ "user_dictionary_test.cc", ], - requires_full_emulation = False, deps = [ ":dictionary_interface", ":dictionary_test_util", @@ -279,6 +277,7 @@ mozc_cc_library( "//base/protobuf:repeated_field", "//base/strings:assign", "//protocol:user_dictionary_storage_cc_proto", + "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/container:fixed_array", "@com_google_absl//absl/strings", ], @@ -288,7 +287,6 @@ mozc_cc_test( name = "user_dictionary_session_test", size = "medium", srcs = ["user_dictionary_session_test.cc"], - requires_full_emulation = False, deps = [ ":user_dictionary_session", ":user_dictionary_storage", @@ -322,7 +320,6 @@ mozc_cc_test( name = "user_dictionary_session_handler_test", size = "small", srcs = ["user_dictionary_session_handler_test.cc"], - requires_full_emulation = True, deps = [ ":user_dictionary_session_handler", "//base:file_util", @@ -350,6 +347,7 @@ mozc_cc_library( "//base:vlog", "//base/protobuf:zero_copy_stream_impl", "//protocol:user_dictionary_storage_cc_proto", + "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/status", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", @@ -361,7 +359,6 @@ mozc_cc_test( name = "user_dictionary_storage_test", size = "small", srcs = ["user_dictionary_storage_test.cc"], - requires_full_emulation = False, deps = [ ":user_dictionary_importer", ":user_dictionary_storage", @@ -406,7 +403,6 @@ mozc_cc_test( name = "user_dictionary_util_test", size = "small", srcs = ["user_dictionary_util_test.cc"], - requires_full_emulation = False, deps = [ ":user_dictionary_util", "//testing:gunit_main", @@ -442,7 +438,6 @@ mozc_cc_test( name = "user_dictionary_importer_test", size = "small", srcs = ["user_dictionary_importer_test.cc"], - requires_full_emulation = False, deps = [ ":user_dictionary_importer", ":user_dictionary_storage", @@ -480,7 +475,6 @@ mozc_cc_test( srcs = [ "text_dictionary_loader_test.cc", ], - requires_full_emulation = False, deps = [ ":dictionary_token", ":pos_matcher", @@ -512,7 +506,6 @@ mozc_cc_test( name = "user_pos_test", size = "small", srcs = ["user_pos_test.cc"], - requires_full_emulation = False, deps = [ ":user_pos", ":user_pos_interface", @@ -611,7 +604,6 @@ mozc_cc_test( name = "suppression_dictionary_test", size = "small", srcs = ["suppression_dictionary_test.cc"], - requires_full_emulation = False, deps = [ ":suppression_dictionary", "//base:thread", @@ -645,7 +637,6 @@ mozc_cc_test( name = "suffix_dictionary_test", size = "small", srcs = ["suffix_dictionary_test.cc"], - requires_full_emulation = False, deps = [ ":dictionary_interface", ":dictionary_test_util", @@ -704,7 +695,6 @@ mozc_cc_test( name = "single_kanji_dictionary_test", size = "small", srcs = ["single_kanji_dictionary_test.cc"], - requires_full_emulation = False, deps = [ ":single_kanji_dictionary", "//data_manager/testing:mock_data_manager", diff --git a/src/dictionary/file/BUILD.bazel b/src/dictionary/file/BUILD.bazel index b7e4c40e5..3ee160e5f 100644 --- a/src/dictionary/file/BUILD.bazel +++ b/src/dictionary/file/BUILD.bazel @@ -70,7 +70,6 @@ mozc_cc_test( name = "dictionary_file_test", size = "small", srcs = ["dictionary_file_test.cc"], - requires_full_emulation = False, deps = [ ":codec_factory", ":dictionary_file", @@ -143,7 +142,6 @@ mozc_cc_test( name = "codec_test", size = "small", srcs = ["codec_test.cc"], - requires_full_emulation = False, deps = [ ":codec", ":codec_factory", diff --git a/src/dictionary/system/BUILD.bazel b/src/dictionary/system/BUILD.bazel index 789d2f38c..68fa4b5e8 100644 --- a/src/dictionary/system/BUILD.bazel +++ b/src/dictionary/system/BUILD.bazel @@ -68,7 +68,6 @@ mozc_cc_test( name = "codec_test", size = "small", srcs = ["codec_test.cc"], - requires_full_emulation = False, deps = [ ":codec", ":words_info", @@ -192,7 +191,6 @@ mozc_cc_test( "system_dictionary_test.cc", ], data = ["//data/dictionary_oss:dictionary00.txt"], - requires_full_emulation = False, deps = [ ":system_dictionary", ":system_dictionary_builder", @@ -221,7 +219,6 @@ mozc_cc_test( name = "value_dictionary_test", size = "medium", srcs = ["value_dictionary_test.cc"], - requires_full_emulation = False, deps = [ ":codec", ":value_dictionary", @@ -249,7 +246,6 @@ mozc_cc_test( name = "key_expansion_table_test", size = "small", srcs = ["key_expansion_table_test.cc"], - requires_full_emulation = False, deps = [ ":key_expansion_table", "//testing:gunit_main", diff --git a/src/dictionary/user_dictionary_session.cc b/src/dictionary/user_dictionary_session.cc index cf2c2d852..ab3c0fee0 100644 --- a/src/dictionary/user_dictionary_session.cc +++ b/src/dictionary/user_dictionary_session.cc @@ -39,6 +39,7 @@ #include #include +#include "absl/base/optimization.h" #include "absl/container/fixed_array.h" #include "absl/strings/string_view.h" #include "base/logging.h" @@ -409,7 +410,7 @@ UserDictionaryCommandStatus::Status UserDictionarySession::Save() { default: return UserDictionaryCommandStatus::UNKNOWN_ERROR; } - // Should never reach here. + ABSL_UNREACHABLE(); } return UserDictionaryCommandStatus::USER_DICTIONARY_COMMAND_SUCCESS; @@ -505,7 +506,7 @@ UserDictionaryCommandStatus::Status UserDictionarySession::RenameDictionary( LOG(ERROR) << "Unknown error code: " << storage_->GetLastError(); return UserDictionaryCommandStatus::UNKNOWN_ERROR; } - // Should never reach here. + ABSL_UNREACHABLE(); } AddUndoCommand(std::make_unique(dictionary_id, diff --git a/src/dictionary/user_dictionary_storage.cc b/src/dictionary/user_dictionary_storage.cc index 255cb745c..1eb9455f1 100644 --- a/src/dictionary/user_dictionary_storage.cc +++ b/src/dictionary/user_dictionary_storage.cc @@ -35,6 +35,7 @@ #include #include +#include "absl/base/optimization.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -462,7 +463,7 @@ bool UserDictionaryStorage::IsValidDictionaryName( LOG(WARNING) << "Unknown status: " << status; return false; } - // Should never reach here. + ABSL_UNREACHABLE(); } std::string UserDictionaryStorage::default_sync_dictionary_name() { diff --git a/src/engine/BUILD.bazel b/src/engine/BUILD.bazel index dfe876baa..3a7ef27a9 100644 --- a/src/engine/BUILD.bazel +++ b/src/engine/BUILD.bazel @@ -63,7 +63,6 @@ mozc_cc_test( "data_loader_test.cc", "//data_manager/testing:mock_mozc.data", ], - requires_full_emulation = False, deps = [ ":engine_builder", "//base:file_util", @@ -242,7 +241,6 @@ mozc_cc_library( mozc_cc_test( name = "engine_factory_test", srcs = ["engine_factory_test.cc"], - requires_full_emulation = False, deps = [ ":engine_factory", ":engine_interface", diff --git a/src/ios/BUILD.bazel b/src/ios/BUILD.bazel index 59136a047..43de45bbc 100644 --- a/src/ios/BUILD.bazel +++ b/src/ios/BUILD.bazel @@ -41,21 +41,20 @@ mozc_cc_library( visibility = [ ], deps = [ - "//base:logging", "//base:port", "//base:util", "//config:config_handler", "//data_manager", "//engine", + "//engine:engine_interface", "//engine:minimal_engine", "//protocol:commands_cc_proto", "//protocol:config_cc_proto", "//protocol:user_dictionary_storage_cc_proto", - "//session", "//session:session_handler", "//session:session_handler_interface", "@com_google_absl//absl/base:core_headers", - "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log", "@com_google_absl//absl/synchronization", ], ) diff --git a/src/ios/ios_engine.cc b/src/ios/ios_engine.cc index f2ab51a00..3df1136c8 100644 --- a/src/ios/ios_engine.cc +++ b/src/ios/ios_engine.cc @@ -34,13 +34,15 @@ #include #include -#include "absl/flags/flag.h" +#include "absl/base/optimization.h" +#include "absl/base/thread_annotations.h" +#include "absl/log/log.h" #include "absl/synchronization/mutex.h" -#include "base/logging.h" #include "base/util.h" #include "config/config_handler.h" #include "data_manager/data_manager.h" #include "engine/engine.h" +#include "engine/engine_interface.h" #include "engine/minimal_engine.h" #include "protocol/commands.pb.h" #include "protocol/user_dictionary_storage.pb.h" @@ -317,8 +319,7 @@ bool IosEngine::SwitchInputMode(InputMode mode) { target_config = ¤t_config_tuple_.digit_config; break; default: - LOG(DFATAL) << "Should never reach here"; - return false; + ABSL_UNREACHABLE(); } if (current_input_config_ == target_config) { return true; diff --git a/src/ipc/BUILD.bazel b/src/ipc/BUILD.bazel index 7531e585b..51f420321 100644 --- a/src/ipc/BUILD.bazel +++ b/src/ipc/BUILD.bazel @@ -138,7 +138,6 @@ mozc_cc_test( name = "ipc_path_manager_test", size = "small", srcs = ["ipc_path_manager_test.cc"], - requires_full_emulation = False, deps = [ ":ipc", ":ipc_cc_proto", @@ -182,7 +181,6 @@ mozc_cc_test( size = "small", srcs = ["ipc_test.cc"], copts = ["$(STACK_FRAME_UNLIMITED)"], # ipc_test.cc - requires_full_emulation = False, deps = [ ":ipc", ":ipc_test_util", @@ -246,7 +244,6 @@ mozc_cc_test( name = "named_event_test", size = "small", srcs = ["named_event_test.cc"], - requires_full_emulation = False, deps = [ ":named_event", "//base:clock", @@ -304,7 +301,6 @@ mozc_cc_test( name = "process_watch_dog_test", size = "small", srcs = ["process_watch_dog_test.cc"], - requires_full_emulation = False, deps = [ ":process_watch_dog", "//base:clock", diff --git a/src/prediction/BUILD.bazel b/src/prediction/BUILD.bazel index cca54bced..7525ef120 100644 --- a/src/prediction/BUILD.bazel +++ b/src/prediction/BUILD.bazel @@ -110,7 +110,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["user_history_predictor_test.cc"], - requires_full_emulation = False, tags = [ "nowin", ], # TODO(yuryu): depends on //base:encryptor @@ -119,12 +118,12 @@ mozc_cc_test( ":user_history_predictor_cc_proto", "//base:clock_mock", "//base:file_util", - "//base:logging", "//base:random", "//base:system_util", "//base:util", "//base/container:trie", "//base/file:temp_dir", + "//base/strings:unicode", "//composer", "//composer:table", "//config:config_handler", @@ -143,6 +142,7 @@ mozc_cc_test( "//testing:mozctest", "//usage_stats", "//usage_stats:usage_stats_testing_util", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/random", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", @@ -245,7 +245,6 @@ mozc_cc_library( "//converter:immutable_converter_interface", "//converter:node_list_builder", "//converter:segments", - "//data_manager:data_manager_interface", "//dictionary:dictionary_interface", "//dictionary:dictionary_token", "//dictionary:pos_matcher", @@ -255,6 +254,7 @@ mozc_cc_library( "//request:conversion_request", "//request:request_util", "//transliteration", + "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/log", "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", @@ -269,13 +269,11 @@ mozc_cc_test( srcs = [ "dictionary_prediction_aggregator_test.cc", ], - requires_full_emulation = False, deps = [ ":dictionary_prediction_aggregator", ":result", ":single_kanji_prediction_aggregator", ":zero_query_dict", - "//base:logging", "//base:util", "//base/container:serialized_string_array", "//composer:query", @@ -300,6 +298,8 @@ mozc_cc_test( "//testing:gunit_main", "//testing:mozctest", "//transliteration", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", ], @@ -312,7 +312,6 @@ mozc_cc_test( srcs = [ "dictionary_predictor_test.cc", ], - requires_full_emulation = False, deps = [ ":dictionary_predictor", ":prediction_aggregator_interface", @@ -382,7 +381,6 @@ mozc_cc_test( srcs = [ "single_kanji_prediction_aggregator_test.cc", ], - requires_full_emulation = False, deps = [ ":result", ":single_kanji_prediction_aggregator", @@ -426,7 +424,6 @@ mozc_cc_library( mozc_cc_test( name = "predictor_test", srcs = ["predictor_test.cc"], - requires_full_emulation = False, deps = [ ":dictionary_predictor", ":predictor", @@ -479,7 +476,6 @@ mozc_cc_library( mozc_cc_test( name = "zero_query_dict_test", srcs = ["zero_query_dict_test.cc"], - requires_full_emulation = False, visibility = ["//visibility:private"], deps = [ ":zero_query_dict", @@ -501,7 +497,6 @@ mozc_cc_binary( "//base:multifile", "//base:util", "//storage:existence_filter", - "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/strings", ], diff --git a/src/prediction/dictionary_prediction_aggregator.cc b/src/prediction/dictionary_prediction_aggregator.cc index 800ee0a0d..300246587 100644 --- a/src/prediction/dictionary_prediction_aggregator.cc +++ b/src/prediction/dictionary_prediction_aggregator.cc @@ -478,7 +478,7 @@ class DictionaryPredictionAggregator::PrefixLookupCallback const int key_len = Util::CharsLen(key); if (key_len < input_key_len_) { result.candidate_attributes |= Segment::Candidate::PARTIALLY_KEY_CONSUMED; - result.consumed_key_size = Util::CharsLen(key); + result.consumed_key_size = key_len; } results_->emplace_back(result); return (results_->size() < limit_) ? TRAVERSE_CONTINUE : TRAVERSE_DONE; @@ -649,7 +649,11 @@ PredictionTypes DictionaryPredictionAggregator::AggregatePrediction( } PredictionTypes selected_types = NO_PREDICTION; if (ShouldAggregateRealTimeConversionResults(request, segments)) { - AggregateRealtimeConversion(request, realtime_max_size, segments, results); + AggregateRealtimeConversion( + request, realtime_max_size, + /* insert_realtime_top_from_actual_converter= */ + request.use_actual_converter_for_realtime_conversion(), + segments, results); selected_types |= REALTIME; } @@ -823,7 +827,7 @@ size_t DictionaryPredictionAggregator::GetRealtimeCandidateMaxSize( size = default_size; break; default: - size = 0; // Never reach here + DLOG(FATAL) << "Unexpected request type: " << request_type; } return std::min(max_size, size); @@ -892,15 +896,20 @@ bool DictionaryPredictionAggregator::PushBackTopConversionResult( void DictionaryPredictionAggregator::AggregateRealtimeConversion( const ConversionRequest &request, size_t realtime_candidates_size, - const Segments &segments, std::vector *results) const { + bool insert_realtime_top_from_actual_converter, const Segments &segments, + std::vector *results) const { DCHECK(converter_); DCHECK(immutable_converter_); DCHECK(results); + if (realtime_candidates_size == 0) { + return; + } + // First insert a top conversion result. // Note: Do not call actual converter for partial suggestion / prediction. // Converter::StartConversion() resets conversion key from composer // rather than using the key in segments. - if (request.use_actual_converter_for_realtime_conversion() && + if (insert_realtime_top_from_actual_converter && request.request_type() != ConversionRequest::PARTIAL_SUGGESTION && request.request_type() != ConversionRequest::PARTIAL_PREDICTION) { if (!PushBackTopConversionResult(request, segments, results)) { @@ -908,10 +917,6 @@ void DictionaryPredictionAggregator::AggregateRealtimeConversion( } } - if (realtime_candidates_size == 0) { - return; - } - const ConversionRequest request_for_realtime = GetConversionRequestForRealtimeCandidates(request, realtime_candidates_size); @@ -1727,8 +1732,10 @@ void DictionaryPredictionAggregator::AggregateTypingCorrectedPrediction( if (is_realtime_only) { constexpr int kRealtimeSize = 1; - AggregateRealtimeConversion(corrected_request, kRealtimeSize, - corrected_segments, &corrected_results); + AggregateRealtimeConversion( + corrected_request, kRealtimeSize, + /* insert_realtime_top_from_actual_converter= */ false, + corrected_segments, &corrected_results); } else { const UnigramConfig &unigram_config = GetUnigramConfig(request); @@ -1740,8 +1747,10 @@ void DictionaryPredictionAggregator::AggregateTypingCorrectedPrediction( if (base_selected_types & REALTIME) { constexpr int kRealtimeSize = 2; - AggregateRealtimeConversion(corrected_request, kRealtimeSize, - corrected_segments, &corrected_results); + AggregateRealtimeConversion( + corrected_request, kRealtimeSize, + /* insert_realtime_top_from_actual_converter= */ false, + corrected_segments, &corrected_results); } if (base_selected_types & BIGRAM) { diff --git a/src/prediction/dictionary_prediction_aggregator.h b/src/prediction/dictionary_prediction_aggregator.h index 64ff6cb2e..e52239ed6 100644 --- a/src/prediction/dictionary_prediction_aggregator.h +++ b/src/prediction/dictionary_prediction_aggregator.h @@ -211,10 +211,10 @@ class DictionaryPredictionAggregator : public PredictionAggregatorInterface { // Aggregate* methods aggregate the candidates with different resources // and algorithms. - void AggregateRealtimeConversion(const ConversionRequest &request, - size_t realtime_candidates_size, - const Segments &segments, - std::vector *results) const; + void AggregateRealtimeConversion( + const ConversionRequest &request, size_t realtime_candidates_size, + bool insert_realtime_top_from_actual_converter, const Segments &segments, + std::vector *results) const; void AggregateBigramPrediction(const ConversionRequest &request, const Segments &segments, diff --git a/src/prediction/dictionary_prediction_aggregator_test.cc b/src/prediction/dictionary_prediction_aggregator_test.cc index 3777b52fb..bc14815dd 100644 --- a/src/prediction/dictionary_prediction_aggregator_test.cc +++ b/src/prediction/dictionary_prediction_aggregator_test.cc @@ -40,12 +40,13 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/match.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" #include "absl/strings/string_view.h" #include "base/container/serialized_string_array.h" -#include "base/logging.h" #include "base/util.h" #include "composer/query.h" #include "composer/table.h" @@ -122,12 +123,13 @@ class DictionaryPredictionAggregatorTestPeer { results); } - void AggregateRealtimeConversion(const ConversionRequest &request, - size_t realtime_candidates_size, - const Segments &segments, - std::vector *results) const { - aggregator_.AggregateRealtimeConversion(request, realtime_candidates_size, - segments, results); + void AggregateRealtimeConversion( + const ConversionRequest &request, size_t realtime_candidates_size, + bool insert_realtime_top_from_actual_converter, const Segments &segments, + std::vector *results) const { + aggregator_.AggregateRealtimeConversion( + request, realtime_candidates_size, + insert_realtime_top_from_actual_converter, segments, results); } void AggregateSuffixPrediction(const ConversionRequest &request, @@ -1660,11 +1662,8 @@ TEST_F(DictionaryPredictionAggregatorTest, AggregateRealtimeConversion) { segments.mutable_conversion_segment(0)->add_candidate()->value = "history2"; std::vector results; - suggestion_convreq_->set_use_actual_converter_for_realtime_conversion( - false); - - aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 10, segments, - &results); + aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 10, false, + segments, &results); ASSERT_EQ(results.size(), 1); EXPECT_EQ(results[0].types, REALTIME); EXPECT_EQ(results[0].key, kKey); @@ -1683,10 +1682,9 @@ TEST_F(DictionaryPredictionAggregatorTest, AggregateRealtimeConversion) { segments.mutable_conversion_segment(0)->add_candidate()->value = "history2"; std::vector results; - suggestion_convreq_->set_use_actual_converter_for_realtime_conversion(true); - aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 10, segments, - &results); + aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 10, true, + segments, &results); // When |request.use_actual_converter_for_realtime_conversion| is true, // the extra label REALTIME_TOP is expected to be added. @@ -1705,6 +1703,100 @@ TEST_F(DictionaryPredictionAggregatorTest, AggregateRealtimeConversion) { } } +TEST_F(DictionaryPredictionAggregatorTest, UseActualConverterRequest) { + auto data_and_aggregator = std::make_unique(); + data_and_aggregator->Init(); + + const DictionaryPredictionAggregatorTestPeer &aggregator = + data_and_aggregator->aggregator(); + + constexpr char kKey[] = "わたしのなまえはなかのです"; + + // Set up mock converter + { + // Make segments like: + // "わたしの" | "なまえは" | "なかのです" + // "Watashino" | "Namaeha" | "Nakanodesu" + Segments segments; + + auto add_segment = [&segments](absl::string_view key, + absl::string_view value) { + Segment *segment = segments.add_segment(); + segment->set_key(key); + Segment::Candidate *candidate = segment->add_candidate(); + candidate->key = std::string(key); + candidate->value = std::string(value); + }; + + add_segment("わたしの", "Watashino"); + add_segment("なまえは", "Namaeha"); + add_segment("なかのです", "Nakanodesu"); + + EXPECT_CALL(*data_and_aggregator->mutable_converter(), + StartConversion(_, _)) + .WillRepeatedly(DoAll(SetArgPointee<1>(segments), Return(true))); + } + // Set up mock immutable converter + { + Segments segments; + Segment *segment = segments.add_segment(); + segment->set_key("わたしのなまえはなかのです"); + Segment::Candidate *candidate = segment->add_candidate(); + candidate->value = "私の名前は中野です"; + candidate->key = ("わたしのなまえはなかのです"); + // "わたしの, 私の", "わたし, 私" + candidate->PushBackInnerSegmentBoundary(12, 6, 9, 3); + // "なまえは, 名前は", "なまえ, 名前" + candidate->PushBackInnerSegmentBoundary(12, 9, 9, 6); + // "なかのです, 中野です", "なかの, 中野" + candidate->PushBackInnerSegmentBoundary(15, 12, 9, 6); + EXPECT_CALL(*data_and_aggregator->mutable_immutable_converter(), + ConvertForRequest(_, _)) + .WillRepeatedly(DoAll(SetArgPointee<1>(segments), Return(true))); + } + + { + Segments segments; + + InitSegmentsWithKey(kKey, &segments); + suggestion_convreq_->set_use_actual_converter_for_realtime_conversion(true); + + std::vector results; + aggregator.AggregatePredictionForRequest(*suggestion_convreq_, segments, + &results); + ASSERT_GT(results.size(), 0); + bool has_realtime_top = false; + for (const Result &r : results) { + if (r.types & PredictionType::REALTIME_TOP) { + has_realtime_top = true; + break; + } + } + EXPECT_TRUE(has_realtime_top); + } + + { + Segments segments; + + InitSegmentsWithKey(kKey, &segments); + + suggestion_convreq_->set_use_actual_converter_for_realtime_conversion( + false); + std::vector results; + aggregator.AggregatePredictionForRequest(*suggestion_convreq_, segments, + &results); + ASSERT_GT(results.size(), 0); + bool has_realtime_top = false; + for (const Result &r : results) { + if (r.types & PredictionType::REALTIME_TOP) { + has_realtime_top = true; + break; + } + } + EXPECT_FALSE(has_realtime_top); + } +} + TEST_F(DictionaryPredictionAggregatorTest, GetCandidateCutoffThreshold) { std::unique_ptr data_and_aggregator = CreateAggregatorWithMockData(); @@ -2291,9 +2383,8 @@ TEST_F(DictionaryPredictionAggregatorTest, std::vector results; - suggestion_convreq_->set_use_actual_converter_for_realtime_conversion(false); - aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 10, segments, - &results); + aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 10, false, + segments, &results); ASSERT_EQ(2, results.size()); EXPECT_EQ(results[0].types, REALTIME); @@ -2358,8 +2449,8 @@ TEST_F(DictionaryPredictionAggregatorTest, } SetUpInputForSuggestion(kKeyWithDe, composer_.get(), &segments); - aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 1, segments, - &results); + aggregator.AggregateRealtimeConversion(*suggestion_convreq_, 1, false, + segments, &results); EXPECT_EQ(results.size(), 1); EXPECT_EQ(results[0].types, REALTIME); EXPECT_NE(0, (results[0].candidate_attributes & diff --git a/src/prediction/gen_suggestion_filter_main.cc b/src/prediction/gen_suggestion_filter_main.cc index 5c3998cac..670423633 100644 --- a/src/prediction/gen_suggestion_filter_main.cc +++ b/src/prediction/gen_suggestion_filter_main.cc @@ -34,7 +34,6 @@ #include #include -#include "absl/base/optimization.h" #include "absl/flags/flag.h" #include "absl/strings/string_view.h" #include "base/codegen_bytearray_stream.h" @@ -130,7 +129,6 @@ ExistenceFilterBuilder SetupFilter( } } LOG(FATAL) << "Gave up retrying suggestion filter generation."; - ABSL_UNREACHABLE(); } } // namespace diff --git a/src/prediction/predictor.cc b/src/prediction/predictor.cc index a40e07f2c..c621f66ce 100644 --- a/src/prediction/predictor.cc +++ b/src/prediction/predictor.cc @@ -307,7 +307,7 @@ ConversionRequest MobilePredictor::GetRequestForPredict( break; } default: - DLOG(ERROR) << "Never reach here."; + DLOG(ERROR) << "Unexpected request type: " << request.request_type(); } return ret; } @@ -391,8 +391,8 @@ bool MobilePredictor::PredictForRequest(const ConversionRequest &request, segments); break; } - default: { - } // Never reach here + default: + DLOG(FATAL) << "Unexpected request type: " << request.request_type(); } MaybeFillFallbackPos(segments); diff --git a/src/prediction/user_history_predictor_test.cc b/src/prediction/user_history_predictor_test.cc index 35152b5b3..cd0e6589c 100644 --- a/src/prediction/user_history_predictor_test.cc +++ b/src/prediction/user_history_predictor_test.cc @@ -38,6 +38,7 @@ #include #include +#include "absl/log/check.h" #include "absl/random/random.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" @@ -49,8 +50,8 @@ #include "base/container/trie.h" #include "base/file/temp_dir.h" #include "base/file_util.h" -#include "base/logging.h" #include "base/random.h" +#include "base/strings/unicode.h" #include "base/system_util.h" #include "base/util.h" #include "composer/composer.h" @@ -2729,20 +2730,15 @@ void InitSegmentsFromInputSequence(const absl::string_view text, DCHECK(composer); DCHECK(request); DCHECK(segments); - const char *begin = text.data(); - const char *end = text.data() + text.size(); - size_t mblen = 0; - - while (begin < end) { + for (const UnicodeChar ch : Utf8AsUnicodeChar(text)) { commands::KeyEvent key; - const char32_t w = Util::Utf8ToCodepoint(begin, end, &mblen); + const char32_t w = ch.char32(); if (w <= 0x7F) { // IsAscii, w is unsigned. - key.set_key_code(*begin); + key.set_key_code(w); } else { key.set_key_code('?'); - key.set_key_string(std::string(begin, mblen)); + key.set_key_string(ch.utf8()); } - begin += mblen; composer->InsertCharacterKeyEvent(key); } diff --git a/src/renderer/BUILD.bazel b/src/renderer/BUILD.bazel index 5469eaaac..749d449e7 100644 --- a/src/renderer/BUILD.bazel +++ b/src/renderer/BUILD.bazel @@ -78,7 +78,6 @@ mozc_cc_test( name = "renderer_client_test", size = "medium", srcs = ["renderer_client_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], deps = [ ":renderer_client", @@ -125,7 +124,6 @@ mozc_cc_test( name = "renderer_server_test", size = "medium", srcs = ["renderer_server_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], deps = [ ":renderer_client", @@ -161,7 +159,6 @@ mozc_cc_test( "table_layout_interface.h", "table_layout_test.cc", ], - requires_full_emulation = False, tags = ["noandroid"], deps = [ ":table_layout", @@ -201,7 +198,6 @@ mozc_cc_test( name = "window_util_test", size = "small", srcs = ["window_util_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], deps = [ ":window_util", @@ -231,7 +227,6 @@ mozc_cc_test( name = "renderer_style_handler_test", size = "small", srcs = ["renderer_style_handler_test.cc"], - requires_full_emulation = False, deps = [ ":renderer_style_handler", "//protocol:renderer_cc_proto", diff --git a/src/renderer/win32/BUILD.bazel b/src/renderer/win32/BUILD.bazel index 490845f24..929ebb017 100644 --- a/src/renderer/win32/BUILD.bazel +++ b/src/renderer/win32/BUILD.bazel @@ -266,10 +266,10 @@ mozc_cc_library( deps = [ "//base:coordinates", "//base:logging", - "//base:util", "//base/win32:wide_char", "//bazel/win32:gdi32", "//bazel/win32:user32", + "@com_google_absl//absl/base:core_headers", "@com_microsoft_wil//:wil", ], ) @@ -326,6 +326,7 @@ mozc_cc_test( "//data/test/renderer/win32:test_spec_cc_proto", "//testing:gunit_main", "//testing:mozctest", + "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/strings", "@com_microsoft_wil//:wil", ], diff --git a/src/renderer/win32/win32_image_util.cc b/src/renderer/win32/win32_image_util.cc index e207f9500..9eab463a5 100644 --- a/src/renderer/win32/win32_image_util.cc +++ b/src/renderer/win32/win32_image_util.cc @@ -29,8 +29,8 @@ #include "renderer/win32/win32_image_util.h" -#include #include +#include #include #include @@ -40,6 +40,7 @@ #include #include +#include "absl/base/optimization.h" #include "base/coordinates.h" #include "base/logging.h" #include "base/win32/wide_char.h" @@ -163,8 +164,7 @@ class Balloon { case BalloonImage::BalloonImageInfo::kLeft: return left_ - balloon_tail_height_; default: - CHECK(false) << "Do not reach here"; - return 0.0; + ABSL_UNREACHABLE(); } } double GetTailY() const { @@ -178,8 +178,7 @@ class Balloon { case BalloonImage::BalloonImageInfo::kLeft: return top_ + height_ / 2.0; default: - CHECK(false) << "Do not reach here"; - return 0.0; + ABSL_UNREACHABLE(); } } diff --git a/src/renderer/win32/win32_image_util_test.cc b/src/renderer/win32/win32_image_util_test.cc index c98d84a97..69611db02 100644 --- a/src/renderer/win32/win32_image_util_test.cc +++ b/src/renderer/win32/win32_image_util_test.cc @@ -33,6 +33,8 @@ #include #include +#include + #undef StrCat #include @@ -41,10 +43,11 @@ #include #include +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "base/file_stream.h" #include "base/file_util.h" -#include "base/logging.h" #include "base/protobuf/text_format.h" #include "base/win32/wide_char.h" #include "base/win32/win_font_test_helper.h" @@ -240,8 +243,7 @@ class BalloonImageTest : public ::testing::Test, case BalloonImageInfo::kRight: return TestSpec::RIGHT; default: - CHECK(false) << "Unexpected direction=" << direction; - return TestSpec::UNSPECIFIED; // must not reach here. + LOG(FATAL) << "Unexpected direction: " << direction; } } @@ -249,9 +251,7 @@ class BalloonImageTest : public ::testing::Test, TestSpec::TailDirection direction) { switch (direction) { case TestSpec::UNSPECIFIED: - CHECK(false) << "TailDirection must be set"; - // must not reach here. - return BalloonImageInfo::TailDirection::kTop; + LOG(FATAL) << "TailDirection must be set."; case TestSpec::TOP: return BalloonImageInfo::TailDirection::kTop; case TestSpec::BOTTOM: @@ -261,9 +261,7 @@ class BalloonImageTest : public ::testing::Test, case TestSpec::RIGHT: return BalloonImageInfo::TailDirection::kRight; default: - CHECK(false) << "Unexpected direction=" << direction; - // must not reach here. - return BalloonImageInfo::TailDirection::kTop; + LOG(FATAL) << "Unexpected direction: " << direction; } } diff --git a/src/rewriter/BUILD.bazel b/src/rewriter/BUILD.bazel index 0a9250a26..6c96977e1 100644 --- a/src/rewriter/BUILD.bazel +++ b/src/rewriter/BUILD.bazel @@ -54,7 +54,6 @@ mozc_cc_test( name = "merger_rewriter_test", size = "small", srcs = ["merger_rewriter_test.cc"], - requires_full_emulation = False, visibility = ["//visibility:private"], deps = [ ":merger_rewriter", @@ -96,7 +95,6 @@ mozc_cc_library( mozc_cc_test( name = "collocation_rewriter_test", srcs = ["collocation_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":collocation_rewriter", "//converter:segments", @@ -144,7 +142,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["user_segment_history_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":number_rewriter", ":user_segment_history_rewriter", @@ -199,7 +196,6 @@ mozc_cc_test( name = "user_boundary_history_rewriter_test", size = "small", srcs = ["user_boundary_history_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":user_boundary_history_rewriter", "//base:file_util", @@ -246,7 +242,6 @@ mozc_cc_test( name = "date_rewriter_test", size = "small", srcs = ["date_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":date_rewriter", "//base:clock", @@ -299,7 +294,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["number_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":number_rewriter", ":rewriter_interface", @@ -343,7 +337,6 @@ mozc_cc_test( name = "small_letter_rewriter_test", size = "small", srcs = ["small_letter_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":small_letter_rewriter", "//base/strings:assign", @@ -386,7 +379,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["transliteration_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":transliteration_rewriter", "//base:logging", @@ -436,7 +428,6 @@ mozc_cc_test( name = "language_aware_rewriter_test", size = "small", srcs = ["language_aware_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":language_aware_rewriter", "//composer", @@ -478,7 +469,6 @@ mozc_cc_test( name = "version_rewriter_test", size = "small", srcs = ["version_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":version_rewriter", "//converter:segments", @@ -519,7 +509,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["symbol_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":symbol_rewriter", "//base:logging", @@ -563,7 +552,6 @@ mozc_cc_test( name = "emoticon_rewriter_test", size = "small", srcs = ["emoticon_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":emoticon_rewriter", ":rewriter_interface", @@ -605,7 +593,6 @@ mozc_cc_test( name = "variants_rewriter_test", size = "small", srcs = ["variants_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":variants_rewriter", "//base:japanese_util", @@ -646,7 +633,6 @@ mozc_cc_test( name = "english_variants_rewriter_test", size = "small", srcs = ["english_variants_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":english_variants_rewriter", "//converter:segments", @@ -680,7 +666,6 @@ mozc_cc_test( name = "fortune_rewriter_test", size = "small", srcs = ["fortune_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":fortune_rewriter", "//base:logging", @@ -711,7 +696,6 @@ mozc_cc_test( name = "dice_rewriter_test", size = "small", srcs = ["dice_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":dice_rewriter", "//converter:segments", @@ -747,7 +731,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["calculator_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":calculator_rewriter", "//base:logging", @@ -792,7 +775,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["unicode_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":unicode_rewriter", "//composer", @@ -826,7 +808,6 @@ mozc_cc_test( name = "user_dictionary_rewriter_test", size = "small", srcs = ["user_dictionary_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":user_dictionary_rewriter", "//base:logging", @@ -859,7 +840,6 @@ mozc_cc_test( name = "dictionary_generator_test", size = "small", srcs = ["dictionary_generator_test.cc"], - requires_full_emulation = False, deps = [ ":dictionary_generator", "//data_manager/testing:mock_data_manager", @@ -946,7 +926,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["emoji_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":emoji_rewriter", ":variants_rewriter", @@ -1015,7 +994,6 @@ mozc_cc_test( name = "single_kanji_rewriter_test", size = "small", srcs = ["single_kanji_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":single_kanji_rewriter", "//converter:segments", @@ -1065,7 +1043,6 @@ mozc_cc_test( name = "focus_candidate_rewriter_test", size = "small", srcs = ["focus_candidate_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":focus_candidate_rewriter", "//base:number_util", @@ -1102,7 +1079,6 @@ mozc_cc_test( srcs = [ "zipcode_rewriter_test.cc", ], - requires_full_emulation = False, deps = [ ":zipcode_rewriter", "//base:logging", @@ -1141,7 +1117,6 @@ mozc_cc_test( name = "t13n_promotion_rewriter_test", size = "small", srcs = ["t13n_promotion_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":t13n_promotion_rewriter", ":transliteration_rewriter", @@ -1178,7 +1153,6 @@ mozc_cc_test( name = "command_rewriter_test", size = "small", srcs = ["command_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":command_rewriter", "//config:config_handler", @@ -1216,7 +1190,6 @@ mozc_cc_test( name = "environmental_filter_rewriter_test", size = "small", srcs = ["environmental_filter_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":emoji_rewriter", ":environmental_filter_rewriter", @@ -1251,7 +1224,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["remove_redundant_candidate_rewriter_test.cc"], - requires_full_emulation = True, deps = [ ":remove_redundant_candidate_rewriter", "//converter:segments", @@ -1305,7 +1277,6 @@ mozc_cc_test( name = "usage_rewriter_test", size = "small", srcs = ["usage_rewriter_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], target_compatible_with = mozc_select_enable_usage_rewriter( off = ["@platforms//:incompatible"], @@ -1358,7 +1329,6 @@ mozc_cc_test( name = "correction_rewriter_test", size = "small", srcs = ["correction_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":correction_rewriter", "//base/container:serialized_string_array", @@ -1403,7 +1373,6 @@ mozc_cc_test( name = "a11y_description_rewriter_test", size = "small", srcs = ["a11y_description_rewriter_test.cc"], - requires_full_emulation = False, deps = [ ":a11y_description_rewriter", "//data_manager", @@ -1470,7 +1439,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["rewriter_test.cc"], - requires_full_emulation = False, deps = [ "rewriter", ":rewriter_interface", @@ -1500,7 +1468,6 @@ mozc_cc_test( name = "collocation_util_test", size = "small", srcs = ["collocation_util_test.cc"], - requires_full_emulation = False, deps = [ ":collocation_util", "//testing:gunit_main", @@ -1580,7 +1547,6 @@ mozc_cc_library( mozc_cc_test( name = "number_compound_util_test", srcs = ["number_compound_util_test.cc"], - requires_full_emulation = False, deps = [ ":number_compound_util", "//base/container:serialized_string_array", diff --git a/src/rewriter/calculator/BUILD.bazel b/src/rewriter/calculator/BUILD.bazel index a5120b4b9..6c31c3432 100644 --- a/src/rewriter/calculator/BUILD.bazel +++ b/src/rewriter/calculator/BUILD.bazel @@ -72,7 +72,6 @@ mozc_cc_test( size = "small", srcs = ["calculator_test.cc"], data = ["//data/test/calculator:testset.txt"], - requires_full_emulation = False, deps = [ ":calculator", "//base:file_util", diff --git a/src/session/BUILD.bazel b/src/session/BUILD.bazel index 348dbd16a..58bd8029c 100644 --- a/src/session/BUILD.bazel +++ b/src/session/BUILD.bazel @@ -90,7 +90,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["session_converter_test.cc"], - requires_full_emulation = False, shard_count = 8, tags = ["noandroid"], # TODO(b/73698251): disabled due to errors deps = [ @@ -125,7 +124,6 @@ mozc_cc_test( size = "small", timeout = "moderate", srcs = ["session_converter_stress_test.cc"], - requires_full_emulation = False, shard_count = 8, deps = [ ":session_converter", @@ -182,7 +180,6 @@ mozc_cc_test( name = "session_test", size = "small", srcs = ["session_test.cc"], - requires_full_emulation = False, shard_count = 8, deps = [ ":request_test_util", @@ -228,7 +225,6 @@ mozc_cc_test( "common.h", "session_regression_test.cc", ], - requires_full_emulation = False, shard_count = 8, deps = [ ":request_test_util", @@ -266,7 +262,6 @@ mozc_cc_test( name = "session_observer_handler_test", size = "small", srcs = ["session_observer_handler_test.cc"], - requires_full_emulation = False, deps = [ ":session_observer_handler", ":session_observer_interface", @@ -358,7 +353,6 @@ mozc_cc_test( "common.h", "session_handler_test.cc", ], - requires_full_emulation = False, deps = [ ":session_handler", ":session_handler_interface", @@ -435,7 +429,6 @@ mozc_cc_test( name = "request_test_util_test", size = "small", srcs = ["request_test_util_test.cc"], - requires_full_emulation = False, deps = [ ":request_test_util", "//protocol:commands_cc_proto", @@ -491,7 +484,6 @@ mozc_cc_test( name = "session_watch_dog_test", size = "small", srcs = ["session_watch_dog_test.cc"], - requires_full_emulation = False, tags = [ "noandroid", "nomac", # TODO(b/281742982) flaky for mac on forge @@ -534,7 +526,6 @@ mozc_cc_test( name = "session_usage_observer_test", size = "small", srcs = ["session_usage_observer_test.cc"], - requires_full_emulation = False, tags = ["noandroid"], # TODO(b/73698251): disabled due to errors deps = [ ":session_usage_observer", @@ -575,7 +566,6 @@ mozc_cc_test( name = "key_info_util_test", size = "small", srcs = ["key_info_util_test.cc"], - requires_full_emulation = False, deps = [ ":key_info_util", "//composer:key_event_util", @@ -605,7 +595,6 @@ mozc_cc_test( name = "session_usage_stats_util_test", size = "small", srcs = ["session_usage_stats_util_test.cc"], - requires_full_emulation = False, deps = [ ":session_usage_stats_util", "//composer:key_parser", @@ -662,7 +651,6 @@ mozc_cc_test( name = "random_keyevents_generator_test", size = "small", srcs = ["random_keyevents_generator_test.cc"], - requires_full_emulation = False, deps = [ ":random_keyevents_generator", "//protocol:commands_cc_proto", @@ -678,7 +666,6 @@ mozc_cc_test( "common.h", "session_handler_stress_test.cc", ], - requires_full_emulation = False, shard_count = 16, tags = ["noandroid"], # TODO(b/73698251): disabled due to errors deps = [ @@ -768,7 +755,6 @@ mozc_cc_test( "//data/test/session/scenario:scenario_files", "//data/test/session/scenario/usage_stats:usage_stats_scenario_files", ], - requires_full_emulation = False, shard_count = 8, tags = [ "noandroid", # TODO(b/73698251): disabled due to errors diff --git a/src/session/request_test_util.cc b/src/session/request_test_util.cc index 8dfc6cbad..1090f97c9 100644 --- a/src/session/request_test_util.cc +++ b/src/session/request_test_util.cc @@ -29,9 +29,10 @@ // Test utility for Request. -#include "protocol/commands.pb.h" #include "session/request_test_util.h" +#include "protocol/commands.pb.h" + namespace mozc { namespace commands { @@ -39,6 +40,9 @@ void RequestForUnitTest::FillMobileRequest(Request *request) { request->set_zero_query_suggestion(true); request->set_mixed_conversion(true); request->set_update_input_mode_from_surrounding_text(false); + // TODO(toshiyuki): + // Change the romanji table to TOGGLE_FLICK_TO_HIRAGANA + // TWELVE_KEYS_TO_HIRAGANA is not used from anywhere in the current Gboard. request->set_special_romanji_table(Request::TWELVE_KEYS_TO_HIRAGANA); request->set_kana_modifier_insensitive_conversion(true); request->set_auto_partial_suggestion(true); diff --git a/src/win32/base/BUILD.bazel b/src/win32/base/BUILD.bazel index e9cb4ceb9..54202bf64 100644 --- a/src/win32/base/BUILD.bazel +++ b/src/win32/base/BUILD.bazel @@ -162,11 +162,11 @@ mozc_cc_library( target_compatible_with = ["@platforms//os:windows"], deps = [ ":input_dll", - ":msctf_dll", ":tsf_profile", "//base:logging", "//base:system_util", "//base/win32:wide_char", + "@com_google_absl//absl/base:core_headers", "@com_microsoft_wil//:wil", ], ) @@ -308,7 +308,7 @@ mozc_cc_library( target_compatible_with = ["@platforms//os:windows"], deps = [ ":keyboard", - "//base:logging", + "@com_google_absl//absl/base:core_headers", ], ) diff --git a/src/win32/base/imm_util.cc b/src/win32/base/imm_util.cc index 036bc5045..80871f314 100644 --- a/src/win32/base/imm_util.cc +++ b/src/win32/base/imm_util.cc @@ -43,6 +43,7 @@ #include #include +#include "absl/base/optimization.h" #include "base/logging.h" #include "base/system_util.h" #include "base/win32/wide_char.h" @@ -144,8 +145,7 @@ bool ImeUtil::WaitForAsmCacheReady(uint32_t timeout_msec) { LOG(ERROR) << "WaitForSingleObject with unknown error: " << result; return false; } - LOG(FATAL) << "Should never reach here."; - return false; + ABSL_UNREACHABLE(); } } // namespace win32 diff --git a/src/win32/base/surrogate_pair_observer.cc b/src/win32/base/surrogate_pair_observer.cc index 8b6b1f632..44050fd9e 100644 --- a/src/win32/base/surrogate_pair_observer.cc +++ b/src/win32/base/surrogate_pair_observer.cc @@ -29,7 +29,7 @@ #include "win32/base/surrogate_pair_observer.h" -#include "base/logging.h" +#include "absl/base/optimization.h" #include "win32/base/keyboard.h" namespace mozc { @@ -196,8 +196,7 @@ SurrogatePairObserver::ClientAction SurrogatePairObserver::OnKeyEvent( return ClientAction(DO_DEFAULT_ACTION_WITH_RETURNED_UCS4, ucs2); } default: - DLOG(FATAL) << "must not reach here."; - return ClientAction(DO_DEFAULT_ACTION, 0); + ABSL_UNREACHABLE(); } } diff --git a/src/win32/tip/BUILD.bazel b/src/win32/tip/BUILD.bazel index 017e53538..a80ea8528 100644 --- a/src/win32/tip/BUILD.bazel +++ b/src/win32/tip/BUILD.bazel @@ -169,9 +169,8 @@ mozc_cc_library( ":tip_dll_module", ":tip_text_service", ":tip_ui_element_delegate", - "//base:logging", "//base/win32:com", - "//base/win32:com_implements", + "@com_google_absl//absl/base:core_headers", "@com_microsoft_wil//:wil", ], ) @@ -426,6 +425,7 @@ mozc_cc_library( "//protocol:candidates_cc_proto", "//protocol:commands_cc_proto", "//protocol:renderer_cc_proto", + "@com_google_absl//absl/log", "@com_microsoft_wil//:wil", ], ) diff --git a/src/win32/tip/tip_text_service.cc b/src/win32/tip/tip_text_service.cc index e328192c4..3b363d69e 100644 --- a/src/win32/tip/tip_text_service.cc +++ b/src/win32/tip/tip_text_service.cc @@ -45,10 +45,10 @@ #include "absl/base/casts.h" #include "absl/container/flat_hash_map.h" #include "absl/functional/any_invocable.h" +#include "absl/log/log.h" #include "base/const.h" #include "base/file_util.h" #include "base/log_file.h" -#include "base/logging.h" #include "base/process.h" #include "base/system_util.h" #include "base/update_util.h" @@ -206,7 +206,8 @@ commands::CompositionMode GetMozcMode(TipLangBarCallback::ItemId menu_id) { case TipLangBarCallback::kHalfKatakana: return commands::HALF_KATAKANA; default: - DLOG(FATAL) << "Must not reach here."; + DLOG(FATAL) << "Unexpected item id: " << menu_id; + // Fall back to DIRECT in release builds. return commands::DIRECT; } } @@ -226,7 +227,7 @@ std::string GetMozcToolCommand(TipLangBarCallback::ItemId menu_id) { // Open the about dialog. return "about_dialog"; default: - DLOG(FATAL) << "Must not reach here."; + DLOG(FATAL) << "Unexpected item id: " << menu_id; return ""; } } diff --git a/src/win32/tip/tip_ui_element_conventional.cc b/src/win32/tip/tip_ui_element_conventional.cc index c7b35d19b..9b2ff8133 100644 --- a/src/win32/tip/tip_ui_element_conventional.cc +++ b/src/win32/tip/tip_ui_element_conventional.cc @@ -37,7 +37,7 @@ #include #include -#include "base/logging.h" +#include "absl/base/optimization.h" #include "base/win32/com.h" #include "win32/tip/tip_dll_module.h" #include "win32/tip/tip_text_service.h" @@ -145,8 +145,7 @@ class TipCandidateListImpl final case TipUiElementConventional::kCandidateWindow: return TipUiElementDelegateFactory::kConventionalCandidateWindow; default: - LOG(FATAL) << "must not reach here."; - return TipUiElementDelegateFactory::kConventionalCandidateWindow; + ABSL_UNREACHABLE(); } } diff --git a/src/win32/tip/tip_ui_element_delegate.cc b/src/win32/tip/tip_ui_element_delegate.cc index 81e84a7a4..c401e45c4 100644 --- a/src/win32/tip/tip_ui_element_delegate.cc +++ b/src/win32/tip/tip_ui_element_delegate.cc @@ -33,12 +33,15 @@ #include #include #include +#include #include #include #include +#include #include +#include "absl/log/log.h" #include "base/logging.h" #include "base/win32/com.h" #include "base/win32/wide_char.h" @@ -467,7 +470,7 @@ class TipUiElementDelegateImpl final : public TipUiElementDelegate { std::wstring msg; switch (status.mode()) { case commands::DIRECT: - DLOG(FATAL) << "Must not reach here."; + DLOG(FATAL) << "Unexpected last output status mode: DIRECT"; break; case commands::HIRAGANA: msg = L"\u3042";