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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_service_unittest.cc

Issue 654653002: Enables the user to select multiple languages for spellchecking (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 5 years, 10 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) 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 <vector> 5 #include <vector>
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" 9 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
10 #include "chrome/browser/spellchecker/spellcheck_factory.h" 10 #include "chrome/browser/spellchecker/spellcheck_factory.h"
(...skipping 23 matching lines...) Expand all
34 TestingProfile profile_; 34 TestingProfile profile_;
35 }; 35 };
36 36
37 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages1) { 37 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages1) {
38 std::vector<std::string> accept_languages; 38 std::vector<std::string> accept_languages;
39 accept_languages.push_back("en"); 39 accept_languages.push_back("en");
40 accept_languages.push_back("en-US"); 40 accept_languages.push_back("en-US");
41 std::vector<std::string> languages; 41 std::vector<std::string> languages;
42 42
43 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( 43 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages(
44 accept_languages, "en-US", &languages); 44 accept_languages, &languages);
45 45
46 EXPECT_EQ(1U, languages.size()); 46 EXPECT_EQ(1U, languages.size());
47 EXPECT_EQ("en-US", languages[0]); 47 EXPECT_EQ("en-US", languages[0]);
48 } 48 }
49 49
50 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages2) { 50 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages2) {
51 std::vector<std::string> accept_languages; 51 std::vector<std::string> accept_languages;
52 accept_languages.push_back("en-US"); 52 accept_languages.push_back("en-US");
53 accept_languages.push_back("en"); 53 accept_languages.push_back("en");
54 std::vector<std::string> languages; 54 std::vector<std::string> languages;
55 55
56 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( 56 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages(
57 accept_languages, "en-US", &languages); 57 accept_languages, &languages);
58 58
59 EXPECT_EQ(1U, languages.size()); 59 EXPECT_EQ(1U, languages.size());
60 EXPECT_EQ("en-US", languages[0]); 60 EXPECT_EQ("en-US", languages[0]);
61 } 61 }
62 62
63 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages3) { 63 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages3) {
64 std::vector<std::string> accept_languages; 64 std::vector<std::string> accept_languages;
65 accept_languages.push_back("en"); 65 accept_languages.push_back("en");
66 accept_languages.push_back("en-US"); 66 accept_languages.push_back("en-US");
67 accept_languages.push_back("en-AU"); 67 accept_languages.push_back("en-AU");
68 std::vector<std::string> languages; 68 std::vector<std::string> languages;
69 69
70 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( 70 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages(
71 accept_languages, "en-US", &languages); 71 accept_languages, &languages);
72 72
73 EXPECT_EQ(2U, languages.size()); 73 EXPECT_EQ(2U, languages.size());
74 74
75 std::sort(languages.begin(), languages.end()); 75 std::sort(languages.begin(), languages.end());
76 EXPECT_EQ("en-AU", languages[0]); 76 EXPECT_EQ("en-AU", languages[0]);
77 EXPECT_EQ("en-US", languages[1]); 77 EXPECT_EQ("en-US", languages[1]);
78 } 78 }
79 79
80 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages4) { 80 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages4) {
81 std::vector<std::string> accept_languages; 81 std::vector<std::string> accept_languages;
82 accept_languages.push_back("en"); 82 accept_languages.push_back("en");
83 accept_languages.push_back("en-US"); 83 accept_languages.push_back("en-US");
84 accept_languages.push_back("fr"); 84 accept_languages.push_back("fr");
85 std::vector<std::string> languages; 85 std::vector<std::string> languages;
86 86
87 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( 87 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages(
88 accept_languages, "en-US", &languages); 88 accept_languages, &languages);
89 89
90 EXPECT_EQ(2U, languages.size()); 90 EXPECT_EQ(2U, languages.size());
91 91
92 std::sort(languages.begin(), languages.end()); 92 std::sort(languages.begin(), languages.end());
93 EXPECT_EQ("en-US", languages[0]); 93 EXPECT_EQ("en-US", languages[0]);
94 EXPECT_EQ("fr", languages[1]); 94 EXPECT_EQ("fr", languages[1]);
95 } 95 }
96 96
97 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages5) { 97 TEST_F(SpellcheckServiceTest, GetSpellCheckLanguages5) {
98 std::vector<std::string> accept_languages; 98 std::vector<std::string> accept_languages;
99 accept_languages.push_back("en"); 99 accept_languages.push_back("en");
100 accept_languages.push_back("en-JP"); // Will not exist. 100 accept_languages.push_back("en-JP"); // Will not exist.
101 accept_languages.push_back("fr"); 101 accept_languages.push_back("fr");
102 accept_languages.push_back("aa"); // Will not exist. 102 accept_languages.push_back("aa"); // Will not exist.
103 std::vector<std::string> languages; 103 std::vector<std::string> languages;
104 104
105 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( 105 SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages(
106 accept_languages, "fr", &languages); 106 accept_languages, &languages);
107 107
108 EXPECT_EQ(1U, languages.size()); 108 EXPECT_EQ(1U, languages.size());
109 EXPECT_EQ("fr", languages[0]); 109 EXPECT_EQ("fr", languages[0]);
110 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698