diff options
-rw-r--r-- | chromeos/ime/extension_ime_util.cc | 7 | ||||
-rw-r--r-- | chromeos/ime/extension_ime_util.h | 5 | ||||
-rw-r--r-- | chromeos/ime/extension_ime_util_unittest.cc | 21 |
3 files changed, 33 insertions, 0 deletions
diff --git a/chromeos/ime/extension_ime_util.cc b/chromeos/ime/extension_ime_util.cc index 7e6d3ac..3c95751 100644 --- a/chromeos/ime/extension_ime_util.cc +++ b/chromeos/ime/extension_ime_util.cc @@ -25,5 +25,12 @@ bool IsExtensionIME(const std::string& input_method_id) { true); // Case sensitive. } +bool IsMemberOfExtension(const std::string& input_method_id, + const std::string& extension_id) { + return StartsWithASCII(input_method_id, + kExtensionIMEPrefix + extension_id, + true); // Case sensitive. +} + } // namespace extension_ime_util } // namespace chromeos diff --git a/chromeos/ime/extension_ime_util.h b/chromeos/ime/extension_ime_util.h index fd8505c..f439ec4 100644 --- a/chromeos/ime/extension_ime_util.h +++ b/chromeos/ime/extension_ime_util.h @@ -21,6 +21,11 @@ std::string CHROMEOS_EXPORT GetInputMethodID(const std::string& extension_id, // Returns true if the |input_method_id| is extension ime. bool CHROMEOS_EXPORT IsExtensionIME(const std::string& input_method_id); +// Returns true if the |input_method| is member of |extension_id|, otherwise +// return false. +bool CHROMEOS_EXPORT IsMemberOfExtension(const std::string& input_method_id, + const std::string& extension_id); + } // extension_ime_util } // namespace chromeos diff --git a/chromeos/ime/extension_ime_util_unittest.cc b/chromeos/ime/extension_ime_util_unittest.cc index a25c1a1..468a725 100644 --- a/chromeos/ime/extension_ime_util_unittest.cc +++ b/chromeos/ime/extension_ime_util_unittest.cc @@ -22,4 +22,25 @@ TEST(ExtensionIMEUtilTest, IsExtensionIMETest) { EXPECT_FALSE(extension_ime_util::IsExtensionIME("mozc")); } +TEST(ExtensionIMEUtilTest, IsMemberOfExtension) { + const char* extention1 = "abcdefg"; + const char* extention2 = "hijklmn"; + const char* engine_id1 = "12345"; + const char* engine_id2 = "67890"; + + const std::string extention_1_engine_1 = + extension_ime_util::GetInputMethodID(extention1, engine_id1); + const std::string extention_1_engine_2 = + extension_ime_util::GetInputMethodID(extention1, engine_id2); + + EXPECT_TRUE(extension_ime_util::IsMemberOfExtension(extention_1_engine_1, + extention1)); + EXPECT_TRUE(extension_ime_util::IsMemberOfExtension(extention_1_engine_2, + extention1)); + EXPECT_FALSE(extension_ime_util::IsMemberOfExtension(extention_1_engine_1, + extention2)); + EXPECT_FALSE(extension_ime_util::IsMemberOfExtension(extention_1_engine_2, + extention2)); +} + } // namespace chromeos |