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

Side by Side Diff: chrome/browser/chromeos/options/language_config_model_unittest.cc

Issue 3159031: Remove wstrings from bookmarks, part 12. (Closed)
Patch Set: rebased ToT Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/chromeos/options/language_config_model.h" 12 #include "chrome/browser/chromeos/options/language_config_model.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 TEST(AddLanguageComboboxModelTest, AddLanguageComboboxModel) { 18 TEST(AddLanguageComboboxModelTest, AddLanguageComboboxModel) {
19 std::vector<std::string> language_codes; 19 std::vector<std::string> language_codes;
20 language_codes.push_back("de"); 20 language_codes.push_back("de");
21 language_codes.push_back("fr"); 21 language_codes.push_back("fr");
22 language_codes.push_back("ko"); 22 language_codes.push_back("ko");
23 AddLanguageComboboxModel model(NULL, language_codes); 23 AddLanguageComboboxModel model(NULL, language_codes);
24 24
25 // GetItemCount() should return 4 ("Add language" + 3 language codes). 25 // GetItemCount() should return 4 ("Add language" + 3 language codes).
26 ASSERT_EQ(4, model.GetItemCount()); 26 ASSERT_EQ(4, model.GetItemCount());
27 27
28 // The first item should be "Add language" labe. 28 // The first item should be "Add language" labe.
29 EXPECT_EQ(l10n_util::GetString( 29 EXPECT_EQ(l10n_util::GetStringUTF16(
30 IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_COMBOBOX), 30 IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_COMBOBOX),
31 model.GetItemAt(0)); 31 model.GetItemAt(0));
32 // Other items should be sorted language display names for UI (hence 32 // Other items should be sorted language display names for UI (hence
33 // French comes before German). Note that the returned display names 33 // French comes before German). Note that the returned display names
34 // are followed by their native representations. To simplify matching, 34 // are followed by their native representations. To simplify matching,
35 // use StartsWith() here. 35 // use StartsWith() here.
36 EXPECT_TRUE(StartsWith(model.GetItemAt(1), L"French", true)) 36 EXPECT_TRUE(StartsWith(model.GetItemAt(1), ASCIIToUTF16("French"), true))
37 << model.GetItemAt(1); 37 << model.GetItemAt(1);
38 EXPECT_TRUE(StartsWith(model.GetItemAt(2), L"German", true)) 38 EXPECT_TRUE(StartsWith(model.GetItemAt(2), ASCIIToUTF16("German"), true))
39 << model.GetItemAt(2); 39 << model.GetItemAt(2);
40 EXPECT_TRUE(StartsWith(model.GetItemAt(3), L"Korean", true)) 40 EXPECT_TRUE(StartsWith(model.GetItemAt(3), ASCIIToUTF16("Korean"), true))
41 << model.GetItemAt(3); 41 << model.GetItemAt(3);
42 42
43 // GetLanguageIndex() returns the given index -1 to offset "Add language". 43 // GetLanguageIndex() returns the given index -1 to offset "Add language".
44 EXPECT_EQ(0, model.GetLanguageIndex(1)); 44 EXPECT_EQ(0, model.GetLanguageIndex(1));
45 EXPECT_EQ(1, model.GetLanguageIndex(2)); 45 EXPECT_EQ(1, model.GetLanguageIndex(2));
46 EXPECT_EQ(2, model.GetLanguageIndex(3)); 46 EXPECT_EQ(2, model.GetLanguageIndex(3));
47 47
48 // The returned index can be used for GetLocaleFromIndex(). 48 // The returned index can be used for GetLocaleFromIndex().
49 EXPECT_EQ("fr", model.GetLocaleFromIndex(model.GetLanguageIndex(1))); 49 EXPECT_EQ("fr", model.GetLocaleFromIndex(model.GetLanguageIndex(1)));
50 EXPECT_EQ("de", model.GetLocaleFromIndex(model.GetLanguageIndex(2))); 50 EXPECT_EQ("de", model.GetLocaleFromIndex(model.GetLanguageIndex(2)));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 EXPECT_EQ("de", model.GetLocaleFromIndex(model.GetLanguageIndex(2))); 89 EXPECT_EQ("de", model.GetLocaleFromIndex(model.GetLanguageIndex(2)));
90 EXPECT_EQ("ko", model.GetLocaleFromIndex(model.GetLanguageIndex(3))); 90 EXPECT_EQ("ko", model.GetLocaleFromIndex(model.GetLanguageIndex(3)));
91 91
92 // Mark "ja" (not in the model) to be ignored. 92 // Mark "ja" (not in the model) to be ignored.
93 model.SetIgnored("ja", true); 93 model.SetIgnored("ja", true);
94 // The GetItemCount() should not be changed. 94 // The GetItemCount() should not be changed.
95 ASSERT_EQ(4, model.GetItemCount()); 95 ASSERT_EQ(4, model.GetItemCount());
96 } 96 }
97 97
98 } // namespace chromeos 98 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/options/language_config_model.cc ('k') | chrome/browser/chromeos/options/language_config_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698