Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / ime / chromeos / extension_ime_util_unittest.cc
blob55532e55c4ab1f3cc3f4cfb9795ce7f6f99ece4c
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/base/ime/chromeos/extension_ime_util.h"
7 #include <string>
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace chromeos {
13 TEST(ExtensionIMEUtilTest, GetInputMethodIDTest) {
14 EXPECT_EQ("_ext_ime_ABCDE12345",
15 extension_ime_util::GetInputMethodID("ABCDE", "12345"));
18 TEST(ExtensionIMEUtilTest, GetComponentInputMethodID) {
19 EXPECT_EQ("_comp_ime_ABCDE12345",
20 extension_ime_util::GetComponentInputMethodID("ABCDE", "12345"));
23 TEST(ExtensionIMEUtilTest, GetExtensionIDFromInputMethodIDTest) {
24 EXPECT_EQ("",
25 extension_ime_util::GetExtensionIDFromInputMethodID("mozc"));
26 EXPECT_EQ("12345678901234567890123456789012",
27 extension_ime_util::GetExtensionIDFromInputMethodID(
28 extension_ime_util::GetInputMethodID(
29 "12345678901234567890123456789012",
30 "mozc")));
31 EXPECT_EQ("12345678901234567890123456789012",
32 extension_ime_util::GetExtensionIDFromInputMethodID(
33 extension_ime_util::GetComponentInputMethodID(
34 "12345678901234567890123456789012",
35 "mozc")));
38 TEST(ExtensionIMEUtilTest, IsExtensionIMETest) {
39 EXPECT_TRUE(extension_ime_util::IsExtensionIME(
40 extension_ime_util::GetInputMethodID(
41 "abcde_xxxxxxxxxxxxxxxxxxxxxxxxxx", "12345")));
42 EXPECT_FALSE(extension_ime_util::IsExtensionIME(
43 extension_ime_util::GetComponentInputMethodID(
44 "abcde_xxxxxxxxxxxxxxxxxxxxxxxxxx", "12345")));
45 EXPECT_FALSE(extension_ime_util::IsExtensionIME(""));
46 EXPECT_FALSE(extension_ime_util::IsExtensionIME("mozc"));
49 TEST(ExtensionIMEUtilTest, IsComponentExtensionIMETest) {
50 EXPECT_TRUE(extension_ime_util::IsComponentExtensionIME(
51 extension_ime_util::GetComponentInputMethodID(
52 "abcde_xxxxxxxxxxxxxxxxxxxxxxxxxx", "12345")));
53 EXPECT_FALSE(extension_ime_util::IsComponentExtensionIME(
54 extension_ime_util::GetInputMethodID(
55 "abcde_xxxxxxxxxxxxxxxxxxxxxxxxxx", "12345")));
56 EXPECT_FALSE(extension_ime_util::IsComponentExtensionIME(""));
57 EXPECT_FALSE(extension_ime_util::IsComponentExtensionIME("mozc"));
60 TEST(ExtensionIMEUtilTest, IsMemberOfExtension) {
61 const char* extention1 = "abcdefg";
62 const char* extention2 = "hijklmn";
63 const char* extention3 = "opqrstu";
64 const char* engine_id1 = "12345";
65 const char* engine_id2 = "67890";
66 const char* engine_id3 = "31415";
68 const std::string extention_1_engine_1 =
69 extension_ime_util::GetInputMethodID(extention1, engine_id1);
70 const std::string extention_1_engine_2 =
71 extension_ime_util::GetInputMethodID(extention1, engine_id2);
72 const std::string component_3_engine_3 =
73 extension_ime_util::GetComponentInputMethodID(extention3, engine_id3);
75 EXPECT_TRUE(extension_ime_util::IsMemberOfExtension(extention_1_engine_1,
76 extention1));
77 EXPECT_TRUE(extension_ime_util::IsMemberOfExtension(extention_1_engine_2,
78 extention1));
79 EXPECT_FALSE(extension_ime_util::IsMemberOfExtension(extention_1_engine_1,
80 extention2));
81 EXPECT_FALSE(extension_ime_util::IsMemberOfExtension(extention_1_engine_2,
82 extention2));
83 EXPECT_FALSE(extension_ime_util::IsMemberOfExtension(component_3_engine_3,
84 extention3));
87 } // namespace chromeos