| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 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 "base/logging.h" |
| 6 #include "chrome/browser/chromeos/input_method/input_method_descriptor.h" |
| 7 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 #if defined(USE_VIRTUAL_KEYBOARD) |
| 11 // Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we |
| 12 // skip the test for now. |
| 13 #define TestCreateInputMethodDescriptor DISABLED_TestCreateInputMethodDescriptor |
| 14 #endif // USE_VIRTUAL_KEYBOARD |
| 15 |
| 16 namespace chromeos { |
| 17 namespace input_method { |
| 18 |
| 19 namespace { |
| 20 |
| 21 const char kFallbackLayout[] = "us"; |
| 22 |
| 23 class InputMethodDescriptorTest : public testing::Test { |
| 24 public: |
| 25 InputMethodDescriptorTest() { |
| 26 } |
| 27 |
| 28 protected: |
| 29 InputMethodDescriptor GetDesc(const std::string& raw_layout) { |
| 30 return InputMethodDescriptor(whitelist_, |
| 31 "id", |
| 32 "", // name |
| 33 raw_layout, |
| 34 "language_code"); |
| 35 } |
| 36 |
| 37 private: |
| 38 const InputMethodWhitelist whitelist_; |
| 39 }; |
| 40 |
| 41 } // namespace |
| 42 |
| 43 TEST_F(InputMethodDescriptorTest, TestCreateInputMethodDescriptor) { |
| 44 EXPECT_EQ("us", GetDesc("us").keyboard_layout()); |
| 45 EXPECT_EQ("us", GetDesc("us,us(dvorak)").keyboard_layout()); |
| 46 EXPECT_EQ("us(dvorak)", GetDesc("us(dvorak),us").keyboard_layout()); |
| 47 |
| 48 EXPECT_EQ("fr", GetDesc("fr").keyboard_layout()); |
| 49 EXPECT_EQ("fr", GetDesc("fr,us(dvorak)").keyboard_layout()); |
| 50 EXPECT_EQ("us(dvorak)", GetDesc("us(dvorak),fr").keyboard_layout()); |
| 51 |
| 52 EXPECT_EQ("fr", GetDesc("not-supported,fr").keyboard_layout()); |
| 53 EXPECT_EQ("fr", GetDesc("fr,not-supported").keyboard_layout()); |
| 54 |
| 55 EXPECT_EQ(kFallbackLayout, GetDesc("not-supported").keyboard_layout()); |
| 56 EXPECT_EQ(kFallbackLayout, GetDesc(",").keyboard_layout()); |
| 57 EXPECT_EQ(kFallbackLayout, GetDesc("").keyboard_layout()); |
| 58 |
| 59 // TODO(yusukes): Add tests for |virtual_keyboard_layout| member. |
| 60 } |
| 61 |
| 62 } // namespace input_method |
| 63 } // namespace chromeos |
| OLD | NEW |