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

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

Issue 9701095: cleanup: Split ibus_controller.h into 5 headers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 8 years, 9 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 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.
4
5 #include "chrome/browser/chromeos/input_method/ibus_controller.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 #if defined(USE_VIRTUAL_KEYBOARD)
12 // Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we
13 // skip the tests for now.
14 #define TestCreateInputMethodDescriptor DISABLED_TestCreateInputMethodDescriptor
15 #define TestInputMethodIdIsWhitelisted DISABLED_TestInputMethodIdIsWhitelisted
16 #define TestXkbLayoutIsSupported DISABLED_TestXkbLayoutIsSupported
17 #endif // USE_VIRTUAL_KEYBOARD
18
19 namespace chromeos {
20 namespace input_method {
21
22 namespace {
23 InputMethodDescriptor GetDesc(IBusController* controller,
24 const std::string& raw_layout) {
25 return controller->CreateInputMethodDescriptor(
26 "id", "", raw_layout, "language_code");
27 }
28 } // namespace
29
30 TEST(IBusControllerTest, TestInputMethodIdIsWhitelisted) {
31 scoped_ptr<IBusController> controller(IBusController::Create());
32 EXPECT_TRUE(controller->InputMethodIdIsWhitelisted("mozc"));
33 EXPECT_TRUE(controller->InputMethodIdIsWhitelisted("xkb:us:dvorak:eng"));
34 EXPECT_FALSE(controller->InputMethodIdIsWhitelisted("mozc,"));
35 EXPECT_FALSE(controller->InputMethodIdIsWhitelisted(
36 "mozc,xkb:us:dvorak:eng"));
37 EXPECT_FALSE(controller->InputMethodIdIsWhitelisted("not-supported-id"));
38 EXPECT_FALSE(controller->InputMethodIdIsWhitelisted(","));
39 EXPECT_FALSE(controller->InputMethodIdIsWhitelisted(""));
40 }
41
42 TEST(IBusControllerTest, TestXkbLayoutIsSupported) {
43 scoped_ptr<IBusController> controller(IBusController::Create());
44 EXPECT_TRUE(controller->XkbLayoutIsSupported("us"));
45 EXPECT_TRUE(controller->XkbLayoutIsSupported("us(dvorak)"));
46 EXPECT_TRUE(controller->XkbLayoutIsSupported("fr"));
47 EXPECT_FALSE(controller->XkbLayoutIsSupported("us,"));
48 EXPECT_FALSE(controller->XkbLayoutIsSupported("us,fr"));
49 EXPECT_FALSE(controller->XkbLayoutIsSupported("xkb:us:dvorak:eng"));
50 EXPECT_FALSE(controller->XkbLayoutIsSupported("mozc"));
51 EXPECT_FALSE(controller->XkbLayoutIsSupported(","));
52 EXPECT_FALSE(controller->XkbLayoutIsSupported(""));
53 }
54
55 TEST(IBusControllerTest, TestCreateInputMethodDescriptor) {
56 scoped_ptr<IBusController> controller(IBusController::Create());
57 EXPECT_EQ("us", GetDesc(controller.get(), "us").keyboard_layout());
58 EXPECT_EQ("us", GetDesc(controller.get(), "us,us(dvorak)").keyboard_layout());
59 EXPECT_EQ("us(dvorak)",
60 GetDesc(controller.get(), "us(dvorak),us").keyboard_layout());
61
62 EXPECT_EQ("fr", GetDesc(controller.get(), "fr").keyboard_layout());
63 EXPECT_EQ("fr", GetDesc(controller.get(), "fr,us(dvorak)").keyboard_layout());
64 EXPECT_EQ("us(dvorak)",
65 GetDesc(controller.get(), "us(dvorak),fr").keyboard_layout());
66
67 EXPECT_EQ("fr",
68 GetDesc(controller.get(), "not-supported,fr").keyboard_layout());
69 EXPECT_EQ("fr",
70 GetDesc(controller.get(), "fr,not-supported").keyboard_layout());
71
72 static const char kFallbackLayout[] = "us";
73 EXPECT_EQ(kFallbackLayout,
74 GetDesc(controller.get(), "not-supported").keyboard_layout());
75 EXPECT_EQ(kFallbackLayout, GetDesc(controller.get(), ",").keyboard_layout());
76 EXPECT_EQ(kFallbackLayout, GetDesc(controller.get(), "").keyboard_layout());
77
78 // TODO(yusukes): Add tests for |virtual_keyboard_layout| member.
79 }
80
81 } // namespace input_method
82 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/ibus_controller.cc ('k') | chrome/browser/chromeos/input_method/input_method_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698