Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / ime / win / imm32_manager_unittest.cc
blob0c73b03d456959317c70f066968ded80ab5bb8c6
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/imm32_manager.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace ui {
10 namespace {
12 struct InputModeTestCase {
13 TextInputMode input_mode;
14 DWORD conversion_mode;
15 BOOL expected_open;
16 DWORD expected_conversion_mode;
19 // Google Test pretty-printer.
20 void PrintTo(const InputModeTestCase& data, std::ostream* os) {
21 *os << " input_mode: " << testing::PrintToString(data.input_mode)
22 << "; conversion_mode: " << testing::PrintToString(data.conversion_mode);
25 class IMM32ManagerTest
26 : public ::testing::TestWithParam<InputModeTestCase> {
29 const InputModeTestCase
30 kInputModeTestCases[] = {
31 {TEXT_INPUT_MODE_DEFAULT, 0, FALSE, 0},
32 {TEXT_INPUT_MODE_DEFAULT, IME_CMODE_NATIVE, FALSE, IME_CMODE_NATIVE},
33 {TEXT_INPUT_MODE_VERBATIM, 0, FALSE, 0},
34 {TEXT_INPUT_MODE_VERBATIM, IME_CMODE_KATAKANA, FALSE, IME_CMODE_KATAKANA},
35 {TEXT_INPUT_MODE_LATIN, 0, FALSE, 0},
36 {TEXT_INPUT_MODE_LATIN, IME_CMODE_NATIVE, FALSE, IME_CMODE_NATIVE},
37 {TEXT_INPUT_MODE_LATIN_NAME, 0, FALSE, 0},
38 {TEXT_INPUT_MODE_LATIN_NAME, IME_CMODE_NATIVE, FALSE, IME_CMODE_NATIVE},
39 {TEXT_INPUT_MODE_LATIN_PROSE, 0, FALSE, 0},
40 {TEXT_INPUT_MODE_LATIN_PROSE, IME_CMODE_NATIVE, FALSE, IME_CMODE_NATIVE},
41 {TEXT_INPUT_MODE_FULL_WIDTH_LATIN,
42 IME_CMODE_NATIVE | IME_CMODE_KATAKANA | IME_CMODE_FULLSHAPE,
43 TRUE,
44 IME_CMODE_FULLSHAPE},
45 {TEXT_INPUT_MODE_KANA,
47 TRUE,
48 IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE},
49 {TEXT_INPUT_MODE_KANA,
50 IME_CMODE_ROMAN,
51 TRUE,
52 IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE | IME_CMODE_ROMAN},
53 {TEXT_INPUT_MODE_KATAKANA,
54 IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE,
55 TRUE,
56 IME_CMODE_NATIVE | IME_CMODE_KATAKANA | IME_CMODE_FULLSHAPE},
57 {TEXT_INPUT_MODE_KATAKANA,
58 IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE | IME_CMODE_ROMAN,
59 TRUE,
60 IME_CMODE_NATIVE | IME_CMODE_KATAKANA | IME_CMODE_FULLSHAPE
61 | IME_CMODE_ROMAN},
62 {TEXT_INPUT_MODE_NUMERIC, 0, FALSE, 0},
63 {TEXT_INPUT_MODE_NUMERIC, IME_CMODE_FULLSHAPE, FALSE, IME_CMODE_FULLSHAPE},
64 {TEXT_INPUT_MODE_TEL, 0, FALSE, 0},
65 {TEXT_INPUT_MODE_TEL, IME_CMODE_ROMAN, FALSE, IME_CMODE_ROMAN},
66 {TEXT_INPUT_MODE_EMAIL, 0, FALSE, 0},
67 {TEXT_INPUT_MODE_EMAIL, IME_CMODE_CHARCODE, FALSE, IME_CMODE_CHARCODE},
68 {TEXT_INPUT_MODE_URL, 0, FALSE, 0},
69 {TEXT_INPUT_MODE_URL, IME_CMODE_HANJACONVERT, FALSE, IME_CMODE_HANJACONVERT},
72 TEST_P(IMM32ManagerTest, ConvertInputModeToImmFlags) {
73 const InputModeTestCase& test_case = GetParam();
75 BOOL open;
76 DWORD conversion_mode;
77 // Call testee method.
78 IMM32Manager::ConvertInputModeToImmFlags(test_case.input_mode,
79 test_case.conversion_mode,
80 &open,
81 &conversion_mode);
83 EXPECT_EQ(test_case.expected_open, open);
84 EXPECT_EQ(test_case.expected_conversion_mode, conversion_mode);
87 INSTANTIATE_TEST_CASE_P(,
88 IMM32ManagerTest,
89 ::testing::ValuesIn(kInputModeTestCases));
91 } // namespace
92 } // namespace ui