Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / base / ime / win / tsf_input_scope_unittest.cc
blobde6ede17ffd16318d5907e8d9573772471c350ee
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/win/tsf_input_scope.h"
7 #include <InputScope.h>
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace ui {
12 namespace {
14 struct GetInputScopesTestCase {
15 TextInputType input_type;
16 TextInputMode input_mode;
17 size_t expected_size;
18 InputScope expected_input_scopes[2];
21 // Google Test pretty-printer.
22 void PrintTo(const GetInputScopesTestCase& data, std::ostream* os) {
23 *os << " input_type: " << testing::PrintToString(data.input_type)
24 << "; input_mode: " << testing::PrintToString(data.input_mode);
27 class TSFInputScopeTest
28 : public testing::TestWithParam<GetInputScopesTestCase> {
31 const GetInputScopesTestCase kGetInputScopesTestCases[] = {
32 // Test cases of TextInputType.
33 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_DEFAULT,
34 1, {IS_DEFAULT}},
35 {TEXT_INPUT_TYPE_TEXT, TEXT_INPUT_MODE_DEFAULT,
36 1, {IS_DEFAULT}},
37 {TEXT_INPUT_TYPE_PASSWORD, TEXT_INPUT_MODE_DEFAULT,
38 1, {IS_PASSWORD}},
39 {TEXT_INPUT_TYPE_SEARCH, TEXT_INPUT_MODE_DEFAULT,
40 1, {IS_SEARCH}},
41 {TEXT_INPUT_TYPE_EMAIL, TEXT_INPUT_MODE_DEFAULT,
42 1, {IS_EMAIL_SMTPEMAILADDRESS}},
43 {TEXT_INPUT_TYPE_NUMBER, TEXT_INPUT_MODE_DEFAULT,
44 1, {IS_NUMBER}},
45 {TEXT_INPUT_TYPE_TELEPHONE, TEXT_INPUT_MODE_DEFAULT,
46 1, {IS_TELEPHONE_FULLTELEPHONENUMBER}},
47 {TEXT_INPUT_TYPE_URL, TEXT_INPUT_MODE_DEFAULT,
48 1, {IS_URL}},
49 {TEXT_INPUT_TYPE_DATE, TEXT_INPUT_MODE_DEFAULT,
50 1, {IS_DEFAULT}},
51 {TEXT_INPUT_TYPE_DATE_TIME, TEXT_INPUT_MODE_DEFAULT,
52 1, {IS_DEFAULT}},
53 {TEXT_INPUT_TYPE_DATE_TIME_LOCAL, TEXT_INPUT_MODE_DEFAULT,
54 1, {IS_DEFAULT}},
55 {TEXT_INPUT_TYPE_MONTH, TEXT_INPUT_MODE_DEFAULT,
56 1, {IS_DEFAULT}},
57 {TEXT_INPUT_TYPE_TIME, TEXT_INPUT_MODE_DEFAULT,
58 1, {IS_DEFAULT}},
59 {TEXT_INPUT_TYPE_WEEK, TEXT_INPUT_MODE_DEFAULT,
60 1, {IS_DEFAULT}},
61 {TEXT_INPUT_TYPE_TEXT_AREA, TEXT_INPUT_MODE_DEFAULT,
62 1, {IS_DEFAULT}},
63 {TEXT_INPUT_TYPE_CONTENT_EDITABLE, TEXT_INPUT_MODE_DEFAULT,
64 1, {IS_DEFAULT}},
65 {TEXT_INPUT_TYPE_DATE_TIME_FIELD, TEXT_INPUT_MODE_DEFAULT,
66 1, {IS_DEFAULT}},
67 // Test cases of TextInputMode.
68 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_DEFAULT,
69 1, {IS_DEFAULT}},
70 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_VERBATIM,
71 1, {IS_DEFAULT}},
72 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_LATIN,
73 1, {IS_DEFAULT}},
74 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_LATIN_NAME,
75 1, {IS_DEFAULT}},
76 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_LATIN_PROSE,
77 1, {IS_DEFAULT}},
78 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_FULL_WIDTH_LATIN,
79 1, {IS_ALPHANUMERIC_FULLWIDTH}},
80 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_KANA,
81 1, {IS_HIRAGANA}},
82 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_KATAKANA,
83 1, {IS_KATAKANA_FULLWIDTH}},
84 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_NUMERIC,
85 1, {IS_NUMBER}},
86 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_TEL,
87 1, {IS_TELEPHONE_FULLTELEPHONENUMBER}},
88 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_EMAIL,
89 1, {IS_EMAIL_SMTPEMAILADDRESS}},
90 {TEXT_INPUT_TYPE_NONE, TEXT_INPUT_MODE_URL,
91 1, {IS_URL}},
92 // Mixed test cases.
93 {TEXT_INPUT_TYPE_SEARCH, TEXT_INPUT_MODE_KANA,
94 2, {IS_SEARCH, IS_HIRAGANA}},
95 {TEXT_INPUT_TYPE_EMAIL, TEXT_INPUT_MODE_EMAIL,
96 1, {IS_EMAIL_SMTPEMAILADDRESS}},
97 {TEXT_INPUT_TYPE_NUMBER, TEXT_INPUT_MODE_NUMERIC,
98 1, {IS_NUMBER}},
99 {TEXT_INPUT_TYPE_TELEPHONE, TEXT_INPUT_MODE_TEL,
100 1, {IS_TELEPHONE_FULLTELEPHONENUMBER}},
101 {TEXT_INPUT_TYPE_URL, TEXT_INPUT_MODE_URL,
102 1, {IS_URL}},
105 TEST_P(TSFInputScopeTest, GetInputScopes) {
106 const GetInputScopesTestCase& test_case = GetParam();
108 std::vector<InputScope> input_scopes = tsf_inputscope::GetInputScopes(
109 test_case.input_type, test_case.input_mode);
111 EXPECT_EQ(test_case.expected_size, input_scopes.size());
112 for (size_t i = 0; i < test_case.expected_size; ++i)
113 EXPECT_EQ(test_case.expected_input_scopes[i], input_scopes[i]);
116 INSTANTIATE_TEST_CASE_P(,
117 TSFInputScopeTest,
118 ::testing::ValuesIn(kGetInputScopesTestCases));
120 } // namespace
121 } // namespace ui