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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_util_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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/input_method/input_method_util.h" 5 #include "chrome/browser/chromeos/input_method/input_method_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/chromeos/input_method/ibus_controller.h" 11 #include "chrome/browser/chromeos/input_method/input_method_whitelist.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 15
16 #if defined(USE_VIRTUAL_KEYBOARD) 16 #if defined(USE_VIRTUAL_KEYBOARD)
17 // Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we 17 // Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we
18 // skip the tests for now. 18 // skip the tests for now.
19 #define TestGetFirstLoginInputMethodIds_Dvorak_And_Ja \ 19 #define TestGetFirstLoginInputMethodIds_Dvorak_And_Ja \
20 DISABLED_TestGetFirstLoginInputMethodIds_Dvorak_And_Ja 20 DISABLED_TestGetFirstLoginInputMethodIds_Dvorak_And_Ja
21 #define TestGetFirstLoginInputMethodIds_JP_And_Ja \ 21 #define TestGetFirstLoginInputMethodIds_JP_And_Ja \
22 DISABLED_TestGetFirstLoginInputMethodIds_JP_And_Ja 22 DISABLED_TestGetFirstLoginInputMethodIds_JP_And_Ja
23 #define TestGetFirstLoginInputMethodIds_Us_And_Ru \ 23 #define TestGetFirstLoginInputMethodIds_Us_And_Ru \
24 DISABLED_TestGetFirstLoginInputMethodIds_Us_And_Ru 24 DISABLED_TestGetFirstLoginInputMethodIds_Us_And_Ru
25 #define TestGetInputMethodDescriptorFromXkbId \ 25 #define TestGetInputMethodDescriptorFromXkbId \
26 DISABLED_TestGetInputMethodDescriptorFromXkbId 26 DISABLED_TestGetInputMethodDescriptorFromXkbId
27 #define TestGetKeyboardLayoutName DISABLED_TestGetKeyboardLayoutName 27 #define TestGetKeyboardLayoutName DISABLED_TestGetKeyboardLayoutName
28 #define TestGetLanguageCodesFromInputMethodIds \ 28 #define TestGetLanguageCodesFromInputMethodIds \
29 DISABLED_TestGetLanguageCodesFromInputMethodIds 29 DISABLED_TestGetLanguageCodesFromInputMethodIds
30 #endif // USE_VIRTUAL_KEYBOARD 30 #endif // USE_VIRTUAL_KEYBOARD
31 31
32 namespace chromeos { 32 namespace chromeos {
33 namespace input_method { 33 namespace input_method {
34 34
35 namespace { 35 namespace {
36 36
37 InputMethodDescriptor GetDesc(IBusController* controller,
38 const std::string& id,
39 const std::string& raw_layout,
40 const std::string& language_code) {
41 return controller->CreateInputMethodDescriptor(id, "", raw_layout,
42 language_code);
43 }
44
45 class TestableInputMethodUtil : public InputMethodUtil { 37 class TestableInputMethodUtil : public InputMethodUtil {
46 public: 38 public:
47 explicit TestableInputMethodUtil(InputMethodDescriptors* methods) 39 explicit TestableInputMethodUtil(InputMethodDescriptors* methods)
48 : InputMethodUtil(methods) { 40 : InputMethodUtil(methods) {
49 } 41 }
50 // Change access rights. 42 // Change access rights.
51 using InputMethodUtil::StringIsSupported; 43 using InputMethodUtil::StringIsSupported;
52 using InputMethodUtil::GetInputMethodIdsFromLanguageCodeInternal; 44 using InputMethodUtil::GetInputMethodIdsFromLanguageCodeInternal;
53 using InputMethodUtil::ReloadInternalMaps; 45 using InputMethodUtil::ReloadInternalMaps;
54 using InputMethodUtil::SortLanguageCodesByNames; 46 using InputMethodUtil::SortLanguageCodesByNames;
55 using InputMethodUtil::supported_input_methods_; 47 using InputMethodUtil::supported_input_methods_;
56 }; 48 };
57 49
58 } // namespace 50 } // namespace
59 51
60 class InputMethodUtilTest : public testing::Test { 52 class InputMethodUtilTest : public testing::Test {
61 public: 53 public:
62 InputMethodUtilTest() 54 InputMethodUtilTest() : util_(whitelist_.GetSupportedInputMethods()) {
63 : controller_(IBusController::Create()),
64 util_(controller_->GetSupportedInputMethods()) {
65 }
66 static void SetUpTestCase() {
67 } 55 }
68 56
69 scoped_ptr<IBusController> controller_; 57 InputMethodWhitelist whitelist_;
70 TestableInputMethodUtil util_; 58 TestableInputMethodUtil util_;
71 }; 59 };
72 60
73 TEST_F(InputMethodUtilTest, TestGetStringUTF8) { 61 TEST_F(InputMethodUtilTest, TestGetStringUTF8) {
74 EXPECT_EQ(UTF8ToUTF16("Pinyin input method"), 62 EXPECT_EQ(UTF8ToUTF16("Pinyin input method"),
75 util_.TranslateString("pinyin")); 63 util_.TranslateString("pinyin"));
76 #if !defined(GOOGLE_CHROME_BUILD) 64 #if !defined(GOOGLE_CHROME_BUILD)
77 EXPECT_EQ(UTF8ToUTF16("Japanese input method (for US Dvorak keyboard)"), 65 EXPECT_EQ(UTF8ToUTF16("Japanese input method (for US Dvorak keyboard)"),
78 util_.TranslateString("mozc-dv")); 66 util_.TranslateString("mozc-dv"));
79 #endif 67 #endif
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 EXPECT_FALSE(display_name.empty()) 331 EXPECT_FALSE(display_name.empty())
344 << "Invalid language code " << language_code; 332 << "Invalid language code " << language_code;
345 // On error, GetDisplayNameForLocale() returns the |language_code| as-is. 333 // On error, GetDisplayNameForLocale() returns the |language_code| as-is.
346 EXPECT_NE(language_code, UTF16ToUTF8(display_name)) 334 EXPECT_NE(language_code, UTF16ToUTF8(display_name))
347 << "Invalid language code " << language_code; 335 << "Invalid language code " << language_code;
348 } 336 }
349 } 337 }
350 338
351 } // namespace input_method 339 } // namespace input_method
352 } // namespace chromeos 340 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698