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

Unified Diff: chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc

Issue 6265010: DOMUI settings: move/rename the language options panel so that it can be use... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
Index: chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc
===================================================================
--- chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc (revision 71729)
+++ chrome/browser/chromeos/dom_ui/language_options_handler_unittest.cc (working copy)
@@ -1,173 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/chromeos/dom_ui/language_options_handler.h"
-
-#include <string>
-
-#include "base/scoped_ptr.h"
-#include "base/values.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/input_method_library.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace chromeos {
-
-static InputMethodDescriptors CreateInputMethodDescriptors() {
- InputMethodDescriptors descriptors;
- descriptors.push_back(
- InputMethodDescriptor("xkb:us::eng", "USA", "us", "eng"));
- descriptors.push_back(
- InputMethodDescriptor("xkb:fr::fra", "France", "fr", "fra"));
- descriptors.push_back(
- InputMethodDescriptor("xkb:be::fra", "Belgium", "be", "fr"));
- descriptors.push_back(
- InputMethodDescriptor("mozc", "Mozc (US keyboard layout)", "us", "ja"));
- return descriptors;
-}
-
-TEST(LanguageOptionsHandlerTest, GetInputMethodList) {
- // Use the stub libcros. The object will take care of the cleanup.
- ScopedStubCrosEnabler stub_cros_enabler;
-
- // Reset the library implementation so it will be initialized
- // again. Otherwise, non-stub implementation can be reused, if it's
- // already initialized elsewhere, which results in a crash.
- CrosLibrary::Get()->GetTestApi()->SetInputMethodLibrary(NULL, false);
-
- InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
- scoped_ptr<ListValue> list(
- LanguageOptionsHandler::GetInputMethodList(descriptors));
- ASSERT_EQ(4U, list->GetSize());
-
- DictionaryValue* entry = NULL;
- DictionaryValue *language_code_set = NULL;
- std::string input_method_id;
- std::string display_name;
- std::string language_code;
-
- // As shown below, the list should be input method ids should appear in
- // the same order of the descriptors.
- ASSERT_TRUE(list->GetDictionary(0, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("xkb:us::eng", input_method_id);
- // Commented out as it depends on translation in generated_resources.grd
- // (i.e. makes the test fragile).
- // EXPECT_EQ("English (USA) keyboard layout", display_name);
- ASSERT_TRUE(language_code_set->HasKey("en-US"));
- ASSERT_TRUE(language_code_set->HasKey("id")); // From kExtraLanguages.
- ASSERT_TRUE(language_code_set->HasKey("fil")); // From kExtraLanguages.
-
- ASSERT_TRUE(list->GetDictionary(1, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("xkb:fr::fra", input_method_id);
- // Commented out. See above.
- // EXPECT_EQ("French keyboard layout", display_name);
- ASSERT_TRUE(language_code_set->HasKey("fr"));
-
- ASSERT_TRUE(list->GetDictionary(2, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("xkb:be::fra", input_method_id);
- // Commented out. See above.
- // EXPECT_EQ("Belgian keyboard layout", display_name);
- ASSERT_TRUE(language_code_set->HasKey("fr"));
-
- ASSERT_TRUE(list->GetDictionary(3, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("mozc", input_method_id);
- // Commented out. See above.
- // EXPECT_EQ("Japanese input method (for US keyboard)", display_name);
- ASSERT_TRUE(language_code_set->HasKey("ja"));
-}
-
-TEST(LanguageOptionsHandlerTest, GetLanguageList) {
- InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
- scoped_ptr<ListValue> list(
- LanguageOptionsHandler::GetLanguageList(descriptors));
- ASSERT_EQ(6U, list->GetSize());
-
- DictionaryValue* entry = NULL;
- std::string language_code;
- std::string display_name;
- std::string native_display_name;
-
- // As shown below, the list should be sorted by the display names,
- // and these names should not have duplicates.
- ASSERT_TRUE(list->GetDictionary(0, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("en-US", language_code);
- EXPECT_EQ("English (United States)", display_name);
- EXPECT_EQ("English (United States)", native_display_name);
-
- // This comes from kExtraLanguages.
- ASSERT_TRUE(list->GetDictionary(1, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("fil", language_code);
- EXPECT_EQ("Filipino", display_name);
- EXPECT_EQ("Filipino", native_display_name);
-
- ASSERT_TRUE(list->GetDictionary(2, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("fr", language_code);
- EXPECT_EQ("French", display_name);
- EXPECT_EQ("fran\u00E7ais", native_display_name);
-
- // This comes from kExtraLanguages.
- ASSERT_TRUE(list->GetDictionary(3, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("id", language_code);
- EXPECT_EQ("Indonesian", display_name);
- EXPECT_EQ("Bahasa Indonesia", native_display_name);
-
- ASSERT_TRUE(list->GetDictionary(4, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("ja", language_code);
- EXPECT_EQ("Japanese", display_name);
- EXPECT_EQ("\u65E5\u672C\u8A9E", native_display_name);
-
- // This comes from kExtraLanguages.
- ASSERT_TRUE(list->GetDictionary(5, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("es-419", language_code);
- EXPECT_EQ("Spanish (Latin America and the Caribbean)", display_name);
- EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica y el Caribe)",
- native_display_name);
-}
-
-TEST(LanguageOptionsHandlerTest, GetUiLanguageCodeSet) {
- scoped_ptr<DictionaryValue> dictionary(
- LanguageOptionsHandler::GetUiLanguageCodeSet());
- EXPECT_TRUE(dictionary->HasKey("en-US"));
- // Note that we don't test a false case, as such an expectation will
- // fail when we add support for the language.
- // EXPECT_FALSE(dictionary->HasKey("no"));
-}
-
-TEST(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) {
- scoped_ptr<DictionaryValue> dictionary(
- LanguageOptionsHandler::GetSpellCheckLanguageCodeSet());
- EXPECT_TRUE(dictionary->HasKey("en-US"));
-}
-
-} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/dom_ui/language_options_handler.cc ('k') | chrome/browser/dom_ui/options/language_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698