Commit 2298a021 authored by satorux@chromium.org's avatar satorux@chromium.org

Copy chromeos_input_method* from libcros as-is.

We'll be modifying these files so we can use the code from Chrome
without going through libcros. Before doing that, we check in the
code as-is, so we can track diffs.

% cp ~/chromeos/src/platform/cros/chromeos_input_method.cc ibus_controller.cc
% cp ~/chromeos/src/platform/cros/chromeos_input_method.h ibus_controller.h
% cp ~/chromeos/src/platform/cros/chromeos_input_method_unittest.cc ibus_controller_unittest.cc

TEST=none (the code is unused now)
BUG=chromium-os:16238

Review URL: http://codereview.chromium.org/7046069

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88502 0039d316-1c4b-4281-b951-d872f2087c98
parent 52789b44
This diff is collapsed.
This diff is collapsed.
// 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.
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment