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"
14 struct GetInputScopesTestCase
{
15 TextInputType input_type
;
16 TextInputMode input_mode
;
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
,
35 {TEXT_INPUT_TYPE_TEXT
, TEXT_INPUT_MODE_DEFAULT
,
37 {TEXT_INPUT_TYPE_PASSWORD
, TEXT_INPUT_MODE_DEFAULT
,
39 {TEXT_INPUT_TYPE_SEARCH
, TEXT_INPUT_MODE_DEFAULT
,
41 {TEXT_INPUT_TYPE_EMAIL
, TEXT_INPUT_MODE_DEFAULT
,
42 1, {IS_EMAIL_SMTPEMAILADDRESS
}},
43 {TEXT_INPUT_TYPE_NUMBER
, TEXT_INPUT_MODE_DEFAULT
,
45 {TEXT_INPUT_TYPE_TELEPHONE
, TEXT_INPUT_MODE_DEFAULT
,
46 1, {IS_TELEPHONE_FULLTELEPHONENUMBER
}},
47 {TEXT_INPUT_TYPE_URL
, TEXT_INPUT_MODE_DEFAULT
,
49 {TEXT_INPUT_TYPE_DATE
, TEXT_INPUT_MODE_DEFAULT
,
51 {TEXT_INPUT_TYPE_DATE_TIME
, TEXT_INPUT_MODE_DEFAULT
,
53 {TEXT_INPUT_TYPE_DATE_TIME_LOCAL
, TEXT_INPUT_MODE_DEFAULT
,
55 {TEXT_INPUT_TYPE_MONTH
, TEXT_INPUT_MODE_DEFAULT
,
57 {TEXT_INPUT_TYPE_TIME
, TEXT_INPUT_MODE_DEFAULT
,
59 {TEXT_INPUT_TYPE_WEEK
, TEXT_INPUT_MODE_DEFAULT
,
61 {TEXT_INPUT_TYPE_TEXT_AREA
, TEXT_INPUT_MODE_DEFAULT
,
63 {TEXT_INPUT_TYPE_CONTENT_EDITABLE
, TEXT_INPUT_MODE_DEFAULT
,
65 {TEXT_INPUT_TYPE_DATE_TIME_FIELD
, TEXT_INPUT_MODE_DEFAULT
,
67 // Test cases of TextInputMode.
68 {TEXT_INPUT_TYPE_NONE
, TEXT_INPUT_MODE_DEFAULT
,
70 {TEXT_INPUT_TYPE_NONE
, TEXT_INPUT_MODE_VERBATIM
,
72 {TEXT_INPUT_TYPE_NONE
, TEXT_INPUT_MODE_LATIN
,
74 {TEXT_INPUT_TYPE_NONE
, TEXT_INPUT_MODE_LATIN_NAME
,
76 {TEXT_INPUT_TYPE_NONE
, TEXT_INPUT_MODE_LATIN_PROSE
,
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
,
82 {TEXT_INPUT_TYPE_NONE
, TEXT_INPUT_MODE_KATAKANA
,
83 1, {IS_KATAKANA_FULLWIDTH
}},
84 {TEXT_INPUT_TYPE_NONE
, TEXT_INPUT_MODE_NUMERIC
,
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
,
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
,
99 {TEXT_INPUT_TYPE_TELEPHONE
, TEXT_INPUT_MODE_TEL
,
100 1, {IS_TELEPHONE_FULLTELEPHONENUMBER
}},
101 {TEXT_INPUT_TYPE_URL
, TEXT_INPUT_MODE_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(,
118 ::testing::ValuesIn(kGetInputScopesTestCases
));