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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/input_method/ibus_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
diff --git a/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc b/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f971f642b30ffbe2c9a45773ec7e60ed1534d72e
--- /dev/null
+++ b/chrome/browser/chromeos/input_method/ibus_controller_unittest.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// How to run the test:
+// $ FEATURES="test" emerge-x86-generic -a libcros
+
+#include "chromeos_input_method.h"
+
+#include <gtest/gtest.h>
+
+#include "base/logging.h"
+
+namespace chromeos {
+namespace {
+InputMethodDescriptor GetDesc(const std::string& raw_layout) {
+ return CreateInputMethodDescriptor(
+ "id", "display_name", raw_layout, "language_code");
+}
+} // namespace
+
+// Tests InputMethodIdIsWhitelisted function.
+TEST(ChromeOSInputMethodTest, TestInputMethodIdIsWhitelisted) {
+ EXPECT_TRUE(InputMethodIdIsWhitelisted("mozc"));
+ EXPECT_TRUE(InputMethodIdIsWhitelisted("xkb:us:dvorak:eng"));
+ EXPECT_FALSE(InputMethodIdIsWhitelisted("mozc,"));
+ EXPECT_FALSE(InputMethodIdIsWhitelisted("mozc,xkb:us:dvorak:eng"));
+ EXPECT_FALSE(InputMethodIdIsWhitelisted("not-supported-id"));
+ EXPECT_FALSE(InputMethodIdIsWhitelisted(","));
+ EXPECT_FALSE(InputMethodIdIsWhitelisted(""));
+}
+
+// Tests XkbLayoutIsSupported function.
+TEST(ChromeOSInputMethodTest, TestXkbLayoutIsSupported) {
+ EXPECT_TRUE(XkbLayoutIsSupported("us"));
+ EXPECT_TRUE(XkbLayoutIsSupported("us(dvorak)"));
+ EXPECT_TRUE(XkbLayoutIsSupported("fr"));
+ EXPECT_FALSE(XkbLayoutIsSupported("us,"));
+ EXPECT_FALSE(XkbLayoutIsSupported("us,fr"));
+ EXPECT_FALSE(XkbLayoutIsSupported("xkb:us:dvorak:eng"));
+ EXPECT_FALSE(XkbLayoutIsSupported("mozc"));
+ EXPECT_FALSE(XkbLayoutIsSupported(","));
+ EXPECT_FALSE(XkbLayoutIsSupported(""));
+}
+
+// Tests CreateInputMethodDescriptor function.
+TEST(ChromeOSInputMethodTest, TestCreateInputMethodDescriptor) {
+ EXPECT_EQ(GetDesc("us").keyboard_layout, "us");
+ EXPECT_EQ(GetDesc("us,us(dvorak)").keyboard_layout, "us");
+ EXPECT_EQ(GetDesc("us(dvorak),us").keyboard_layout, "us(dvorak)");
+
+ EXPECT_EQ(GetDesc("fr").keyboard_layout, "fr");
+ EXPECT_EQ(GetDesc("fr,us(dvorak)").keyboard_layout, "fr");
+ EXPECT_EQ(GetDesc("us(dvorak),fr").keyboard_layout, "us(dvorak)");
+
+ EXPECT_EQ(GetDesc("not-supported,fr").keyboard_layout, "fr");
+ EXPECT_EQ(GetDesc("fr,not-supported").keyboard_layout, "fr");
+
+ static const char kFallbackLayout[] = "us";
+ EXPECT_EQ(GetDesc("not-supported").keyboard_layout, kFallbackLayout);
+ EXPECT_EQ(GetDesc(",").keyboard_layout, kFallbackLayout);
+ EXPECT_EQ(GetDesc("").keyboard_layout, kFallbackLayout);
+
+ // TODO(yusukes): Add tests for |virtual_keyboard_layout| member.
+}
+
+}
« 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