Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/chromeos/input_method/ibus_controller_unittest.cc

Issue 7046069: Copy chromeos_input_method* from libcros as-is. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/input_method/ibus_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium OS 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.
4
5 // How to run the test:
6 // $ FEATURES="test" emerge-x86-generic -a libcros
7
8 #include "chromeos_input_method.h"
9
10 #include <gtest/gtest.h>
11
12 #include "base/logging.h"
13
14 namespace chromeos {
15 namespace {
16 InputMethodDescriptor GetDesc(const std::string& raw_layout) {
17 return CreateInputMethodDescriptor(
18 "id", "display_name", raw_layout, "language_code");
19 }
20 } // namespace
21
22 // Tests InputMethodIdIsWhitelisted function.
23 TEST(ChromeOSInputMethodTest, TestInputMethodIdIsWhitelisted) {
24 EXPECT_TRUE(InputMethodIdIsWhitelisted("mozc"));
25 EXPECT_TRUE(InputMethodIdIsWhitelisted("xkb:us:dvorak:eng"));
26 EXPECT_FALSE(InputMethodIdIsWhitelisted("mozc,"));
27 EXPECT_FALSE(InputMethodIdIsWhitelisted("mozc,xkb:us:dvorak:eng"));
28 EXPECT_FALSE(InputMethodIdIsWhitelisted("not-supported-id"));
29 EXPECT_FALSE(InputMethodIdIsWhitelisted(","));
30 EXPECT_FALSE(InputMethodIdIsWhitelisted(""));
31 }
32
33 // Tests XkbLayoutIsSupported function.
34 TEST(ChromeOSInputMethodTest, TestXkbLayoutIsSupported) {
35 EXPECT_TRUE(XkbLayoutIsSupported("us"));
36 EXPECT_TRUE(XkbLayoutIsSupported("us(dvorak)"));
37 EXPECT_TRUE(XkbLayoutIsSupported("fr"));
38 EXPECT_FALSE(XkbLayoutIsSupported("us,"));
39 EXPECT_FALSE(XkbLayoutIsSupported("us,fr"));
40 EXPECT_FALSE(XkbLayoutIsSupported("xkb:us:dvorak:eng"));
41 EXPECT_FALSE(XkbLayoutIsSupported("mozc"));
42 EXPECT_FALSE(XkbLayoutIsSupported(","));
43 EXPECT_FALSE(XkbLayoutIsSupported(""));
44 }
45
46 // Tests CreateInputMethodDescriptor function.
47 TEST(ChromeOSInputMethodTest, TestCreateInputMethodDescriptor) {
48 EXPECT_EQ(GetDesc("us").keyboard_layout, "us");
49 EXPECT_EQ(GetDesc("us,us(dvorak)").keyboard_layout, "us");
50 EXPECT_EQ(GetDesc("us(dvorak),us").keyboard_layout, "us(dvorak)");
51
52 EXPECT_EQ(GetDesc("fr").keyboard_layout, "fr");
53 EXPECT_EQ(GetDesc("fr,us(dvorak)").keyboard_layout, "fr");
54 EXPECT_EQ(GetDesc("us(dvorak),fr").keyboard_layout, "us(dvorak)");
55
56 EXPECT_EQ(GetDesc("not-supported,fr").keyboard_layout, "fr");
57 EXPECT_EQ(GetDesc("fr,not-supported").keyboard_layout, "fr");
58
59 static const char kFallbackLayout[] = "us";
60 EXPECT_EQ(GetDesc("not-supported").keyboard_layout, kFallbackLayout);
61 EXPECT_EQ(GetDesc(",").keyboard_layout, kFallbackLayout);
62 EXPECT_EQ(GetDesc("").keyboard_layout, kFallbackLayout);
63
64 // TODO(yusukes): Add tests for |virtual_keyboard_layout| member.
65 }
66
67 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/ibus_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698